#create a data matrix
t <- seq(0,4*pi,len=50)
X.org <- matrix(cbind(cos(t),sin(2*t)),length(t),2) %*%
matrix(rnorm(20),2,10)
#add some normal errors
X <- X.org + .25*rnorm(length(X.org))
#and mark some data as missing
X[runif(length(X))<.25] <- NA
#run the missing data svd
res <- SVD.miss(X, niter=100, ncomp=2)
#look at the status
res$status
#plot the first column of the data matrix
plot(t,X[,1])
lines(t,res$Xfill[,1])
lines(t,X.org[,1],col=2)
if( max(abs(res$Xfill-X),na.rm=TRUE) > 1e-10 ){
stop("SVD.miss: Points not interpolated")
}
Run the code above in your browser using DataLab