set.seed(2000)
N<-50;M<-24
N<-30;M<-12
X<-rnorm(N,mean=0)
time<-seq(0,1,length.out=M)
Y<-simulate_simple_dfrr(beta0=function(t){cos(pi*t+pi)},
beta1=function(t){2*t},
X=X,time=time)
#The argument T_E indicates the number of EM algorithm.
#T_E is set to 1 for the demonstration purpose only.
#Remove this argument for the purpose of converging the EM algorithm.
dfrr_fit<-dfrr(Y~X,yind=time,T_E=1)
newdata<-data.frame(X=c(1,0))
preds<-predict(dfrr_fit,newdata=newdata)
plot(preds)
newdata<-data.frame(X=c(1,0))
newydata<-data.frame(.obs=rep(1,5),.index=c(0.0,0.1,0.2,0.3,0.7),.value=c(1,1,1,0,0))
preds<-predict(dfrr_fit,newdata=newdata,newydata = newydata)
plot(preds)
Run the code above in your browser using DataLab