Hagan SEM Homework
rm(list=ls())
#################### READ IN DATA AND DELETE MISSING #########################
IPIP <- read.csv("C:/Users/Courtney/Desktop/HW1.csv") # https://ipip.ori.org/newBigFive5broadKey.htm
head(IPIP)
## id Start End Agree01 Agree02 Agree03 Agree04
## 1 1 8/26/2013 14:43 8/26/2013 15:04 5 4 7 7
## 2 2 8/26/2013 15:37 8/26/2013 16:23 6 7 6 6
## 3 3 8/27/2013 17:29 8/27/2013 17:57 6 6 6 6
## 4 4 8/27/2013 21:08 8/27/2013 21:51 5 5 5 4
## 5 5 8/27/2013 23:41 8/28/2013 0:09 3 6 6 6
## 6 6 8/28/2013 16:53 8/28/2013 17:50 3 2 7 6
## Agree05 Agree06 Agree07 Agree08 Agree09 Agree10 Agree11 Agree12 Agree13
## 1 5 5 3 7 6 7 5 1 3
## 2 7 6 6 6 7 5 5 2 4
## 3 5 6 6 6 6 6 6 2 2
## 4 4 5 5 3 5 5 5 4 5
## 5 5 6 5 6 5 6 5 2 3
## 6 6 7 3 5 4 6 6 2 6
## Agree14 Agree15 Agree16 Agree17 Agree18 Agree19 Agree20 BIDR01 BIDR02
## 1 4 2 4 5 2 2 4 5 5
## 2 1 1 4 6 6 1 2 5 4
## 3 2 2 2 5 1 1 2 3 2
## 4 5 2 4 6 5 6 5 6 5
## 5 4 5 2 5 2 2 2 5 5
## 6 4 2 1 4 2 6 5 6 6
## BIDR03 BIDR04 BIDR05 BIDR06 BIDR07 BIDR08 BIDR09 BIDR10 BIDR11 BIDR12
## 1 3 4 3 4 4 4 7 5 3 5
## 2 7 5 5 5 5 3 6 2 3 2
## 3 5 2 6 2 2 4 7 1 5 2
## 4 6 5 6 4 5 5 3 6 2 3
## 5 5 6 3 4 6 2 5 6 1 6
## 6 5 6 5 5 5 3 5 6 1 4
## BIDR13 BIDR14 BIDR15 BIDR16 BIDR17 BIDR18 BIDR19 BIDR20 BIDR21 BIDR22
## 1 4 2 4 4 4 2 4 6 5 4
## 2 4 2 5 2 6 1 7 2 4 4
## 3 4 2 6 2 3 3 4 2 5 7
## 4 6 2 6 5 5 6 6 5 2 2
## 5 5 2 6 3 5 4 5 6 6 2
## 6 6 5 4 3 5 5 5 6 6 5
## BIDR23 BIDR24 BIDR25 BIDR26 BIDR27 BIDR28 BIDR29 BIDR30 BIDR31 BIDR32
## 1 5 3 5 4 5 4 4 4 4 4
## 2 4 7 1 4 4 5 4 4 6 2
## 3 2 6 2 5 2 6 1 6 2 6
## 4 5 6 4 7 6 4 2 2 1 7
## 5 6 2 6 2 6 5 2 6 2 2
## 6 5 1 5 5 2 3 4 6 6 2
## BIDR33 BIDR34 BIDR35 BIDR36 BIDR37 BIDR38 BIDR39 BIDR40 Consc01 Consc02
## 1 6 7 7 4 7 3 4 3 6 6
## 2 7 7 6 5 2 7 4 7 6 7
## 3 5 2 5 6 6 5 3 6 6 6
## 4 6 6 6 6 5 5 3 4 4 5
## 5 6 3 6 6 6 4 6 3 6 6
## 6 6 6 5 3 5 6 7 5 5 6
## Consc03 Consc04 Consc05 Consc06 Consc07 Consc08 Consc09 Consc10 Consc11
## 1 6 5 5 7 5 3 6 6 1
## 2 3 7 6 6 4 5 6 6 1
## 3 7 6 6 6 2 6 6 6 2
## 4 3 6 5 6 6 6 5 5 5
## 5 6 6 5 6 6 6 6 5 2
## 6 3 5 5 6 5 7 5 4 6
## Consc12 Consc13 Consc14 Consc15 Consc16 Consc17 Consc18 Consc19 Consc20
## 1 1 1 5 2 3 1 1 1 4
## 2 4 1 2 1 2 3 1 2 3
## 3 1 5 1 1 2 2 2 2 2
## 4 3 5 4 2 2 3 2 2 5
## 5 2 2 2 2 5 2 2 5 6
## 6 6 6 5 1 3 5 3 4 6
## Extra01 Extra02 Extra03 Extra04 Extra05 Extra06 Extra07 Extra08 Extra09
## 1 5 7 5 4 4 6 6 6 5
## 2 7 7 6 5 7 7 5 5 7
## 3 5 3 6 2 4 4 5 3 2
## 4 5 5 2 4 3 5 3 5 3
## 5 5 5 5 4 4 6 5 6 5
## 6 6 5 5 3 4 5 2 5 3
## Extra10 Extra11 Extra12 Extra13 Extra14 Extra15 Extra16 Extra17 Extra18
## 1 7 2 2 3 3 2 1 2 2
## 2 6 3 6 2 6 4 1 4 5
## 3 5 5 5 5 5 5 2 3 2
## 4 6 2 3 2 5 2 4 4 5
## 5 6 2 3 2 5 3 2 2 3
## 6 5 2 5 2 5 4 4 4 4
## Extra19 Extra20 Neurot01 Neurot02 Neurot03 Neurot04 Neurot05 Neurot06
## 1 1 4 4 3 2 4 5 4
## 2 2 1 1 2 1 1 1 3
## 3 2 2 2 2 2 6 2 1
## 4 4 4 5 2 3 4 4 5
## 5 6 5 5 5 6 3 6 6
## 6 2 5 6 5 5 5 5 6
## Neurot07 Neurot09 Neurot10 Neurot11 Neurot12 Neurot13 Neurot14 Neurot15
## 1 4 6 6 4 5 3 2 6
## 2 1 1 1 6 7 7 7 7
## 3 2 2 2 6 6 2 6 4
## 4 3 3 4 3 7 2 2 6
## 5 5 6 7 2 2 2 2 2
## 6 1 5 6 2 2 3 2 3
## Neurot16 Neurot17 Neurot18 Neurot19 Neurot20 Neurot8 Open01 Open02
## 1 3 4 4 2 3 6 2 5
## 2 7 7 7 7 6 2 6 6
## 3 6 6 2 6 6 2 7 6
## 4 5 2 2 4 3 5 5 6
## 5 3 3 2 2 3 7 4 6
## 6 5 2 3 4 5 6 7 6
## Open03 Open04 Open05 Open06 Open07 Open08 Open09 Open10 Open11 Open12
## 1 4 6 5 6 4 4 5 7 4 4
## 2 4 5 6 7 6 4 6 7 2 2
## 3 3 4 7 6 4 7 7 6 1 1
## 4 1 5 4 6 3 5 4 6 6 2
## 5 4 5 6 6 5 5 5 6 3 3
## 6 7 6 6 6 5 6 6 4 2 1
## Open13 Open14 Open15 Open16 Open17 Open18 Open19 Open20 Qual01 Qual02
## 1 3 4 4 2 5 4 4 4 1 1
## 2 2 2 4 4 1 4 1 2 1 1
## 3 6 3 4 1 5 4 1 1 1 1
## 4 3 2 6 3 5 5 4 3 1 1
## 5 3 5 4 3 3 4 5 3 1 1
## 6 1 1 1 3 2 1 1 2 1 1
## Age Race GenderMF
## 1 18 5 2
## 2 20 5 1
## 3 20 5 1
## 4 18 5 2
## 5 18 5 2
## 6 20 1 2
#delete out rows with missing data
d.0 <- IPIP[complete.cases(IPIP),]
rm(IPIP)
library("psych")
library("lessR")
## Warning: package 'lessR' was built under R version 3.6.3
##
## lessR 3.9.6 feedback: gerbing@pdx.edu web: lessRstats.com/new
## -----------------------------------------------------------------
## > d <- Read("") Read text, Excel, SPSS, SAS or R data file
## d is default data frame, no need for data= in analysis routines
##
## > vignette("topic") for help on the following topics
## "Read": read data and variable labels, write data to a file
## "BarChart", "Histogram", "Plot": visualizations
## "Means": analyze means with t-tests and ANOVA
## "Regression": least-squares, logistic regression
## "Customize": custom color palettes and more customization
## "Extract": general, simple data frame subsetting
## "pivot": 1-d and 2-d simply created pivot tables
##
## Attaching package: 'lessR'
## The following objects are masked from 'package:psych':
##
## reflect, scree
#reverse code IPIP items
d <- Recode(c(Agree11,Agree12,Agree13,Agree14,Agree15,Agree16,Agree17,Agree18,Agree19,
Agree20,BIDR02,BIDR04,BIDR06,BIDR08,BIDR10,BIDR12,BIDR14,BIDR16,BIDR18,
BIDR20,BIDR21,BIDR23,BIDR25,BIDR27,BIDR29,BIDR31,BIDR33,BIDR35,BIDR37,
BIDR39,Consc11,Consc12,Consc13,Consc14,Consc15,Consc16,Consc17,Consc18,
Consc19,Consc20,Extra11,Extra12,Extra13,Extra14,Extra15,Extra16,Extra17,
Extra18,Extra19,Extra20,Neurot11,Neurot12,Neurot13,Neurot14,Neurot15,
Neurot16,Neurot17,Neurot18,Neurot19,Neurot20,Open11,Open12,Open13,Open14,
Open15,Open16,Open17,Open18,Open19,Open20),
old=1:7, new=7:1, data=d.0)
##
## --------------------------------------------------------
## First four rows of data to recode for data frame: d.0
## --------------------------------------------------------
## Agree11 Agree12 Agree13 Agree14 Agree15 Agree16 Agree17 Agree18 Agree19
## 1 5 1 3 4 2 4 5 2 2
## 2 5 2 4 1 1 4 6 6 1
## 3 6 2 2 2 2 2 5 1 1
## 4 5 4 5 5 2 4 6 5 6
## Agree20 BIDR02 BIDR04 BIDR06 BIDR08 BIDR10 BIDR12 BIDR14 BIDR16 BIDR18
## 1 4 5 4 4 4 5 5 2 4 2
## 2 2 4 5 5 3 2 2 2 2 1
## 3 2 2 2 2 4 1 2 2 2 3
## 4 5 5 5 4 5 6 3 2 5 6
## BIDR20 BIDR21 BIDR23 BIDR25 BIDR27 BIDR29 BIDR31 BIDR33 BIDR35 BIDR37
## 1 6 5 5 5 5 4 4 6 7 7
## 2 2 4 4 1 4 4 6 7 6 2
## 3 2 5 2 2 2 1 2 5 5 6
## 4 5 2 5 4 6 2 1 6 6 5
## BIDR39 Consc11 Consc12 Consc13 Consc14 Consc15 Consc16 Consc17 Consc18
## 1 4 1 1 1 5 2 3 1 1
## 2 4 1 4 1 2 1 2 3 1
## 3 3 2 1 5 1 1 2 2 2
## 4 3 5 3 5 4 2 2 3 2
## Consc19 Consc20 Extra11 Extra12 Extra13 Extra14 Extra15 Extra16 Extra17
## 1 1 4 2 2 3 3 2 1 2
## 2 2 3 3 6 2 6 4 1 4
## 3 2 2 5 5 5 5 5 2 3
## 4 2 5 2 3 2 5 2 4 4
## Extra18 Extra19 Extra20 Neurot11 Neurot12 Neurot13 Neurot14 Neurot15
## 1 2 1 4 4 5 3 2 6
## 2 5 2 1 6 7 7 7 7
## 3 2 2 2 6 6 2 6 4
## 4 5 4 4 3 7 2 2 6
## Neurot16 Neurot17 Neurot18 Neurot19 Neurot20 Open11 Open12 Open13 Open14
## 1 3 4 4 2 3 4 4 3 4
## 2 7 7 7 7 6 2 2 2 2
## 3 6 6 2 6 6 1 1 6 3
## 4 5 2 2 4 3 6 2 3 2
## Open15 Open16 Open17 Open18 Open19 Open20
## 1 4 2 5 4 4 4
## 2 4 4 1 4 1 2
## 3 4 1 5 4 1 1
## 4 6 3 5 5 4 3
##
##
## Recoding Specification
## ----------------------
## 1 --> 7
## 2 --> 6
## 3 --> 5
## 4 --> 4
## 5 --> 3
## 6 --> 2
## 7 --> 1
##
## Number of cases (rows) to recode: 164
##
## Replace existing values of each specified variable, no value for option: new.var
##
## --- Recode: Agree11 ---------------------------------
## Number of unique values of Agree11 in the data: 7
## Number of values of Agree11 to recode: 7
##
## --- Recode: Agree12 ---------------------------------
## Number of unique values of Agree12 in the data: 6
## >>> Note: A value specified to recode, 7, is not in the data.
##
## Number of values of Agree12 to recode: 7
##
## --- Recode: Agree13 ---------------------------------
## Number of unique values of Agree13 in the data: 7
## Number of values of Agree13 to recode: 7
##
## --- Recode: Agree14 ---------------------------------
## Number of unique values of Agree14 in the data: 7
## Number of values of Agree14 to recode: 7
##
## --- Recode: Agree15 ---------------------------------
## Number of unique values of Agree15 in the data: 6
## >>> Note: A value specified to recode, 7, is not in the data.
##
## Number of values of Agree15 to recode: 7
##
## --- Recode: Agree16 ---------------------------------
## Number of unique values of Agree16 in the data: 7
## Number of values of Agree16 to recode: 7
##
## --- Recode: Agree17 ---------------------------------
## Number of unique values of Agree17 in the data: 7
## Number of values of Agree17 to recode: 7
##
## --- Recode: Agree18 ---------------------------------
## Number of unique values of Agree18 in the data: 7
## Number of values of Agree18 to recode: 7
##
## --- Recode: Agree19 ---------------------------------
## Number of unique values of Agree19 in the data: 7
## Number of values of Agree19 to recode: 7
##
## --- Recode: Agree20 ---------------------------------
## Number of unique values of Agree20 in the data: 7
## Number of values of Agree20 to recode: 7
##
## --- Recode: BIDR02 ---------------------------------
## Number of unique values of BIDR02 in the data: 7
## Number of values of BIDR02 to recode: 7
##
## --- Recode: BIDR04 ---------------------------------
## Number of unique values of BIDR04 in the data: 7
## Number of values of BIDR04 to recode: 7
##
## --- Recode: BIDR06 ---------------------------------
## Number of unique values of BIDR06 in the data: 7
## Number of values of BIDR06 to recode: 7
##
## --- Recode: BIDR08 ---------------------------------
## Number of unique values of BIDR08 in the data: 7
## Number of values of BIDR08 to recode: 7
##
## --- Recode: BIDR10 ---------------------------------
## Number of unique values of BIDR10 in the data: 7
## Number of values of BIDR10 to recode: 7
##
## --- Recode: BIDR12 ---------------------------------
## Number of unique values of BIDR12 in the data: 7
## Number of values of BIDR12 to recode: 7
##
## --- Recode: BIDR14 ---------------------------------
## Number of unique values of BIDR14 in the data: 7
## Number of values of BIDR14 to recode: 7
##
## --- Recode: BIDR16 ---------------------------------
## Number of unique values of BIDR16 in the data: 7
## Number of values of BIDR16 to recode: 7
##
## --- Recode: BIDR18 ---------------------------------
## Number of unique values of BIDR18 in the data: 7
## Number of values of BIDR18 to recode: 7
##
## --- Recode: BIDR20 ---------------------------------
## Number of unique values of BIDR20 in the data: 7
## Number of values of BIDR20 to recode: 7
##
## --- Recode: BIDR21 ---------------------------------
## Number of unique values of BIDR21 in the data: 7
## Number of values of BIDR21 to recode: 7
##
## --- Recode: BIDR23 ---------------------------------
## Number of unique values of BIDR23 in the data: 7
## Number of values of BIDR23 to recode: 7
##
## --- Recode: BIDR25 ---------------------------------
## Number of unique values of BIDR25 in the data: 7
## Number of values of BIDR25 to recode: 7
##
## --- Recode: BIDR27 ---------------------------------
## Number of unique values of BIDR27 in the data: 7
## Number of values of BIDR27 to recode: 7
##
## --- Recode: BIDR29 ---------------------------------
## Number of unique values of BIDR29 in the data: 7
## Number of values of BIDR29 to recode: 7
##
## --- Recode: BIDR31 ---------------------------------
## Number of unique values of BIDR31 in the data: 7
## Number of values of BIDR31 to recode: 7
##
## --- Recode: BIDR33 ---------------------------------
## Number of unique values of BIDR33 in the data: 7
## Number of values of BIDR33 to recode: 7
##
## --- Recode: BIDR35 ---------------------------------
## Number of unique values of BIDR35 in the data: 7
## Number of values of BIDR35 to recode: 7
##
## --- Recode: BIDR37 ---------------------------------
## Number of unique values of BIDR37 in the data: 7
## Number of values of BIDR37 to recode: 7
##
## --- Recode: BIDR39 ---------------------------------
## Number of unique values of BIDR39 in the data: 7
## Number of values of BIDR39 to recode: 7
##
## --- Recode: Consc11 ---------------------------------
## Number of unique values of Consc11 in the data: 7
## Number of values of Consc11 to recode: 7
##
## --- Recode: Consc12 ---------------------------------
## Number of unique values of Consc12 in the data: 7
## Number of values of Consc12 to recode: 7
##
## --- Recode: Consc13 ---------------------------------
## Number of unique values of Consc13 in the data: 6
## >>> Note: A value specified to recode, 7, is not in the data.
##
## Number of values of Consc13 to recode: 7
##
## --- Recode: Consc14 ---------------------------------
## Number of unique values of Consc14 in the data: 7
## Number of values of Consc14 to recode: 7
##
## --- Recode: Consc15 ---------------------------------
## Number of unique values of Consc15 in the data: 6
## >>> Note: A value specified to recode, 7, is not in the data.
##
## Number of values of Consc15 to recode: 7
##
## --- Recode: Consc16 ---------------------------------
## Number of unique values of Consc16 in the data: 6
## >>> Note: A value specified to recode, 7, is not in the data.
##
## Number of values of Consc16 to recode: 7
##
## --- Recode: Consc17 ---------------------------------
## Number of unique values of Consc17 in the data: 6
## >>> Note: A value specified to recode, 7, is not in the data.
##
## Number of values of Consc17 to recode: 7
##
## --- Recode: Consc18 ---------------------------------
## Number of unique values of Consc18 in the data: 6
## >>> Note: A value specified to recode, 7, is not in the data.
##
## Number of values of Consc18 to recode: 7
##
## --- Recode: Consc19 ---------------------------------
## Number of unique values of Consc19 in the data: 7
## Number of values of Consc19 to recode: 7
##
## --- Recode: Consc20 ---------------------------------
## Number of unique values of Consc20 in the data: 7
## Number of values of Consc20 to recode: 7
##
## --- Recode: Extra11 ---------------------------------
## Number of unique values of Extra11 in the data: 7
## Number of values of Extra11 to recode: 7
##
## --- Recode: Extra12 ---------------------------------
## Number of unique values of Extra12 in the data: 7
## Number of values of Extra12 to recode: 7
##
## --- Recode: Extra13 ---------------------------------
## Number of unique values of Extra13 in the data: 6
## >>> Note: A value specified to recode, 7, is not in the data.
##
## Number of values of Extra13 to recode: 7
##
## --- Recode: Extra14 ---------------------------------
## Number of unique values of Extra14 in the data: 7
## Number of values of Extra14 to recode: 7
##
## --- Recode: Extra15 ---------------------------------
## Number of unique values of Extra15 in the data: 7
## Number of values of Extra15 to recode: 7
##
## --- Recode: Extra16 ---------------------------------
## Number of unique values of Extra16 in the data: 7
## Number of values of Extra16 to recode: 7
##
## --- Recode: Extra17 ---------------------------------
## Number of unique values of Extra17 in the data: 7
## Number of values of Extra17 to recode: 7
##
## --- Recode: Extra18 ---------------------------------
## Number of unique values of Extra18 in the data: 7
## Number of values of Extra18 to recode: 7
##
## --- Recode: Extra19 ---------------------------------
## Number of unique values of Extra19 in the data: 7
## Number of values of Extra19 to recode: 7
##
## --- Recode: Extra20 ---------------------------------
## Number of unique values of Extra20 in the data: 7
## Number of values of Extra20 to recode: 7
##
## --- Recode: Neurot11 ---------------------------------
## Number of unique values of Neurot11 in the data: 7
## Number of values of Neurot11 to recode: 7
##
## --- Recode: Neurot12 ---------------------------------
## Number of unique values of Neurot12 in the data: 7
## Number of values of Neurot12 to recode: 7
##
## --- Recode: Neurot13 ---------------------------------
## Number of unique values of Neurot13 in the data: 7
## Number of values of Neurot13 to recode: 7
##
## --- Recode: Neurot14 ---------------------------------
## Number of unique values of Neurot14 in the data: 7
## Number of values of Neurot14 to recode: 7
##
## --- Recode: Neurot15 ---------------------------------
## Number of unique values of Neurot15 in the data: 7
## Number of values of Neurot15 to recode: 7
##
## --- Recode: Neurot16 ---------------------------------
## Number of unique values of Neurot16 in the data: 7
## Number of values of Neurot16 to recode: 7
##
## --- Recode: Neurot17 ---------------------------------
## Number of unique values of Neurot17 in the data: 7
## Number of values of Neurot17 to recode: 7
##
## --- Recode: Neurot18 ---------------------------------
## Number of unique values of Neurot18 in the data: 7
## Number of values of Neurot18 to recode: 7
##
## --- Recode: Neurot19 ---------------------------------
## Number of unique values of Neurot19 in the data: 7
## Number of values of Neurot19 to recode: 7
##
## --- Recode: Neurot20 ---------------------------------
## Number of unique values of Neurot20 in the data: 7
## Number of values of Neurot20 to recode: 7
##
## --- Recode: Open11 ---------------------------------
## Number of unique values of Open11 in the data: 7
## Number of values of Open11 to recode: 7
##
## --- Recode: Open12 ---------------------------------
## Number of unique values of Open12 in the data: 7
## Number of values of Open12 to recode: 7
##
## --- Recode: Open13 ---------------------------------
## Number of unique values of Open13 in the data: 7
## Number of values of Open13 to recode: 7
##
## --- Recode: Open14 ---------------------------------
## Number of unique values of Open14 in the data: 7
## Number of values of Open14 to recode: 7
##
## --- Recode: Open15 ---------------------------------
## Number of unique values of Open15 in the data: 7
## Number of values of Open15 to recode: 7
##
## --- Recode: Open16 ---------------------------------
## Number of unique values of Open16 in the data: 7
## Number of values of Open16 to recode: 7
##
## --- Recode: Open17 ---------------------------------
## Number of unique values of Open17 in the data: 6
## >>> Note: A value specified to recode, 7, is not in the data.
##
## Number of values of Open17 to recode: 7
##
## --- Recode: Open18 ---------------------------------
## Number of unique values of Open18 in the data: 7
## Number of values of Open18 to recode: 7
##
## --- Recode: Open19 ---------------------------------
## Number of unique values of Open19 in the data: 7
## Number of values of Open19 to recode: 7
##
## --- Recode: Open20 ---------------------------------
## Number of unique values of Open20 in the data: 7
## Number of values of Open20 to recode: 7
##
##
## ------------------------------------------------
## First four rows of recoded data
## ------------------------------------------------
## Agree11 Agree12 Agree13 Agree14 Agree15 Agree16 Agree17 Agree18 Agree19
## 1 3 7 5 4 6 4 3 6 6
## 2 3 6 4 7 7 4 2 2 7
## 3 2 6 6 6 6 6 3 7 7
## 4 3 4 3 3 6 4 2 3 2
## Agree20 BIDR02 BIDR04 BIDR06 BIDR08 BIDR10 BIDR12 BIDR14 BIDR16 BIDR18
## 1 4 3 4 4 4 3 3 6 4 6
## 2 6 4 3 3 5 6 6 6 6 7
## 3 6 6 6 6 4 7 6 6 6 5
## 4 3 3 3 4 3 2 5 6 3 2
## BIDR20 BIDR21 BIDR23 BIDR25 BIDR27 BIDR29 BIDR31 BIDR33 BIDR35 BIDR37
## 1 2 3 3 3 3 4 4 2 1 1
## 2 6 4 4 7 4 4 2 1 2 6
## 3 6 3 6 6 6 7 6 3 3 2
## 4 3 6 3 4 2 6 7 2 2 3
## BIDR39 Consc11 Consc12 Consc13 Consc14 Consc15 Consc16 Consc17 Consc18
## 1 4 7 7 7 3 6 5 7 7
## 2 4 7 4 7 6 7 6 5 7
## 3 5 6 7 3 7 7 6 6 6
## 4 5 3 5 3 4 6 6 5 6
## Consc19 Consc20 Extra11 Extra12 Extra13 Extra14 Extra15 Extra16 Extra17
## 1 7 4 6 6 5 5 6 7 6
## 2 6 5 5 2 6 2 4 7 4
## 3 6 6 3 3 3 3 3 6 5
## 4 6 3 6 5 6 3 6 4 4
## Extra18 Extra19 Extra20 Neurot11 Neurot12 Neurot13 Neurot14 Neurot15
## 1 6 7 4 4 3 5 6 2
## 2 3 6 7 2 1 1 1 1
## 3 6 6 6 2 2 6 2 4
## 4 3 4 4 5 1 6 6 2
## Neurot16 Neurot17 Neurot18 Neurot19 Neurot20 Open11 Open12 Open13 Open14
## 1 5 4 4 6 5 4 4 5 4
## 2 1 1 1 1 2 6 6 6 6
## 3 2 2 6 2 2 7 7 2 5
## 4 3 6 6 4 5 2 6 5 6
## Open15 Open16 Open17 Open18 Open19 Open20
## 1 4 6 3 4 4 4
## 2 4 4 7 4 7 6
## 3 4 7 3 4 7 7
## 4 2 5 3 3 4 5
rm(d.0)
names(d)
## [1] "id" "Start" "End" "Agree01" "Agree02" "Agree03"
## [7] "Agree04" "Agree05" "Agree06" "Agree07" "Agree08" "Agree09"
## [13] "Agree10" "Agree11" "Agree12" "Agree13" "Agree14" "Agree15"
## [19] "Agree16" "Agree17" "Agree18" "Agree19" "Agree20" "BIDR01"
## [25] "BIDR02" "BIDR03" "BIDR04" "BIDR05" "BIDR06" "BIDR07"
## [31] "BIDR08" "BIDR09" "BIDR10" "BIDR11" "BIDR12" "BIDR13"
## [37] "BIDR14" "BIDR15" "BIDR16" "BIDR17" "BIDR18" "BIDR19"
## [43] "BIDR20" "BIDR21" "BIDR22" "BIDR23" "BIDR24" "BIDR25"
## [49] "BIDR26" "BIDR27" "BIDR28" "BIDR29" "BIDR30" "BIDR31"
## [55] "BIDR32" "BIDR33" "BIDR34" "BIDR35" "BIDR36" "BIDR37"
## [61] "BIDR38" "BIDR39" "BIDR40" "Consc01" "Consc02" "Consc03"
## [67] "Consc04" "Consc05" "Consc06" "Consc07" "Consc08" "Consc09"
## [73] "Consc10" "Consc11" "Consc12" "Consc13" "Consc14" "Consc15"
## [79] "Consc16" "Consc17" "Consc18" "Consc19" "Consc20" "Extra01"
## [85] "Extra02" "Extra03" "Extra04" "Extra05" "Extra06" "Extra07"
## [91] "Extra08" "Extra09" "Extra10" "Extra11" "Extra12" "Extra13"
## [97] "Extra14" "Extra15" "Extra16" "Extra17" "Extra18" "Extra19"
## [103] "Extra20" "Neurot01" "Neurot02" "Neurot03" "Neurot04" "Neurot05"
## [109] "Neurot06" "Neurot07" "Neurot09" "Neurot10" "Neurot11" "Neurot12"
## [115] "Neurot13" "Neurot14" "Neurot15" "Neurot16" "Neurot17" "Neurot18"
## [121] "Neurot19" "Neurot20" "Neurot8" "Open01" "Open02" "Open03"
## [127] "Open04" "Open05" "Open06" "Open07" "Open08" "Open09"
## [133] "Open10" "Open11" "Open12" "Open13" "Open14" "Open15"
## [139] "Open16" "Open17" "Open18" "Open19" "Open20" "Qual01"
## [145] "Qual02" "Age" "Race" "GenderMF"
library("lavaan")
## This is lavaan 0.6-7
## lavaan is BETA software! Please report any bugs.
##
## Attaching package: 'lavaan'
## The following object is masked from 'package:lessR':
##
## cfa
## The following object is masked from 'package:psych':
##
## cor2cov
library("lavaanPlot")
ex <- 'extra =~ Extra01+ Extra02 + Extra03 + Extra04 + Extra05 + Extra06 + Extra07 + Extra08 + Extra09 + Extra10 + Extra11 + Extra12 + Extra13 + Extra14 + Extra15 + Extra16 + Extra17 + Extra18 + Extra19 + Extra20'
lavaanify(model=ex)
## id lhs op rhs user block group free ustart exo label plabel
## 1 1 extra =~ Extra01 1 1 1 1 NA 0 .p1.
## 2 2 extra =~ Extra02 1 1 1 2 NA 0 .p2.
## 3 3 extra =~ Extra03 1 1 1 3 NA 0 .p3.
## 4 4 extra =~ Extra04 1 1 1 4 NA 0 .p4.
## 5 5 extra =~ Extra05 1 1 1 5 NA 0 .p5.
## 6 6 extra =~ Extra06 1 1 1 6 NA 0 .p6.
## 7 7 extra =~ Extra07 1 1 1 7 NA 0 .p7.
## 8 8 extra =~ Extra08 1 1 1 8 NA 0 .p8.
## 9 9 extra =~ Extra09 1 1 1 9 NA 0 .p9.
## 10 10 extra =~ Extra10 1 1 1 10 NA 0 .p10.
## 11 11 extra =~ Extra11 1 1 1 11 NA 0 .p11.
## 12 12 extra =~ Extra12 1 1 1 12 NA 0 .p12.
## 13 13 extra =~ Extra13 1 1 1 13 NA 0 .p13.
## 14 14 extra =~ Extra14 1 1 1 14 NA 0 .p14.
## 15 15 extra =~ Extra15 1 1 1 15 NA 0 .p15.
## 16 16 extra =~ Extra16 1 1 1 16 NA 0 .p16.
## 17 17 extra =~ Extra17 1 1 1 17 NA 0 .p17.
## 18 18 extra =~ Extra18 1 1 1 18 NA 0 .p18.
## 19 19 extra =~ Extra19 1 1 1 19 NA 0 .p19.
## 20 20 extra =~ Extra20 1 1 1 20 NA 0 .p20.
## 21 21 Extra01 ~~ Extra01 0 1 1 0 0 0 .p21.
## 22 22 Extra02 ~~ Extra02 0 1 1 0 0 0 .p22.
## 23 23 Extra03 ~~ Extra03 0 1 1 0 0 0 .p23.
## 24 24 Extra04 ~~ Extra04 0 1 1 0 0 0 .p24.
## 25 25 Extra05 ~~ Extra05 0 1 1 0 0 0 .p25.
## 26 26 Extra06 ~~ Extra06 0 1 1 0 0 0 .p26.
## 27 27 Extra07 ~~ Extra07 0 1 1 0 0 0 .p27.
## 28 28 Extra08 ~~ Extra08 0 1 1 0 0 0 .p28.
## 29 29 Extra09 ~~ Extra09 0 1 1 0 0 0 .p29.
## 30 30 Extra10 ~~ Extra10 0 1 1 0 0 0 .p30.
## 31 31 Extra11 ~~ Extra11 0 1 1 0 0 0 .p31.
## 32 32 Extra12 ~~ Extra12 0 1 1 0 0 0 .p32.
## 33 33 Extra13 ~~ Extra13 0 1 1 0 0 0 .p33.
## 34 34 Extra14 ~~ Extra14 0 1 1 0 0 0 .p34.
## 35 35 Extra15 ~~ Extra15 0 1 1 0 0 0 .p35.
## 36 36 Extra16 ~~ Extra16 0 1 1 0 0 0 .p36.
## 37 37 Extra17 ~~ Extra17 0 1 1 0 0 0 .p37.
## 38 38 Extra18 ~~ Extra18 0 1 1 0 0 0 .p38.
## 39 39 Extra19 ~~ Extra19 0 1 1 0 0 0 .p39.
## 40 40 Extra20 ~~ Extra20 0 1 1 0 0 0 .p40.
## 41 41 extra ~~ extra 0 1 1 0 0 0 .p41.
ex.out <-cfa(ex, data=d)
lavaanPlot(model = ex.out)
summary(ex.out, fit.measures=TRUE, standardized = TRUE)
## lavaan 0.6-7 ended normally after 29 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of free parameters 40
##
## Number of observations 164
##
## Model Test User Model:
##
## Test statistic 521.869
## Degrees of freedom 170
## P-value (Chi-square) 0.000
##
## Model Test Baseline Model:
##
## Test statistic 1779.688
## Degrees of freedom 190
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.779
## Tucker-Lewis Index (TLI) 0.753
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -5255.790
## Loglikelihood unrestricted model (H1) -4994.855
##
## Akaike (AIC) 10591.580
## Bayesian (BIC) 10715.574
## Sample-size adjusted Bayesian (BIC) 10588.937
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.112
## 90 Percent confidence interval - lower 0.101
## 90 Percent confidence interval - upper 0.123
## P-value RMSEA <= 0.05 0.000
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.084
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## extra =~
## Extra01 1.000 0.805 0.699
## Extra02 1.216 0.132 9.179 0.000 0.979 0.755
## Extra03 1.163 0.144 8.066 0.000 0.937 0.661
## Extra04 1.173 0.156 7.525 0.000 0.945 0.615
## Extra05 0.828 0.135 6.131 0.000 0.667 0.499
## Extra06 1.244 0.131 9.483 0.000 1.002 0.781
## Extra07 0.930 0.134 6.968 0.000 0.749 0.568
## Extra08 1.421 0.181 7.839 0.000 1.145 0.641
## Extra09 0.988 0.171 5.791 0.000 0.795 0.471
## Extra10 0.673 0.110 6.107 0.000 0.542 0.497
## Extra11 1.117 0.159 7.023 0.000 0.900 0.573
## Extra12 1.431 0.167 8.551 0.000 1.153 0.702
## Extra13 0.843 0.136 6.197 0.000 0.679 0.504
## Extra14 0.891 0.151 5.888 0.000 0.718 0.479
## Extra15 1.614 0.174 9.263 0.000 1.300 0.762
## Extra16 1.220 0.139 8.782 0.000 0.983 0.721
## Extra17 1.045 0.174 6.004 0.000 0.842 0.488
## Extra18 1.211 0.149 8.126 0.000 0.975 0.666
## Extra19 1.417 0.160 8.863 0.000 1.141 0.728
## Extra20 1.015 0.159 6.402 0.000 0.818 0.521
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .Extra01 0.679 0.080 8.458 0.000 0.679 0.511
## .Extra02 0.723 0.088 8.226 0.000 0.723 0.430
## .Extra03 1.133 0.132 8.572 0.000 1.133 0.564
## .Extra04 1.467 0.169 8.676 0.000 1.467 0.622
## .Extra05 1.341 0.152 8.849 0.000 1.341 0.751
## .Extra06 0.641 0.079 8.076 0.000 0.641 0.390
## .Extra07 1.176 0.134 8.758 0.000 1.176 0.677
## .Extra08 1.874 0.217 8.619 0.000 1.874 0.589
## .Extra09 2.221 0.250 8.878 0.000 2.221 0.778
## .Extra10 0.895 0.101 8.851 0.000 0.895 0.753
## .Extra11 1.656 0.189 8.750 0.000 1.656 0.672
## .Extra12 1.372 0.162 8.450 0.000 1.372 0.508
## .Extra13 1.352 0.153 8.843 0.000 1.352 0.746
## .Extra14 1.731 0.195 8.870 0.000 1.731 0.771
## .Extra15 1.217 0.149 8.188 0.000 1.217 0.419
## .Extra16 0.891 0.106 8.378 0.000 0.891 0.480
## .Extra17 2.261 0.255 8.860 0.000 2.261 0.761
## .Extra18 1.195 0.140 8.559 0.000 1.195 0.557
## .Extra19 1.154 0.138 8.350 0.000 1.154 0.470
## .Extra20 1.790 0.203 8.822 0.000 1.790 0.728
## extra 0.649 0.129 5.021 0.000 1.000 1.000
ex2 <- 'extra2 =~ Extra01+ Extra02 + Extra03 + Extra06 + Extra08 + Extra12 + Extra15 + Extra16 + Extra18 + Extra19'
lavaanify(model=ex2)
## id lhs op rhs user block group free ustart exo label plabel
## 1 1 extra2 =~ Extra01 1 1 1 1 NA 0 .p1.
## 2 2 extra2 =~ Extra02 1 1 1 2 NA 0 .p2.
## 3 3 extra2 =~ Extra03 1 1 1 3 NA 0 .p3.
## 4 4 extra2 =~ Extra06 1 1 1 4 NA 0 .p4.
## 5 5 extra2 =~ Extra08 1 1 1 5 NA 0 .p5.
## 6 6 extra2 =~ Extra12 1 1 1 6 NA 0 .p6.
## 7 7 extra2 =~ Extra15 1 1 1 7 NA 0 .p7.
## 8 8 extra2 =~ Extra16 1 1 1 8 NA 0 .p8.
## 9 9 extra2 =~ Extra18 1 1 1 9 NA 0 .p9.
## 10 10 extra2 =~ Extra19 1 1 1 10 NA 0 .p10.
## 11 11 Extra01 ~~ Extra01 0 1 1 0 0 0 .p11.
## 12 12 Extra02 ~~ Extra02 0 1 1 0 0 0 .p12.
## 13 13 Extra03 ~~ Extra03 0 1 1 0 0 0 .p13.
## 14 14 Extra06 ~~ Extra06 0 1 1 0 0 0 .p14.
## 15 15 Extra08 ~~ Extra08 0 1 1 0 0 0 .p15.
## 16 16 Extra12 ~~ Extra12 0 1 1 0 0 0 .p16.
## 17 17 Extra15 ~~ Extra15 0 1 1 0 0 0 .p17.
## 18 18 Extra16 ~~ Extra16 0 1 1 0 0 0 .p18.
## 19 19 Extra18 ~~ Extra18 0 1 1 0 0 0 .p19.
## 20 20 Extra19 ~~ Extra19 0 1 1 0 0 0 .p20.
## 21 21 extra2 ~~ extra2 0 1 1 0 0 0 .p21.
ex2.out <-cfa(ex2, data=d)
lavaanPlot(model = ex2.out)
summary(ex2.out, fit.measures=TRUE, standardized = TRUE)
## lavaan 0.6-7 ended normally after 24 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of free parameters 20
##
## Number of observations 164
##
## Model Test User Model:
##
## Test statistic 81.571
## Degrees of freedom 35
## P-value (Chi-square) 0.000
##
## Model Test Baseline Model:
##
## Test statistic 860.051
## Degrees of freedom 45
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.943
## Tucker-Lewis Index (TLI) 0.927
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -2552.818
## Loglikelihood unrestricted model (H1) -2512.032
##
## Akaike (AIC) 5145.635
## Bayesian (BIC) 5207.632
## Sample-size adjusted Bayesian (BIC) 5144.314
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.090
## 90 Percent confidence interval - lower 0.065
## 90 Percent confidence interval - upper 0.116
## P-value RMSEA <= 0.05 0.006
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.048
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## extra2 =~
## Extra01 1.000 0.788 0.684
## Extra02 1.219 0.141 8.656 0.000 0.960 0.740
## Extra03 1.187 0.152 7.788 0.000 0.935 0.659
## Extra06 1.311 0.141 9.329 0.000 1.032 0.805
## Extra08 1.399 0.191 7.327 0.000 1.102 0.618
## Extra12 1.432 0.177 8.080 0.000 1.128 0.686
## Extra15 1.662 0.186 8.949 0.000 1.309 0.768
## Extra16 1.255 0.148 8.497 0.000 0.988 0.725
## Extra18 1.238 0.158 7.852 0.000 0.975 0.665
## Extra19 1.503 0.170 8.817 0.000 1.184 0.755
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .Extra01 0.707 0.085 8.321 0.000 0.707 0.533
## .Extra02 0.761 0.095 8.039 0.000 0.761 0.452
## .Extra03 1.136 0.135 8.411 0.000 1.136 0.565
## .Extra06 0.580 0.077 7.510 0.000 0.580 0.352
## .Extra08 1.970 0.231 8.540 0.000 1.970 0.618
## .Extra12 1.429 0.172 8.310 0.000 1.429 0.529
## .Extra15 1.192 0.152 7.848 0.000 1.192 0.410
## .Extra16 0.880 0.108 8.126 0.000 0.880 0.474
## .Extra18 1.196 0.143 8.391 0.000 1.196 0.557
## .Extra19 1.055 0.133 7.940 0.000 1.055 0.430
## extra2 0.620 0.129 4.827 0.000 1.000 1.000