{"id":42452819,"url":"https://github.com/haziqj/lavaan.bingof","last_synced_at":"2026-01-28T08:51:09.516Z","repository":{"id":152328437,"uuid":"625132705","full_name":"haziqj/lavaan.bingof","owner":"haziqj","description":"Limited Information Goodness of Fit Tests for Binary Factor Models","archived":false,"fork":false,"pushed_at":"2025-02-02T23:53:28.000Z","size":1782968,"stargazers_count":0,"open_issues_count":4,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-03T00:26:09.624Z","etag":null,"topics":["complex-samples","composite-likelihood","factor-analysis","goodness-of-fit","latent-variables","pairwise","psychometrics","r","simulation","survey-weights"],"latest_commit_sha":null,"homepage":"https://haziqj.ml/lavaan.bingof/","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}},"created_at":"2023-04-08T06:55:37.000Z","updated_at":"2025-02-02T23:47:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"60141be7-9469-434c-b385-4fcc76eb4120","html_url":"https://github.com/haziqj/lavaan.bingof","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/haziqj/lavaan.bingof","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haziqj%2Flavaan.bingof","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haziqj%2Flavaan.bingof/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haziqj%2Flavaan.bingof/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haziqj%2Flavaan.bingof/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/haziqj","download_url":"https://codeload.github.com/haziqj/lavaan.bingof/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haziqj%2Flavaan.bingof/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28842917,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T07:39:25.367Z","status":"ssl_error","status_checked_at":"2026-01-28T07:39:24.487Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["complex-samples","composite-likelihood","factor-analysis","goodness-of-fit","latent-variables","pairwise","psychometrics","r","simulation","survey-weights"],"created_at":"2026-01-28T08:51:08.382Z","updated_at":"2026-01-28T08:51:09.511Z","avatar_url":"https://github.com/haziqj.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\nlibrary(lavaan.bingof)\nlibrary(tidyverse)\n```\n\n# lavaan.bingof\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/lavaan.bingof/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/haziqj/lavaan.bingof/actions/workflows/R-CMD-check.yaml)\n[![Codecov test coverage](https://codecov.io/gh/haziqj/lavaan.bingof/branch/main/graph/badge.svg)](https://app.codecov.io/gh/haziqj/lavaan.bingof?branch=main)\n\u003c!-- badges: end --\u003e\n\n\u003c!-- https://github.com/r-lib/pkgdown/issues/133 --\u003e\n![](https://raw.githubusercontent.com/haziqj/lavaan.bingof/main/inst/mult_bern_data.png)\n\nThis is the accompanying R package for the article\n\n\u003e Jamil, H., Moustaki, I., \u0026 Skinner, C. (2024). Pairwise likelihood estimation and limited-information goodness-of-fit test statistics for binary factor analysis models under complex survey sampling. *British Journal of Mathematical and Statistical Psychology*. (to appear)\n\nThis package contains the functions to compute the test statistics and conduct simulation studies described in the above manuscript.\nCurrently, the package implements the following tests based on univariate and bivariate residuals of a binary factor analysis model:\n\n|   | Name                    | R function          | Remarks                                          |\n|---|-------------------------|---------------------|--------------------------------------------------|\n| 1 | Wald test               | `Wald_test()`       | Described in Reiser (1996)                       |\n| 2 | Wald test (diagonal)    | `Wald_diag_test()`    | A more efficient Wald test                       |\n| 3 | Wald test (VCOV free)  | `Wald_vcovf_test()`    | Described in Maydeu-Olivares and Joe (2005,2006) |\n| 4 | Pearson test            | `Pearson_test()` | Moment matching approximation                    |\n| 5 | Residual sum of squares | `RSS_test()`        | Moment matching approximation                    |\n| 6 | Multinomial test        | `Multn_test()`      | Moment matching approximation                    |\n\n## Installation\n\nInstall this package from this GitHub repository:\n\n```{r, eval = FALSE}\n# install.packages(\"pak\") \npak::pkg_install(\"haziqj/lavaan.bingof\")\nlibrary(lavaan.bingof)  # load package\n```\n\n## Usage\n\nThere are three main functionalities of this package:\n\n1. Generate simulated data either from an infinite population or from a finite population using a complex sampling procedure.\n\n2. Obtain the test statistic values, the degrees of freedom of these chi-square variates, and corresponding $p$-values to determine goodness-of-fit.\n\n3. Wrap functions 1 and 2 in a convenient way to perform simulation studies for Type I errors and power.\n\n### Create a simulated data set of ordinal binary responses\n\nThe true parameter values are according to the models specified in the research article.\n\n```{r}\n(dat \u003c- gen_data_bin(n = 1000, seed = 123))\n```\n\n### Obtain the various test statistics and $p$-values\n\n```{r}\n# Fit lavaan model using PML estimation\n(mod \u003c- txt_mod(model_no = 1))\nfit \u003c- lavaan::sem(mod, dat, std.lv = TRUE, estimator = \"PML\")\n\n# Test statistics\nall_tests(fit)\n```\n\n### Test statistics under a complex sampling scheme\n\n```{r}\n# Simulate a two-stage stratified cluster sampling with 50 PSUs sampled per\n# stratum, and 1 cluster sampled within each PSU.\n(dat \u003c- gen_data_bin_strcl(population = make_population(1), npsu = 50, \n                           seed = 9423))\n\n# Fit lavaan model and create survey object\nfit0 \u003c- lavaan::sem(mod, dat, std.lv = TRUE, estimator = \"PML\")  # ignore wt\nfit1 \u003c- lavaan::sem(mod, dat, std.lv = TRUE, estimator = \"PML\",\n                    sampling.weights = \"wt\")\n\n# Compare with and without sampling weights\nWald_test(fit0)\nWald_test(fit1)  # with sampling weights\n```\n\n### Simulation wrapper\n\n```{r}\n# Conduct a simulation study based on a 5 factor model (32 repetitions only for\n# illustration). Data generated according to a stratified complex sample.\n(pc \u003c- parallel::detectCores())   # how many cores do we have?\n\nres \u003c- run_ligof_sims(model_no = 1, nsim = pc, ncores = pc - 2, samp = \"strat\",\n                      simtype = \"type1\")\n```\n\n\u003c!-- #\u003e|======================================================================| 100% --\u003e\n\n```{r}\nres\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaziqj%2Flavaan.bingof","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhaziqj%2Flavaan.bingof","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaziqj%2Flavaan.bingof/lists"}