Nota Esse é o banco de dados simulados que foi utilizado para a reunião do LAVIS (UFMG) sobre análise fatorial confirmatória.
Em caso de problemas, entre em contato: pedrosaulo95@gmail.com
A sintaxe abaixo foi adaptada de https://groups.google.com/g/lavaan/c/sZIkmH32acs
library(lavaan)
library(tidyverse)
set.seed(123456)
pop<-'
f1 =~ 0.85*x1 + 1.4*x2 + 1.25*x3 + 2*x4 + 0.5*x5 + 0.38*x6
f2 =~ 0.55*y1 + 1.4*y2 + 1.1*y3 + 0.8*y4
f1 + f2 ~ 0*1
f2 ~ 0.22*f1
f1 ~~ 1*f1
f2 ~~ 0.9516*f2
x1 | -1.7*t1 + 1.5*t2
x2 | -1.2*t1 + 1.9*t2
x3 | 0.7*t1 + 2.3*t2
x4 | -1.45*t1 + 2.75*t2
x5 | 0.8*t1 + 2.2*t2
x6 | 1.2*t1 + 2*t2
y1 | -2*t1 + -0.8*t2
y2 | -2.5*t1 + -0.9*t2
y3 | -1.5*t1 + -0.2*t2
y4 | -1.7*t1 + 0.3*t2
'
sample<-simulateData(model=pop,parameterization="theta",
sample.nobs = 500)
sample %>%
mutate(across(everything(), ~factor(.x,
labels = c("1","2","3")))) %>%
arsenal::tableby(~., data = .) %>% summary()
| Overall (N=500) | |
|---|---|
| x1 | |
| 1 | 15 (3.0%) |
| 2 | 460 (92.0%) |
| 3 | 25 (5.0%) |
| x2 | |
| 1 | 46 (9.2%) |
| 2 | 444 (88.8%) |
| 3 | 10 (2.0%) |
| x3 | |
| 1 | 371 (74.2%) |
| 2 | 124 (24.8%) |
| 3 | 5 (1.0%) |
| x4 | |
| 1 | 33 (6.6%) |
| 2 | 466 (93.2%) |
| 3 | 1 (0.2%) |
| x5 | |
| 1 | 400 (80.0%) |
| 2 | 93 (18.6%) |
| 3 | 7 (1.4%) |
| x6 | |
| 1 | 444 (88.8%) |
| 2 | 42 (8.4%) |
| 3 | 14 (2.8%) |
| y1 | |
| 1 | 9 (1.8%) |
| 2 | 96 (19.2%) |
| 3 | 395 (79.0%) |
| y2 | |
| 1 | 5 (1.0%) |
| 2 | 95 (19.0%) |
| 3 | 400 (80.0%) |
| y3 | |
| 1 | 34 (6.8%) |
| 2 | 177 (35.4%) |
| 3 | 289 (57.8%) |
| y4 | |
| 1 | 19 (3.8%) |
| 2 | 290 (58.0%) |
| 3 | 191 (38.2%) |
library(DT)
sample %>%
datatable(extensions = 'Buttons',
options = list(dom = 'Blfrtip',
buttons = c('copy', 'csv', 'excel', 'pdf', 'print'),
lengthMenu = list(c(10,25,50,-1),
c(10,25,50,"All"))))