Description Usage Arguments Details Value Author(s) See Also Examples
Structural Equation Models (SEM) and particular cases using rstan interface
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | sem(
data,
blocks,
paths,
exogenous,
signals,
row_names = rownames(data),
prior_specs = list(beta = c("normal(0,1)"), sigma2 = c("inv_gamma(2.1, 1.1)"), gamma0
= c("normal(0,1)"), gamma = c("normal(0,1)"), tau2 = c("inv_gamma(2.1, 1.1)")),
cores = parallel::detectCores(),
pars = c("alpha", "lambda", "sigma2"),
iter = 2000,
chains = 4,
scaled = FALSE,
verbose = FALSE,
refresh = 100,
...
)
|
data |
a mandatory 'matrix' object where the columns are variables and the rows are observations |
blocks |
a mandatory named list of colnames (or integers in 1:ncol(data)) indicating the manisfest variables corresponding to each block; generic names are assumed for latent variables internally if not defined |
paths |
list referring to the inner model paths; a list of characters or integers referring to the scores relationship; the jth first latent variable are explained if names(paths) is NULL |
exogenous |
list referring to the inner model exogenous; a list of characters or integers referring to relationship between exogenous and latent variables; the lth first columns are explained if names(exogenous) is NULL |
signals |
list referring to the signals of the factor loadings initial values; must be true: (length(signals) == length(blocks)) && (lengths(signals) == lengths(blocks)); (not allowed in runShiny) |
row_names |
optional identifier for the observations (observation = row) |
prior_specs |
prior settings for the Bayesian approach; only 'normal' and 'cauchy' for gamma0, gamma and beta; 'gamma', 'lognormal' and 'inv_gamma' for sigma2 and tau2 are available, those prior specifications are ignored if not needed (FA or SEM) |
cores |
number of core threads to be used |
pars |
allows parameters to omitted in the outcome; options are any subset of default c("alpha", "lambda", "sigma2") |
iter |
number of iterations |
chains |
number of chains |
scaled |
logical; indicates whether to center and scale the data; default FALSE |
verbose |
logical; see |
refresh |
defaults to 100; see |
... |
further arguments passed to Stan such as warmup, adapt_delta and others, see |
Fits the SEM to specific data
Consider:
- the outer model as: – outer blocks:
X_{p x n} = α_{p x k}λ_{k x n} + ε_{p x n}
where X is the data matrix with variables in the rows and sample elements in the columns, α_{p x j} is the column vector of loadings for the jth latent variable and λ_{j x n} is the row vector of scores for the jth unobserved variable, j =1,…,k. Normality is assumed for the errors as ε_{ij}~ N(0, σ_i ^2) for i = 1,…, p.
- the inner model as:
– inner paths:
λ_{j x n} = β λ^(-j) + ν
where β is a column vector of constant coefficients and λ^(-j)_{ (k-1) x n} represents a subset of the matrix of scores, i.e. at least excluding the jth row scores. The error assumes ν_j ~ N(0,1).
– inner exogenous:
Y_{l x n} = γ_0 + γ λ + ξ
where γ is a column vector of constant coefficients and γ_0 is the intercept. λ_{k x n} is the matrix of scores and the error assumes ξ_l~ N(0,τ_l^2).
An object of class bsem
; a list of 14 to 19:
S4 object of class stanfit
the list of posterior draws separated by chains
character; pointer to pre-defined stan model
matrix of factor loadings posterior means
matrix of factor scores posterior means
vector of error variances posterior means
vector of regression coefficients posterior means
vector of inner paths error variances posterior means
vector of inner paths regression coefficients posterior means
vector of inner paths intercept posterior means
posterior descriptives statistics
list of blocks
list of paths
Highest posterior density intervals (HPD)
vector of posterior communalities
vector of total variance proportions
adjusted coefficient of determination
explained sums of squares
total sums of squares
Renato Panaro
plot.bsem
, simdata
, arrayplot
, summary.bsem
, print.bsem
1 2 3 4 5 6 7 8 9 10 11 12 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.