simul.dedic.facmod {BayesFM} R Documentation

Generate synthetic data from a dedicated factor model

Description

This function simulates data from a dedicated factor model. The parameters of the model are either passed by the user or simulated by the function.

Usage

simul.dedic.facmod(N, dedic, alpha, sigma, R, R.corr = TRUE,
max.corr = 0.85, R.max.trial = 1000)

Arguments

 N Number of observations in data set. dedic Vector of indicators. The number of manifest variables is equal to the length of this vector, and the number of factors is equal to the number of unique nonzero elements. Each integer element indicates on which latent factor the corresponding variable loads uniquely. alpha Vector of factor loadings, should be of same length as dedic. If missing, values are simulated (see details below). sigma Idiosyncratic variances, should be of same length as dedic. If missing, values are simulated (see details below). R Covariance matrix of the latent factors. If missing, values are simulated (see details below). R.corr If TRUE, covariance matrix R is rescaled to be a correlation matrix. max.corr Maximum correlation allowed between the latent factors. R.max.trial Maximum number of trials allowed to sample from the truncated distribution of the covariance matrix of the latent factors (accept/reject sampling scheme, to make sure max.corr is not exceeded).

Details

The function simulates data from the following dedicated factor model, for i = 1, ..., N:

Y_i = α θ_i + ε_i

θ_i ~ N(0, R)

ε_i ~ N(0, Σ)

where the K-vector θ_i contains the latent factors, and α is the (M*K)-matrix of factor loadings. Each row m of α contains only zeros, besides its element indicated by the mth element of dedic that is equal to the mth element of alpha (denoted α_m^Δ below). The M-vector ε_i is the vector of error terms, with Σ = diag(sigma). M is equal to the length of the vector dedic, and K is equal to the maximum value of this vector.

Only N and dedic are required, all the other parameters can be missing, completely or partially. Missing values (NA) are independently sampled from the following distributions, for each manifest variable m = 1, ..., M:

α_m^Δ = (-1)^φ_m√(a_m)

φ_m ~ Ber(0.5)

a_m ~ Unif (0.04, 0.64)

Idiosyncratic variances:

σ^2_m ~ Unif (0.2, 0.8)

For the variables that do not load on any factors (i.e., for which the corresponding elements of dedic are equal to 0), it is specified that α_m^Δ = 0 and σ^2_m = 1.

Covariance matrix of the latent factors:

Ω ~ Inv-Wishart(K+5, I_K)

which is rescaled to be a correlation matrix if R.corr = TRUE:

R = Λ^-1/2 Ω Λ^-1/2

Λ = diag(Ω)

Note that the distribution of the covariance matrix is truncated such that all the off-diagonal elements of the implied correlation matrix R are below max.corr in absolute value. The truncation is also applied if the covariance matrix is used instead of the correlation matrix (i.e., if R.corr = FALSE).

The distributions and the corresponding default values used to simulate the model parameters are specified as in the Monte Carlo study of CFSHP, see section 4.1 (p.43).

Value

The function returns a data frame with N observations simulated from the corresponding dedicated factor model. The parameters used to generate the data are saved as attributes: dedic, alpha, sigma and R.

Author(s)

Rémi Piatek remi.piatek@gmail.com

References

G. Conti, S. Frühwirth-Schnatter, J.J. Heckman, R. Piatek (2014): “Bayesian Exploratory Factor Analysis”, Journal of Econometrics, 183(1), pages 31-57, doi: 10.1016/j.jeconom.2014.06.008.

Examples

# generate 1000 observations from model with 4 factors and 20 variables