ppca
statistics: coeff = ppca (Y, K)
statistics: [coeff, score] = ppca (Y, K)
statistics: [coeff, score, pcvar] = ppca (Y, K)
statistics: [coeff, score, pcvar, mu] = ppca (Y, K)
statistics: [coeff, score, pcvar, mu, v] = ppca (Y, K)
statistics: [coeff, score, pcvar, mu, v, S] = ppca (Y, K)
statistics: […] = ppca (…, Name, Value)
Probabilistic principal component analysis.
coeff = ppca (Y, K) fits a probabilistic principal
component analysis (PPCA) model with K components to the
data matrix Y (rows are observations, columns are variables) and returns
the matrix coeff of orthonormal principal component
coefficients, ordered by decreasing component variance. Y may contain
NaN values marking missing observations; the model is fitted by an
expectation-maximization algorithm that accounts for them. K must be a
positive integer smaller than .
[coeff, score, pcvar, mu, v, S] =
ppca (…) returns further outputs:
W, the
expected scores Xexp, the reconstruction Recon, the number of
iterations NumIter, and the root-mean-square residual RMSResid.Name/Value pairs control the fit:
'W0''Options'statset, whose
MaxIter, TolFun, and TolX fields set the maximum number
of iterations and the convergence tolerances of the
expectation-maximization algorithm.When Y has no missing values the model is fitted directly from the eigendecomposition of its covariance matrix; coeff, pcvar, and v are then the principal component directions, the leading variances, and the mean of the trailing variances, respectively.
See also: pca, pcacov, pcares, factoran, barttest
Source Code: ppca
Fit a two-component PPCA model and reconstruct the data.
Y = [ 1.0, 2.0, 0.5; 2.1, 3.9, 1.2; ...
-1.0, -2.2, -0.4; -2.0, -3.8, -1.1; ...
0.5, 1.1, 0.9; 1.6, 2.8, -0.2];
[coeff, score, pcvar, mu, v] = ppca (Y, 2);
coeff
coeff = 0.4537 -0.1784 0.8668 -0.1393 0.2070 0.9740
pcvar
pcvar =
12.0061
0.2533
The scores reconstruct the data through the coefficients.
max (abs (vec (score * coeff' + mu - Y)))
ans = 0.098713