Zelig-factor-bayes-class: Bayesian Factor Analysis

Zelig-factor-bayes-classR Documentation

Bayesian Factor Analysis

Description

Bayesian Factor Analysis

Arguments

formula

a symbolic representation of the model to be estimated, in the form ~ Y1 + Y2 + Y3, where Y1, Y2, and Y3 are variables of interest in factor analysis (manifest variables), assumed to be normally distributed. The model requires a minimum of three manifest variables contained in the same dataset. The + symbol means “inclusion” not “addition.”

factors

number of the factors to be fitted (defaults to 2).

model

the name of a statistical model to estimate. For a list of other supported models and their documentation see: http://docs.zeligproject.org/articles/.

data

the name of a data frame containing the variables referenced in the formula or a list of multiply imputed data frames each having the same variable names and row numbers (created by Amelia or to_zelig_mi).

...

additional arguments passed to zelig, relevant for the model to be estimated.

by

a factor variable contained in data. If supplied, zelig will subset the data frame based on the levels in the by variable, and estimate a model for each subset. This can save a considerable amount of effort. You may also use by to run models using MatchIt subclasses.

cite

If is set to 'TRUE' (default), the model citation will be printed to the console.

Details

In addition, zelig() accepts the following additional arguments for model specification:

  • lambda.constraints: list containing the equality or inequality constraints on the factor loadings. Choose from one of the following forms:

  • varname = list(): by default, no constraints are imposed.

  • varname = list(d, c): constrains the dth loading for the variable named varname to be equal to c.

  • varname = list(d, +): constrains the dth loading for the variable named varname to be positive;

  • varname = list(d, -): constrains the dth loading for the variable named varname to be negative.

  • std.var: defaults to FALSE (manifest variables are rescaled to zero mean, but retain observed variance). If TRUE, the manifest variables are rescaled to be mean zero and unit variance.

In addition, zelig() accepts the following additional inputs for bayes.factor:

  • burnin: number of the initial MCMC iterations to be discarded (defaults to 1,000).

  • mcmc: number of the MCMC iterations after burnin (defaults to 20,000).

  • thin: thinning interval for the Markov chain. Only every thin-th draw from the Markov chain is kept. The value of mcmc must be divisible by this value. The default value is 1.

  • verbose: defaults to FALSE. If TRUE, the progress of the sampler (every 10

  • seed: seed for the random number generator. The default is NA which corresponds to a random seed 12345.

  • Lambda.start: starting values of the factor loading matrix \Lambda, either a scalar (all unconstrained loadings are set to that value), or a matrix with compatible dimensions. The default is NA, where the start value are set to be 0 for unconstrained factor loadings, and 0.5 or - 0.5 for constrained factor loadings (depending on the nature of the constraints).

  • Psi.start: starting values for the uniquenesses, either a scalar (the starting values for all diagonal elements of \Psi are set to be this value), or a vector with length equal to the number of manifest variables. In the latter case, the starting values of the diagonal elements of \Psi take the values of Psi.start. The default value is NA where the starting values of the all the uniquenesses are set to be 0.5.

  • store.lambda: defaults to TRUE, which stores the posterior draws of the factor loadings.

  • store.scores: defaults to FALSE. If TRUE, stores the posterior draws of the factor scores. (Storing factor scores may take large amount of memory for a large number of draws or observations.)

The model also accepts the following additional arguments to specify prior parameters:

  • l0: mean of the Normal prior for the factor loadings, either a scalar or a matrix with the same dimensions as \Lambda. If a scalar value, that value will be the prior mean for all the factor loadings. Defaults to 0.

  • L0: precision parameter of the Normal prior for the factor loadings, either a scalar or a matrix with the same dimensions as \Lambda. If L0 takes a scalar value, then the precision matrix will be a diagonal matrix with the diagonal elements set to that value. The default value is 0, which leads to an improper prior.

  • a0: the shape parameter of the Inverse Gamma prior for the uniquenesses is a0/2. It can take a scalar value or a vector. The default value is 0.001.

  • b0: the scale parameter of the Inverse Gamma prior for the uniquenesses is b0/2. It can take a scalar value or a vector. The default value is 0.001.

Additional parameters avaialable to this model include:

Value

Depending on the class of model selected, zelig will return an object with elements including coefficients, residuals, and formula which may be summarized using summary(z.out) or individually extracted using, for example, coef(z.out). See http://docs.zeligproject.org/articles/getters.html for a list of functions to extract model components. You can also extract whole fitted model objects using from_zelig_model.

Methods

zelig(formula, data, model = NULL, ..., weights = NULL, by, bootstrap = FALSE)

The zelig function estimates a variety of statistical models

See Also

Vignette: http://docs.zeligproject.org/articles/zelig_factorbayes.html

Examples

## Not run: 
data(swiss)
names(swiss) <- c("Fert", "Agr", "Exam", "Educ", "Cath", "InfMort")
z.out <- zelig(~ Agr + Exam + Educ + Cath + InfMort,
model = "factor.bayes", data = swiss,
factors = 2, verbose = FALSE,
a0 = 1, b0 = 0.15, burnin = 500, mcmc = 5000)

z.out$geweke.diag()
z.out <- zelig(~ Agr + Exam + Educ + Cath + InfMort,
model = "factor.bayes", data = swiss, factors = 2,
lambda.constraints =
   list(Exam = list(1,"+"),
        Exam = list(2,"-"),
        Educ = c(2, 0),
        InfMort = c(1, 0)),
verbose = FALSE, a0 = 1, b0 = 0.15,
burnin = 500, mcmc = 5000)

z.out$geweke.diag()
z.out$heidel.diag()
z.out$raftery.diag()
summary(z.out)

## End(Not run)


IQSS/Zelig documentation built on Dec. 11, 2023, 1:51 a.m.