-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
94 lines (67 loc) · 2.19 KB
/
README.Rmd
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
---
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%"
)
```
# pathmodelfit
<!-- badges: start -->
[](https://github.com/tmsalab/pathmodelfit/actions)
[-brightgreen.svg?style=flat)](http://www.gnu.org/licenses/gpl-2.0.html)
<!-- badges: end -->
The goal of `pathmodelfit` is to provide fit indices for the path components of
latent variable Structural Equation Models (SEM).
## Installation
You can install the released version of pathmodelfit from [CRAN](https://CRAN.R-project.org) with:
``` r
install.packages("pathmodelfit")
```
Or, you can be on the cutting-edge development version on [GitHub](https://github.com/) using:
``` r
if(!requireNamespace("remotes")) { install.packages("remotes") }
remotes::install_github("tmsalab/pathmodelfit")
```
## Usage
To use `pathmodelfit`, load the package using:
```{r}
library("pathmodelfit")
```
From there, load the data, setup the path and obtain a lavaan model.
```{r}
# Load example data
data(mediationVC, package = "pathmodelfit")
# Define path model for lavaan
model4 <- "
Ldrrew =~ LdrrewI1 + LdrrewI2 + LdrrewI3
Jobcom =~ JobcomI1 + JobcomI2 + JobcomI3
Jobsat =~ JobsatI1 + JobsatI2 + JobsatI3
Orgcom =~ OrgcomI1 + OrgcomI2 + OrgcomI3
Jobsat ~ Ldrrew + Jobcom
Orgcom ~ Jobsat"
# Fit the pathmodel with lavaan's sem() function
fit <- lavaan::sem(model4, sample.cov = mediationVC, sample.nobs = 232)
```
Then, the fit indices can be estimated using:
```{r}
# Compute the fit indices
pathmodelfit_info = pathmodelfit(fit)
# View results
pathmodelfit_info
```
## Authors
Steven Andrew Culpepper and Larry Williams
## Citing the `pathmodelfit` package
To ensure future development of the package, please cite `pathmodelfit`
package if used during an analysis or simulation study. Citation information
for the package may be acquired by using in *R*:
```{r, eval = FALSE}
citation("pathmodelfit")
```
## License
GPL (>= 2)