GithubHelp home page GithubHelp logo

bsem's Introduction

bsem

CRAN status CRAN RStudio mirror downloads R build status Travis build status Codecov test coverage


An R package for Bayesian structural equation modeling.

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.

Install

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)

Basic working example

  • Get some simulated data.
dt <- bsem::simdata()
  • Fit your SEM model
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 the outcome:
print(semfit) 
  • Get posterior summary statistics:
summary(semfit)
  • Plot a diagram with the relatioships between variables:
plot(semfit)

Access to ShinyApp

bsem::runShiny()

         

Future work and improvements

Feel free to collaborate with me or to open an issue.

bsem's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.