BIARinterpolation {iAR} | R Documentation |
Interpolation from BIAR model
Description
Interpolation of missing values from models fitted by BIARkalman
Usage
BIARinterpolation(
x,
y1,
y2,
t,
delta1 = 0,
delta2 = 0,
yini1 = 0,
yini2 = 0,
zero.mean = TRUE,
niter = 10,
seed = 1234,
nsmooth = 1
)
Arguments
x |
An array with the parameters of the BIAR model. The elements of the array are, in order, the real (phiR) and the imaginary (phiI) part of the coefficient of BIAR model. |
y1 |
Array with the observations of the first time series of the BIAR process. |
y2 |
Array with the observations of the second time series of the BIAR process. |
t |
Array with the irregular observational times. |
delta1 |
Array with the measurements error standard deviations of the first time series of the BIAR process. |
delta2 |
Array with the measurements error standard deviations of the second time series of the BIAR process. |
yini1 |
a single value, initial value of the estimation of the missing value of the first time series of the BIAR process. |
yini2 |
a single value, initial value of the estimation of the missing value of the second time series of the BIAR process. |
zero.mean |
logical; if TRUE, the array y has zero mean; if FALSE, y has a mean different from zero. |
niter |
Number of iterations in which the function nlminb will be repeated. |
seed |
a single value, interpreted as the seed of the random process. |
nsmooth |
a single value; If 1, only one time series of the BIAR process has a missing value. If 2, both time series of the BIAR process have a missing value. |
Value
A list with the following components:
fitted Estimation of the missing values of the BIAR process.
ll Value of the negative log likelihood evaluated in the fitted missing values.
References
Elorrieta F, Eyheramendy S, Palma W, Ojeda C (2021). “A novel bivariate autoregressive model for predicting and forecasting irregularly observed time series.” Monthly Notices of the Royal Astronomical Society, 505(1), 1105–1116. ISSN 0035-8711, doi: 10.1093/mnras/stab1216, https://academic.oup.com/mnras/article-pdf/505/1/1105/38391762/stab1216.pdf.
See Also
gentime
, BIARsample
, BIARphikalman
Examples
set.seed(6713)
n=100
st<-gentime(n)
x=BIARsample(n=n,phiR=0.9,phiI=0.3,st=st,rho=0.9)
y=x$y
y1=y/apply(y,1,sd)
yerr1=rep(0,n)
yerr2=rep(0,n)
biar=BIARkalman(y1=y1[1,],y2=y1[2,],t=st,delta1 = yerr1,delta2=yerr2)
biar
napos=10
y0=y1
y1[1,napos]=NA
xest=c(biar$phiR,biar$phiI)
yest=BIARinterpolation(xest,y1=y1[1,],y2=y1[2,],t=st,delta1=yerr1,
delta2=yerr2,nsmooth=1)
yest$fitted
mse=(y0[1,napos]-yest$fitted)^2
print(mse)
par(mfrow=c(2,1))
plot(st,x$y[1,],type='l',xlim=c(st[napos-5],st[napos+5]))
points(st,x$y[1,],pch=20)
points(st[napos],yest$fitted*apply(y,1,sd)[1],col="red",pch=20)
plot(st,x$y[2,],type='l',xlim=c(st[napos-5],st[napos+5]))
points(st,x$y[2,],pch=20)