compute_loglikeobs: Compute the log-likelihood of the observed data given PCA...

Description Usage Arguments Value Examples

View source: R/pca_full.R

Description

The log-likelihood of the data for probabilistic PCA is known to be multivariate Gaussian. Using this, one can check the log-likelihood value of the observed data values given the parameter estimates from the PCA model. This can be useful to compare different models.

Usage

1
compute_loglikeobs(dat, covmat, meanvec, verbose = TRUE)

Arguments

dat

matrix – the data matrix with variables in rows and observations in columns.

covmat

matrix – the estimated covariance matrix.

meanvec

numeric – the estimated mean vector.

verbose

logical – whether extra output should be displayed.

Value

the log-likelihood value

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
p <- 20
n <- 7
set.seed(10045)
X <- matrix(rnorm(p*n), p, n)
miss.inds <- sample(1:(p*n), (p*n)/4)
X[miss.inds] <- NA
M <- !is.na(X)
Nobs_i <- rowSums(M)
Mu <- rowSums(X, na.rm = TRUE) / Nobs_i
Mu2 <- rep(0, p)
covmat <- diag(p)
# using sample mean
compute_loglikeobs(dat=X, covmat=covmat, meanvec=Mu, verbose=TRUE)
# using zero mean
compute_loglikeobs(dat=X, covmat=covmat, meanvec=Mu2, verbose=TRUE)

HGray384/pcaNet documentation built on Nov. 14, 2020, 11:11 a.m.