-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathREADME.Rmd
81 lines (59 loc) · 1.91 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
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
eval = TRUE
)
options(width = 100)
polcom <- tidyversity::polcom
```
# tidysem <img src="man/figures/logo.png" width="160px" align="right" />
[](https://www.tidyverse.org/lifecycle/#experimental)
🎓 Tidy tools for academics
## \*\*\* This package is in very early development. Feedback is encouraged!!! \*\*\*
## Installation
<!-- You can install the released version of tidysem from [CRAN](https://CRAN.R-project.org) with:
``` r
install.packages("tidysem")
```
-->
Install the development version from [Github](https://github.com/mkearney/tidysem) with:
```{r install, eval=FALSE}
## install devtools if not already
if (!requireNamespace("devtools", quietly = TRUE)) {
install.packages("devtools")
}
## install tidysem from Github
devtools::install_github("mkearney/tidysem")
```
Load the package (it, of course, plays nicely with tidyverse).
```{r library}
## load tidyverse
library(tidyverse)
## load tidysem
library(tidysem)
```
## Latent variable models
### Structural equation modeling (SEM)
Conduct latent variable analysis using structural equation modeling.
```{r sem}
## mutate data and then specify and estimate model
sem1 <- polcom %>%
mutate(therm_2 = therm_2 / 10,
therm_1 = 10 - therm_1 / 10) %>%
tidy_sem_model(news =~ news_1 + news_2 + news_3 + news_4 + news_5 + news_6,
ambiv_sexism =~ ambiv_sexism_1 + ambiv_sexism_2 + ambiv_sexism_3 +
ambiv_sexism_4 + ambiv_sexism_5 + ambiv_sexism_6,
partisan =~ a*therm_1 + a*therm_2,
ambiv_sexism ~ age + sex + hhinc + edu + news + partisan) %>%
tidy_sem()
## print model summary
sem1 %>%
tidy_summary()
```