Description Usage Arguments Value Author(s) References See Also Examples
Function that completes a data matrix using iterative svd as described in
Fuentes et. al. (2006). The function iterates between computing the svd for
the matrix and replacing the missing values by linear regression of the
columns onto the first ncomp
svd components. As initial replacement
for the missing values regression on the column averages are used. The
function will fail if entire rows and/or columns are missing from the
data matrix.
1 |
X |
Data matrix, with missing values marked by |
niter |
Maximum number of iterations to run before exiting,
|
ncomp |
Number of SVD components to use in the reconstruction (>0). |
conv.reldiff |
Assume the iterative procedure has converged when
the relative difference between two consecutive iterations is less than
|
A list with the following components:
Xfill |
The completed data matrix with missing values replaced by
fitting the data to the |
svd |
The result of svd on the completed data matrix, i.e.
|
status |
A vector of status variables: |
Paul D. Sampson and Johan Lindstrom
M. Fuentes, P. Guttorp, and P. D. Sampson. (2006) Using Transforms to Analyze Space-Time Processes in Statistical methods for spatio-temporal systems (B. Finkenstadt, L. Held, V. Isham eds.) 77-150
Other SVD for missing data: SVDsmooth
,
calcSmoothTrends
, plot.SVDcv
,
print.SVDcv
,
updateTrend.STdata
Other data matrix: SVDsmooth
,
createDataMatrix
,
estimateBetaFields
,
mesa.data.raw
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ##create a data matrix
t <- seq(0,4*pi,len=50)
X.org <- cbind(cos(t),sin(2*t)) %*% 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
##Ensure that we have complet columns/rows
while( any(rowSums(is.na(X))==dim(X)[2]) || any(colSums(is.na(X))==dim(X)[1]) ){
X <- X.org + .25*rnorm(length(X.org))
X[runif(length(X))<.25] <- NA
}
#run the missing data svd
res <- SVDmiss(X, niter=100, ncomp=2)
#look at the status
res$status
#plot the first four columns of the data matrix
par(mfrow=c(2,2))
for(i in 1:4){
plot(t, X[,i])
lines(t, res$Xfill[,i])
lines(t, X.org[,i], col=2)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.