Last chance! 50% off unlimited learning
Sale ends in
MCMCfactanal(x, factors, lambda.constraints=list(),
data=list(), burnin = 1000, mcmc = 10000,
thin=5, verbose = FALSE, seed = 0,
lambda.start = NA, psi.start = NA,
l0=0, L0=0, a0=0.001, b0=0.001,
store.scores = FALSE, std.var=TRUE, ... )
varname=list(d,c)
which
will constrain the dth loading for the variable named lambda.start
is set to a scalar the starting value for
all unconstrained loadings will be set to that scalar. If
lambda.start
is a matrix of the same dimensionspsi.start
is set to a scalar then the starting value for all
diagonal elements of Psi
are set to this value. If
psi.start
is a $k$-vector (where $k$ is the
numLambda
.Lambda
.TRUE
(the default) the manifest variables are
rescaled to have zero mean and unit variance. Otherwise, the manifest
variables are rescaled to have zero mean but retain their observed
variances.
where $x_i$ is the $k$-vector of observed variables specific to observation $i$, $\Lambda$ is the $k \times d$ matrix of factor loadings, $\phi_i$ is the $d$-vector of latent factor scores, and $\Psi$ is a diagonal, positive definite matrix. Traditional factor analysis texts refer to the diagonal elements of $\Psi$ as uniquenesses.
The implementation used here assumes independent conjugate priors for each element of $\Lambda$, each $\phi_i$, and each diagonal element of $\Psi$. More specifically we assume:
MCMCfactanal
simulates from the posterior density using
standard Gibbs sampling. The simulation proper is done in
compiled C++ code to maximize efficiency. Please consult the
coda documentation for a comprehensive list of functions that
can be used to analyze the posterior density sample.
plot.mcmc
,summary.mcmc
,factanal
### An example using the formula interface
data(swiss)
posterior <- MCMCfactanal(~Agriculture+Examination+Education+Catholic
+Infant.Mortality, factors=2,
lambda.constraints=list(Examination=list(1,"+"),
Examination=list(2,"-"), Education=c(2,0),
Infant.Mortality=c(1,0)),
verbose=FALSE, store.scores=FALSE, a0=1, b0=0.15,
data=swiss, burnin=5000, mcmc=50000, thin=20)
plot(posterior)
summary(posterior)
### An example using the matrix interface
Lambda <- matrix(runif(45,-.5,.5), 15, 3)
Psi <- diag(1 - apply(Lambda ^2, 1, sum))
Sigma <- Lambda %*% t(Lambda) + Psi
Y <- t(t(chol(Sigma)) %*% matrix(rnorm(500*15), 15, 500))
posterior <- MCMCfactanal(Y, factors=3,
lambda.constraints=list(V1=c(2,0),
V1=c(3,0), V2=c(3,0), V3=list(1,"+"),
V3=list(2,"+"), V3=list(3,"+")),
verbose=FALSE)
plot(posterior)
summary(posterior)
Run the code above in your browser using DataLab