library(haven); library(dplyr)

ICILS 2018 USA data

ICILS測量八年級學生電腦科學與運算思維的能力與觀感,其中包含以下構念:

Positive Perception = IS2G28A + IS2G28B + IS2G28F + IS2G28G
Negative Perception = IS2G28C + IS2G28D + IS2G28E + IS2G28H
Expectation = IS2G28I + IS2G28J + IS2G28K
Self-Efficacy use specialist = IS2G27B + IS2G27E + IS2G27G + IS2G27H
Self-Efficacy use general = IS2G27A + IS2G27C + IS2G27D + IS2G27I + IS2G27J + IS2G27K + IS2G27L IS2G27M
每題皆為四點量表 1-4[非常不同意-不同意-同意-非常同意]

dat <- read_sav("./BSGUSAI2.sav")|>
  dplyr::select(c(IDSTUD, S_TLANG, S_SEX, S_ISCED, S_P1ISCED, S_P2ISCED, S_HISCED, 
                  S_IMMBGR, S_IMMIG, S_INTNET,  S_SPECEFF, S_GENEFF, S_ICTFUT,
                  S_ICTNEG, S_ICTPOS,
                  IS2G28A, IS2G28B, IS2G28F, IS2G28G, 
                  IS2G28C, IS2G28D, IS2G28E, IS2G28H, 
                  IS2G28I, IS2G28J, IS2G28K,
                  IS2G27B, IS2G27E, IS2G27G, IS2G27H,
                  IS2G27A, IS2G27C, IS2G27D, IS2G27I, IS2G27J, IS2G27K, IS2G27L, IS2G27M))
str(dat)
## tibble [6,790 × 38] (S3: tbl_df/tbl/data.frame)
##  $ IDSTUD   : dbl+lbl [1:6790] 1e+07, 1e+07, 1e+07, 1e+07, 1e+07, 1e+07, 1e+07, 1e+0...
##    ..@ label      : chr "Student ID"
##    ..@ format.spss: chr "F8.0"
##    ..@ labels     : Named num [1:2] 1e+08 1e+08
##    .. ..- attr(*, "names")= chr [1:2] "Not administered or missing by design" "Presented but not answered or invalid"
##  $ S_TLANG  : dbl+lbl [1:6790] 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1,...
##    ..@ label      : chr "Test language spoken at home"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:4] 0 1 8 9
##    .. ..- attr(*, "names")= chr [1:4] "Other Language" "Language of test" "Not administered or missing by design" "Presented but not answered or invalid"
##  $ S_SEX    : dbl+lbl [1:6790] 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1,...
##    ..@ label      : chr "Sex of student"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:4] 0 1 8 9
##    .. ..- attr(*, "names")= chr [1:4] "Boy" "Girl" "Not administered or missing by design" "Presented but not answered or invalid"
##  $ S_ISCED  : dbl+lbl [1:6790] 4, 3, 4, 4, 4, 4, 4, 4, 3, 4, 0, 4, 4, 3, 3, 4, 4, 4,...
##    ..@ label      : chr "Expected ISCED by student"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:7] 0 1 2 3 4 8 9
##    .. ..- attr(*, "names")= chr [1:7] "I do not expect to complete ISCED level 2" "ISCED level 2" "ISCED level 3" "ISCED level 4 or 5" ...
##  $ S_P1ISCED: dbl+lbl [1:6790]  1,  3,  1,  3,  3,  3,  3,  4,  1,  2,  2,  2,  4, N...
##    ..@ label      : chr "ISCED of parent 1"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:7] 0 1 2 3 4 8 9
##    .. ..- attr(*, "names")= chr [1:7] "He/She did not complete ISCED level 2" "ISCED level 2" "ISCED level 3" "ISCED level 4 or 5" ...
##  $ S_P2ISCED: dbl+lbl [1:6790]  1,  3,  1,  2,  3,  2, NA,  4,  2,  3,  3,  2,  3, N...
##    ..@ label      : chr "ISCED of parent 2"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:7] 0 1 2 3 4 8 9
##    .. ..- attr(*, "names")= chr [1:7] "He/She did not complete ISCED level 2" "ISCED level 2" "ISCED level 3" "ISCED level 4 or 5" ...
##  $ S_HISCED : dbl+lbl [1:6790]  1,  3,  1,  3,  3,  3,  3,  4,  2,  3,  3,  2,  4, N...
##    ..@ label      : chr "Highest ISCED of parents"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:7] 0 1 2 3 4 8 9
##    .. ..- attr(*, "names")= chr [1:7] "He/She did not complete ISCED level 2" "ISCED level 2" "ISCED level 3" "ISCED level 4 or 5" ...
##  $ S_IMMBGR : dbl+lbl [1:6790]  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  ...
##    ..@ label      : chr "Immigration status (dichotomous)"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:4] 0 1 8 9
##    .. ..- attr(*, "names")= chr [1:4] "Students without immigrant background" "Students with immigrant background" "Not administered or missing by design" "Presented but not answered or invalid"
##  $ S_IMMIG  : dbl+lbl [1:6790]  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  ...
##    ..@ label      : chr "Immigration status"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:5] 0 1 2 8 9
##    .. ..- attr(*, "names")= chr [1:5] "Students and/or at least one parent born in country of test" "Student born in country of test but both/only parent(s) born abroad" "Student and both/only parent(s) born abroad" "Not administered or missing by design" ...
##  $ S_INTNET : dbl+lbl [1:6790] NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
##    ..@ label      : chr "Internet access at home"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:4] 0 1 8 9
##    .. ..- attr(*, "names")= chr [1:4] "No" "Yes" "Not administered or missing by design" "Presented but not answered or invalid"
##  $ S_SPECEFF: dbl+lbl [1:6790] 54.1, 30.5, 38.7, 38.7, 43.3, 47.1, 50.6, 50.6, 43.3,...
##    ..@ label      : chr "ICT self-efficacy regarding the use of specialist applications"
##    ..@ format.spss: chr "F6.2"
##    ..@ labels     : Named num [1:2] 998 999
##    .. ..- attr(*, "names")= chr [1:2] "Not administered or missing by design" "Presented but not answered or invalid"
##  $ S_GENEFF : dbl+lbl [1:6790] 52.5, 29.5, 48.2, 61.1, 52.5, 52.5, 61.1, 48.2, 61.1,...
##    ..@ label      : chr "ICT self-efficacy regarding the use of general applications"
##    ..@ format.spss: chr "F6.2"
##    ..@ labels     : Named num [1:2] 998 999
##    .. ..- attr(*, "names")= chr [1:2] "Not administered or missing by design" "Presented but not answered or invalid"
##  $ S_ICTFUT : dbl+lbl [1:6790] 53.0, 53.7, 50.1, 43.4, 43.4, 43.4, 50.1, 36.2, 46.6,...
##    ..@ label      : chr "Expectations of future ICT use for work and study"
##    ..@ format.spss: chr "F6.2"
##    ..@ labels     : Named num [1:2] 998 999
##    .. ..- attr(*, "names")= chr [1:2] "Not administered or missing by design" "Presented but not answered or invalid"
##  $ S_ICTNEG : dbl+lbl [1:6790] 54.7, 44.4, 54.7, 38.0, 44.4, 44.4, 47.7, 38.0, 51.1,...
##    ..@ label      : chr "Negative perceptions of ICT for society"
##    ..@ format.spss: chr "F6.2"
##    ..@ labels     : Named num [1:2] 998 999
##    .. ..- attr(*, "names")= chr [1:2] "Not administered or missing by design" "Presented but not answered or invalid"
##  $ S_ICTPOS : dbl+lbl [1:6790] 56.1, 51.8, 41.8, 56.1, 46.4, 46.5, 46.5, 56.1, 41.8,...
##    ..@ label      : chr "Positive perceptions of ICT for society"
##    ..@ format.spss: chr "F6.2"
##    ..@ labels     : Named num [1:2] 998 999
##    .. ..- attr(*, "names")= chr [1:2] "Not administered or missing by design" "Presented but not answered or invalid"
##  $ IS2G28A  : dbl+lbl [1:6790]  1,  2,  3,  2, NA,  2,  2,  2,  2,  3,  2,  3,  2, N...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/Agree or disagree with the following statements about ICT in society/Advances in "| __truncated__
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:6] 1 2 3 4 8 9
##    .. ..- attr(*, "names")= chr [1:6] "Strongly agree" "Agree" "Disagree" "Strongly disagree" ...
##  $ IS2G28B  : dbl+lbl [1:6790]  2,  1,  2,  1,  2,  2,  2,  2,  3,  2,  2,  3,  2, N...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/Agree or disagree with the following statements about ICT in society/ICT helps us"| __truncated__
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:6] 1 2 3 4 8 9
##    .. ..- attr(*, "names")= chr [1:6] "Strongly agree" "Agree" "Disagree" "Strongly disagree" ...
##  $ IS2G28F  : dbl+lbl [1:6790]  2,  2,  2,  2,  2,  2,  2,  1,  2,  1,  1,  3,  3, N...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/Agree or disagree with the following statements about ICT in society/ICT is valuable to society"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:6] 1 2 3 4 8 9
##    .. ..- attr(*, "names")= chr [1:6] "Strongly agree" "Agree" "Disagree" "Strongly disagree" ...
##  $ IS2G28G  : dbl+lbl [1:6790]  1,  2,  2,  1,  2,  2,  2,  1,  2,  1,  2,  3,  2, N...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/Agree or disagree with the following statements about ICT in society/Advances in "| __truncated__
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:6] 1 2 3 4 8 9
##    .. ..- attr(*, "names")= chr [1:6] "Strongly agree" "Agree" "Disagree" "Strongly disagree" ...
##  $ IS2G28C  : dbl+lbl [1:6790]  2,  3,  2,  2,  2,  2,  2,  2,  1,  1,  3,  3,  2, N...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/Agree or disagree with the following statements about ICT in society/Using ICT ma"| __truncated__
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:6] 1 2 3 4 8 9
##    .. ..- attr(*, "names")= chr [1:6] "Strongly agree" "Agree" "Disagree" "Strongly disagree" ...
##  $ IS2G28D  : dbl+lbl [1:6790]  2,  2,  1,  3,  3,  3,  3,  3,  3,  3,  2,  3,  3, N...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/Agree or disagree with the following statements about ICT in society/With more IC"| __truncated__
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:6] 1 2 3 4 8 9
##    .. ..- attr(*, "names")= chr [1:6] "Strongly agree" "Agree" "Disagree" "Strongly disagree" ...
##  $ IS2G28E  : dbl+lbl [1:6790]  1,  2,  2,  3,  2,  2,  2,  3,  1,  1,  2,  3,  2, N...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/Agree or disagree with the following statements about ICT in society/People spend"| __truncated__
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:6] 1 2 3 4 8 9
##    .. ..- attr(*, "names")= chr [1:6] "Strongly agree" "Agree" "Disagree" "Strongly disagree" ...
##  $ IS2G28H  : dbl+lbl [1:6790]  2,  3,  2,  4,  3,  3,  2,  4,  3,  2,  2,  3,  2, N...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/Agree or disagree with the following statements about ICT in society/Using ICT ma"| __truncated__
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:6] 1 2 3 4 8 9
##    .. ..- attr(*, "names")= chr [1:6] "Strongly agree" "Agree" "Disagree" "Strongly disagree" ...
##  $ IS2G28I  : dbl+lbl [1:6790]  2,  2,  3,  3,  3,  4,  2,  4,  3,  2, NA,  3,  3, N...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/Agree or disagree with the following statements about ICT in society/I would like"| __truncated__
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:6] 1 2 3 4 8 9
##    .. ..- attr(*, "names")= chr [1:6] "Strongly agree" "Agree" "Disagree" "Strongly disagree" ...
##  $ IS2G28J  : dbl+lbl [1:6790] NA,  2,  2,  3,  3,  3,  3,  4,  3,  3, NA,  3,  3, N...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/Agree or disagree with the following statements about ICT in society/I hope to fi"| __truncated__
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:6] 1 2 3 4 8 9
##    .. ..- attr(*, "names")= chr [1:6] "Strongly agree" "Agree" "Disagree" "Strongly disagree" ...
##  $ IS2G28K  : dbl+lbl [1:6790]  2,  2,  2,  3,  3,  2,  2,  3,  2,  2, NA,  3,  3, N...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/Agree or disagree with the following statements about ICT in society/Learning how"| __truncated__
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:6] 1 2 3 4 8 9
##    .. ..- attr(*, "names")= chr [1:6] "Strongly agree" "Agree" "Disagree" "Strongly disagree" ...
##  $ IS2G27B  : dbl+lbl [1:6790]  2,  3,  3,  3,  3,  2,  2,  2,  2,  3,  3,  2,  2,  ...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/How well can you do/Create a database (e.g. using [Microsoft Access ®])"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:5] 1 2 3 8 9
##    .. ..- attr(*, "names")= chr [1:5] "I know how to do this." "I have never done this but I could work out how to do this." "I do not think I could do this." "Not administered or missing by design" ...
##  $ IS2G27E  : dbl+lbl [1:6790]  1,  3,  2,  2,  2,  1,  2,  2,  2,  2,  1,  2,  3,  ...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/How well can you do/Build or edit a webpage"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:5] 1 2 3 8 9
##    .. ..- attr(*, "names")= chr [1:5] "I know how to do this." "I have never done this but I could work out how to do this." "I do not think I could do this." "Not administered or missing by design" ...
##  $ IS2G27G  : dbl+lbl [1:6790]  2,  3,  3,  3,  2,  3,  2,  2,  3,  3, NA,  2,  3,  ...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/How well can you do/Create a computer program, macro, or [app]"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:5] 1 2 3 8 9
##    .. ..- attr(*, "names")= chr [1:5] "I know how to do this." "I have never done this but I could work out how to do this." "I do not think I could do this." "Not administered or missing by design" ...
##  $ IS2G27H  : dbl+lbl [1:6790]  2,  3,  3,  3,  3,  3,  2,  2,  3,  3, NA,  2,  3,  ...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/How well can you do/Set up a local area network of computers or other ICT"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:5] 1 2 3 8 9
##    .. ..- attr(*, "names")= chr [1:5] "I know how to do this." "I have never done this but I could work out how to do this." "I do not think I could do this." "Not administered or missing by design" ...
##  $ IS2G27A  : dbl+lbl [1:6790]  1,  3,  2,  1,  1,  2,  1,  2,  1,  3,  1,  1,  1,  ...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/How well can you do/Edit digital photographs or other graphic images"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:5] 1 2 3 8 9
##    .. ..- attr(*, "names")= chr [1:5] "I know how to do this." "I have never done this but I could work out how to do this." "I do not think I could do this." "Not administered or missing by design" ...
##  $ IS2G27C  : dbl+lbl [1:6790]  1,  3,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  ...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/How well can you do/Write or edit text for a school assignment"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:5] 1 2 3 8 9
##    .. ..- attr(*, "names")= chr [1:5] "I know how to do this." "I have never done this but I could work out how to do this." "I do not think I could do this." "Not administered or missing by design" ...
##  $ IS2G27D  : dbl+lbl [1:6790]  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  ...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/How well can you do/Search for and find relevant information for a school project"| __truncated__
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:5] 1 2 3 8 9
##    .. ..- attr(*, "names")= chr [1:5] "I know how to do this." "I have never done this but I could work out how to do this." "I do not think I could do this." "Not administered or missing by design" ...
##  $ IS2G27I  : dbl+lbl [1:6790]  1,  3,  2,  1,  1,  1,  1,  2,  1,  3, NA,  1,  1,  ...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/How well can you do/Create a multi-media presentation"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:5] 1 2 3 8 9
##    .. ..- attr(*, "names")= chr [1:5] "I know how to do this." "I have never done this but I could work out how to do this." "I do not think I could do this." "Not administered or missing by design" ...
##  $ IS2G27J  : dbl+lbl [1:6790]  1,  3,  1,  1,  1,  1,  1,  1,  1,  1, NA,  1,  1,  ...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/How well can you do/Upload text, images, or video to an online profile"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:5] 1 2 3 8 9
##    .. ..- attr(*, "names")= chr [1:5] "I know how to do this." "I have never done this but I could work out how to do this." "I do not think I could do this." "Not administered or missing by design" ...
##  $ IS2G27K  : dbl+lbl [1:6790]  1,  3,  1,  1,  1,  1,  1,  1,  1,  1, NA,  1,  1,  ...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/How well can you do/Insert an image into a document or message"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:5] 1 2 3 8 9
##    .. ..- attr(*, "names")= chr [1:5] "I know how to do this." "I have never done this but I could work out how to do this." "I do not think I could do this." "Not administered or missing by design" ...
##  $ IS2G27L  : dbl+lbl [1:6790]  1,  3,  1,  1,  1,  1,  1,  1,  1,  1, NA,  1,  1,  ...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/How well can you do/Install a program or [<app>]"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:5] 1 2 3 8 9
##    .. ..- attr(*, "names")= chr [1:5] "I know how to do this." "I have never done this but I could work out how to do this." "I do not think I could do this." "Not administered or missing by design" ...
##  $ IS2G27M  : dbl+lbl [1:6790]  2,  1,  1,  1,  2,  1,  1,  1,  1,  1, NA,  2,  1,  ...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/How well can you do/Judge whether you can trust information you find on the Internet"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:5] 1 2 3 8 9
##    .. ..- attr(*, "names")= chr [1:5] "I know how to do this." "I have never done this but I could work out how to do this." "I do not think I could do this." "Not administered or missing by design" ...
# recode & sum 
vars <- c("IS2G28A", "IS2G28B", "IS2G28F", "IS2G28G", 
          "IS2G28C", "IS2G28D", "IS2G28E", "IS2G28H", 
          "IS2G28I", "IS2G28J", "IS2G28K")
table(dat$IS2G28A)
## 
##    1    2    3    4 
## 1339 3449  900  139
dat[vars] <- lapply(dat[vars], function(x) 5 - x)
table(dat$IS2G28A)
## 
##    1    2    3    4 
##  139  900 3449 1339
dat <- dat |>
       dplyr::mutate(PP = IS2G28A + IS2G28B + IS2G28F + IS2G28G, # PP Positive Perception 
                     NP = IS2G28C + IS2G28D + IS2G28E + IS2G28H, # NP Negative Perception
                     EP = IS2G28I + IS2G28J + IS2G28K,           # EP Expectation
                     SEs = IS2G27B + IS2G27E + IS2G27G + IS2G27H,# Self-Efficacy use specialist
                     SEg = IS2G27A + IS2G27C + IS2G27D + IS2G27I + IS2G27J + IS2G27K + IS2G27L + IS2G27M)|> # Self-Efficacy use general
        dplyr::mutate(PP = as.factor(PP),
                      NP = as.factor(NP),
                      EP = as.factor(EP),
                      SEs = as.factor(SEs),
                      SEg = as.factor(SEg)) 

names(dat)
##  [1] "IDSTUD"    "S_TLANG"   "S_SEX"     "S_ISCED"   "S_P1ISCED" "S_P2ISCED"
##  [7] "S_HISCED"  "S_IMMBGR"  "S_IMMIG"   "S_INTNET"  "S_SPECEFF" "S_GENEFF" 
## [13] "S_ICTFUT"  "S_ICTNEG"  "S_ICTPOS"  "IS2G28A"   "IS2G28B"   "IS2G28F"  
## [19] "IS2G28G"   "IS2G28C"   "IS2G28D"   "IS2G28E"   "IS2G28H"   "IS2G28I"  
## [25] "IS2G28J"   "IS2G28K"   "IS2G27B"   "IS2G27E"   "IS2G27G"   "IS2G27H"  
## [31] "IS2G27A"   "IS2G27C"   "IS2G27D"   "IS2G27I"   "IS2G27J"   "IS2G27K"  
## [37] "IS2G27L"   "IS2G27M"   "PP"        "NP"        "EP"        "SEs"      
## [43] "SEg"
str(dat[,c(16:43)])
## tibble [6,790 × 28] (S3: tbl_df/tbl/data.frame)
##  $ IS2G28A: num [1:6790] 4 3 2 3 NA 3 3 3 3 2 ...
##  $ IS2G28B: num [1:6790] 3 4 3 4 3 3 3 3 2 3 ...
##  $ IS2G28F: num [1:6790] 3 3 3 3 3 3 3 4 3 4 ...
##  $ IS2G28G: num [1:6790] 4 3 3 4 3 3 3 4 3 4 ...
##  $ IS2G28C: num [1:6790] 3 2 3 3 3 3 3 3 4 4 ...
##  $ IS2G28D: num [1:6790] 3 3 4 2 2 2 2 2 2 2 ...
##  $ IS2G28E: num [1:6790] 4 3 3 2 3 3 3 2 4 4 ...
##  $ IS2G28H: num [1:6790] 3 2 3 1 2 2 3 1 2 3 ...
##  $ IS2G28I: num [1:6790] 3 3 2 2 2 1 3 1 2 3 ...
##  $ IS2G28J: num [1:6790] NA 3 3 2 2 2 2 1 2 2 ...
##  $ IS2G28K: num [1:6790] 3 3 3 2 2 3 3 2 3 3 ...
##  $ IS2G27B: dbl+lbl [1:6790]  2,  3,  3,  3,  3,  2,  2,  2,  2,  3,  3,  2,  2,  ...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/How well can you do/Create a database (e.g. using [Microsoft Access ®])"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:5] 1 2 3 8 9
##    .. ..- attr(*, "names")= chr [1:5] "I know how to do this." "I have never done this but I could work out how to do this." "I do not think I could do this." "Not administered or missing by design" ...
##  $ IS2G27E: dbl+lbl [1:6790]  1,  3,  2,  2,  2,  1,  2,  2,  2,  2,  1,  2,  3,  ...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/How well can you do/Build or edit a webpage"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:5] 1 2 3 8 9
##    .. ..- attr(*, "names")= chr [1:5] "I know how to do this." "I have never done this but I could work out how to do this." "I do not think I could do this." "Not administered or missing by design" ...
##  $ IS2G27G: dbl+lbl [1:6790]  2,  3,  3,  3,  2,  3,  2,  2,  3,  3, NA,  2,  3,  ...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/How well can you do/Create a computer program, macro, or [app]"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:5] 1 2 3 8 9
##    .. ..- attr(*, "names")= chr [1:5] "I know how to do this." "I have never done this but I could work out how to do this." "I do not think I could do this." "Not administered or missing by design" ...
##  $ IS2G27H: dbl+lbl [1:6790]  2,  3,  3,  3,  3,  3,  2,  2,  3,  3, NA,  2,  3,  ...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/How well can you do/Set up a local area network of computers or other ICT"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:5] 1 2 3 8 9
##    .. ..- attr(*, "names")= chr [1:5] "I know how to do this." "I have never done this but I could work out how to do this." "I do not think I could do this." "Not administered or missing by design" ...
##  $ IS2G27A: dbl+lbl [1:6790]  1,  3,  2,  1,  1,  2,  1,  2,  1,  3,  1,  1,  1,  ...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/How well can you do/Edit digital photographs or other graphic images"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:5] 1 2 3 8 9
##    .. ..- attr(*, "names")= chr [1:5] "I know how to do this." "I have never done this but I could work out how to do this." "I do not think I could do this." "Not administered or missing by design" ...
##  $ IS2G27C: dbl+lbl [1:6790]  1,  3,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  ...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/How well can you do/Write or edit text for a school assignment"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:5] 1 2 3 8 9
##    .. ..- attr(*, "names")= chr [1:5] "I know how to do this." "I have never done this but I could work out how to do this." "I do not think I could do this." "Not administered or missing by design" ...
##  $ IS2G27D: dbl+lbl [1:6790]  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  ...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/How well can you do/Search for and find relevant information for a school project"| __truncated__
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:5] 1 2 3 8 9
##    .. ..- attr(*, "names")= chr [1:5] "I know how to do this." "I have never done this but I could work out how to do this." "I do not think I could do this." "Not administered or missing by design" ...
##  $ IS2G27I: dbl+lbl [1:6790]  1,  3,  2,  1,  1,  1,  1,  2,  1,  3, NA,  1,  1,  ...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/How well can you do/Create a multi-media presentation"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:5] 1 2 3 8 9
##    .. ..- attr(*, "names")= chr [1:5] "I know how to do this." "I have never done this but I could work out how to do this." "I do not think I could do this." "Not administered or missing by design" ...
##  $ IS2G27J: dbl+lbl [1:6790]  1,  3,  1,  1,  1,  1,  1,  1,  1,  1, NA,  1,  1,  ...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/How well can you do/Upload text, images, or video to an online profile"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:5] 1 2 3 8 9
##    .. ..- attr(*, "names")= chr [1:5] "I know how to do this." "I have never done this but I could work out how to do this." "I do not think I could do this." "Not administered or missing by design" ...
##  $ IS2G27K: dbl+lbl [1:6790]  1,  3,  1,  1,  1,  1,  1,  1,  1,  1, NA,  1,  1,  ...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/How well can you do/Insert an image into a document or message"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:5] 1 2 3 8 9
##    .. ..- attr(*, "names")= chr [1:5] "I know how to do this." "I have never done this but I could work out how to do this." "I do not think I could do this." "Not administered or missing by design" ...
##  $ IS2G27L: dbl+lbl [1:6790]  1,  3,  1,  1,  1,  1,  1,  1,  1,  1, NA,  1,  1,  ...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/How well can you do/Install a program or [<app>]"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:5] 1 2 3 8 9
##    .. ..- attr(*, "names")= chr [1:5] "I know how to do this." "I have never done this but I could work out how to do this." "I do not think I could do this." "Not administered or missing by design" ...
##  $ IS2G27M: dbl+lbl [1:6790]  2,  1,  1,  1,  2,  1,  1,  1,  1,  1, NA,  2,  1,  ...
##    ..@ label      : chr "YOUR THOUGHTS ABOUT USING ICT/How well can you do/Judge whether you can trust information you find on the Internet"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:5] 1 2 3 8 9
##    .. ..- attr(*, "names")= chr [1:5] "I know how to do this." "I have never done this but I could work out how to do this." "I do not think I could do this." "Not administered or missing by design" ...
##  $ PP     : Factor w/ 13 levels "4","5","6","7",..: 11 10 8 11 NA 9 9 11 8 10 ...
##  $ NP     : Factor w/ 13 levels "4","5","6","7",..: 10 7 10 5 7 7 8 5 9 10 ...
##  $ EP     : Factor w/ 10 levels "3","4","5","6",..: NA 7 6 4 4 4 6 2 5 6 ...
##  $ SEs    : Factor w/ 9 levels "4","5","6","7",..: 4 9 8 8 7 6 5 5 7 8 ...
##  $ SEg    : Factor w/ 17 levels "8","9","10","11",..: 2 13 3 1 2 2 1 3 1 5 ...
lapply(dat[,c(39:43)], levels)
## $PP
##  [1] "4"  "5"  "6"  "7"  "8"  "9"  "10" "11" "12" "13" "14" "15" "16"
## 
## $NP
##  [1] "4"  "5"  "6"  "7"  "8"  "9"  "10" "11" "12" "13" "14" "15" "16"
## 
## $EP
##  [1] "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10" "11" "12"
## 
## $SEs
## [1] "4"  "5"  "6"  "7"  "8"  "9"  "10" "11" "12"
## 
## $SEg
##  [1] "8"  "9"  "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" "21" "22"
## [16] "23" "24"
# hunt for missing values by variables
apply(apply(dat, 1, is.na), 1, sum)
##    IDSTUD   S_TLANG     S_SEX   S_ISCED S_P1ISCED S_P2ISCED  S_HISCED  S_IMMBGR 
##         0       361         7       418       819      1099       736       482 
##   S_IMMIG  S_INTNET S_SPECEFF  S_GENEFF  S_ICTFUT  S_ICTNEG  S_ICTPOS   IS2G28A 
##       482      6790       807       786      1156       951       936       963 
##   IS2G28B   IS2G28F   IS2G28G   IS2G28C   IS2G28D   IS2G28E   IS2G28H   IS2G28I 
##       967      1007      1050      1069      1026      1017      1039      1182 
##   IS2G28J   IS2G28K   IS2G27B   IS2G27E   IS2G27G   IS2G27H   IS2G27A   IS2G27C 
##      1187      1190       874       842       972      1025       791       862 
##   IS2G27D   IS2G27I   IS2G27J   IS2G27K   IS2G27L   IS2G27M        PP        NP 
##       851      1023      1033      1019      1079      1080      1167      1293 
##        EP       SEs       SEg 
##      1274      1189      1403

Over View

Perception & Expectation

tabP <- apply(dat[,c(16:26)], 2, function(x) table(x))
par(mfrow=c(3,4))
lapply(colnames(tabP), function(x) barplot(tabP[ , x], main = x, ylim =c(0,3000)))
## [[1]]
##      [,1]
## [1,]  0.7
## [2,]  1.9
## [3,]  3.1
## [4,]  4.3
## 
## [[2]]
##      [,1]
## [1,]  0.7
## [2,]  1.9
## [3,]  3.1
## [4,]  4.3
## 
## [[3]]
##      [,1]
## [1,]  0.7
## [2,]  1.9
## [3,]  3.1
## [4,]  4.3
## 
## [[4]]
##      [,1]
## [1,]  0.7
## [2,]  1.9
## [3,]  3.1
## [4,]  4.3
## 
## [[5]]
##      [,1]
## [1,]  0.7
## [2,]  1.9
## [3,]  3.1
## [4,]  4.3
## 
## [[6]]
##      [,1]
## [1,]  0.7
## [2,]  1.9
## [3,]  3.1
## [4,]  4.3
## 
## [[7]]
##      [,1]
## [1,]  0.7
## [2,]  1.9
## [3,]  3.1
## [4,]  4.3
## 
## [[8]]
##      [,1]
## [1,]  0.7
## [2,]  1.9
## [3,]  3.1
## [4,]  4.3
## 
## [[9]]
##      [,1]
## [1,]  0.7
## [2,]  1.9
## [3,]  3.1
## [4,]  4.3
## 
## [[10]]
##      [,1]
## [1,]  0.7
## [2,]  1.9
## [3,]  3.1
## [4,]  4.3
## 
## [[11]]
##      [,1]
## [1,]  0.7
## [2,]  1.9
## [3,]  3.1
## [4,]  4.3

Self-Efficacy

tabE <- apply(dat[ ,c(27:38)], 2, function(x) table(x))
par(mfrow=c(3,4))
lapply(colnames(tabE), function(x) barplot(tabE[ , x], main = x, ylim =c(0,4500)))

## [[1]]
##      [,1]
## [1,]  0.7
## [2,]  1.9
## [3,]  3.1
## 
## [[2]]
##      [,1]
## [1,]  0.7
## [2,]  1.9
## [3,]  3.1
## 
## [[3]]
##      [,1]
## [1,]  0.7
## [2,]  1.9
## [3,]  3.1
## 
## [[4]]
##      [,1]
## [1,]  0.7
## [2,]  1.9
## [3,]  3.1
## 
## [[5]]
##      [,1]
## [1,]  0.7
## [2,]  1.9
## [3,]  3.1
## 
## [[6]]
##      [,1]
## [1,]  0.7
## [2,]  1.9
## [3,]  3.1
## 
## [[7]]
##      [,1]
## [1,]  0.7
## [2,]  1.9
## [3,]  3.1
## 
## [[8]]
##      [,1]
## [1,]  0.7
## [2,]  1.9
## [3,]  3.1
## 
## [[9]]
##      [,1]
## [1,]  0.7
## [2,]  1.9
## [3,]  3.1
## 
## [[10]]
##      [,1]
## [1,]  0.7
## [2,]  1.9
## [3,]  3.1
## 
## [[11]]
##      [,1]
## [1,]  0.7
## [2,]  1.9
## [3,]  3.1
## 
## [[12]]
##      [,1]
## [1,]  0.7
## [2,]  1.9
## [3,]  3.1

Gender or Culture

1.Culture

pacman::p_load(tidyverse, knitr, furniture, ggplot2)

kable(table1(dat,as.factor(PP), splitby = ~ S_TLANG, col_wise=T, output = 'text2'))
. 0 1
n = 914 n = 4692
as factor(PP)
4 9 (1%) 31 (0.7%)
5 0 (0%) 3 (0.1%)
6 5 (0.5%) 18 (0.4%)
7 7 (0.8%) 27 (0.6%)
8 14 (1.5%) 89 (1.9%)
9 40 (4.4%) 167 (3.6%)
10 74 (8.1%) 405 (8.6%)
11 149 (16.3%) 664 (14.2%)
12 282 (30.9%) 1298 (27.7%)
13 114 (12.5%) 602 (12.8%)
14 93 (10.2%) 572 (12.2%)
15 48 (5.3%) 358 (7.6%)
16 79 (8.6%) 458 (9.8%)
kable(table1(dat,as.factor(NP), splitby = ~ S_TLANG, col_wise=T, output = 'text2'))
. 0 1
n = 894 n = 4587
as factor(NP)
4 12 (1.3%) 49 (1.1%)
5 4 (0.4%) 42 (0.9%)
6 9 (1%) 94 (2%)
7 27 (3%) 225 (4.9%)
8 70 (7.8%) 453 (9.9%)
9 100 (11.2%) 606 (13.2%)
10 141 (15.8%) 719 (15.7%)
11 159 (17.8%) 697 (15.2%)
12 161 (18%) 724 (15.8%)
13 88 (9.8%) 411 (9%)
14 61 (6.8%) 278 (6.1%)
15 36 (4%) 158 (3.4%)
16 26 (2.9%) 131 (2.9%)
kable(table1(dat,as.factor(EP), splitby = ~ S_TLANG, col_wise=T, output = 'text2'))
. 0 1
n = 905 n = 4594
as factor(EP)
3 32 (3.5%) 219 (4.8%)
4 15 (1.7%) 131 (2.9%)
5 35 (3.9%) 282 (6.1%)
6 101 (11.2%) 747 (16.3%)
7 121 (13.4%) 755 (16.4%)
8 152 (16.8%) 641 (14%)
9 231 (25.5%) 834 (18.2%)
10 80 (8.8%) 319 (6.9%)
11 56 (6.2%) 254 (5.5%)
12 82 (9.1%) 412 (9%)


2.Gender

kable(table1(dat,as.factor(PP), splitby = ~ S_SEX, col_wise=T, output = 'text2'))
. 0 1
n = 2834 n = 2789
as factor(PP)
4 26 (0.9%) 14 (0.5%)
5 1 (0%) 2 (0.1%)
6 9 (0.3%) 15 (0.5%)
7 17 (0.6%) 17 (0.6%)
8 59 (2.1%) 44 (1.6%)
9 98 (3.5%) 110 (3.9%)
10 202 (7.1%) 277 (9.9%)
11 323 (11.4%) 491 (17.6%)
12 736 (26%) 848 (30.4%)
13 378 (13.3%) 342 (12.3%)
14 386 (13.6%) 280 (10%)
15 239 (8.4%) 170 (6.1%)
16 360 (12.7%) 179 (6.4%)
kable(table1(dat,as.factor(NP), splitby = ~ S_SEX, col_wise=T, output = 'text2'))
. 0 1
n = 2759 n = 2738
as factor(NP)
4 42 (1.5%) 19 (0.7%)
5 30 (1.1%) 16 (0.6%)
6 65 (2.4%) 38 (1.4%)
7 160 (5.8%) 92 (3.4%)
8 288 (10.4%) 236 (8.6%)
9 388 (14.1%) 318 (11.6%)
10 433 (15.7%) 430 (15.7%)
11 399 (14.5%) 458 (16.7%)
12 425 (15.4%) 464 (16.9%)
13 227 (8.2%) 274 (10%)
14 142 (5.1%) 199 (7.3%)
15 71 (2.6%) 125 (4.6%)
16 89 (3.2%) 69 (2.5%)
kable(table1(dat,as.factor(EP), splitby = ~ S_SEX, col_wise=T, output = 'text2'))
. 0 1
n = 2735 n = 2781
as factor(EP)
3 100 (3.7%) 152 (5.5%)
4 54 (2%) 93 (3.3%)
5 121 (4.4%) 196 (7%)
6 350 (12.8%) 500 (18%)
7 351 (12.8%) 530 (19.1%)
8 375 (13.7%) 419 (15.1%)
9 576 (21.1%) 493 (17.7%)
10 246 (9%) 154 (5.5%)
11 216 (7.9%) 96 (3.5%)
12 346 (12.7%) 148 (5.3%)

Clean up & Describe

Clean up

datP <- dat|>
  dplyr::select(c(IDSTUD, S_TLANG, S_SEX,
                  S_ICTNEG, S_ICTPOS, S_ICTFUT,
                  IS2G28A, IS2G28B, IS2G28F, IS2G28G, 
                  IS2G28C, IS2G28D, IS2G28E, IS2G28H, 
                  IS2G28I, IS2G28J, IS2G28K,
                  PP, NP, EP))|>
  dplyr::mutate(S_SEX = recode_factor(as.factor(S_SEX), "0" = "m", "1" = "f"))|>
  na.omit(.)


str(datP)
## tibble [5,074 × 20] (S3: tbl_df/tbl/data.frame)
##  $ IDSTUD  : dbl+lbl [1:5074] 1e+07, 1e+07, 1e+07, 1e+07, 1e+07, 1e+07, 1e+07, 1e+0...
##    ..@ label      : chr "Student ID"
##    ..@ format.spss: chr "F8.0"
##    ..@ labels     : Named num [1:2] 1e+08 1e+08
##    .. ..- attr(*, "names")= chr [1:2] "Not administered or missing by design" "Presented but not answered or invalid"
##  $ S_TLANG : dbl+lbl [1:5074] 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,...
##    ..@ label      : chr "Test language spoken at home"
##    ..@ format.spss: chr "F1.0"
##    ..@ labels     : Named num [1:4] 0 1 8 9
##    .. ..- attr(*, "names")= chr [1:4] "Other Language" "Language of test" "Not administered or missing by design" "Presented but not answered or invalid"
##  $ S_SEX   : Factor w/ 2 levels "m","f": 1 2 2 2 2 1 2 1 2 1 ...
##  $ S_ICTNEG: dbl+lbl [1:5074] 44.4, 54.7, 38.0, 44.4, 47.7, 38.0, 51.1, 54.7, 38.0,...
##    ..@ label      : chr "Negative perceptions of ICT for society"
##    ..@ format.spss: chr "F6.2"
##    ..@ labels     : Named num [1:2] 998 999
##    .. ..- attr(*, "names")= chr [1:2] "Not administered or missing by design" "Presented but not answered or invalid"
##  $ S_ICTPOS: dbl+lbl [1:5074] 51.8, 41.8, 56.1, 46.5, 46.5, 56.1, 41.8, 51.8, 33.5,...
##    ..@ label      : chr "Positive perceptions of ICT for society"
##    ..@ format.spss: chr "F6.2"
##    ..@ labels     : Named num [1:2] 998 999
##    .. ..- attr(*, "names")= chr [1:2] "Not administered or missing by design" "Presented but not answered or invalid"
##  $ S_ICTFUT: dbl+lbl [1:5074] 53.7, 50.1, 43.4, 43.4, 50.1, 36.2, 46.6, 50.1, 43.4,...
##    ..@ label      : chr "Expectations of future ICT use for work and study"
##    ..@ format.spss: chr "F6.2"
##    ..@ labels     : Named num [1:2] 998 999
##    .. ..- attr(*, "names")= chr [1:2] "Not administered or missing by design" "Presented but not answered or invalid"
##  $ IS2G28A : num [1:5074] 3 2 3 3 3 3 3 2 2 3 ...
##  $ IS2G28B : num [1:5074] 4 3 4 3 3 3 2 3 2 3 ...
##  $ IS2G28F : num [1:5074] 3 3 3 3 3 4 3 4 2 2 ...
##  $ IS2G28G : num [1:5074] 3 3 4 3 3 4 3 4 2 3 ...
##  $ IS2G28C : num [1:5074] 2 3 3 3 3 3 4 4 2 3 ...
##  $ IS2G28D : num [1:5074] 3 4 2 2 2 2 2 2 2 2 ...
##  $ IS2G28E : num [1:5074] 3 3 2 3 3 2 4 4 2 3 ...
##  $ IS2G28H : num [1:5074] 2 3 1 2 3 1 2 3 2 3 ...
##  $ IS2G28I : num [1:5074] 3 2 2 1 3 1 2 3 2 2 ...
##  $ IS2G28J : num [1:5074] 3 3 2 2 2 1 2 2 2 2 ...
##  $ IS2G28K : num [1:5074] 3 3 2 3 3 2 3 3 2 2 ...
##  $ PP      : Factor w/ 13 levels "4","5","6","7",..: 10 8 11 9 9 11 8 10 5 8 ...
##  $ NP      : Factor w/ 13 levels "4","5","6","7",..: 7 10 5 7 8 5 9 10 5 8 ...
##  $ EP      : Factor w/ 10 levels "3","4","5","6",..: 7 6 4 4 6 2 5 6 4 4 ...
##  - attr(*, "na.action")= 'omit' Named int [1:1716] 1 5 11 14 17 20 28 30 36 40 ...
##   ..- attr(*, "names")= chr [1:1716] "1" "5" "11" "14" ...

Describe

library(psych)
describe(datP[ ,c(7:20)],type=2)
##         vars    n mean   sd median trimmed  mad min max range  skew kurtosis
## IS2G28A    1 5074 3.03 0.69      3    3.06 0.00   1   4     3 -0.47     0.46
## IS2G28B    2 5074 3.14 0.69      3    3.20 0.00   1   4     3 -0.56     0.46
## IS2G28F    3 5074 3.16 0.71      3    3.23 0.00   1   4     3 -0.61     0.41
## IS2G28G    4 5074 3.04 0.75      3    3.09 0.00   1   4     3 -0.52     0.12
## IS2G28C    5 5074 2.70 0.84      3    2.71 1.48   1   4     3 -0.11    -0.61
## IS2G28D    6 5074 2.39 0.86      2    2.36 1.48   1   4     3  0.26    -0.56
## IS2G28E    7 5074 2.91 0.86      3    2.96 1.48   1   4     3 -0.42    -0.47
## IS2G28H    8 5074 2.70 0.86      3    2.75 1.48   1   4     3 -0.25    -0.57
## IS2G28I    9 5074 2.50 0.92      2    2.50 1.48   1   4     3  0.06    -0.85
## IS2G28J   10 5074 2.49 0.92      2    2.49 1.48   1   4     3  0.05    -0.84
## IS2G28K   11 5074 2.91 0.86      3    2.98 1.48   1   4     3 -0.49    -0.36
## PP*       12 5074 9.37 2.14      9    9.40 1.48   1  13    12 -0.43     1.06
## NP*       13 5074 7.70 2.42      8    7.71 2.97   1  13    12 -0.09    -0.06
## EP*       14 5074 5.90 2.31      6    5.90 2.97   1  10     9 -0.04    -0.47
##           se
## IS2G28A 0.01
## IS2G28B 0.01
## IS2G28F 0.01
## IS2G28G 0.01
## IS2G28C 0.01
## IS2G28D 0.01
## IS2G28E 0.01
## IS2G28H 0.01
## IS2G28I 0.01
## IS2G28J 0.01
## IS2G28K 0.01
## PP*     0.03
## NP*     0.03
## EP*     0.03
# 根據Curran、West與Finch(1996)之建議
# 以偏態係數絕對值小於2及峰度係數絕對值小於7作為判斷資料常態性的標準。
# 選擇所需的變數

ken_vars <- datP |>
  dplyr::select(IS2G28A, IS2G28B, IS2G28F, IS2G28G, 
                IS2G28C, IS2G28D, IS2G28E, IS2G28H, 
                IS2G28I, IS2G28J, IS2G28K,
                PP, NP, EP)
# 將因子轉換為數值型
ken_varp <- as.data.frame(lapply(ken_vars[,c(1:4,12:14)], as.numeric))
ken_varn <- as.data.frame(lapply(ken_vars[,c(5:8,12:14)], as.numeric))
ken_vare <- as.data.frame(lapply(ken_vars[,c(9:11,12:14)], as.numeric))
# 計算Kendall相關係數
ken_matp <- cor(ken_varp, method = "kendall")
ken_matn <- cor(ken_varn, method = "kendall")
ken_mate <- cor(ken_vare, method = "kendall")
kable(ken_matp, digits = 3)
IS2G28A IS2G28B IS2G28F IS2G28G PP NP EP
IS2G28A 1.000 0.489 0.345 0.340 0.634 -0.041 0.248
IS2G28B 0.489 1.000 0.406 0.359 0.672 -0.027 0.250
IS2G28F 0.345 0.406 1.000 0.424 0.654 -0.025 0.221
IS2G28G 0.340 0.359 0.424 1.000 0.652 -0.076 0.225
PP 0.634 0.672 0.654 0.652 1.000 -0.068 0.281
NP -0.041 -0.027 -0.025 -0.076 -0.068 1.000 -0.015
EP 0.248 0.250 0.221 0.225 0.281 -0.015 1.000
kable(ken_matn, digits = 3)
IS2G28C IS2G28D IS2G28E IS2G28H PP NP EP
IS2G28C 1.000 0.256 0.337 0.273 -0.012 0.589 0.012
IS2G28D 0.256 1.000 0.290 0.230 -0.044 0.557 0.008
IS2G28E 0.337 0.290 1.000 0.387 -0.092 0.655 -0.043
IS2G28H 0.273 0.230 0.387 1.000 -0.024 0.604 0.005
PP -0.012 -0.044 -0.092 -0.024 1.000 -0.068 0.281
NP 0.589 0.557 0.655 0.604 -0.068 1.000 -0.015
EP 0.012 0.008 -0.043 0.005 0.281 -0.015 1.000
kable(ken_mate, digits = 3)
IS2G28I IS2G28J IS2G28K PP NP EP
IS2G28I 1.000 0.627 0.458 0.232 -0.015 0.779
IS2G28J 0.627 1.000 0.500 0.241 -0.022 0.801
IS2G28K 0.458 0.500 1.000 0.315 -0.012 0.696
PP 0.232 0.241 0.315 1.000 -0.068 0.281
NP -0.015 -0.022 -0.012 -0.068 1.000 -0.015
EP 0.779 0.801 0.696 0.281 -0.015 1.000
kable(table1(datP,PP, splitby = ~ S_SEX, col_wise=T, output = 'text2'))
. m f
n = 2528 n = 2546
PP
4 24 (0.9%) 13 (0.5%)
5 1 (0%) 2 (0.1%)
6 6 (0.2%) 14 (0.5%)
7 16 (0.6%) 13 (0.5%)
8 51 (2%) 41 (1.6%)
9 83 (3.3%) 98 (3.8%)
10 176 (7%) 249 (9.8%)
11 284 (11.2%) 453 (17.8%)
12 668 (26.4%) 771 (30.3%)
13 327 (12.9%) 319 (12.5%)
14 344 (13.6%) 257 (10.1%)
15 213 (8.4%) 151 (5.9%)
16 335 (13.3%) 165 (6.5%)
kable(table1(datP,NP, splitby = ~ S_SEX, col_wise=T, output = 'text2'))
. m f
n = 2528 n = 2546
NP
4 41 (1.6%) 19 (0.7%)
5 27 (1.1%) 14 (0.5%)
6 61 (2.4%) 35 (1.4%)
7 149 (5.9%) 84 (3.3%)
8 261 (10.3%) 222 (8.7%)
9 360 (14.2%) 290 (11.4%)
10 397 (15.7%) 404 (15.9%)
11 359 (14.2%) 429 (16.8%)
12 392 (15.5%) 434 (17%)
13 208 (8.2%) 256 (10.1%)
14 128 (5.1%) 186 (7.3%)
15 62 (2.5%) 115 (4.5%)
16 83 (3.3%) 58 (2.3%)
kable(table1(datP,EP, splitby = ~ S_SEX, col_wise=T, output = 'text2'))
. m f
n = 2528 n = 2546
EP
3 89 (3.5%) 143 (5.6%)
4 53 (2.1%) 81 (3.2%)
5 112 (4.4%) 187 (7.3%)
6 319 (12.6%) 466 (18.3%)
7 324 (12.8%) 479 (18.8%)
8 337 (13.3%) 383 (15%)
9 543 (21.5%) 440 (17.3%)
10 218 (8.6%) 142 (5.6%)
11 202 (8%) 88 (3.5%)
12 331 (13.1%) 137 (5.4%)

Pic

datP |> 
  gather(key, value, IS2G28A:IS2G28G) |>
  ggplot(aes(as.factor(S_SEX), value, group = S_SEX))+
  stat_summary(fun.data = 'mean_se')+
  facet_grid(~ key)+
  labs(x = "gender", y = "Positive Perception")

datP |> 
  gather(key, value, IS2G28C:IS2G28H) |>
  ggplot(aes(as.factor(S_SEX), value, group = S_SEX))+
  stat_summary(fun.data = 'mean_se')+
  facet_grid(~ key)+
  labs(x = "gender", y = "Negative Perception")

datP |> 
  gather(key, value, IS2G28I:IS2G28K) |>
  ggplot(aes(as.factor(S_SEX), value, group = S_SEX))+
  stat_summary(fun.data = 'mean_se')+
  facet_grid(~ key)+
  labs(x = "gender", y = "Expectation")

Model

library(lavaan); library(semTools);library(semPlot)

PMod <-'
 PosP =~ IS2G28A + IS2G28B + IS2G28F + IS2G28G
 NegP =~ IS2G28C + IS2G28D + IS2G28E + IS2G28H
 ExeP =~ IS2G28I + IS2G28J + IS2G28K'

資料屬於ordinal[1-4],因此估計法採用WLSMV。

Base

# total
fitRes <- cfa(PMod, data=datP,  estimator="WLSMV",
               ordered=c("IS2G28A", "IS2G28B", "IS2G28F", "IS2G28G",
                         "IS2G28C", "IS2G28D", "IS2G28E", "IS2G28H",
                         "IS2G28I", "IS2G28J", "IS2G28K"),
              std.lv = TRUE, meanstructure = TRUE)
summary(fitRes, fit.measures=T)
## lavaan 0.6.16 ended normally after 21 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                        47
## 
##   Number of observations                          5074
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                               647.500     875.206
##   Degrees of freedom                                41          41
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  0.746
##   Shift parameter                                            7.782
##     simple second-order correction                                
## 
## Model Test Baseline Model:
## 
##   Test statistic                             52758.866   29036.063
##   Degrees of freedom                                55          55
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.819
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.988       0.971
##   Tucker-Lewis Index (TLI)                       0.985       0.961
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.950
##   Robust Tucker-Lewis Index (TLI)                            0.933
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.054       0.063
##   90 Percent confidence interval - lower         0.050       0.060
##   90 Percent confidence interval - upper         0.058       0.067
##   P-value H_0: RMSEA <= 0.050                    0.035       0.000
##   P-value H_0: RMSEA >= 0.080                    0.000       0.000
##                                                                   
##   Robust RMSEA                                               0.068
##   90 Percent confidence interval - lower                     0.064
##   90 Percent confidence interval - upper                     0.072
##   P-value H_0: Robust RMSEA <= 0.050                         0.000
##   P-value H_0: Robust RMSEA >= 0.080                         0.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.040       0.040
## 
## Parameter Estimates:
## 
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP =~                                             
##     IS2G28A           0.738    0.009   78.420    0.000
##     IS2G28B           0.787    0.009   89.280    0.000
##     IS2G28F           0.696    0.010   70.935    0.000
##     IS2G28G           0.673    0.010   67.947    0.000
##   NegP =~                                             
##     IS2G28C           0.573    0.013   43.971    0.000
##     IS2G28D           0.523    0.013   40.363    0.000
##     IS2G28E           0.784    0.012   65.732    0.000
##     IS2G28H           0.627    0.012   52.560    0.000
##   ExeP =~                                             
##     IS2G28I           0.833    0.007  125.079    0.000
##     IS2G28J           0.878    0.006  139.815    0.000
##     IS2G28K           0.763    0.008  100.266    0.000
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP ~~                                             
##     NegP             -0.041    0.019   -2.199    0.028
##     ExeP              0.517    0.013   39.967    0.000
##   NegP ~~                                             
##     ExeP             -0.019    0.018   -1.053    0.292
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.000                           
##    .IS2G28B           0.000                           
##    .IS2G28F           0.000                           
##    .IS2G28G           0.000                           
##    .IS2G28C           0.000                           
##    .IS2G28D           0.000                           
##    .IS2G28E           0.000                           
##    .IS2G28H           0.000                           
##    .IS2G28I           0.000                           
##    .IS2G28J           0.000                           
##    .IS2G28K           0.000                           
##     PosP              0.000                           
##     NegP              0.000                           
##     ExeP              0.000                           
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A|t1       -1.991    0.038  -51.743    0.000
##     IS2G28A|t2       -0.932    0.021  -45.084    0.000
##     IS2G28A|t3        0.753    0.020   38.554    0.000
##     IS2G28B|t1       -2.044    0.040  -50.784    0.000
##     IS2G28B|t2       -1.086    0.022  -49.499    0.000
##     IS2G28B|t3        0.535    0.019   28.867    0.000
##     IS2G28F|t1       -2.016    0.039  -51.287    0.000
##     IS2G28F|t2       -1.089    0.022  -49.565    0.000
##     IS2G28F|t3        0.470    0.018   25.639    0.000
##     IS2G28G|t1       -1.864    0.035  -53.647    0.000
##     IS2G28G|t2       -0.861    0.020  -42.668    0.000
##     IS2G28G|t3        0.615    0.019   32.616    0.000
##     IS2G28C|t1       -1.466    0.027  -55.263    0.000
##     IS2G28C|t2       -0.240    0.018  -13.519    0.000
##     IS2G28C|t3        0.935    0.021   45.183    0.000
##     IS2G28D|t1       -1.102    0.022  -49.896    0.000
##     IS2G28D|t2        0.234    0.018   13.184    0.000
##     IS2G28D|t3        1.191    0.023   51.833    0.000
##     IS2G28E|t1       -1.534    0.028  -55.516    0.000
##     IS2G28E|t2       -0.551    0.019  -29.609    0.000
##     IS2G28E|t3        0.638    0.019   33.648    0.000
##     IS2G28H|t1       -1.331    0.025  -54.066    0.000
##     IS2G28H|t2       -0.306    0.018  -17.071    0.000
##     IS2G28H|t3        0.929    0.021   44.985    0.000
##     IS2G28I|t1       -1.060    0.022  -48.847    0.000
##     IS2G28I|t2        0.042    0.018    2.358    0.018
##     IS2G28I|t3        1.002    0.021   47.220    0.000
##     IS2G28J|t1       -1.042    0.022  -48.367    0.000
##     IS2G28J|t2        0.040    0.018    2.274    0.023
##     IS2G28J|t3        1.022    0.021   47.809    0.000
##     IS2G28K|t1       -1.476    0.027  -55.316    0.000
##     IS2G28K|t2       -0.590    0.019  -31.443    0.000
##     IS2G28K|t3        0.647    0.019   34.027    0.000
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.456                           
##    .IS2G28B           0.380                           
##    .IS2G28F           0.515                           
##    .IS2G28G           0.547                           
##    .IS2G28C           0.672                           
##    .IS2G28D           0.726                           
##    .IS2G28E           0.386                           
##    .IS2G28H           0.607                           
##    .IS2G28I           0.306                           
##    .IS2G28J           0.229                           
##    .IS2G28K           0.417                           
##     PosP              1.000                           
##     NegP              1.000                           
##     ExeP              1.000                           
## 
## Scales y*:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A           1.000                           
##     IS2G28B           1.000                           
##     IS2G28F           1.000                           
##     IS2G28G           1.000                           
##     IS2G28C           1.000                           
##     IS2G28D           1.000                           
##     IS2G28E           1.000                           
##     IS2G28H           1.000                           
##     IS2G28I           1.000                           
##     IS2G28J           1.000                           
##     IS2G28K           1.000
semTools::reliability(fitRes) #look at omega3
##                PosP      NegP      ExeP
## alpha     0.7483773 0.6681175 0.8111381
## alpha.ord 0.8094102 0.7186578 0.8568402
## omega     0.7486839 0.6778500 0.8230025
## omega2    0.7486839 0.6778500 0.8230025
## omega3    0.7549905 0.6776522 0.8309717
## avevar    0.5254963 0.4022300 0.6827472
# plot
semPaths(fitRes, whatLabels = "std",
         edge.label.cex = 1,
         layout = "tree", rotation = 2, color = "lightblue")

# gender
fitResG <- cfa(PMod, data=datP,  estimator="WLSMV",
              ordered=c("IS2G28A", "IS2G28B", "IS2G28F", "IS2G28G",
                        "IS2G28C", "IS2G28D", "IS2G28E", "IS2G28H",
                        "IS2G28I", "IS2G28J", "IS2G28K"),
              group = "S_SEX",
              std.lv = TRUE, meanstructure = TRUE)
summary(fitResG, fit.measures=T)
## lavaan 0.6.16 ended normally after 17 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                        94
## 
##   Number of observations per group:                   
##     m                                             2528
##     f                                             2546
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                               715.464     948.300
##   Degrees of freedom                                82          82
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  0.767
##   Shift parameter                                           15.824
##     simple second-order correction                                
##   Test statistic for each group:
##     m                                          354.129     469.426
##     f                                          361.335     478.874
## 
## Model Test Baseline Model:
## 
##   Test statistic                             50760.158   28275.687
##   Degrees of freedom                               110         110
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.798
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.987       0.969
##   Tucker-Lewis Index (TLI)                       0.983       0.959
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.945
##   Robust Tucker-Lewis Index (TLI)                            0.927
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.055       0.065
##   90 Percent confidence interval - lower         0.052       0.061
##   90 Percent confidence interval - upper         0.059       0.068
##   P-value H_0: RMSEA <= 0.050                    0.010       0.000
##   P-value H_0: RMSEA >= 0.080                    0.000       0.000
##                                                                   
##   Robust RMSEA                                               0.070
##   90 Percent confidence interval - lower                     0.066
##   90 Percent confidence interval - upper                     0.075
##   P-value H_0: Robust RMSEA <= 0.050                         0.000
##   P-value H_0: Robust RMSEA >= 0.080                         0.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.043       0.043
## 
## Parameter Estimates:
## 
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## 
## Group 1 [m]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP =~                                             
##     IS2G28A           0.753    0.012   61.575    0.000
##     IS2G28B           0.813    0.011   74.024    0.000
##     IS2G28F           0.721    0.013   54.494    0.000
##     IS2G28G           0.698    0.013   53.965    0.000
##   NegP =~                                             
##     IS2G28C           0.584    0.017   33.380    0.000
##     IS2G28D           0.550    0.018   30.914    0.000
##     IS2G28E           0.758    0.016   47.039    0.000
##     IS2G28H           0.662    0.016   42.020    0.000
##   ExeP =~                                             
##     IS2G28I           0.836    0.009   96.137    0.000
##     IS2G28J           0.886    0.008  111.699    0.000
##     IS2G28K           0.797    0.010   80.746    0.000
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP ~~                                             
##     NegP              0.031    0.025    1.242    0.214
##     ExeP              0.587    0.016   35.918    0.000
##   NegP ~~                                             
##     ExeP              0.045    0.025    1.774    0.076
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.000                           
##    .IS2G28B           0.000                           
##    .IS2G28F           0.000                           
##    .IS2G28G           0.000                           
##    .IS2G28C           0.000                           
##    .IS2G28D           0.000                           
##    .IS2G28E           0.000                           
##    .IS2G28H           0.000                           
##    .IS2G28I           0.000                           
##    .IS2G28J           0.000                           
##    .IS2G28K           0.000                           
##     PosP              0.000                           
##     NegP              0.000                           
##     ExeP              0.000                           
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A|t1       -1.975    0.054  -36.707    0.000
##     IS2G28A|t2       -1.052    0.031  -34.321    0.000
##     IS2G28A|t3        0.565    0.026   21.378    0.000
##     IS2G28B|t1       -2.011    0.055  -36.264    0.000
##     IS2G28B|t2       -1.162    0.032  -36.169    0.000
##     IS2G28B|t3        0.380    0.026   14.837    0.000
##     IS2G28F|t1       -1.968    0.053  -36.788    0.000
##     IS2G28F|t2       -1.109    0.031  -35.332    0.000
##     IS2G28F|t3        0.308    0.025   12.151    0.000
##     IS2G28G|t1       -1.809    0.047  -38.316    0.000
##     IS2G28G|t2       -0.892    0.029  -30.861    0.000
##     IS2G28G|t3        0.504    0.026   19.314    0.000
##     IS2G28C|t1       -1.357    0.035  -38.374    0.000
##     IS2G28C|t2       -0.159    0.025   -6.361    0.000
##     IS2G28C|t3        0.955    0.030   32.339    0.000
##     IS2G28D|t1       -1.002    0.030  -33.329    0.000
##     IS2G28D|t2        0.286    0.025   11.319    0.000
##     IS2G28D|t3        1.198    0.033   36.678    0.000
##     IS2G28E|t1       -1.398    0.036  -38.661    0.000
##     IS2G28E|t2       -0.418    0.026  -16.255    0.000
##     IS2G28E|t3        0.749    0.028   27.079    0.000
##     IS2G28H|t1       -1.235    0.033  -37.160    0.000
##     IS2G28H|t2       -0.247    0.025   -9.814    0.000
##     IS2G28H|t3        0.992    0.030   33.127    0.000
##     IS2G28I|t1       -1.255    0.034  -37.390    0.000
##     IS2G28I|t2       -0.233    0.025   -9.258    0.000
##     IS2G28I|t3        0.801    0.028   28.532    0.000
##     IS2G28J|t1       -1.210    0.033  -36.842    0.000
##     IS2G28J|t2       -0.165    0.025   -6.599    0.000
##     IS2G28J|t3        0.799    0.028   28.495    0.000
##     IS2G28K|t1       -1.550    0.040  -39.200    0.000
##     IS2G28K|t2       -0.692    0.027  -25.416    0.000
##     IS2G28K|t3        0.471    0.026   18.140    0.000
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.433                           
##    .IS2G28B           0.340                           
##    .IS2G28F           0.480                           
##    .IS2G28G           0.512                           
##    .IS2G28C           0.659                           
##    .IS2G28D           0.698                           
##    .IS2G28E           0.425                           
##    .IS2G28H           0.562                           
##    .IS2G28I           0.302                           
##    .IS2G28J           0.215                           
##    .IS2G28K           0.365                           
##     PosP              1.000                           
##     NegP              1.000                           
##     ExeP              1.000                           
## 
## Scales y*:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A           1.000                           
##     IS2G28B           1.000                           
##     IS2G28F           1.000                           
##     IS2G28G           1.000                           
##     IS2G28C           1.000                           
##     IS2G28D           1.000                           
##     IS2G28E           1.000                           
##     IS2G28H           1.000                           
##     IS2G28I           1.000                           
##     IS2G28J           1.000                           
##     IS2G28K           1.000                           
## 
## 
## Group 2 [f]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP =~                                             
##     IS2G28A           0.703    0.015   45.815    0.000
##     IS2G28B           0.756    0.015   51.285    0.000
##     IS2G28F           0.660    0.015   43.692    0.000
##     IS2G28G           0.642    0.015   41.424    0.000
##   NegP =~                                             
##     IS2G28C           0.570    0.019   29.525    0.000
##     IS2G28D           0.495    0.019   26.007    0.000
##     IS2G28E           0.785    0.018   43.199    0.000
##     IS2G28H           0.591    0.018   32.222    0.000
##   ExeP =~                                             
##     IS2G28I           0.815    0.011   71.867    0.000
##     IS2G28J           0.859    0.011   77.427    0.000
##     IS2G28K           0.710    0.012   58.299    0.000
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP ~~                                             
##     NegP             -0.089    0.028   -3.194    0.001
##     ExeP              0.387    0.021   18.154    0.000
##   NegP ~~                                             
##     ExeP             -0.026    0.026   -1.013    0.311
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.000                           
##    .IS2G28B           0.000                           
##    .IS2G28F           0.000                           
##    .IS2G28G           0.000                           
##    .IS2G28C           0.000                           
##    .IS2G28D           0.000                           
##    .IS2G28E           0.000                           
##    .IS2G28H           0.000                           
##    .IS2G28I           0.000                           
##    .IS2G28J           0.000                           
##    .IS2G28K           0.000                           
##     PosP              0.000                           
##     NegP              0.000                           
##     ExeP              0.000                           
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A|t1       -2.007    0.055  -36.450    0.000
##     IS2G28A|t2       -0.825    0.028  -29.287    0.000
##     IS2G28A|t3        0.971    0.030   32.799    0.000
##     IS2G28B|t1       -2.078    0.059  -35.494    0.000
##     IS2G28B|t2       -1.016    0.030  -33.743    0.000
##     IS2G28B|t3        0.704    0.027   25.862    0.000
##     IS2G28F|t1       -2.070    0.058  -35.613    0.000
##     IS2G28F|t2       -1.069    0.031  -34.751    0.000
##     IS2G28F|t3        0.643    0.027   23.999    0.000
##     IS2G28G|t1       -1.925    0.051  -37.399    0.000
##     IS2G28G|t2       -0.832    0.028  -29.469    0.000
##     IS2G28G|t3        0.733    0.027   26.728    0.000
##     IS2G28C|t1       -1.595    0.041  -39.343    0.000
##     IS2G28C|t2       -0.323    0.025  -12.738    0.000
##     IS2G28C|t3        0.916    0.029   31.550    0.000
##     IS2G28D|t1       -1.214    0.033  -37.028    0.000
##     IS2G28D|t2        0.183    0.025    7.328    0.000
##     IS2G28D|t3        1.184    0.032   36.616    0.000
##     IS2G28E|t1       -1.706    0.044  -39.062    0.000
##     IS2G28E|t2       -0.693    0.027  -25.522    0.000
##     IS2G28E|t3        0.536    0.026   20.453    0.000
##     IS2G28H|t1       -1.439    0.037  -39.029    0.000
##     IS2G28H|t2       -0.364    0.025  -14.313    0.000
##     IS2G28H|t3        0.870    0.029   30.447    0.000
##     IS2G28I|t1       -0.901    0.029  -31.196    0.000
##     IS2G28I|t2        0.317    0.025   12.541    0.000
##     IS2G28I|t3        1.252    0.033   37.495    0.000
##     IS2G28J|t1       -0.901    0.029  -31.196    0.000
##     IS2G28J|t2        0.246    0.025    9.779    0.000
##     IS2G28J|t3        1.310    0.034   38.109    0.000
##     IS2G28K|t1       -1.410    0.036  -38.870    0.000
##     IS2G28K|t2       -0.494    0.026  -19.014    0.000
##     IS2G28K|t3        0.843    0.028   29.760    0.000
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.505                           
##    .IS2G28B           0.429                           
##    .IS2G28F           0.565                           
##    .IS2G28G           0.588                           
##    .IS2G28C           0.676                           
##    .IS2G28D           0.755                           
##    .IS2G28E           0.384                           
##    .IS2G28H           0.651                           
##    .IS2G28I           0.335                           
##    .IS2G28J           0.263                           
##    .IS2G28K           0.496                           
##     PosP              1.000                           
##     NegP              1.000                           
##     ExeP              1.000                           
## 
## Scales y*:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A           1.000                           
##     IS2G28B           1.000                           
##     IS2G28F           1.000                           
##     IS2G28G           1.000                           
##     IS2G28C           1.000                           
##     IS2G28D           1.000                           
##     IS2G28E           1.000                           
##     IS2G28H           1.000                           
##     IS2G28I           1.000                           
##     IS2G28J           1.000                           
##     IS2G28K           1.000
semTools::reliability(fitResG) #look at omega3 
## $m
##                PosP      NegP      ExeP
## alpha     0.7724314 0.6798854 0.8261390
## alpha.ord 0.8302690 0.7292777 0.8712987
## omega     0.7710003 0.6909177 0.8356101
## omega2    0.7710003 0.6909177 0.8356101
## omega3    0.7754805 0.6932554 0.8423391
## avevar    0.5588009 0.4137162 0.7061027
## 
## $f
##                PosP      NegP      ExeP
## alpha     0.7100299 0.6476386 0.7789774
## alpha.ord 0.7764945 0.7006369 0.8278674
## omega     0.7128381 0.6566092 0.7917626
## omega2    0.7128381 0.6566092 0.7917626
## omega3    0.7218309 0.6559818 0.8002435
## avevar    0.4781747 0.3836946 0.6355555
semPaths(fitResG, whatLabels = "std",
         edge.label.cex = 1,
         layout = "tree", rotation = 2, color = "lightblue")

# 因模型參數不同 不能直接comparefit
# 提取χ²值和自由度
chi2_fitRes <- fitmeasures(fitRes)[["chisq"]]
df_fitRes <- fitmeasures(fitRes)[["df"]]

chi2_fitResG <- fitmeasures(fitResG)[["chisq"]]
df_fitResG <- fitmeasures(fitResG)[["df"]]

# 計算CFI、TLI、RMSEA等
cfi_fitRes <- fitmeasures(fitRes)[["cfi"]]
tli_fitRes <- fitmeasures(fitRes)[["tli"]]
rmsea_fitRes <- fitmeasures(fitRes)[["rmsea"]]

cfi_fitResG <- fitmeasures(fitResG)[["cfi"]]
tli_fitResG <- fitmeasures(fitResG)[["tli"]]
rmsea_fitResG <- fitmeasures(fitResG)[["rmsea"]]

# 構建比較表
comparison_table <- data.frame(
  Model = c("fitRes", "fitResG"),
  ChiSquare = c(chi2_fitRes, chi2_fitResG),
  DegreesOfFreedom = c(df_fitRes, df_fitResG),
  CFI = c(cfi_fitRes, cfi_fitResG),
  TLI = c(tli_fitRes, tli_fitResG),
  RMSEA = c(rmsea_fitRes, rmsea_fitResG))

# 打印比較表
print(comparison_table, digits = 3)
##     Model ChiSquare DegreesOfFreedom   CFI   TLI  RMSEA
## 1  fitRes       648               41 0.988 0.985 0.0540
## 2 fitResG       715               82 0.987 0.983 0.0552
Alpha <- data.frame(round(rbind(semTools::reliability(fitRes, what = "alpha")[1,1:3],
                             semTools::reliability(fitResG, what = "alpha")$m[1,1:3],
                             semTools::reliability(fitResG, what = "alpha")$f[1,1:3]),2),
                 row.names = c("Whole", "Male", "Female"))

CR <- data.frame(round(rbind(semTools::reliability(fitRes, what = "omega3")[1,1:3],
                             semTools::reliability(fitResG, what = "omega3")$m[1,1:3],
                             semTools::reliability(fitResG, what = "omega3")$f[1,1:3]),2),
                 row.names = c("Whole", "Male", "Female"))
CR
##        PosP NegP ExeP
## Whole  0.75 0.68 0.83
## Male   0.78 0.69 0.84
## Female 0.72 0.66 0.80
AVE <- data.frame(round(rbind(semTools::reliability(fitRes, what = "ave")[1,1:3],
                             semTools::reliability(fitResG, what = "ave")$m[1,1:3],
                             semTools::reliability(fitResG, what = "ave")$f[1,1:3]),2),
                 row.names = c("Whole", "Male", "Female"))
AVE
##        PosP NegP ExeP
## Whole  0.53 0.40 0.68
## Male   0.56 0.41 0.71
## Female 0.48 0.38 0.64

若AVE > 0.5 alpha > 0.8 CR(omega3) > 0.8則良好

Configural

ConfiguralRes <- cfa(PMod, data = datP, estimator = "WLSMV",
                     ordered = c("IS2G28A", "IS2G28B", "IS2G28F", "IS2G28G",
                                 "IS2G28C", "IS2G28D", "IS2G28E", "IS2G28H",
                                 "IS2G28I", "IS2G28J", "IS2G28K"),
                     fixed.x = F, group= "S_SEX")
summary(ConfiguralRes, fit.measures=T)
## lavaan 0.6.16 ended normally after 45 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                        94
## 
##   Number of observations per group:                   
##     m                                             2528
##     f                                             2546
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                               715.464     948.300
##   Degrees of freedom                                82          82
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  0.767
##   Shift parameter                                           15.824
##     simple second-order correction                                
##   Test statistic for each group:
##     m                                          354.129     469.426
##     f                                          361.335     478.874
## 
## Model Test Baseline Model:
## 
##   Test statistic                             50760.158   28275.687
##   Degrees of freedom                               110         110
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.798
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.987       0.969
##   Tucker-Lewis Index (TLI)                       0.983       0.959
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.945
##   Robust Tucker-Lewis Index (TLI)                            0.927
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.055       0.065
##   90 Percent confidence interval - lower         0.052       0.061
##   90 Percent confidence interval - upper         0.059       0.068
##   P-value H_0: RMSEA <= 0.050                    0.010       0.000
##   P-value H_0: RMSEA >= 0.080                    0.000       0.000
##                                                                   
##   Robust RMSEA                                               0.070
##   90 Percent confidence interval - lower                     0.066
##   90 Percent confidence interval - upper                     0.075
##   P-value H_0: Robust RMSEA <= 0.050                         0.000
##   P-value H_0: Robust RMSEA >= 0.080                         0.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.043       0.043
## 
## Parameter Estimates:
## 
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## 
## Group 1 [m]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP =~                                             
##     IS2G28A           1.000                           
##     IS2G28B           1.080    0.023   47.180    0.000
##     IS2G28F           0.958    0.022   43.832    0.000
##     IS2G28G           0.928    0.021   43.536    0.000
##   NegP =~                                             
##     IS2G28C           1.000                           
##     IS2G28D           0.942    0.039   24.124    0.000
##     IS2G28E           1.299    0.050   26.143    0.000
##     IS2G28H           1.133    0.042   27.288    0.000
##   ExeP =~                                             
##     IS2G28I           1.000                           
##     IS2G28J           1.060    0.016   64.698    0.000
##     IS2G28K           0.954    0.014   69.323    0.000
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP ~~                                             
##     NegP              0.014    0.011    1.230    0.219
##     ExeP              0.369    0.014   26.801    0.000
##   NegP ~~                                             
##     ExeP              0.022    0.012    1.756    0.079
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.000                           
##    .IS2G28B           0.000                           
##    .IS2G28F           0.000                           
##    .IS2G28G           0.000                           
##    .IS2G28C           0.000                           
##    .IS2G28D           0.000                           
##    .IS2G28E           0.000                           
##    .IS2G28H           0.000                           
##    .IS2G28I           0.000                           
##    .IS2G28J           0.000                           
##    .IS2G28K           0.000                           
##     PosP              0.000                           
##     NegP              0.000                           
##     ExeP              0.000                           
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A|t1       -1.975    0.054  -36.707    0.000
##     IS2G28A|t2       -1.052    0.031  -34.321    0.000
##     IS2G28A|t3        0.565    0.026   21.378    0.000
##     IS2G28B|t1       -2.011    0.055  -36.264    0.000
##     IS2G28B|t2       -1.162    0.032  -36.169    0.000
##     IS2G28B|t3        0.380    0.026   14.837    0.000
##     IS2G28F|t1       -1.968    0.053  -36.788    0.000
##     IS2G28F|t2       -1.109    0.031  -35.332    0.000
##     IS2G28F|t3        0.308    0.025   12.151    0.000
##     IS2G28G|t1       -1.809    0.047  -38.316    0.000
##     IS2G28G|t2       -0.892    0.029  -30.861    0.000
##     IS2G28G|t3        0.504    0.026   19.314    0.000
##     IS2G28C|t1       -1.357    0.035  -38.374    0.000
##     IS2G28C|t2       -0.159    0.025   -6.361    0.000
##     IS2G28C|t3        0.955    0.030   32.339    0.000
##     IS2G28D|t1       -1.002    0.030  -33.329    0.000
##     IS2G28D|t2        0.286    0.025   11.319    0.000
##     IS2G28D|t3        1.198    0.033   36.678    0.000
##     IS2G28E|t1       -1.398    0.036  -38.661    0.000
##     IS2G28E|t2       -0.418    0.026  -16.255    0.000
##     IS2G28E|t3        0.749    0.028   27.079    0.000
##     IS2G28H|t1       -1.235    0.033  -37.160    0.000
##     IS2G28H|t2       -0.247    0.025   -9.814    0.000
##     IS2G28H|t3        0.992    0.030   33.127    0.000
##     IS2G28I|t1       -1.255    0.034  -37.390    0.000
##     IS2G28I|t2       -0.233    0.025   -9.258    0.000
##     IS2G28I|t3        0.801    0.028   28.532    0.000
##     IS2G28J|t1       -1.210    0.033  -36.842    0.000
##     IS2G28J|t2       -0.165    0.025   -6.599    0.000
##     IS2G28J|t3        0.799    0.028   28.495    0.000
##     IS2G28K|t1       -1.550    0.040  -39.200    0.000
##     IS2G28K|t2       -0.692    0.027  -25.416    0.000
##     IS2G28K|t3        0.471    0.026   18.140    0.000
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.433                           
##    .IS2G28B           0.340                           
##    .IS2G28F           0.480                           
##    .IS2G28G           0.512                           
##    .IS2G28C           0.659                           
##    .IS2G28D           0.698                           
##    .IS2G28E           0.425                           
##    .IS2G28H           0.562                           
##    .IS2G28I           0.302                           
##    .IS2G28J           0.215                           
##    .IS2G28K           0.365                           
##     PosP              0.567    0.018   30.788    0.000
##     NegP              0.341    0.020   16.690    0.000
##     ExeP              0.698    0.015   48.069    0.000
## 
## Scales y*:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A           1.000                           
##     IS2G28B           1.000                           
##     IS2G28F           1.000                           
##     IS2G28G           1.000                           
##     IS2G28C           1.000                           
##     IS2G28D           1.000                           
##     IS2G28E           1.000                           
##     IS2G28H           1.000                           
##     IS2G28I           1.000                           
##     IS2G28J           1.000                           
##     IS2G28K           1.000                           
## 
## 
## Group 2 [f]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP =~                                             
##     IS2G28A           1.000                           
##     IS2G28B           1.074    0.033   32.122    0.000
##     IS2G28F           0.938    0.028   33.520    0.000
##     IS2G28G           0.912    0.028   32.316    0.000
##   NegP =~                                             
##     IS2G28C           1.000                           
##     IS2G28D           0.869    0.043   20.387    0.000
##     IS2G28E           1.378    0.062   22.256    0.000
##     IS2G28H           1.038    0.046   22.718    0.000
##   ExeP =~                                             
##     IS2G28I           1.000                           
##     IS2G28J           1.053    0.024   43.249    0.000
##     IS2G28K           0.871    0.017   50.574    0.000
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP ~~                                             
##     NegP             -0.036    0.011   -3.205    0.001
##     ExeP              0.222    0.014   15.829    0.000
##   NegP ~~                                             
##     ExeP             -0.012    0.012   -1.013    0.311
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.000                           
##    .IS2G28B           0.000                           
##    .IS2G28F           0.000                           
##    .IS2G28G           0.000                           
##    .IS2G28C           0.000                           
##    .IS2G28D           0.000                           
##    .IS2G28E           0.000                           
##    .IS2G28H           0.000                           
##    .IS2G28I           0.000                           
##    .IS2G28J           0.000                           
##    .IS2G28K           0.000                           
##     PosP              0.000                           
##     NegP              0.000                           
##     ExeP              0.000                           
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A|t1       -2.007    0.055  -36.450    0.000
##     IS2G28A|t2       -0.825    0.028  -29.287    0.000
##     IS2G28A|t3        0.971    0.030   32.799    0.000
##     IS2G28B|t1       -2.078    0.059  -35.494    0.000
##     IS2G28B|t2       -1.016    0.030  -33.743    0.000
##     IS2G28B|t3        0.704    0.027   25.862    0.000
##     IS2G28F|t1       -2.070    0.058  -35.613    0.000
##     IS2G28F|t2       -1.069    0.031  -34.751    0.000
##     IS2G28F|t3        0.643    0.027   23.999    0.000
##     IS2G28G|t1       -1.925    0.051  -37.399    0.000
##     IS2G28G|t2       -0.832    0.028  -29.469    0.000
##     IS2G28G|t3        0.733    0.027   26.728    0.000
##     IS2G28C|t1       -1.595    0.041  -39.343    0.000
##     IS2G28C|t2       -0.323    0.025  -12.738    0.000
##     IS2G28C|t3        0.916    0.029   31.550    0.000
##     IS2G28D|t1       -1.214    0.033  -37.028    0.000
##     IS2G28D|t2        0.183    0.025    7.328    0.000
##     IS2G28D|t3        1.184    0.032   36.616    0.000
##     IS2G28E|t1       -1.706    0.044  -39.062    0.000
##     IS2G28E|t2       -0.693    0.027  -25.522    0.000
##     IS2G28E|t3        0.536    0.026   20.453    0.000
##     IS2G28H|t1       -1.439    0.037  -39.029    0.000
##     IS2G28H|t2       -0.364    0.025  -14.313    0.000
##     IS2G28H|t3        0.870    0.029   30.447    0.000
##     IS2G28I|t1       -0.901    0.029  -31.196    0.000
##     IS2G28I|t2        0.317    0.025   12.541    0.000
##     IS2G28I|t3        1.252    0.033   37.495    0.000
##     IS2G28J|t1       -0.901    0.029  -31.196    0.000
##     IS2G28J|t2        0.246    0.025    9.779    0.000
##     IS2G28J|t3        1.310    0.034   38.109    0.000
##     IS2G28K|t1       -1.410    0.036  -38.870    0.000
##     IS2G28K|t2       -0.494    0.026  -19.014    0.000
##     IS2G28K|t3        0.843    0.028   29.760    0.000
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.505                           
##    .IS2G28B           0.429                           
##    .IS2G28F           0.565                           
##    .IS2G28G           0.588                           
##    .IS2G28C           0.676                           
##    .IS2G28D           0.755                           
##    .IS2G28E           0.384                           
##    .IS2G28H           0.651                           
##    .IS2G28I           0.335                           
##    .IS2G28J           0.263                           
##    .IS2G28K           0.496                           
##     PosP              0.495    0.022   22.908    0.000
##     NegP              0.324    0.022   14.763    0.000
##     ExeP              0.665    0.019   35.934    0.000
## 
## Scales y*:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A           1.000                           
##     IS2G28B           1.000                           
##     IS2G28F           1.000                           
##     IS2G28G           1.000                           
##     IS2G28C           1.000                           
##     IS2G28D           1.000                           
##     IS2G28E           1.000                           
##     IS2G28H           1.000                           
##     IS2G28I           1.000                           
##     IS2G28J           1.000                           
##     IS2G28K           1.000

PP NP EP的 covariance代表構念間有相關,是正常的,因為相同子量表下的變項。
但不要高度相關,因為可能是相同變項;也可注意變項相關方向是否正確(正相關、附相關)
假設每個題目都是一個常態分配(所以四個點的分數有+-)
IS2G28A 此題可以有4個點 -0.56 1.05 1.975 在不同能力的人會掉入不同的分數值域

Metric

# 1
MetricRes <- cfa(PMod, data = datP, estimator = "WLSMV",
                 ordered = c("IS2G28A", "IS2G28B", "IS2G28F", "IS2G28G",
                             "IS2G28C", "IS2G28D", "IS2G28E", "IS2G28H",
                             "IS2G28I", "IS2G28J", "IS2G28K"),
                 fixed.x = F, group= "S_SEX", 
                 group.equal=c("loadings"))
summary(MetricRes, fit.measures=T)
## lavaan 0.6.16 ended normally after 35 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                        94
##   Number of equality constraints                     8
## 
##   Number of observations per group:                   
##     m                                             2528
##     f                                             2546
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                               735.401     953.677
##   Degrees of freedom                                90          90
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  0.785
##   Shift parameter                                           16.719
##     simple second-order correction                                
##   Test statistic for each group:
##     m                                          361.770     469.252
##     f                                          373.632     484.424
## 
## Model Test Baseline Model:
## 
##   Test statistic                             50760.158   28275.687
##   Degrees of freedom                               110         110
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.798
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.987       0.969
##   Tucker-Lewis Index (TLI)                       0.984       0.963
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.944
##   Robust Tucker-Lewis Index (TLI)                            0.932
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.053       0.062
##   90 Percent confidence interval - lower         0.050       0.058
##   90 Percent confidence interval - upper         0.057       0.065
##   P-value H_0: RMSEA <= 0.050                    0.069       0.000
##   P-value H_0: RMSEA >= 0.080                    0.000       0.000
##                                                                   
##   Robust RMSEA                                               0.068
##   90 Percent confidence interval - lower                     0.064
##   90 Percent confidence interval - upper                     0.072
##   P-value H_0: Robust RMSEA <= 0.050                         0.000
##   P-value H_0: Robust RMSEA >= 0.080                         0.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.043       0.043
## 
## Parameter Estimates:
## 
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## 
## Group 1 [m]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP =~                                             
##     IS2G28A           1.000                           
##     IS2G28B (.p2.)    1.078    0.019   57.057    0.000
##     IS2G28F (.p3.)    0.951    0.017   55.119    0.000
##     IS2G28G (.p4.)    0.923    0.017   54.246    0.000
##   NegP =~                                             
##     IS2G28C           1.000                           
##     IS2G28D (.p6.)    0.908    0.029   31.534    0.000
##     IS2G28E (.p7.)    1.331    0.039   34.326    0.000
##     IS2G28H (.p8.)    1.089    0.031   35.482    0.000
##   ExeP =~                                             
##     IS2G28I           1.000                           
##     IS2G28J (.10.)    1.058    0.014   77.899    0.000
##     IS2G28K (.11.)    0.924    0.011   86.000    0.000
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP ~~                                             
##     NegP              0.013    0.011    1.187    0.235
##     ExeP              0.374    0.014   27.566    0.000
##   NegP ~~                                             
##     ExeP              0.021    0.013    1.712    0.087
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.000                           
##    .IS2G28B           0.000                           
##    .IS2G28F           0.000                           
##    .IS2G28G           0.000                           
##    .IS2G28C           0.000                           
##    .IS2G28D           0.000                           
##    .IS2G28E           0.000                           
##    .IS2G28H           0.000                           
##    .IS2G28I           0.000                           
##    .IS2G28J           0.000                           
##    .IS2G28K           0.000                           
##     PosP              0.000                           
##     NegP              0.000                           
##     ExeP              0.000                           
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A|t1       -1.975    0.054  -36.707    0.000
##     IS2G28A|t2       -1.052    0.031  -34.321    0.000
##     IS2G28A|t3        0.565    0.026   21.378    0.000
##     IS2G28B|t1       -2.011    0.055  -36.264    0.000
##     IS2G28B|t2       -1.162    0.032  -36.169    0.000
##     IS2G28B|t3        0.380    0.026   14.837    0.000
##     IS2G28F|t1       -1.968    0.053  -36.788    0.000
##     IS2G28F|t2       -1.109    0.031  -35.332    0.000
##     IS2G28F|t3        0.308    0.025   12.151    0.000
##     IS2G28G|t1       -1.809    0.047  -38.316    0.000
##     IS2G28G|t2       -0.892    0.029  -30.861    0.000
##     IS2G28G|t3        0.504    0.026   19.314    0.000
##     IS2G28C|t1       -1.357    0.035  -38.374    0.000
##     IS2G28C|t2       -0.159    0.025   -6.361    0.000
##     IS2G28C|t3        0.955    0.030   32.339    0.000
##     IS2G28D|t1       -1.002    0.030  -33.329    0.000
##     IS2G28D|t2        0.286    0.025   11.319    0.000
##     IS2G28D|t3        1.198    0.033   36.678    0.000
##     IS2G28E|t1       -1.398    0.036  -38.661    0.000
##     IS2G28E|t2       -0.418    0.026  -16.255    0.000
##     IS2G28E|t3        0.749    0.028   27.079    0.000
##     IS2G28H|t1       -1.235    0.033  -37.160    0.000
##     IS2G28H|t2       -0.247    0.025   -9.814    0.000
##     IS2G28H|t3        0.992    0.030   33.127    0.000
##     IS2G28I|t1       -1.255    0.034  -37.390    0.000
##     IS2G28I|t2       -0.233    0.025   -9.258    0.000
##     IS2G28I|t3        0.801    0.028   28.532    0.000
##     IS2G28J|t1       -1.210    0.033  -36.842    0.000
##     IS2G28J|t2       -0.165    0.025   -6.599    0.000
##     IS2G28J|t3        0.799    0.028   28.495    0.000
##     IS2G28K|t1       -1.550    0.040  -39.200    0.000
##     IS2G28K|t2       -0.692    0.027  -25.416    0.000
##     IS2G28K|t3        0.471    0.026   18.140    0.000
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.430                           
##    .IS2G28B           0.337                           
##    .IS2G28F           0.484                           
##    .IS2G28G           0.514                           
##    .IS2G28C           0.654                           
##    .IS2G28D           0.714                           
##    .IS2G28E           0.386                           
##    .IS2G28H           0.589                           
##    .IS2G28I           0.290                           
##    .IS2G28J           0.206                           
##    .IS2G28K           0.394                           
##     PosP              0.570    0.016   35.042    0.000
##     NegP              0.346    0.017   20.680    0.000
##     ExeP              0.710    0.013   54.740    0.000
## 
## Scales y*:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A           1.000                           
##     IS2G28B           1.000                           
##     IS2G28F           1.000                           
##     IS2G28G           1.000                           
##     IS2G28C           1.000                           
##     IS2G28D           1.000                           
##     IS2G28E           1.000                           
##     IS2G28H           1.000                           
##     IS2G28I           1.000                           
##     IS2G28J           1.000                           
##     IS2G28K           1.000                           
## 
## 
## Group 2 [f]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP =~                                             
##     IS2G28A           1.000                           
##     IS2G28B (.p2.)    1.078    0.019   57.057    0.000
##     IS2G28F (.p3.)    0.951    0.017   55.119    0.000
##     IS2G28G (.p4.)    0.923    0.017   54.246    0.000
##   NegP =~                                             
##     IS2G28C           1.000                           
##     IS2G28D (.p6.)    0.908    0.029   31.534    0.000
##     IS2G28E (.p7.)    1.331    0.039   34.326    0.000
##     IS2G28H (.p8.)    1.089    0.031   35.482    0.000
##   ExeP =~                                             
##     IS2G28I           1.000                           
##     IS2G28J (.10.)    1.058    0.014   77.899    0.000
##     IS2G28K (.11.)    0.924    0.011   86.000    0.000
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP ~~                                             
##     NegP             -0.035    0.011   -3.164    0.002
##     ExeP              0.218    0.013   16.476    0.000
##   NegP ~~                                             
##     ExeP             -0.011    0.012   -0.950    0.342
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.000                           
##    .IS2G28B           0.000                           
##    .IS2G28F           0.000                           
##    .IS2G28G           0.000                           
##    .IS2G28C           0.000                           
##    .IS2G28D           0.000                           
##    .IS2G28E           0.000                           
##    .IS2G28H           0.000                           
##    .IS2G28I           0.000                           
##    .IS2G28J           0.000                           
##    .IS2G28K           0.000                           
##     PosP              0.000                           
##     NegP              0.000                           
##     ExeP              0.000                           
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A|t1       -2.007    0.055  -36.450    0.000
##     IS2G28A|t2       -0.825    0.028  -29.287    0.000
##     IS2G28A|t3        0.971    0.030   32.799    0.000
##     IS2G28B|t1       -2.078    0.059  -35.494    0.000
##     IS2G28B|t2       -1.016    0.030  -33.743    0.000
##     IS2G28B|t3        0.704    0.027   25.862    0.000
##     IS2G28F|t1       -2.070    0.058  -35.613    0.000
##     IS2G28F|t2       -1.069    0.031  -34.751    0.000
##     IS2G28F|t3        0.643    0.027   23.999    0.000
##     IS2G28G|t1       -1.925    0.051  -37.399    0.000
##     IS2G28G|t2       -0.832    0.028  -29.469    0.000
##     IS2G28G|t3        0.733    0.027   26.728    0.000
##     IS2G28C|t1       -1.595    0.041  -39.343    0.000
##     IS2G28C|t2       -0.323    0.025  -12.738    0.000
##     IS2G28C|t3        0.916    0.029   31.550    0.000
##     IS2G28D|t1       -1.214    0.033  -37.028    0.000
##     IS2G28D|t2        0.183    0.025    7.328    0.000
##     IS2G28D|t3        1.184    0.032   36.616    0.000
##     IS2G28E|t1       -1.706    0.044  -39.062    0.000
##     IS2G28E|t2       -0.693    0.027  -25.522    0.000
##     IS2G28E|t3        0.536    0.026   20.453    0.000
##     IS2G28H|t1       -1.439    0.037  -39.029    0.000
##     IS2G28H|t2       -0.364    0.025  -14.313    0.000
##     IS2G28H|t3        0.870    0.029   30.447    0.000
##     IS2G28I|t1       -0.901    0.029  -31.196    0.000
##     IS2G28I|t2        0.317    0.025   12.541    0.000
##     IS2G28I|t3        1.252    0.033   37.495    0.000
##     IS2G28J|t1       -0.901    0.029  -31.196    0.000
##     IS2G28J|t2        0.246    0.025    9.779    0.000
##     IS2G28J|t3        1.310    0.034   38.109    0.000
##     IS2G28K|t1       -1.410    0.036  -38.870    0.000
##     IS2G28K|t2       -0.494    0.026  -19.014    0.000
##     IS2G28K|t3        0.843    0.028   29.760    0.000
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.512                           
##    .IS2G28B           0.433                           
##    .IS2G28F           0.558                           
##    .IS2G28G           0.584                           
##    .IS2G28C           0.681                           
##    .IS2G28D           0.737                           
##    .IS2G28E           0.434                           
##    .IS2G28H           0.621                           
##    .IS2G28I           0.354                           
##    .IS2G28J           0.277                           
##    .IS2G28K           0.449                           
##     PosP              0.488    0.016   31.382    0.000
##     NegP              0.319    0.016   20.423    0.000
##     ExeP              0.646    0.013   50.912    0.000
## 
## Scales y*:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A           1.000                           
##     IS2G28B           1.000                           
##     IS2G28F           1.000                           
##     IS2G28G           1.000                           
##     IS2G28C           1.000                           
##     IS2G28D           1.000                           
##     IS2G28E           1.000                           
##     IS2G28H           1.000                           
##     IS2G28I           1.000                           
##     IS2G28J           1.000                           
##     IS2G28K           1.000
anova(ConfiguralRes, MetricRes)
## 
## Scaled Chi-Squared Difference Test (method = "satorra.2000")
## 
## lavaan NOTE:
##     The "Chisq" column contains standard test statistics, not the
##     robust test that should be reported per model. A robust difference
##     test is a function of two standard (not robust) statistics.
##  
##               Df AIC BIC  Chisq Chisq diff Df diff Pr(>Chisq)   
## ConfiguralRes 82         715.46                                 
## MetricRes     90         735.40     23.352       8   0.002941 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
lavTestScore(MetricRes)
## $test
## 
## total score test:
## 
##    test     X2 df p.value
## 1 score 19.724  8   0.011
## 
## $uni
## 
## univariate score tests:
## 
##     lhs op   rhs     X2 df p.value
## 1  .p2. == .p88.  0.068  1   0.794
## 2  .p3. == .p89.  0.225  1   0.635
## 3  .p4. == .p90.  0.067  1   0.796
## 4  .p6. == .p92.  1.715  1   0.190
## 5  .p7. == .p93.  4.496  1   0.034
## 6  .p8. == .p94.  2.561  1   0.110
## 7 .p10. == .p96.  2.960  1   0.085
## 8 .p11. == .p97. 11.916  1   0.001
# p11 = IS2G28K release ExeP =~ IS2G28K

# 2
PartialMetricRes <- cfa(PMod, data = datP, estimator = "WLSMV",
                        ordered = c("IS2G28A", "IS2G28B", "IS2G28F", "IS2G28G",
                                    "IS2G28C", "IS2G28D", "IS2G28E", "IS2G28H",
                                    "IS2G28I", "IS2G28J", "IS2G28K"),
                        fixed.x = F, group= "S_SEX", 
                        group.equal=c("loadings"),
                        group.partial=c("ExeP =~ IS2G28K"))

summary(PartialMetricRes, fit.measures=T)
## lavaan 0.6.16 ended normally after 35 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                        94
##   Number of equality constraints                     7
## 
##   Number of observations per group:                   
##     m                                             2528
##     f                                             2546
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                               723.150     937.275
##   Degrees of freedom                                89          89
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  0.786
##   Shift parameter                                           16.663
##     simple second-order correction                                
##   Test statistic for each group:
##     m                                          357.485     463.402
##     f                                          365.665     473.874
## 
## Model Test Baseline Model:
## 
##   Test statistic                             50760.158   28275.687
##   Degrees of freedom                               110         110
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.798
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.987       0.970
##   Tucker-Lewis Index (TLI)                       0.985       0.963
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.945
##   Robust Tucker-Lewis Index (TLI)                            0.933
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.053       0.061
##   90 Percent confidence interval - lower         0.049       0.058
##   90 Percent confidence interval - upper         0.057       0.065
##   P-value H_0: RMSEA <= 0.050                    0.081       0.000
##   P-value H_0: RMSEA >= 0.080                    0.000       0.000
##                                                                   
##   Robust RMSEA                                               0.067
##   90 Percent confidence interval - lower                     0.063
##   90 Percent confidence interval - upper                     0.072
##   P-value H_0: Robust RMSEA <= 0.050                         0.000
##   P-value H_0: Robust RMSEA >= 0.080                         0.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.043       0.043
## 
## Parameter Estimates:
## 
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## 
## Group 1 [m]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP =~                                             
##     IS2G28A           1.000                           
##     IS2G28B (.p2.)    1.078    0.019   57.081    0.000
##     IS2G28F (.p3.)    0.951    0.017   55.113    0.000
##     IS2G28G (.p4.)    0.922    0.017   54.234    0.000
##   NegP =~                                             
##     IS2G28C           1.000                           
##     IS2G28D (.p6.)    0.908    0.029   31.533    0.000
##     IS2G28E (.p7.)    1.331    0.039   34.325    0.000
##     IS2G28H (.p8.)    1.089    0.031   35.481    0.000
##   ExeP =~                                             
##     IS2G28I           1.000                           
##     IS2G28J (.10.)    1.058    0.014   77.823    0.000
##     IS2G28K           0.953    0.013   72.182    0.000
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP ~~                                             
##     NegP              0.013    0.011    1.187    0.235
##     ExeP              0.371    0.013   27.672    0.000
##   NegP ~~                                             
##     ExeP              0.021    0.012    1.713    0.087
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.000                           
##    .IS2G28B           0.000                           
##    .IS2G28F           0.000                           
##    .IS2G28G           0.000                           
##    .IS2G28C           0.000                           
##    .IS2G28D           0.000                           
##    .IS2G28E           0.000                           
##    .IS2G28H           0.000                           
##    .IS2G28I           0.000                           
##    .IS2G28J           0.000                           
##    .IS2G28K           0.000                           
##     PosP              0.000                           
##     NegP              0.000                           
##     ExeP              0.000                           
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A|t1       -1.975    0.054  -36.707    0.000
##     IS2G28A|t2       -1.052    0.031  -34.321    0.000
##     IS2G28A|t3        0.565    0.026   21.378    0.000
##     IS2G28B|t1       -2.011    0.055  -36.264    0.000
##     IS2G28B|t2       -1.162    0.032  -36.169    0.000
##     IS2G28B|t3        0.380    0.026   14.837    0.000
##     IS2G28F|t1       -1.968    0.053  -36.788    0.000
##     IS2G28F|t2       -1.109    0.031  -35.332    0.000
##     IS2G28F|t3        0.308    0.025   12.151    0.000
##     IS2G28G|t1       -1.809    0.047  -38.316    0.000
##     IS2G28G|t2       -0.892    0.029  -30.861    0.000
##     IS2G28G|t3        0.504    0.026   19.314    0.000
##     IS2G28C|t1       -1.357    0.035  -38.374    0.000
##     IS2G28C|t2       -0.159    0.025   -6.361    0.000
##     IS2G28C|t3        0.955    0.030   32.339    0.000
##     IS2G28D|t1       -1.002    0.030  -33.329    0.000
##     IS2G28D|t2        0.286    0.025   11.319    0.000
##     IS2G28D|t3        1.198    0.033   36.678    0.000
##     IS2G28E|t1       -1.398    0.036  -38.661    0.000
##     IS2G28E|t2       -0.418    0.026  -16.255    0.000
##     IS2G28E|t3        0.749    0.028   27.079    0.000
##     IS2G28H|t1       -1.235    0.033  -37.160    0.000
##     IS2G28H|t2       -0.247    0.025   -9.814    0.000
##     IS2G28H|t3        0.992    0.030   33.127    0.000
##     IS2G28I|t1       -1.255    0.034  -37.390    0.000
##     IS2G28I|t2       -0.233    0.025   -9.258    0.000
##     IS2G28I|t3        0.801    0.028   28.532    0.000
##     IS2G28J|t1       -1.210    0.033  -36.842    0.000
##     IS2G28J|t2       -0.165    0.025   -6.599    0.000
##     IS2G28J|t3        0.799    0.028   28.495    0.000
##     IS2G28K|t1       -1.550    0.040  -39.200    0.000
##     IS2G28K|t2       -0.692    0.027  -25.416    0.000
##     IS2G28K|t3        0.471    0.026   18.140    0.000
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.430                           
##    .IS2G28B           0.338                           
##    .IS2G28F           0.484                           
##    .IS2G28G           0.515                           
##    .IS2G28C           0.654                           
##    .IS2G28D           0.714                           
##    .IS2G28E           0.386                           
##    .IS2G28H           0.589                           
##    .IS2G28I           0.300                           
##    .IS2G28J           0.217                           
##    .IS2G28K           0.365                           
##     PosP              0.570    0.016   35.036    0.000
##     NegP              0.346    0.017   20.680    0.000
##     ExeP              0.700    0.013   54.155    0.000
## 
## Scales y*:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A           1.000                           
##     IS2G28B           1.000                           
##     IS2G28F           1.000                           
##     IS2G28G           1.000                           
##     IS2G28C           1.000                           
##     IS2G28D           1.000                           
##     IS2G28E           1.000                           
##     IS2G28H           1.000                           
##     IS2G28I           1.000                           
##     IS2G28J           1.000                           
##     IS2G28K           1.000                           
## 
## 
## Group 2 [f]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP =~                                             
##     IS2G28A           1.000                           
##     IS2G28B (.p2.)    1.078    0.019   57.081    0.000
##     IS2G28F (.p3.)    0.951    0.017   55.113    0.000
##     IS2G28G (.p4.)    0.922    0.017   54.234    0.000
##   NegP =~                                             
##     IS2G28C           1.000                           
##     IS2G28D (.p6.)    0.908    0.029   31.533    0.000
##     IS2G28E (.p7.)    1.331    0.039   34.325    0.000
##     IS2G28H (.p8.)    1.089    0.031   35.481    0.000
##   ExeP =~                                             
##     IS2G28I           1.000                           
##     IS2G28J (.10.)    1.058    0.014   77.823    0.000
##     IS2G28K           0.873    0.016   56.141    0.000
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP ~~                                             
##     NegP             -0.035    0.011   -3.164    0.002
##     ExeP              0.220    0.013   16.485    0.000
##   NegP ~~                                             
##     ExeP             -0.011    0.012   -0.962    0.336
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.000                           
##    .IS2G28B           0.000                           
##    .IS2G28F           0.000                           
##    .IS2G28G           0.000                           
##    .IS2G28C           0.000                           
##    .IS2G28D           0.000                           
##    .IS2G28E           0.000                           
##    .IS2G28H           0.000                           
##    .IS2G28I           0.000                           
##    .IS2G28J           0.000                           
##    .IS2G28K           0.000                           
##     PosP              0.000                           
##     NegP              0.000                           
##     ExeP              0.000                           
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A|t1       -2.007    0.055  -36.450    0.000
##     IS2G28A|t2       -0.825    0.028  -29.287    0.000
##     IS2G28A|t3        0.971    0.030   32.799    0.000
##     IS2G28B|t1       -2.078    0.059  -35.494    0.000
##     IS2G28B|t2       -1.016    0.030  -33.743    0.000
##     IS2G28B|t3        0.704    0.027   25.862    0.000
##     IS2G28F|t1       -2.070    0.058  -35.613    0.000
##     IS2G28F|t2       -1.069    0.031  -34.751    0.000
##     IS2G28F|t3        0.643    0.027   23.999    0.000
##     IS2G28G|t1       -1.925    0.051  -37.399    0.000
##     IS2G28G|t2       -0.832    0.028  -29.469    0.000
##     IS2G28G|t3        0.733    0.027   26.728    0.000
##     IS2G28C|t1       -1.595    0.041  -39.343    0.000
##     IS2G28C|t2       -0.323    0.025  -12.738    0.000
##     IS2G28C|t3        0.916    0.029   31.550    0.000
##     IS2G28D|t1       -1.214    0.033  -37.028    0.000
##     IS2G28D|t2        0.183    0.025    7.328    0.000
##     IS2G28D|t3        1.184    0.032   36.616    0.000
##     IS2G28E|t1       -1.706    0.044  -39.062    0.000
##     IS2G28E|t2       -0.693    0.027  -25.522    0.000
##     IS2G28E|t3        0.536    0.026   20.453    0.000
##     IS2G28H|t1       -1.439    0.037  -39.029    0.000
##     IS2G28H|t2       -0.364    0.025  -14.313    0.000
##     IS2G28H|t3        0.870    0.029   30.447    0.000
##     IS2G28I|t1       -0.901    0.029  -31.196    0.000
##     IS2G28I|t2        0.317    0.025   12.541    0.000
##     IS2G28I|t3        1.252    0.033   37.495    0.000
##     IS2G28J|t1       -0.901    0.029  -31.196    0.000
##     IS2G28J|t2        0.246    0.025    9.779    0.000
##     IS2G28J|t3        1.310    0.034   38.109    0.000
##     IS2G28K|t1       -1.410    0.036  -38.870    0.000
##     IS2G28K|t2       -0.494    0.026  -19.014    0.000
##     IS2G28K|t3        0.843    0.028   29.760    0.000
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.512                           
##    .IS2G28B           0.433                           
##    .IS2G28F           0.558                           
##    .IS2G28G           0.584                           
##    .IS2G28C           0.681                           
##    .IS2G28D           0.737                           
##    .IS2G28E           0.434                           
##    .IS2G28H           0.621                           
##    .IS2G28I           0.338                           
##    .IS2G28J           0.259                           
##    .IS2G28K           0.496                           
##     PosP              0.488    0.016   31.391    0.000
##     NegP              0.319    0.016   20.423    0.000
##     ExeP              0.662    0.013   52.094    0.000
## 
## Scales y*:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A           1.000                           
##     IS2G28B           1.000                           
##     IS2G28F           1.000                           
##     IS2G28G           1.000                           
##     IS2G28C           1.000                           
##     IS2G28D           1.000                           
##     IS2G28E           1.000                           
##     IS2G28H           1.000                           
##     IS2G28I           1.000                           
##     IS2G28J           1.000                           
##     IS2G28K           1.000
anova(ConfiguralRes, PartialMetricRes)
## 
## Scaled Chi-Squared Difference Test (method = "satorra.2000")
## 
## lavaan NOTE:
##     The "Chisq" column contains standard test statistics, not the
##     robust test that should be reported per model. A robust difference
##     test is a function of two standard (not robust) statistics.
##  
##                  Df AIC BIC  Chisq Chisq diff Df diff Pr(>Chisq)
## ConfiguralRes    82         715.46                              
## PartialMetricRes 89         723.15     8.8617       7     0.2627

Scalar

# 1
PartailScalarRes <- cfa(PMod, data = datP, estimator = "WLSMV",
                         ordered = c("IS2G28A", "IS2G28B", "IS2G28F", "IS2G28G",
                                     "IS2G28C", "IS2G28D", "IS2G28E", "IS2G28H",
                                     "IS2G28I", "IS2G28J", "IS2G28K"),
                         fixed.x = F, group= "S_SEX",
                         group.equal=c("loadings", "thresholds"),
                         group.partial=c("ExeP =~ IS2G28K"))
summary(PartailScalarRes, fit.measures=T)
## lavaan 0.6.16 ended normally after 55 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                       108
##   Number of equality constraints                    40
## 
##   Number of observations per group:                   
##     m                                             2528
##     f                                             2546
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                               769.105    1004.803
##   Degrees of freedom                               108         108
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  0.780
##   Shift parameter                                           18.692
##     simple second-order correction                                
##   Test statistic for each group:
##     m                                          383.832     501.444
##     f                                          385.273     503.359
## 
## Model Test Baseline Model:
## 
##   Test statistic                             50760.158   28275.687
##   Degrees of freedom                               110         110
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.798
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.987       0.968
##   Tucker-Lewis Index (TLI)                       0.987       0.968
##                                                                   
##   Robust Comparative Fit Index (CFI)                            NA
##   Robust Tucker-Lewis Index (TLI)                               NA
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.049       0.057
##   90 Percent confidence interval - lower         0.046       0.054
##   90 Percent confidence interval - upper         0.052       0.060
##   P-value H_0: RMSEA <= 0.050                    0.663       0.000
##   P-value H_0: RMSEA >= 0.080                    0.000       0.000
##                                                                   
##   Robust RMSEA                                                  NA
##   90 Percent confidence interval - lower                        NA
##   90 Percent confidence interval - upper                        NA
##   P-value H_0: Robust RMSEA <= 0.050                            NA
##   P-value H_0: Robust RMSEA >= 0.080                            NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.043       0.043
## 
## Parameter Estimates:
## 
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## 
## Group 1 [m]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP =~                                             
##     IS2G28A           1.000                           
##     IS2G28B (.p2.)    1.072    0.020   54.781    0.000
##     IS2G28F (.p3.)    0.942    0.018   50.914    0.000
##     IS2G28G (.p4.)    0.913    0.018   50.558    0.000
##   NegP =~                                             
##     IS2G28C           1.000                           
##     IS2G28D (.p6.)    0.916    0.031   29.801    0.000
##     IS2G28E (.p7.)    1.343    0.042   31.971    0.000
##     IS2G28H (.p8.)    1.120    0.033   33.926    0.000
##   ExeP =~                                             
##     IS2G28I           1.000                           
##     IS2G28J (.10.)    1.046    0.014   74.483    0.000
##     IS2G28K           0.948    0.013   71.372    0.000
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP ~~                                             
##     NegP              0.013    0.011    1.187    0.235
##     ExeP              0.375    0.014   27.766    0.000
##   NegP ~~                                             
##     ExeP              0.021    0.012    1.717    0.086
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.000                           
##    .IS2G28B           0.000                           
##    .IS2G28F           0.000                           
##    .IS2G28G           0.000                           
##    .IS2G28C           0.000                           
##    .IS2G28D           0.000                           
##    .IS2G28E           0.000                           
##    .IS2G28H           0.000                           
##    .IS2G28I           0.000                           
##    .IS2G28J           0.000                           
##    .IS2G28K           0.000                           
##     PosP              0.000                           
##     NegP              0.000                           
##     ExeP              0.000                           
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A (.12.)   -1.978    0.046  -43.123    0.000
##     IS2G28A (.13.)   -0.990    0.027  -37.192    0.000
##     IS2G28A (.14.)    0.590    0.024   24.179    0.000
##     IS2G28B (.15.)   -2.033    0.048  -42.759    0.000
##     IS2G28B (.16.)   -1.143    0.029  -39.645    0.000
##     IS2G28B (.17.)    0.370    0.024   15.635    0.000
##     IS2G28F (.18.)   -1.979    0.045  -44.021    0.000
##     IS2G28F (.19.)   -1.123    0.027  -41.423    0.000
##     IS2G28F (.20.)    0.321    0.022   14.431    0.000
##     IS2G28G (.21.)   -1.845    0.040  -45.876    0.000
##     IS2G28G (.22.)   -0.915    0.024  -37.426    0.000
##     IS2G28G (.23.)    0.460    0.023   19.928    0.000
##     IS2G28C (.24.)   -1.342    0.031  -42.618    0.000
##     IS2G28C (.25.)   -0.158    0.020   -7.903    0.000
##     IS2G28C (.26.)    0.968    0.025   38.167    0.000
##     IS2G28D (.27.)   -1.005    0.026  -38.721    0.000
##     IS2G28D (.28.)    0.293    0.020   14.689    0.000
##     IS2G28D (.29.)    1.217    0.029   42.675    0.000
##     IS2G28E (.30.)   -1.389    0.034  -41.258    0.000
##     IS2G28E (.31.)   -0.434    0.023  -18.923    0.000
##     IS2G28E (.32.)    0.708    0.025   27.927    0.000
##     IS2G28H (.33.)   -1.244    0.030  -41.844    0.000
##     IS2G28H (.34.)   -0.224    0.021  -10.620    0.000
##     IS2G28H (.35.)    1.000    0.027   37.542    0.000
##     IS2G28I (.36.)   -1.248    0.030  -40.993    0.000
##     IS2G28I (.37.)   -0.162    0.022   -7.251    0.000
##     IS2G28I (.38.)    0.792    0.027   29.490    0.000
##     IS2G28J (.39.)   -1.236    0.031  -40.503    0.000
##     IS2G28J (.40.)   -0.177    0.023   -7.789    0.000
##     IS2G28J (.41.)    0.801    0.027   29.262    0.000
##     IS2G28K (.42.)   -1.541    0.036  -42.281    0.000
##     IS2G28K (.43.)   -0.722    0.024  -30.309    0.000
##     IS2G28K (.44.)    0.441    0.023   19.552    0.000
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.423                           
##    .IS2G28B           0.337                           
##    .IS2G28F           0.488                           
##    .IS2G28G           0.519                           
##    .IS2G28C           0.662                           
##    .IS2G28D           0.716                           
##    .IS2G28E           0.390                           
##    .IS2G28H           0.576                           
##    .IS2G28I           0.292                           
##    .IS2G28J           0.225                           
##    .IS2G28K           0.364                           
##     PosP              0.577    0.017   34.338    0.000
##     NegP              0.338    0.017   19.569    0.000
##     ExeP              0.708    0.013   52.468    0.000
## 
## Scales y*:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A           1.000                           
##     IS2G28B           1.000                           
##     IS2G28F           1.000                           
##     IS2G28G           1.000                           
##     IS2G28C           1.000                           
##     IS2G28D           1.000                           
##     IS2G28E           1.000                           
##     IS2G28H           1.000                           
##     IS2G28I           1.000                           
##     IS2G28J           1.000                           
##     IS2G28K           1.000                           
## 
## 
## Group 2 [f]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP =~                                             
##     IS2G28A           1.000                           
##     IS2G28B (.p2.)    1.072    0.020   54.781    0.000
##     IS2G28F (.p3.)    0.942    0.018   50.914    0.000
##     IS2G28G (.p4.)    0.913    0.018   50.558    0.000
##   NegP =~                                             
##     IS2G28C           1.000                           
##     IS2G28D (.p6.)    0.916    0.031   29.801    0.000
##     IS2G28E (.p7.)    1.343    0.042   31.971    0.000
##     IS2G28H (.p8.)    1.120    0.033   33.926    0.000
##   ExeP =~                                             
##     IS2G28I           1.000                           
##     IS2G28J (.10.)    1.046    0.014   74.483    0.000
##     IS2G28K           0.794    0.026   30.472    0.000
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP ~~                                             
##     NegP             -0.028    0.009   -3.167    0.002
##     ExeP              0.180    0.014   13.172    0.000
##   NegP ~~                                             
##     ExeP             -0.010    0.010   -0.986    0.324
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.000                           
##    .IS2G28B           0.000                           
##    .IS2G28F           0.000                           
##    .IS2G28G           0.000                           
##    .IS2G28C           0.000                           
##    .IS2G28D           0.000                           
##    .IS2G28E           0.000                           
##    .IS2G28H           0.000                           
##    .IS2G28I           0.000                           
##    .IS2G28J           0.000                           
##    .IS2G28K           0.000                           
##     PosP             -0.232    0.023  -10.103    0.000
##     NegP              0.139    0.019    7.247    0.000
##     ExeP             -0.397    0.026  -15.083    0.000
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A (.12.)   -1.978    0.046  -43.123    0.000
##     IS2G28A (.13.)   -0.990    0.027  -37.192    0.000
##     IS2G28A (.14.)    0.590    0.024   24.179    0.000
##     IS2G28B (.15.)   -2.033    0.048  -42.759    0.000
##     IS2G28B (.16.)   -1.143    0.029  -39.645    0.000
##     IS2G28B (.17.)    0.370    0.024   15.635    0.000
##     IS2G28F (.18.)   -1.979    0.045  -44.021    0.000
##     IS2G28F (.19.)   -1.123    0.027  -41.423    0.000
##     IS2G28F (.20.)    0.321    0.022   14.431    0.000
##     IS2G28G (.21.)   -1.845    0.040  -45.876    0.000
##     IS2G28G (.22.)   -0.915    0.024  -37.426    0.000
##     IS2G28G (.23.)    0.460    0.023   19.928    0.000
##     IS2G28C (.24.)   -1.342    0.031  -42.618    0.000
##     IS2G28C (.25.)   -0.158    0.020   -7.903    0.000
##     IS2G28C (.26.)    0.968    0.025   38.167    0.000
##     IS2G28D (.27.)   -1.005    0.026  -38.721    0.000
##     IS2G28D (.28.)    0.293    0.020   14.689    0.000
##     IS2G28D (.29.)    1.217    0.029   42.675    0.000
##     IS2G28E (.30.)   -1.389    0.034  -41.258    0.000
##     IS2G28E (.31.)   -0.434    0.023  -18.923    0.000
##     IS2G28E (.32.)    0.708    0.025   27.927    0.000
##     IS2G28H (.33.)   -1.244    0.030  -41.844    0.000
##     IS2G28H (.34.)   -0.224    0.021  -10.620    0.000
##     IS2G28H (.35.)    1.000    0.027   37.542    0.000
##     IS2G28I (.36.)   -1.248    0.030  -40.993    0.000
##     IS2G28I (.37.)   -0.162    0.022   -7.251    0.000
##     IS2G28I (.38.)    0.792    0.027   29.490    0.000
##     IS2G28J (.39.)   -1.236    0.031  -40.503    0.000
##     IS2G28J (.40.)   -0.177    0.023   -7.789    0.000
##     IS2G28J (.41.)    0.801    0.027   29.262    0.000
##     IS2G28K (.42.)   -1.541    0.036  -42.281    0.000
##     IS2G28K (.43.)   -0.722    0.024  -30.309    0.000
##     IS2G28K (.44.)    0.441    0.023   19.552    0.000
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.389                           
##    .IS2G28B           0.328                           
##    .IS2G28F           0.403                           
##    .IS2G28G           0.440                           
##    .IS2G28C           0.569                           
##    .IS2G28D           0.644                           
##    .IS2G28E           0.347                           
##    .IS2G28H           0.617                           
##    .IS2G28I           0.297                           
##    .IS2G28J           0.221                           
##    .IS2G28K           0.377                           
##     PosP              0.370    0.022   17.107    0.000
##     NegP              0.273    0.018   15.230    0.000
##     ExeP              0.587    0.033   17.732    0.000
## 
## Scales y*:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A           1.148    0.028   41.713    0.000
##     IS2G28B           1.153    0.029   39.906    0.000
##     IS2G28F           1.169    0.028   42.199    0.000
##     IS2G28G           1.156    0.027   43.339    0.000
##     IS2G28C           1.090    0.025   43.025    0.000
##     IS2G28D           1.070    0.024   44.399    0.000
##     IS2G28E           1.091    0.028   39.603    0.000
##     IS2G28H           1.021    0.024   43.249    0.000
##     IS2G28I           1.064    0.027   39.408    0.000
##     IS2G28J           1.076    0.028   38.560    0.000
##     IS2G28K           1.156    0.030   38.237    0.000
anova(PartialMetricRes, PartailScalarRes)
## 
## Scaled Chi-Squared Difference Test (method = "satorra.2000")
## 
## lavaan NOTE:
##     The "Chisq" column contains standard test statistics, not the
##     robust test that should be reported per model. A robust difference
##     test is a function of two standard (not robust) statistics.
##  
##                   Df AIC BIC  Chisq Chisq diff Df diff Pr(>Chisq)    
## PartialMetricRes  89         723.15                                  
## PartailScalarRes 108         769.11     65.504      19  5.056e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
lavTestScore(PartailScalarRes)
## $test
## 
## total score test:
## 
##    test    X2 df p.value
## 1 score 53.57 40   0.074
## 
## $uni
## 
## univariate score tests:
## 
##      lhs op    rhs     X2 df p.value
## 1   .p2. ==  .p88.  0.262  1   0.609
## 2   .p3. ==  .p89.  1.494  1   0.222
## 3   .p4. ==  .p90.  1.063  1   0.302
## 4   .p6. ==  .p92.  2.899  1   0.089
## 5   .p7. ==  .p93.  5.485  1   0.019
## 6   .p8. ==  .p94.  0.439  1   0.507
## 7  .p10. ==  .p96.  3.114  1   0.078
## 8  .p12. ==  .p98.  0.008  1   0.930
## 9  .p13. ==  .p99.  9.084  1   0.003
## 10 .p14. == .p100.  2.806  1   0.094
## 11 .p15. == .p101.  0.390  1   0.532
## 12 .p16. == .p102.  0.869  1   0.351
## 13 .p17. == .p103.  0.387  1   0.534
## 14 .p18. == .p104.  0.106  1   0.745
## 15 .p19. == .p105.  0.463  1   0.496
## 16 .p20. == .p106.  0.653  1   0.419
## 17 .p21. == .p107.  1.596  1   0.206
## 18 .p22. == .p108.  1.473  1   0.225
## 19 .p23. == .p109.  7.788  1   0.005
## 20 .p24. == .p110.  0.758  1   0.384
## 21 .p25. == .p111.  0.004  1   0.950
## 22 .p26. == .p112.  0.585  1   0.444
## 23 .p27. == .p113.  0.035  1   0.851
## 24 .p28. == .p114.  0.131  1   0.718
## 25 .p29. == .p115.  1.164  1   0.281
## 26 .p30. == .p116.  0.284  1   0.594
## 27 .p31. == .p117.  0.953  1   0.329
## 28 .p32. == .p118.  6.366  1   0.012
## 29 .p33. == .p119.  0.297  1   0.585
## 30 .p34. == .p120.  1.981  1   0.159
## 31 .p35. == .p121.  0.256  1   0.613
## 32 .p36. == .p122.  0.111  1   0.739
## 33 .p37. == .p123. 18.291  1   0.000
## 34 .p38. == .p124.  0.442  1   0.506
## 35 .p39. == .p125.  2.053  1   0.152
## 36 .p40. == .p126.  0.510  1   0.475
## 37 .p41. == .p127.  0.010  1   0.920
## 38 .p42. == .p128.  0.261  1   0.610
## 39 .p43. == .p129.  3.044  1   0.081
## 40 .p44. == .p130.  3.624  1   0.057
# .p37. == .p123.
# seek 
para.tab <- parametertable(PartailScalarRes)
para.tab[para.tab$label == '.p37.' & para.tab$plabel == '.p123.',]
##      id     lhs op rhs user block group free ustart exo label plabel start
## 123 123 IS2G28I  |  t2    0     2     2   81     NA   0 .p37. .p123. 0.317
##        est    se
## 123 -0.162 0.022
# is IS2G28I  |  t2

# 2
PartailScalarRes2 <- cfa(PMod, data = datP, estimator = "WLSMV",
                        ordered = c("IS2G28A", "IS2G28B", "IS2G28F", "IS2G28G",
                                    "IS2G28C", "IS2G28D", "IS2G28E", "IS2G28H",
                                    "IS2G28I", "IS2G28J", "IS2G28K"),
                        fixed.x = F, group= "S_SEX",
                        group.equal=c("loadings", "thresholds"),
                        group.partial=c("ExeP =~ IS2G28K","IS2G28I  |  t2"))
summary(PartailScalarRes2, fit.measures=T)
## lavaan 0.6.16 ended normally after 53 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                       108
##   Number of equality constraints                    39
## 
##   Number of observations per group:                   
##     m                                             2528
##     f                                             2546
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                               750.797     979.639
##   Degrees of freedom                               107         107
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  0.781
##   Shift parameter                                           18.527
##     simple second-order correction                                
##   Test statistic for each group:
##     m                                          373.871     487.831
##     f                                          376.926     491.808
## 
## Model Test Baseline Model:
## 
##   Test statistic                             50760.158   28275.687
##   Degrees of freedom                               110         110
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.798
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.987       0.969
##   Tucker-Lewis Index (TLI)                       0.987       0.968
##                                                                   
##   Robust Comparative Fit Index (CFI)                            NA
##   Robust Tucker-Lewis Index (TLI)                               NA
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.049       0.057
##   90 Percent confidence interval - lower         0.045       0.053
##   90 Percent confidence interval - upper         0.052       0.060
##   P-value H_0: RMSEA <= 0.050                    0.735       0.000
##   P-value H_0: RMSEA >= 0.080                    0.000       0.000
##                                                                   
##   Robust RMSEA                                                  NA
##   90 Percent confidence interval - lower                        NA
##   90 Percent confidence interval - upper                        NA
##   P-value H_0: Robust RMSEA <= 0.050                            NA
##   P-value H_0: Robust RMSEA >= 0.080                            NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.043       0.043
## 
## Parameter Estimates:
## 
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## 
## Group 1 [m]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP =~                                             
##     IS2G28A           1.000                           
##     IS2G28B (.p2.)    1.072    0.020   54.782    0.000
##     IS2G28F (.p3.)    0.942    0.018   50.914    0.000
##     IS2G28G (.p4.)    0.913    0.018   50.558    0.000
##   NegP =~                                             
##     IS2G28C           1.000                           
##     IS2G28D (.p6.)    0.916    0.031   29.801    0.000
##     IS2G28E (.p7.)    1.343    0.042   31.971    0.000
##     IS2G28H (.p8.)    1.120    0.033   33.925    0.000
##   ExeP =~                                             
##     IS2G28I           1.000                           
##     IS2G28J (.10.)    1.052    0.014   73.732    0.000
##     IS2G28K           0.950    0.013   71.370    0.000
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP ~~                                             
##     NegP              0.013    0.011    1.187    0.235
##     ExeP              0.374    0.013   27.724    0.000
##   NegP ~~                                             
##     ExeP              0.021    0.012    1.715    0.086
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.000                           
##    .IS2G28B           0.000                           
##    .IS2G28F           0.000                           
##    .IS2G28G           0.000                           
##    .IS2G28C           0.000                           
##    .IS2G28D           0.000                           
##    .IS2G28E           0.000                           
##    .IS2G28H           0.000                           
##    .IS2G28I           0.000                           
##    .IS2G28J           0.000                           
##    .IS2G28K           0.000                           
##     PosP              0.000                           
##     NegP              0.000                           
##     ExeP              0.000                           
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A (.12.)   -1.978    0.046  -43.123    0.000
##     IS2G28A (.13.)   -0.990    0.027  -37.192    0.000
##     IS2G28A (.14.)    0.590    0.024   24.179    0.000
##     IS2G28B (.15.)   -2.033    0.048  -42.759    0.000
##     IS2G28B (.16.)   -1.143    0.029  -39.645    0.000
##     IS2G28B (.17.)    0.370    0.024   15.635    0.000
##     IS2G28F (.18.)   -1.979    0.045  -44.021    0.000
##     IS2G28F (.19.)   -1.123    0.027  -41.423    0.000
##     IS2G28F (.20.)    0.321    0.022   14.431    0.000
##     IS2G28G (.21.)   -1.845    0.040  -45.876    0.000
##     IS2G28G (.22.)   -0.915    0.024  -37.426    0.000
##     IS2G28G (.23.)    0.460    0.023   19.928    0.000
##     IS2G28C (.24.)   -1.342    0.031  -42.618    0.000
##     IS2G28C (.25.)   -0.158    0.020   -7.903    0.000
##     IS2G28C (.26.)    0.968    0.025   38.167    0.000
##     IS2G28D (.27.)   -1.005    0.026  -38.721    0.000
##     IS2G28D (.28.)    0.293    0.020   14.689    0.000
##     IS2G28D (.29.)    1.217    0.029   42.675    0.000
##     IS2G28E (.30.)   -1.389    0.034  -41.259    0.000
##     IS2G28E (.31.)   -0.434    0.023  -18.923    0.000
##     IS2G28E (.32.)    0.708    0.025   27.927    0.000
##     IS2G28H (.33.)   -1.244    0.030  -41.844    0.000
##     IS2G28H (.34.)   -0.224    0.021  -10.620    0.000
##     IS2G28H (.35.)    1.000    0.027   37.542    0.000
##     IS2G28I (.36.)   -1.232    0.031  -40.357    0.000
##     IS2G28I          -0.233    0.025   -9.258    0.000
##     IS2G28I (.38.)    0.805    0.027   29.884    0.000
##     IS2G28J (.39.)   -1.218    0.031  -39.768    0.000
##     IS2G28J (.40.)   -0.163    0.023   -7.110    0.000
##     IS2G28J (.41.)    0.811    0.027   29.556    0.000
##     IS2G28K (.42.)   -1.539    0.036  -42.219    0.000
##     IS2G28K (.43.)   -0.715    0.024  -29.896    0.000
##     IS2G28K (.44.)    0.455    0.023   19.982    0.000
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.423                           
##    .IS2G28B           0.337                           
##    .IS2G28F           0.488                           
##    .IS2G28G           0.519                           
##    .IS2G28C           0.662                           
##    .IS2G28D           0.716                           
##    .IS2G28E           0.390                           
##    .IS2G28H           0.576                           
##    .IS2G28I           0.296                           
##    .IS2G28J           0.221                           
##    .IS2G28K           0.364                           
##     PosP              0.577    0.017   34.339    0.000
##     NegP              0.338    0.017   19.569    0.000
##     ExeP              0.704    0.014   52.094    0.000
## 
## Scales y*:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A           1.000                           
##     IS2G28B           1.000                           
##     IS2G28F           1.000                           
##     IS2G28G           1.000                           
##     IS2G28C           1.000                           
##     IS2G28D           1.000                           
##     IS2G28E           1.000                           
##     IS2G28H           1.000                           
##     IS2G28I           1.000                           
##     IS2G28J           1.000                           
##     IS2G28K           1.000                           
## 
## 
## Group 2 [f]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP =~                                             
##     IS2G28A           1.000                           
##     IS2G28B (.p2.)    1.072    0.020   54.782    0.000
##     IS2G28F (.p3.)    0.942    0.018   50.914    0.000
##     IS2G28G (.p4.)    0.913    0.018   50.558    0.000
##   NegP =~                                             
##     IS2G28C           1.000                           
##     IS2G28D (.p6.)    0.916    0.031   29.801    0.000
##     IS2G28E (.p7.)    1.343    0.042   31.971    0.000
##     IS2G28H (.p8.)    1.120    0.033   33.925    0.000
##   ExeP =~                                             
##     IS2G28I           1.000                           
##     IS2G28J (.10.)    1.052    0.014   73.732    0.000
##     IS2G28K           0.810    0.027   30.223    0.000
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP ~~                                             
##     NegP             -0.028    0.009   -3.167    0.002
##     ExeP              0.180    0.014   13.174    0.000
##   NegP ~~                                             
##     ExeP             -0.010    0.010   -0.983    0.325
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.000                           
##    .IS2G28B           0.000                           
##    .IS2G28F           0.000                           
##    .IS2G28G           0.000                           
##    .IS2G28C           0.000                           
##    .IS2G28D           0.000                           
##    .IS2G28E           0.000                           
##    .IS2G28H           0.000                           
##    .IS2G28I           0.000                           
##    .IS2G28J           0.000                           
##    .IS2G28K           0.000                           
##     PosP             -0.232    0.023  -10.103    0.000
##     NegP              0.139    0.019    7.247    0.000
##     ExeP             -0.369    0.027  -13.854    0.000
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A (.12.)   -1.978    0.046  -43.123    0.000
##     IS2G28A (.13.)   -0.990    0.027  -37.192    0.000
##     IS2G28A (.14.)    0.590    0.024   24.179    0.000
##     IS2G28B (.15.)   -2.033    0.048  -42.759    0.000
##     IS2G28B (.16.)   -1.143    0.029  -39.645    0.000
##     IS2G28B (.17.)    0.370    0.024   15.635    0.000
##     IS2G28F (.18.)   -1.979    0.045  -44.021    0.000
##     IS2G28F (.19.)   -1.123    0.027  -41.423    0.000
##     IS2G28F (.20.)    0.321    0.022   14.431    0.000
##     IS2G28G (.21.)   -1.845    0.040  -45.876    0.000
##     IS2G28G (.22.)   -0.915    0.024  -37.426    0.000
##     IS2G28G (.23.)    0.460    0.023   19.928    0.000
##     IS2G28C (.24.)   -1.342    0.031  -42.618    0.000
##     IS2G28C (.25.)   -0.158    0.020   -7.903    0.000
##     IS2G28C (.26.)    0.968    0.025   38.167    0.000
##     IS2G28D (.27.)   -1.005    0.026  -38.721    0.000
##     IS2G28D (.28.)    0.293    0.020   14.689    0.000
##     IS2G28D (.29.)    1.217    0.029   42.675    0.000
##     IS2G28E (.30.)   -1.389    0.034  -41.259    0.000
##     IS2G28E (.31.)   -0.434    0.023  -18.923    0.000
##     IS2G28E (.32.)    0.708    0.025   27.927    0.000
##     IS2G28H (.33.)   -1.244    0.030  -41.844    0.000
##     IS2G28H (.34.)   -0.224    0.021  -10.620    0.000
##     IS2G28H (.35.)    1.000    0.027   37.542    0.000
##     IS2G28I (.36.)   -1.232    0.031  -40.357    0.000
##     IS2G28I          -0.070    0.028   -2.503    0.012
##     IS2G28I (.38.)    0.805    0.027   29.884    0.000
##     IS2G28J (.39.)   -1.218    0.031  -39.768    0.000
##     IS2G28J (.40.)   -0.163    0.023   -7.110    0.000
##     IS2G28J (.41.)    0.811    0.027   29.556    0.000
##     IS2G28K (.42.)   -1.539    0.036  -42.219    0.000
##     IS2G28K (.43.)   -0.715    0.024  -29.896    0.000
##     IS2G28K (.44.)    0.455    0.023   19.982    0.000
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.389                           
##    .IS2G28B           0.328                           
##    .IS2G28F           0.403                           
##    .IS2G28G           0.440                           
##    .IS2G28C           0.569                           
##    .IS2G28D           0.644                           
##    .IS2G28E           0.347                           
##    .IS2G28H           0.617                           
##    .IS2G28I           0.305                           
##    .IS2G28J           0.214                           
##    .IS2G28K           0.384                           
##     PosP              0.370    0.022   17.107    0.000
##     NegP              0.273    0.018   15.230    0.000
##     ExeP              0.582    0.033   17.702    0.000
## 
## Scales y*:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A           1.148    0.028   41.713    0.000
##     IS2G28B           1.153    0.029   39.906    0.000
##     IS2G28F           1.169    0.028   42.199    0.000
##     IS2G28G           1.156    0.027   43.339    0.000
##     IS2G28C           1.090    0.025   43.025    0.000
##     IS2G28D           1.070    0.024   44.399    0.000
##     IS2G28E           1.091    0.028   39.603    0.000
##     IS2G28H           1.021    0.024   43.249    0.000
##     IS2G28I           1.062    0.027   39.377    0.000
##     IS2G28J           1.079    0.028   38.476    0.000
##     IS2G28K           1.143    0.030   38.145    0.000
anova(PartialMetricRes, PartailScalarRes2) 
## 
## Scaled Chi-Squared Difference Test (method = "satorra.2000")
## 
## lavaan NOTE:
##     The "Chisq" column contains standard test statistics, not the
##     robust test that should be reported per model. A robust difference
##     test is a function of two standard (not robust) statistics.
##  
##                    Df AIC BIC  Chisq Chisq diff Df diff Pr(>Chisq)   
## PartialMetricRes   89         723.15                                 
## PartailScalarRes2 107         750.80     39.541      18   0.002409 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# p-value = 0.002409 still have to release

lavTestScore(PartailScalarRes2)
## $test
## 
## total score test:
## 
##    test     X2 df p.value
## 1 score 35.276 39    0.64
## 
## $uni
## 
## univariate score tests:
## 
##      lhs op    rhs    X2 df p.value
## 1   .p2. ==  .p88. 0.262  1   0.609
## 2   .p3. ==  .p89. 1.493  1   0.222
## 3   .p4. ==  .p90. 1.063  1   0.303
## 4   .p6. ==  .p92. 2.899  1   0.089
## 5   .p7. ==  .p93. 5.482  1   0.019
## 6   .p8. ==  .p94. 0.439  1   0.508
## 7  .p10. ==  .p96. 1.124  1   0.289
## 8  .p12. ==  .p98. 0.008  1   0.929
## 9  .p13. ==  .p99. 9.082  1   0.003
## 10 .p14. == .p100. 2.807  1   0.094
## 11 .p15. == .p101. 0.390  1   0.532
## 12 .p16. == .p102. 0.869  1   0.351
## 13 .p17. == .p103. 0.387  1   0.534
## 14 .p18. == .p104. 0.106  1   0.745
## 15 .p19. == .p105. 0.463  1   0.496
## 16 .p20. == .p106. 0.653  1   0.419
## 17 .p21. == .p107. 1.595  1   0.207
## 18 .p22. == .p108. 1.473  1   0.225
## 19 .p23. == .p109. 7.788  1   0.005
## 20 .p24. == .p110. 0.758  1   0.384
## 21 .p25. == .p111. 0.004  1   0.950
## 22 .p26. == .p112. 0.585  1   0.444
## 23 .p27. == .p113. 0.035  1   0.851
## 24 .p28. == .p114. 0.131  1   0.718
## 25 .p29. == .p115. 1.164  1   0.281
## 26 .p30. == .p116. 0.283  1   0.595
## 27 .p31. == .p117. 0.953  1   0.329
## 28 .p32. == .p118. 6.365  1   0.012
## 29 .p33. == .p119. 0.297  1   0.586
## 30 .p34. == .p120. 1.981  1   0.159
## 31 .p35. == .p121. 0.256  1   0.613
## 32 .p36. == .p122. 1.512  1   0.219
## 33 .p38. == .p124. 0.109  1   0.741
## 34 .p39. == .p125. 0.188  1   0.664
## 35 .p40. == .p126. 0.031  1   0.861
## 36 .p41. == .p127. 0.801  1   0.371
## 37 .p42. == .p128. 0.343  1   0.558
## 38 .p43. == .p129. 1.769  1   0.183
## 39 .p44. == .p130. 1.132  1   0.287
# .p13. ==  .p99. 9.082
para.tab <- parametertable(PartailScalarRes2)
para.tab[para.tab$label == '.p13.' & para.tab$plabel == '.p99.',]
##    id     lhs op rhs user block group free ustart exo label plabel  start   est
## 99 99 IS2G28A  |  t2    0     2     2   57     NA   0 .p13.  .p99. -0.825 -0.99
##       se
## 99 0.027
# IS2G28A  |  t2

# 3
PartailScalarRes3 <- cfa(PMod, data = datP, estimator = "WLSMV",
                         ordered = c("IS2G28A", "IS2G28B", "IS2G28F", "IS2G28G",
                                     "IS2G28C", "IS2G28D", "IS2G28E", "IS2G28H",
                                     "IS2G28I", "IS2G28J", "IS2G28K"),
                         fixed.x = F, group= "S_SEX",
                         group.equal=c("loadings", "thresholds"),
                         group.partial=c("ExeP =~ IS2G28K","IS2G28I  |  t2", "IS2G28A  |  t2"))

summary(PartailScalarRes3, fit.measures=T)
## lavaan 0.6.16 ended normally after 52 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                       108
##   Number of equality constraints                    38
## 
##   Number of observations per group:                   
##     m                                             2528
##     f                                             2546
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                               741.717     969.588
##   Degrees of freedom                               106         106
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  0.780
##   Shift parameter                                           18.402
##     simple second-order correction                                
##   Test statistic for each group:
##     m                                          368.436     481.655
##     f                                          373.281     487.933
## 
## Model Test Baseline Model:
## 
##   Test statistic                             50760.158   28275.687
##   Degrees of freedom                               110         110
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.798
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.987       0.969
##   Tucker-Lewis Index (TLI)                       0.987       0.968
##                                                                   
##   Robust Comparative Fit Index (CFI)                            NA
##   Robust Tucker-Lewis Index (TLI)                               NA
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.049       0.057
##   90 Percent confidence interval - lower         0.045       0.053
##   90 Percent confidence interval - upper         0.052       0.060
##   P-value H_0: RMSEA <= 0.050                    0.747       0.000
##   P-value H_0: RMSEA >= 0.080                    0.000       0.000
##                                                                   
##   Robust RMSEA                                                  NA
##   90 Percent confidence interval - lower                        NA
##   90 Percent confidence interval - upper                        NA
##   P-value H_0: Robust RMSEA <= 0.050                            NA
##   P-value H_0: Robust RMSEA >= 0.080                            NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.043       0.043
## 
## Parameter Estimates:
## 
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## 
## Group 1 [m]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP =~                                             
##     IS2G28A           1.000                           
##     IS2G28B (.p2.)    1.085    0.020   53.504    0.000
##     IS2G28F (.p3.)    0.953    0.019   49.728    0.000
##     IS2G28G (.p4.)    0.924    0.019   49.562    0.000
##   NegP =~                                             
##     IS2G28C           1.000                           
##     IS2G28D (.p6.)    0.916    0.031   29.800    0.000
##     IS2G28E (.p7.)    1.343    0.042   31.970    0.000
##     IS2G28H (.p8.)    1.120    0.033   33.925    0.000
##   ExeP =~                                             
##     IS2G28I           1.000                           
##     IS2G28J (.10.)    1.052    0.014   73.712    0.000
##     IS2G28K           0.950    0.013   71.379    0.000
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP ~~                                             
##     NegP              0.013    0.011    1.186    0.236
##     ExeP              0.371    0.013   27.579    0.000
##   NegP ~~                                             
##     ExeP              0.021    0.012    1.715    0.086
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.000                           
##    .IS2G28B           0.000                           
##    .IS2G28F           0.000                           
##    .IS2G28G           0.000                           
##    .IS2G28C           0.000                           
##    .IS2G28D           0.000                           
##    .IS2G28E           0.000                           
##    .IS2G28H           0.000                           
##    .IS2G28I           0.000                           
##    .IS2G28J           0.000                           
##    .IS2G28K           0.000                           
##     PosP              0.000                           
##     NegP              0.000                           
##     ExeP              0.000                           
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A (.12.)   -1.941    0.047  -40.903    0.000
##     IS2G28A          -1.052    0.031  -34.321    0.000
##     IS2G28A (.14.)    0.586    0.024   24.088    0.000
##     IS2G28B (.15.)   -2.024    0.048  -42.278    0.000
##     IS2G28B (.16.)   -1.134    0.029  -38.850    0.000
##     IS2G28B (.17.)    0.377    0.024   15.820    0.000
##     IS2G28F (.18.)   -1.970    0.045  -43.573    0.000
##     IS2G28F (.19.)   -1.115    0.027  -40.661    0.000
##     IS2G28F (.20.)    0.327    0.022   14.623    0.000
##     IS2G28G (.21.)   -1.837    0.041  -45.328    0.000
##     IS2G28G (.22.)   -0.907    0.025  -36.793    0.000
##     IS2G28G (.23.)    0.465    0.023   20.114    0.000
##     IS2G28C (.24.)   -1.342    0.031  -42.619    0.000
##     IS2G28C (.25.)   -0.158    0.020   -7.903    0.000
##     IS2G28C (.26.)    0.968    0.025   38.167    0.000
##     IS2G28D (.27.)   -1.005    0.026  -38.721    0.000
##     IS2G28D (.28.)    0.293    0.020   14.689    0.000
##     IS2G28D (.29.)    1.217    0.029   42.675    0.000
##     IS2G28E (.30.)   -1.389    0.034  -41.258    0.000
##     IS2G28E (.31.)   -0.434    0.023  -18.922    0.000
##     IS2G28E (.32.)    0.708    0.025   27.927    0.000
##     IS2G28H (.33.)   -1.244    0.030  -41.844    0.000
##     IS2G28H (.34.)   -0.224    0.021  -10.620    0.000
##     IS2G28H (.35.)    1.000    0.027   37.542    0.000
##     IS2G28I (.36.)   -1.232    0.031  -40.357    0.000
##     IS2G28I          -0.233    0.025   -9.258    0.000
##     IS2G28I (.38.)    0.805    0.027   29.884    0.000
##     IS2G28J (.39.)   -1.218    0.031  -39.768    0.000
##     IS2G28J (.40.)   -0.163    0.023   -7.110    0.000
##     IS2G28J (.41.)    0.811    0.027   29.556    0.000
##     IS2G28K (.42.)   -1.539    0.036  -42.219    0.000
##     IS2G28K (.43.)   -0.715    0.024  -29.896    0.000
##     IS2G28K (.44.)    0.455    0.023   19.983    0.000
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.433                           
##    .IS2G28B           0.332                           
##    .IS2G28F           0.485                           
##    .IS2G28G           0.516                           
##    .IS2G28C           0.662                           
##    .IS2G28D           0.716                           
##    .IS2G28E           0.390                           
##    .IS2G28H           0.576                           
##    .IS2G28I           0.296                           
##    .IS2G28J           0.221                           
##    .IS2G28K           0.364                           
##     PosP              0.567    0.017   33.596    0.000
##     NegP              0.338    0.017   19.568    0.000
##     ExeP              0.704    0.014   52.091    0.000
## 
## Scales y*:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A           1.000                           
##     IS2G28B           1.000                           
##     IS2G28F           1.000                           
##     IS2G28G           1.000                           
##     IS2G28C           1.000                           
##     IS2G28D           1.000                           
##     IS2G28E           1.000                           
##     IS2G28H           1.000                           
##     IS2G28I           1.000                           
##     IS2G28J           1.000                           
##     IS2G28K           1.000                           
## 
## 
## Group 2 [f]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP =~                                             
##     IS2G28A           1.000                           
##     IS2G28B (.p2.)    1.085    0.020   53.504    0.000
##     IS2G28F (.p3.)    0.953    0.019   49.728    0.000
##     IS2G28G (.p4.)    0.924    0.019   49.562    0.000
##   NegP =~                                             
##     IS2G28C           1.000                           
##     IS2G28D (.p6.)    0.916    0.031   29.800    0.000
##     IS2G28E (.p7.)    1.343    0.042   31.970    0.000
##     IS2G28H (.p8.)    1.120    0.033   33.925    0.000
##   ExeP =~                                             
##     IS2G28I           1.000                           
##     IS2G28J (.10.)    1.052    0.014   73.712    0.000
##     IS2G28K           0.810    0.027   30.222    0.000
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP ~~                                             
##     NegP             -0.027    0.009   -3.168    0.002
##     ExeP              0.176    0.013   13.087    0.000
##   NegP ~~                                             
##     ExeP             -0.010    0.010   -0.983    0.325
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.000                           
##    .IS2G28B           0.000                           
##    .IS2G28F           0.000                           
##    .IS2G28G           0.000                           
##    .IS2G28C           0.000                           
##    .IS2G28D           0.000                           
##    .IS2G28E           0.000                           
##    .IS2G28H           0.000                           
##    .IS2G28I           0.000                           
##    .IS2G28J           0.000                           
##    .IS2G28K           0.000                           
##     PosP             -0.217    0.023   -9.279    0.000
##     NegP              0.139    0.019    7.247    0.000
##     ExeP             -0.369    0.027  -13.854    0.000
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A (.12.)   -1.941    0.047  -40.903    0.000
##     IS2G28A          -0.916    0.035  -25.862    0.000
##     IS2G28A (.14.)    0.586    0.024   24.088    0.000
##     IS2G28B (.15.)   -2.024    0.048  -42.278    0.000
##     IS2G28B (.16.)   -1.134    0.029  -38.850    0.000
##     IS2G28B (.17.)    0.377    0.024   15.820    0.000
##     IS2G28F (.18.)   -1.970    0.045  -43.573    0.000
##     IS2G28F (.19.)   -1.115    0.027  -40.661    0.000
##     IS2G28F (.20.)    0.327    0.022   14.623    0.000
##     IS2G28G (.21.)   -1.837    0.041  -45.328    0.000
##     IS2G28G (.22.)   -0.907    0.025  -36.793    0.000
##     IS2G28G (.23.)    0.465    0.023   20.114    0.000
##     IS2G28C (.24.)   -1.342    0.031  -42.619    0.000
##     IS2G28C (.25.)   -0.158    0.020   -7.903    0.000
##     IS2G28C (.26.)    0.968    0.025   38.167    0.000
##     IS2G28D (.27.)   -1.005    0.026  -38.721    0.000
##     IS2G28D (.28.)    0.293    0.020   14.689    0.000
##     IS2G28D (.29.)    1.217    0.029   42.675    0.000
##     IS2G28E (.30.)   -1.389    0.034  -41.258    0.000
##     IS2G28E (.31.)   -0.434    0.023  -18.922    0.000
##     IS2G28E (.32.)    0.708    0.025   27.927    0.000
##     IS2G28H (.33.)   -1.244    0.030  -41.844    0.000
##     IS2G28H (.34.)   -0.224    0.021  -10.620    0.000
##     IS2G28H (.35.)    1.000    0.027   37.542    0.000
##     IS2G28I (.36.)   -1.232    0.031  -40.357    0.000
##     IS2G28I          -0.070    0.028   -2.503    0.012
##     IS2G28I (.38.)    0.805    0.027   29.884    0.000
##     IS2G28J (.39.)   -1.218    0.031  -39.768    0.000
##     IS2G28J (.40.)   -0.163    0.023   -7.110    0.000
##     IS2G28J (.41.)    0.811    0.027   29.556    0.000
##     IS2G28K (.42.)   -1.539    0.036  -42.219    0.000
##     IS2G28K (.43.)   -0.715    0.024  -29.896    0.000
##     IS2G28K (.44.)    0.455    0.023   19.983    0.000
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.360                           
##    .IS2G28B           0.330                           
##    .IS2G28F           0.403                           
##    .IS2G28G           0.440                           
##    .IS2G28C           0.569                           
##    .IS2G28D           0.644                           
##    .IS2G28E           0.347                           
##    .IS2G28H           0.617                           
##    .IS2G28I           0.305                           
##    .IS2G28J           0.214                           
##    .IS2G28K           0.384                           
##     PosP              0.357    0.022   16.534    0.000
##     NegP              0.273    0.018   15.229    0.000
##     ExeP              0.582    0.033   17.702    0.000
## 
## Scales y*:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A           1.181    0.031   38.042    0.000
##     IS2G28B           1.155    0.029   39.825    0.000
##     IS2G28F           1.172    0.028   42.032    0.000
##     IS2G28G           1.159    0.027   43.162    0.000
##     IS2G28C           1.090    0.025   43.025    0.000
##     IS2G28D           1.070    0.024   44.399    0.000
##     IS2G28E           1.091    0.028   39.603    0.000
##     IS2G28H           1.021    0.024   43.249    0.000
##     IS2G28I           1.062    0.027   39.377    0.000
##     IS2G28J           1.079    0.028   38.475    0.000
##     IS2G28K           1.143    0.030   38.145    0.000
anova(PartialMetricRes, PartailScalarRes3)
## 
## Scaled Chi-Squared Difference Test (method = "satorra.2000")
## 
## lavaan NOTE:
##     The "Chisq" column contains standard test statistics, not the
##     robust test that should be reported per model. A robust difference
##     test is a function of two standard (not robust) statistics.
##  
##                    Df AIC BIC  Chisq Chisq diff Df diff Pr(>Chisq)  
## PartialMetricRes   89         723.15                                
## PartailScalarRes3 106         741.72     26.941      17    0.05895 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# p-value = 0.05895 done

Strict Invariance

fixing one factor loarding to 1 to fixing the latent factor’s varaicne to 1
https://groups.google.com/g/lavaan/c/ivqyRRVR5cQ

# use parameterization = "theta"
PartailStrictRes <- cfa(PMod, data = datP, estimator = "WLSMV",
                          ordered = c("IS2G28A", "IS2G28B", "IS2G28F", "IS2G28G",
                                      "IS2G28C", "IS2G28D", "IS2G28E", "IS2G28H",
                                      "IS2G28I", "IS2G28J", "IS2G28K"),
                          fixed.x = F, group= "S_SEX",
                          group.equal=c("loadings", "thresholds"),
                          group.partial=c("ExeP =~ IS2G28K","IS2G28I  |  t2", "IS2G28A  |  t2"),
                          parameterization = "theta")
summary(PartailStrictRes, fit.measures=T)
## lavaan 0.6.16 ended normally after 145 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                       108
##   Number of equality constraints                    38
## 
##   Number of observations per group:                   
##     m                                             2528
##     f                                             2546
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                               741.717     969.587
##   Degrees of freedom                               106         106
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  0.780
##   Shift parameter                                           18.402
##     simple second-order correction                                
##   Test statistic for each group:
##     m                                          368.436     481.655
##     f                                          373.280     487.932
## 
## Model Test Baseline Model:
## 
##   Test statistic                             50760.158   28275.687
##   Degrees of freedom                               110         110
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.798
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.987       0.969
##   Tucker-Lewis Index (TLI)                       0.987       0.968
##                                                                   
##   Robust Comparative Fit Index (CFI)                            NA
##   Robust Tucker-Lewis Index (TLI)                               NA
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.049       0.057
##   90 Percent confidence interval - lower         0.045       0.053
##   90 Percent confidence interval - upper         0.052       0.060
##   P-value H_0: RMSEA <= 0.050                    0.747       0.000
##   P-value H_0: RMSEA >= 0.080                    0.000       0.000
##                                                                   
##   Robust RMSEA                                                  NA
##   90 Percent confidence interval - lower                        NA
##   90 Percent confidence interval - upper                        NA
##   P-value H_0: Robust RMSEA <= 0.050                            NA
##   P-value H_0: Robust RMSEA >= 0.080                            NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.043       0.043
## 
## Parameter Estimates:
## 
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## 
## Group 1 [m]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP =~                                             
##     IS2G28A           1.000                           
##     IS2G28B (.p2.)    1.238    0.061   20.437    0.000
##     IS2G28F (.p3.)    0.901    0.039   22.880    0.000
##     IS2G28G (.p4.)    0.846    0.036   23.530    0.000
##   NegP =~                                             
##     IS2G28C           1.000                           
##     IS2G28D (.p6.)    0.881    0.043   20.572    0.000
##     IS2G28E (.p7.)    1.750    0.106   16.563    0.000
##     IS2G28H (.p8.)    1.201    0.057   21.176    0.000
##   ExeP =~                                             
##     IS2G28I           1.000                           
##     IS2G28J (.10.)    1.218    0.065   18.868    0.000
##     IS2G28K           0.857    0.036   23.910    0.000
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP ~~                                             
##     NegP              0.025    0.021    1.177    0.239
##     ExeP              1.036    0.064   16.304    0.000
##   NegP ~~                                             
##     ExeP              0.048    0.028    1.702    0.089
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.000                           
##    .IS2G28B           0.000                           
##    .IS2G28F           0.000                           
##    .IS2G28G           0.000                           
##    .IS2G28C           0.000                           
##    .IS2G28D           0.000                           
##    .IS2G28E           0.000                           
##    .IS2G28H           0.000                           
##    .IS2G28I           0.000                           
##    .IS2G28J           0.000                           
##    .IS2G28K           0.000                           
##     PosP              0.000                           
##     NegP              0.000                           
##     ExeP              0.000                           
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A (.12.)   -2.951    0.087  -33.741    0.000
##     IS2G28A          -1.599    0.052  -30.797    0.000
##     IS2G28A (.14.)    0.891    0.038   23.407    0.000
##     IS2G28B (.15.)   -3.510    0.106  -33.019    0.000
##     IS2G28B (.16.)   -1.967    0.065  -30.384    0.000
##     IS2G28B (.17.)    0.653    0.042   15.483    0.000
##     IS2G28F (.18.)   -2.830    0.075  -37.804    0.000
##     IS2G28F (.19.)   -1.601    0.046  -34.526    0.000
##     IS2G28F (.20.)    0.469    0.032   14.686    0.000
##     IS2G28G (.21.)   -2.558    0.063  -40.830    0.000
##     IS2G28G (.22.)   -1.263    0.038  -33.268    0.000
##     IS2G28G (.23.)    0.647    0.032   20.050    0.000
##     IS2G28C (.24.)   -1.649    0.042  -39.429    0.000
##     IS2G28C (.25.)   -0.194    0.025   -7.897    0.000
##     IS2G28C (.26.)    1.190    0.034   35.108    0.000
##     IS2G28D (.27.)   -1.187    0.032  -37.366    0.000
##     IS2G28D (.28.)    0.346    0.024   14.424    0.000
##     IS2G28D (.29.)    1.438    0.036   39.488    0.000
##     IS2G28E (.30.)   -2.224    0.077  -28.749    0.000
##     IS2G28E (.31.)   -0.695    0.041  -17.017    0.000
##     IS2G28E (.32.)    1.133    0.050   22.633    0.000
##     IS2G28H (.33.)   -1.640    0.042  -39.056    0.000
##     IS2G28H (.34.)   -0.296    0.028  -10.590    0.000
##     IS2G28H (.35.)    1.319    0.039   34.185    0.000
##     IS2G28I (.36.)   -2.263    0.068  -33.321    0.000
##     IS2G28I          -0.428    0.047   -9.153    0.000
##     IS2G28I (.38.)    1.479    0.053   28.137    0.000
##     IS2G28J (.39.)   -2.590    0.087  -29.920    0.000
##     IS2G28J (.40.)   -0.346    0.049   -7.003    0.000
##     IS2G28J (.41.)    1.725    0.070   24.644    0.000
##     IS2G28K (.42.)   -2.550    0.065  -39.475    0.000
##     IS2G28K (.43.)   -1.184    0.042  -27.940    0.000
##     IS2G28K (.44.)    0.753    0.037   20.177    0.000
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           1.000                           
##    .IS2G28B           1.000                           
##    .IS2G28F           1.000                           
##    .IS2G28G           1.000                           
##    .IS2G28C           1.000                           
##    .IS2G28D           1.000                           
##    .IS2G28E           1.000                           
##    .IS2G28H           1.000                           
##    .IS2G28I           1.000                           
##    .IS2G28J           1.000                           
##    .IS2G28K           1.000                           
##     PosP              1.311    0.090   14.539    0.000
##     NegP              0.511    0.039   12.952    0.000
##     ExeP              2.374    0.154   15.437    0.000
## 
## Scales y*:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A           0.658                           
##     IS2G28B           0.577                           
##     IS2G28F           0.696                           
##     IS2G28G           0.718                           
##     IS2G28C           0.814                           
##     IS2G28D           0.846                           
##     IS2G28E           0.624                           
##     IS2G28H           0.759                           
##     IS2G28I           0.544                           
##     IS2G28J           0.470                           
##     IS2G28K           0.604                           
## 
## 
## Group 2 [f]:
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP =~                                             
##     IS2G28A           1.000                           
##     IS2G28B (.p2.)    1.238    0.061   20.437    0.000
##     IS2G28F (.p3.)    0.901    0.039   22.880    0.000
##     IS2G28G (.p4.)    0.846    0.036   23.530    0.000
##   NegP =~                                             
##     IS2G28C           1.000                           
##     IS2G28D (.p6.)    0.881    0.043   20.572    0.000
##     IS2G28E (.p7.)    1.750    0.106   16.563    0.000
##     IS2G28H (.p8.)    1.201    0.057   21.176    0.000
##   ExeP =~                                             
##     IS2G28I           1.000                           
##     IS2G28J (.10.)    1.218    0.065   18.868    0.000
##     IS2G28K           0.730    0.031   23.461    0.000
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   PosP ~~                                             
##     NegP             -0.051    0.016   -3.154    0.002
##     ExeP              0.492    0.040   12.226    0.000
##   NegP ~~                                             
##     ExeP             -0.023    0.023   -0.983    0.326
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.000                           
##    .IS2G28B           0.000                           
##    .IS2G28F           0.000                           
##    .IS2G28G           0.000                           
##    .IS2G28C           0.000                           
##    .IS2G28D           0.000                           
##    .IS2G28E           0.000                           
##    .IS2G28H           0.000                           
##    .IS2G28I           0.000                           
##    .IS2G28J           0.000                           
##    .IS2G28K           0.000                           
##     PosP             -0.330    0.037   -8.932    0.000
##     NegP              0.170    0.024    7.161    0.000
##     ExeP             -0.677    0.052  -13.136    0.000
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A (.12.)   -2.951    0.087  -33.741    0.000
##     IS2G28A          -1.392    0.062  -22.515    0.000
##     IS2G28A (.14.)    0.891    0.038   23.407    0.000
##     IS2G28B (.15.)   -3.510    0.106  -33.019    0.000
##     IS2G28B (.16.)   -1.967    0.065  -30.384    0.000
##     IS2G28B (.17.)    0.653    0.042   15.483    0.000
##     IS2G28F (.18.)   -2.830    0.075  -37.804    0.000
##     IS2G28F (.19.)   -1.601    0.046  -34.526    0.000
##     IS2G28F (.20.)    0.469    0.032   14.686    0.000
##     IS2G28G (.21.)   -2.558    0.063  -40.830    0.000
##     IS2G28G (.22.)   -1.263    0.038  -33.268    0.000
##     IS2G28G (.23.)    0.647    0.032   20.050    0.000
##     IS2G28C (.24.)   -1.649    0.042  -39.429    0.000
##     IS2G28C (.25.)   -0.194    0.025   -7.897    0.000
##     IS2G28C (.26.)    1.190    0.034   35.108    0.000
##     IS2G28D (.27.)   -1.187    0.032  -37.366    0.000
##     IS2G28D (.28.)    0.346    0.024   14.424    0.000
##     IS2G28D (.29.)    1.438    0.036   39.488    0.000
##     IS2G28E (.30.)   -2.224    0.077  -28.749    0.000
##     IS2G28E (.31.)   -0.695    0.041  -17.017    0.000
##     IS2G28E (.32.)    1.133    0.050   22.633    0.000
##     IS2G28H (.33.)   -1.640    0.042  -39.056    0.000
##     IS2G28H (.34.)   -0.296    0.028  -10.590    0.000
##     IS2G28H (.35.)    1.319    0.039   34.185    0.000
##     IS2G28I (.36.)   -2.263    0.068  -33.321    0.000
##     IS2G28I          -0.128    0.051   -2.490    0.013
##     IS2G28I (.38.)    1.479    0.053   28.137    0.000
##     IS2G28J (.39.)   -2.590    0.087  -29.920    0.000
##     IS2G28J (.40.)   -0.346    0.049   -7.003    0.000
##     IS2G28J (.41.)    1.725    0.070   24.644    0.000
##     IS2G28K (.42.)   -2.550    0.065  -39.475    0.000
##     IS2G28K (.43.)   -1.184    0.042  -27.940    0.000
##     IS2G28K (.44.)    0.753    0.037   20.177    0.000
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .IS2G28A           0.831    0.060   13.817    0.000
##    .IS2G28B           0.992    0.073   13.582    0.000
##    .IS2G28F           0.832    0.053   15.663    0.000
##    .IS2G28G           0.852    0.051   16.652    0.000
##    .IS2G28C           0.860    0.049   17.432    0.000
##    .IS2G28D           0.900    0.049   18.413    0.000
##    .IS2G28E           0.891    0.072   12.356    0.000
##    .IS2G28H           1.071    0.062   17.316    0.000
##    .IS2G28I           1.028    0.072   14.350    0.000
##    .IS2G28J           0.969    0.083   11.690    0.000
##    .IS2G28K           1.054    0.061   17.412    0.000
##     PosP              0.824    0.064   12.973    0.000
##     NegP              0.413    0.033   12.464    0.000
##     ExeP              1.965    0.138   14.288    0.000
## 
## Scales y*:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     IS2G28A           0.777                           
##     IS2G28B           0.666                           
##     IS2G28F           0.816                           
##     IS2G28G           0.833                           
##     IS2G28C           0.887                           
##     IS2G28D           0.905                           
##     IS2G28E           0.681                           
##     IS2G28H           0.775                           
##     IS2G28I           0.578                           
##     IS2G28J           0.507                           
##     IS2G28K           0.690
anova(PartailScalarRes3, PartailStrictRes)
## 
## Scaled Chi-Squared Difference Test (method = "satorra.2000")
## 
## lavaan NOTE:
##     The "Chisq" column contains standard test statistics, not the
##     robust test that should be reported per model. A robust difference
##     test is a function of two standard (not robust) statistics.
##  
##                    Df AIC BIC  Chisq Chisq diff Df diff Pr(>Chisq)
## PartailScalarRes3 106         741.72                              
## PartailStrictRes  106         741.72 2.8121e-07       0
# chist not change because df is the same
# the estimate is change

Compare

compareFit(ConfiguralRes, PartialMetricRes, PartailScalarRes) |>
  summary()
## ################### Nested Model Comparison #########################
## 
## Scaled Chi-Squared Difference Test (method = "satorra.2000")
## 
## lavaan NOTE:
##     The "Chisq" column contains standard test statistics, not the
##     robust test that should be reported per model. A robust difference
##     test is a function of two standard (not robust) statistics.
##  
##                   Df AIC BIC  Chisq Chisq diff Df diff Pr(>Chisq)    
## ConfiguralRes     82         715.46                                  
## PartialMetricRes  89         723.15      8.862       7     0.2627    
## PartailScalarRes 108         769.11     65.504      19  5.056e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## ####################### Model Fit Indices ###########################
##                  chisq.scaled df.scaled pvalue.scaled rmsea.scaled cfi.scaled
## ConfiguralRes        948.300         82          .000        .065       .969 
## PartialMetricRes     937.275†        89          .000        .061       .970†
## PartailScalarRes    1004.803        108          .000        .057†      .968 
##                  tli.scaled  srmr
## ConfiguralRes         .959  .043†
## PartialMetricRes      .963  .043 
## PartailScalarRes      .968† .043 
## 
## ################## Differences in Fit Indices #######################
##                                     df.scaled rmsea.scaled cfi.scaled
## PartialMetricRes - ConfiguralRes            7       -0.003      0.001
## PartailScalarRes - PartialMetricRes        19       -0.004     -0.002
##                                     tli.scaled srmr
## PartialMetricRes - ConfiguralRes         0.004    0
## PartailScalarRes - PartialMetricRes      0.005    0