pca | R Documentation |
Standard (linear) PCA accounting for missing data, assuming a 2-d field like structure for inputs.
pca(A)
A |
Array, usually represinting a [longitude,latitudade, n] field, where the two first dimensions represent the geographical distribution and the third dimension the sequence over which PCA is to be done (time series or experiment ensemble ) |
elementary SVD
List of
mean |
2-d matrix of mean field over the third dimension |
PCA |
Array |
amps |
Matrix |
d |
Vector of eigenvalues |
Michel Crucifix
##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (A)
{
nlon = dim(A)[1]
nlat = dim(A)[2]
nr = dim(A)[3]
A = matrix(A, nlon * nlat, nr)
mean = apply(A, 1, mean)
Am = sweep(A, 1, apply(A, 1, mean))
o = which(!is.na(Am[, 1]))
U = svd(Am[o, ])
O = A
V = A
O[o, ] = U$u
O = array(O, c(nlon, nlat, nr))
mean = matrix(mean, nlon, nlat)
d = U$d
return(list(mean = mean, PCA = O, amps = U$v, d = d))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.