-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.Rmd
More file actions
74 lines (53 loc) · 3.04 KB
/
README.Rmd
File metadata and controls
74 lines (53 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# noisemaker
<!-- badges: start -->
[](https://codecov.io/gh/JustinKracht/noisemaker?branch=main)
[](https://lifecycle.r-lib.org/articles/stages.html#experimental)
<!-- badges: end -->
The goal of noisemaker is to provide functions to make it easy to generate population correlation matrices that fit a common factor analysis model imperfectly. In particular, the `noisemaker()` function provides an interface to three methods for generating population correlation matrices with RMSEA and/or CFI values that are close to user-specified target values.
## Installation
You can install the development version from [GitHub](https://github.com/) with:
```{r eval=FALSE}
# install.packages("devtools")
devtools::install_github("JustinKracht/noisemaker")
```
To also build the vignette when the package is installed (highly recommended), you can use:
```{r eval=FALSE}
devtools::install_github("JustinKracht/noisemaker", build_vignettes = TRUE)
```
## Examples
In this example, the factor model has two factors, each with three salient items. I'll demonstrate using the `noisemaker()` function to generate a population correlation matrix with model error ($\Sigma$) such that $\textrm{RMSEA}(\Sigma, \Omega) = 0.05$, where $\Omega$ is the model-implied correlation matrix. For this first example, I'll use the method described by [Cudeck and Browne (1992)](https://doi-org.ezp1.lib.umn.edu/10.1007/BF02295424).
```{r example}
library(noisemaker)
library(fungible)
# Generate a simple factor model with two factors and six items
mod <- simFA(Model = list(NFac = 2, NItemPerFac = 3),
Seed = 42)
(Omega <- mod$Rpop) # the model-implied correlation matrix
set.seed(42)
# Generate a population correlation matrix with model error (Sigma) using the
# Cudeck and Browne (1992) method
noisemaker(mod, method = "CB", target_rmsea = 0.05)
```
The `noisemaker()` function implements a method for simulating correlation matrices with RMSEA values close to a target value based on the adventitious error framework developed by [Wu and Browne (2015)](https://link-springer-com.ezp1.lib.umn.edu/article/10.1007/s11336-015-9451-3).
```{r}
noisemaker(mod, method = "WB", target_rmsea = 0.05)
```
Finally, the `noisemaker()` function implements a procedure that optimizes the values of the parameters for the [Tucker, Koopman, and Linn (1969)](https://doi-org.ezp1.lib.umn.edu/10.1007/BF02290601) method to produce a $\Sigma$ matrix that has both RMSEA and CFI values close to the user-specified targets:
```{r}
noisemaker(mod, method = "TKL",
target_rmsea = 0.05,
target_cfi = 0.95,
tkl_ctrl = list(optim_type = "optim"))
```