{"id":38281402,"url":"https://github.com/haziqj/inlavaan","last_synced_at":"2026-04-05T09:01:47.740Z","repository":{"id":241496647,"uuid":"746948869","full_name":"haziqj/INLAvaan","owner":"haziqj","description":"An R package for Bayesian structural equation modeling using INLA","archived":false,"fork":false,"pushed_at":"2026-04-02T11:03:57.000Z","size":52818,"stargazers_count":12,"open_issues_count":9,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-04-02T21:12:14.824Z","etag":null,"topics":["bayesian-inference","bayesian-statistics","factor-analysis","growth-curve-models","inla","laplace-approximation","latent-variables","path-analysis","psychometrics","skew-normal","statistical-modeling","structural-equation-modeling"],"latest_commit_sha":null,"homepage":"https://inlavaan.haziqj.ml/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/haziqj.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-01-23T00:39:35.000Z","updated_at":"2026-04-02T20:37:20.000Z","dependencies_parsed_at":"2024-05-28T19:52:23.377Z","dependency_job_id":"ae2e0869-c945-46b9-9b1b-b53e174de5b1","html_url":"https://github.com/haziqj/INLAvaan","commit_stats":null,"previous_names":["haziqj/inlavaan"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/haziqj/INLAvaan","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haziqj%2FINLAvaan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haziqj%2FINLAvaan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haziqj%2FINLAvaan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haziqj%2FINLAvaan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/haziqj","download_url":"https://codeload.github.com/haziqj/INLAvaan/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haziqj%2FINLAvaan/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31430011,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T08:13:15.228Z","status":"ssl_error","status_checked_at":"2026-04-05T08:13:11.839Z","response_time":75,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bayesian-inference","bayesian-statistics","factor-analysis","growth-curve-models","inla","laplace-approximation","latent-variables","path-analysis","psychometrics","skew-normal","statistical-modeling","structural-equation-modeling"],"created_at":"2026-01-17T01:59:05.954Z","updated_at":"2026-04-05T09:01:47.728Z","avatar_url":"https://github.com/haziqj.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\neditor_options: \n  chunk_output_type: console\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r setup, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\noptions(cli.dynamic = FALSE, cli.progress_show_after = 2)\n\nlibrary(INLAvaan)\nlibrary(lavaan)\nlibrary(blavaan)\nlibrary(tidyverse)\n```\n\n# INLAvaan \u003ca href=\"https://inlavaan.haziqj.ml\"\u003e\u003cimg src=\"man/figures/logo.png\" align=\"right\" height=\"139\" alt=\"INLAvaan website\" /\u003e\u003c/a\u003e\n\n\u003c!-- badges: start --\u003e\n[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)\n[![R-CMD-check](https://github.com/haziqj/INLAvaan/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/haziqj/INLAvaan/actions/workflows/R-CMD-check.yaml)\n[![Codecov test coverage](https://codecov.io/gh/haziqj/INLAvaan/branch/main/graph/badge.svg)](https://app.codecov.io/gh/haziqj/INLAvaan?branch=main)\n[![CRAN_Status_Badge_version_ago](http://www.r-pkg.org/badges/version-ago/INLAvaan)](https://cran.r-project.org/package=INLAvaan)\n[![Dependencies](https://tinyverse.netlify.app/badge/INLAvaan)](https://cran.r-project.org/package=INLAvaan)\n[![CRAN Downloads](http://cranlogs.r-pkg.org/badges/grand-total/INLAvaan)](https://cran.r-project.org/package=INLAvaan)\n[![GitHub Repo stars](https://img.shields.io/github/stars/haziqj/inlavaan)](https://github.com/haziqj/INLAvaan/stargazers)\n\u003c!-- badges: end --\u003e\n\n\u003e Efficient approximate Bayesian inference for Structural Equation Models.\n\nWhile Markov Chain Monte Carlo (MCMC) methods remain the gold standard for exact Bayesian inference, they can be prohibitively slow for iterative model development. \n`{INLAvaan}` offers a rapid alternative for \u003cu\u003e**la**\u003c/u\u003etent \u003cu\u003e**va**\u003c/u\u003eriable \u003cu\u003e**an**\u003c/u\u003ealysis, delivering Bayesian results at (or near) the speed of frequentist estimators.\nIt achieves this through a custom, ground-up implementation of the [Integrated Nested Laplace Approximation (INLA)](https://www.r-inla.org), engineered specifically for the [lavaan](https://lavaan.ugent.be) modelling framework.\n\n## A familiar interface\n\n`{INLAvaan}` is designed to fit seamlessly into your existing workflow.\nIf you are familiar with the [(b)lavaan syntax](https://lavaan.ugent.be/tutorial/syntax1.html), you can begin using `{INLAvaan}` immediately.\n\nAs a first impression of the package, consider the canonical example of SEM applied to the Industrialisation and Political Democracy data set of Bollen (1989)^[Bollen, K. A. (1989). *Structural equations with latent variables* (pp. xiv, 514). John Wiley \u0026 Sons. \u003chttps://doi.org/10.1002/9781118619179\u003e]:\n\n```{r}\n#| label: inlavaan-poldem\nlibrary(INLAvaan)\nmod_poldem \u003c- \"\n  # Latent variable definitions\n     ind60 =~ x1 + x2 + x3\n     dem60 =~ y1 + y2 + y3\n     dem65 =~ y5 + y6 + y7 + y8\n\n  # Latent regressions\n    dem60 ~ ind60\n    dem65 ~ ind60 + dem60\n\n  # Residual correlations\n    y1 ~~ y5\n    y2 ~~ y4 + y6\n    y3 ~~ y7\n    y4 ~~ y8\n    y6 ~~ y8\n  \n  # Fixed loading\n    dem60 =~ 1.5*y4\n  \n  # Custom priors on latent variances\n    ind60 ~~ prior('gamma(1, 1)')*ind60\n    dem60 ~~ prior('gamma(2, 1)')*dem60\n    dem65 ~~ prior('gamma(1,.5)')*dem65\n\"\nutils::data(\"PoliticalDemocracy\", package = \"lavaan\")\n\nfit \u003c- asem(model = mod_poldem, data = PoliticalDemocracy)\n\nsummary(fit)\n```\n\n## Validation against MCMC\n\nComputation speed is valuable only when accuracy is preserved.\nOur method yields posterior distributions that are visually and numerically comparable to those obtained via MCMC (e.g., via `{blavaan}`/Stan), but at a fraction of the computational cost.\n\nThe figure below illustrates the posterior density overlap for the example above.\nThe percentages refer to the one minus the [Jensen-Shannon distance](https://en.wikipedia.org/wiki/Jensen–Shannon_divergence), which gives a measure of similarity between two probability distributions.\n\n```{r}\n#| label: fig-compare-poldem\n#| message: false\n#| warning: false\n#| results: \"hide\"\n#| fig-height: 4.7\n#| fig-width: 8\n#| out-width: 100%\n#| fig-dpi: 300\n\n# install.packages(\"blavaan\")\nlibrary(blavaan)\nfit_blav \u003c- bsem(model = mod_poldem, data = PoliticalDemocracy, seed = 2026)\nres \u003c- INLAvaan:::compare_mcmc(fit_blav, INLAvaan = fit)\nprint(res$p_compare)\n```\n\n## Installation\n\nInstall the CRAN version of `{INLAvaan}` using:\n\n```r\ninstall.packages(\"INLAvaan\")\n```\n\nAlternatively, install the development version of `{INLAvaan}` from GitHub using:\n\n```r\n# install.packages(\"pak\")\npak::pak(\"haziqj/INLAvaan\")\n```\n\n*Optionally*^[R-INLA dependency has been removed temporarily from v0.2.0.], you may wish to install [INLA](https://www.r-inla.org).\nFollowing the official instructions given [here](https://www.r-inla.org/download-install), install the package by running this command in R:\n\n```r\ninstall.packages(\n  \"INLA\",\n  repos = c(getOption(\"repos\"), \n            INLA = \"https://inla.r-inla-download.org/R/stable\"), \n  dep = TRUE\n)\n```\n\n## Citation\n\nThere are two papers related to `{INLAvaan}` and its underlying methodology.\nTo cite `{INLAvaan}` in publications, consider citing both.\n\nTo cite the methodological contribution exclusively, please use:\n\n\u003e Jamil, H., \u0026 Rue, H. (2026). _Approximate Bayesian inference for structural equation models using integrated nested Laplace approximations_ (2603.25690 [stat.ME]). arXiv. https://doi.org/10.48550/arXiv.2603.25690\n\nTo cite the software implementation and workflows, please use:\n\n\u003e Jamil, H., \u0026 Rue, H. (2026). _Implementation and workflows for INLA-based approximate Bayesian structural equation modelling_ (2604.00671 [stat.CO]). arXiv. https://doi.org/10.48550/arXiv.2604.00671\n\nBibTeX entries for LaTeX users:\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(comment = \"\")\n```\n\n```{r, echo = FALSE}\ntoBibtex(citation(\"INLAvaan\"))\n```\n\n## License\n\nThe `{INLAvaan}` package is licensed under the [GPL-3](https://www.gnu.org/licenses/gpl-3.0.en.html). \n\n```plaintext\nINLAvaan: Bayesian Latent Variable Analysis using INLA\nCopyright (C) 2026 Haziq Jamil\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see \u003chttp://www.gnu.org/licenses/\u003e.\n```\n\n\u003c!-- By using this package, you agree to comply with both licenses:  --\u003e\n\u003c!-- the GPL-3 license for the software and the CC BY 4.0 license for the data. --\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaziqj%2Finlavaan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhaziqj%2Finlavaan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaziqj%2Finlavaan/lists"}