The package allows Bayesian analysis for particular cases of structural equation models (SEMs) based on rstan integration. Examples in get started and exploring bsem include confirmatory factor analysis and confirmatory SEM. The full SEM model (outer and inner models), enables the evaluation of user-defined latent variables along with the analysis of established linear relationships among the latent scores.
Please install remotes package and devtools before installing:
install.packages("remotes")
install.packages("devtools")
Due to R 4.0 chain info is not working properly. As discussed here a possible fix is to get the under development version with:
remotes::install_github("stan-dev/rstan", ref = "develop", subdir = "rstan/rstan")
Afterwards, you can install bsem using:
devtools::install_github("rvpanaro/bsem", dependencies = TRUE)
dt <- bsem::simdata()
semfit <- bsem::sem(
data = dt$data,
blocks = dt$blocks,
paths = dt$paths,
exogenous = dt$exogenous,
signals = dt$signals,
iter = 2000,
warmup = 1000,
chains = 4
)
print(semfit)
summary(semfit)
plot(semfit)
bsem::runShiny()
Feel free to collaborate with me or to open an issue.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.