Categories &

Functions List

Function Reference: 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 N × P data matrix Y (rows are observations, columns are variables) and returns the P × K 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 P.

[coeff, score, pcvar, mu, v, S] = ppca (…) returns further outputs:

score
The N × K principal component scores (the data projected onto the components; missing entries are reconstructed from the model before projection).
pcvar
A K × 1 vector of the principal component variances (the variance explained by each component).
mu
A 1 × P vector of the estimated mean of Y.
v
The estimated residual (isotropic noise) variance.
S
A structure with the fitted model details: the loadings 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'
A P × K initial value for the loadings used by the expectation-maximization algorithm (missing-data case).
'Options'
A structure of algorithm options, as returned by 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