#Loading packages
library(lme4)
## Loading required package: Matrix
library(lmerTest)
##
## Attaching package: 'lmerTest'
## The following object is masked from 'package:lme4':
##
## lmer
## The following object is masked from 'package:stats':
##
## step
library(lavaan)
## This is lavaan 0.6-19
## lavaan is FREE software! Please report any bugs.
library(asherR)
library(reshape2)
Loading data
source("../Scripts/F23_Chem1040_Data_Combination.R", chdir = T)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.1 ✔ tibble 3.2.1
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ tidyr::expand() masks Matrix::expand()
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ✖ tidyr::pack() masks Matrix::pack()
## ✖ tidyr::unpack() masks Matrix::unpack()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
##
## Attaching package: 'janitor'
##
##
## The following objects are masked from 'package:stats':
##
## chisq.test, fisher.test
##
##
## |-------------------------------------|
## | misty 0.6.8 (2024-10-24) |
## | Miscellaneous Functions T. Yanagida |
## |-------------------------------------|
##
##
## Attaching package: 'misty'
##
##
## The following object is masked from 'package:janitor':
##
## crosstab
##
##
## Rows: 2101 Columns: 123
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (22): StartDate, EndDate, IPAddress, RecordedDate, ResponseId, Recipient...
## dbl (91): Status, Progress, Duration (in seconds), Finished, LocationLatitud...
## num (1): race2_b
## lgl (9): RecipientLastName, RecipientFirstName, ExternalReference, userName...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Rows: 22338 Columns: 60
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (14): StartDate, EndDate, IPAddress, RecordedDate, ResponseId, Recipient...
## dbl (43): Status, Progress, Duration (in seconds), Finished, LocationLatitud...
## lgl (3): RecipientLastName, RecipientFirstName, ExternalReference
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Rows: 11973 Columns: 16
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): start_date_diary, end_date_diary, stud_id
## dbl (13): booster_quote1_eoc, booster_quote2_eoc, booster_quote3_eoc, booste...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Rows: 1708 Columns: 157
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (22): StartDate, EndDate, IPAddress, RecordedDate, ResponseId, Recipien...
## dbl (126): Status, Progress, Duration (in seconds), Finished, LocationLatitu...
## lgl (9): RecipientLastName, RecipientFirstName, ExternalReference, userNam...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Rows: 2271 Columns: 4
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (4): student, loginid, recipient_email, stud_id
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
## Rows: 2075 Columns: 108
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (14): section, ass_oct30, ass_nov1, ass_nov3, ass_nov6, ass_nov8, rec_w3...
## dbl (93): exam_1, exam_2, exam_3, exam_4, examASC_cumulative_final, ass_aug2...
## lgl (1): ACH_override_status
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Rows: 1898 Columns: 34
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (21): student, recipient_email, UCID, Course, f23_last_term_enrolled, f2...
## dbl (13): f23_uc_gpa_inst, f23_gpa, f23_college_code, f23_credits_taken, f23...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Rows: 1898 Columns: 19
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): recipient_email, s24_last_term_enrolled, s24_enrollment_status, s2...
## dbl (10): s24_uc_gpa_inst, s24_gpa, s24_college_code, s24_credits_taken, s24...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Rows: 1898 Columns: 19
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): recipient_email, f24_last_term_enrolled, f24_enrollment_status, f2...
## dbl (10): f24_uc_gpa_inst, f24_gpa, f24_college_code, f24_credits_taken, f24...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Rows: 2270 Columns: 6
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (4): student, userid, loginid, email
## dbl (2): section, uvi
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Rows: 301 Columns: 4
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): stud_id
## dbl (3): major_b_stem_code, major_f_stem_code, major_change_code
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Rows: 1962 Columns: 4
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): stud_id
## dbl (3): lc_like_f_code, lc_dislike_f_code, lc_open_f_code
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Joining with `by = join_by(loginid)`
## Joining with `by = join_by(recipient_email, course, student, loginid, stud_id, section, uvi)`
## Joining with `by = join_by(stud_id, uvi)`
## Warning in psych::alpha(chem_1040_baseline[, c("bel1_b", "bel2_b", "bel3_b", : Some items were negatively correlated with the first principal component and were automatically reversed.
## This is indicated by a negative sign for the variable name.
## Warning in psych::alpha(chem_1040_baseline[, c("maj_sat1_b", "maj_sat2_b", : Some items were negatively correlated with the first principal component and were automatically reversed.
## This is indicated by a negative sign for the variable name.
## Warning in psych::alpha(chem_1040_diary[, c("sr1_eoc", "sr2_eoc", "sr3_eoc")], : Some items were negatively correlated with the first principal component and were automatically reversed.
## This is indicated by a negative sign for the variable name.
## Warning in psych::alpha(chem_1040_final[, c("bel1_f", "bel2_f", "bel3_f", : Some items were negatively correlated with the first principal component and were automatically reversed.
## This is indicated by a negative sign for the variable name.
## Warning in psych::alpha(chem_1040_final[, c("maj_sat1_f", "maj_sat2_f", : Some items were negatively correlated with the first principal component and were automatically reversed.
## This is indicated by a negative sign for the variable name.
## Warning in psych::alpha(chem_1040_final[, c("lc_bel1_f", "lc_bel2_f", "lc_bel3_f", : Some items were negatively correlated with the first principal component and were automatically reversed.
## This is indicated by a negative sign for the variable name.
#Joining Data
chem_bf <- left_join(chem_1040_baseline, chem_1040_final, by = "stud_id")
chem_bf <- left_join(chem_bf, chem_1040_grades, by = "stud_id")
chem_bf_diary_only <- left_join(chem_1040_diary_wide, chem_bf, by = "stud_id")
chem_all <- left_join(chem_1040_diary, chem_bf, by = "stud_id")
#Filtering based on control and removing other datasets
chem_bf_control <- chem_bf %>% filter(uvi == 0)
chem_diary_control <- chem_all %>% filter(uvi == 0)
chem_diary_wide_control <- chem_bf_diary_only %>% filter(uvi == 0)
remove(chem_1040_baseline)
remove(chem_1040_final)
remove(chem_1040_grades)
remove(chem_all)
remove(chem_bf_diary_only)
remove(chem_1040_diary)
remove(chem_1040_diary_wide)
remove(chem_bf)
#Creating interaction variables
chem_diary_wide_control$fg_x_urm <- chem_diary_wide_control$fg * chem_diary_wide_control$urm
chem_diary_wide_control$urm_x_female <- chem_diary_wide_control$female * chem_diary_wide_control$urm
# chem_diary_wide_control %>% write_csv("chem_diary_wide_control.csv")
#Unconditional Models for Competence - Intercept only
#Intercept only constrained residuals
model <- '
#intercept and slope with fixed coefficients
i =~ 1*comp_eoc_1 + 1*comp_eoc_2 + 1*comp_eoc_3 + 1*comp_eoc_4 + 1*comp_eoc_5 + 1*comp_eoc_6 + 1*comp_eoc_7 + 1*comp_eoc_8 + 1*comp_eoc_9 + 1*comp_eoc_10 + 1*comp_eoc_11 + 1*comp_eoc_12 + 1*comp_eoc_13
#residual variances
comp_eoc_1 ~~ r*comp_eoc_1
comp_eoc_2 ~~ r*comp_eoc_2
comp_eoc_3 ~~ r*comp_eoc_3
comp_eoc_4 ~~ r*comp_eoc_4
comp_eoc_5 ~~ r*comp_eoc_5
comp_eoc_6 ~~ r*comp_eoc_6
comp_eoc_7 ~~ r*comp_eoc_7
comp_eoc_8 ~~ r*comp_eoc_8
comp_eoc_9 ~~ r*comp_eoc_9
comp_eoc_10 ~~ r*comp_eoc_10
comp_eoc_11 ~~ r*comp_eoc_11
comp_eoc_12 ~~ r*comp_eoc_12
comp_eoc_13 ~~ r*comp_eoc_13
'
fit <- growth(model, missing = "fiml", estimator = "MLR", data = chem_diary_wide_control)
## Warning: lavaan->lav_data_full():
## some cases are empty and will be ignored: 852.
summary(fit, fit.measures = TRUE, standardized = TRUE)
## lavaan 0.6-19 ended normally after 22 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 15
## Number of equality constraints 12
##
## Used Total
## Number of observations 860 861
## Number of missing patterns 426
##
## Model Test User Model:
## Standard Scaled
## Test Statistic 1079.632 703.177
## Degrees of freedom 101 101
## P-value (Chi-square) 0.000 0.000
## Scaling correction factor 1.535
## Yuan-Bentler correction (Mplus variant)
##
## Model Test Baseline Model:
##
## Test statistic 4181.179 2448.785
## Degrees of freedom 78 78
## P-value 0.000 0.000
## Scaling correction factor 1.707
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.761 0.746
## Tucker-Lewis Index (TLI) 0.816 0.804
##
## Robust Comparative Fit Index (CFI) 0.769
## Robust Tucker-Lewis Index (TLI) 0.821
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -10857.186 -10857.186
## Scaling correction factor 0.481
## for the MLR correction
## Loglikelihood unrestricted model (H1) -10317.370 -10317.370
## Scaling correction factor 1.560
## for the MLR correction
##
## Akaike (AIC) 21720.373 21720.373
## Bayesian (BIC) 21734.643 21734.643
## Sample-size adjusted Bayesian (SABIC) 21725.116 21725.116
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.106 0.083
## 90 Percent confidence interval - lower 0.100 0.079
## 90 Percent confidence interval - upper 0.112 0.088
## P-value H_0: RMSEA <= 0.050 0.000 0.000
## P-value H_0: RMSEA >= 0.080 1.000 0.877
##
## Robust RMSEA 0.125
## 90 Percent confidence interval - lower 0.115
## 90 Percent confidence interval - upper 0.134
## P-value H_0: Robust RMSEA <= 0.050 0.000
## P-value H_0: Robust RMSEA >= 0.080 1.000
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.113 0.113
##
## Parameter Estimates:
##
## Standard errors Sandwich
## Information bread Observed
## Observed information based on Hessian
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## i =~
## comp_eoc_1 1.000 0.705 0.674
## comp_eoc_2 1.000 0.705 0.674
## comp_eoc_3 1.000 0.705 0.674
## comp_eoc_4 1.000 0.705 0.674
## comp_eoc_5 1.000 0.705 0.674
## comp_eoc_6 1.000 0.705 0.674
## comp_eoc_7 1.000 0.705 0.674
## comp_eoc_8 1.000 0.705 0.674
## comp_eoc_9 1.000 0.705 0.674
## comp_eoc_10 1.000 0.705 0.674
## comp_eoc_11 1.000 0.705 0.674
## comp_eoc_12 1.000 0.705 0.674
## comp_eoc_13 1.000 0.705 0.674
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## i 5.221 0.026 203.356 0.000 7.408 7.408
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .comp_eoc_1 (r) 0.597 0.022 26.933 0.000 0.597 0.546
## .comp_eoc_2 (r) 0.597 0.022 26.933 0.000 0.597 0.546
## .comp_eoc_3 (r) 0.597 0.022 26.933 0.000 0.597 0.546
## .comp_eoc_4 (r) 0.597 0.022 26.933 0.000 0.597 0.546
## .comp_eoc_5 (r) 0.597 0.022 26.933 0.000 0.597 0.546
## .comp_eoc_6 (r) 0.597 0.022 26.933 0.000 0.597 0.546
## .comp_eoc_7 (r) 0.597 0.022 26.933 0.000 0.597 0.546
## .comp_eoc_8 (r) 0.597 0.022 26.933 0.000 0.597 0.546
## .comp_eoc_9 (r) 0.597 0.022 26.933 0.000 0.597 0.546
## .comp_ec_10 (r) 0.597 0.022 26.933 0.000 0.597 0.546
## .comp_ec_11 (r) 0.597 0.022 26.933 0.000 0.597 0.546
## .comp_ec_12 (r) 0.597 0.022 26.933 0.000 0.597 0.546
## .comp_ec_13 (r) 0.597 0.022 26.933 0.000 0.597 0.546
## i 0.497 0.026 19.112 0.000 1.000 1.000
#Unconditional Models for Competence - Linear Intercept & Slope: CFI = 0.911
#Intercept only constrained residuals
model <- '
#intercept and slope with fixed coefficients
i =~ 1*comp_eoc_1 + 1*comp_eoc_2 + 1*comp_eoc_3 + 1*comp_eoc_4 + 1*comp_eoc_5 + 1*comp_eoc_6 + 1*comp_eoc_7 + 1*comp_eoc_8 + 1*comp_eoc_9 + 1*comp_eoc_10 + 1*comp_eoc_11 + 1*comp_eoc_12 + 1*comp_eoc_13
s =~ 0*comp_eoc_1 + 1*comp_eoc_2 + 2*comp_eoc_3 + 3*comp_eoc_4 + 4*comp_eoc_5 + 5*comp_eoc_6 + 6*comp_eoc_7 + 7*comp_eoc_8 + 8*comp_eoc_9 + 9*comp_eoc_10 + 10*comp_eoc_11 + 11*comp_eoc_12 + 12*comp_eoc_13
#residual variances
comp_eoc_1 ~~ r*comp_eoc_1
comp_eoc_2 ~~ r*comp_eoc_2
comp_eoc_3 ~~ r*comp_eoc_3
comp_eoc_4 ~~ r*comp_eoc_4
comp_eoc_5 ~~ r*comp_eoc_5
comp_eoc_6 ~~ r*comp_eoc_6
comp_eoc_7 ~~ r*comp_eoc_7
comp_eoc_8 ~~ r*comp_eoc_8
comp_eoc_9 ~~ r*comp_eoc_9
comp_eoc_10 ~~ r*comp_eoc_10
comp_eoc_11 ~~ r*comp_eoc_11
comp_eoc_12 ~~ r*comp_eoc_12
comp_eoc_13 ~~ r*comp_eoc_13
'
fit <- growth(model, missing = "fiml", estimator = "MLR", data = chem_diary_wide_control)
## Warning: lavaan->lav_data_full():
## some cases are empty and will be ignored: 852.
summary(fit, fit.measures = TRUE, standardized = TRUE)
## lavaan 0.6-19 ended normally after 54 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 18
## Number of equality constraints 12
##
## Used Total
## Number of observations 860 861
## Number of missing patterns 426
##
## Model Test User Model:
## Standard Scaled
## Test Statistic 463.058 299.969
## Degrees of freedom 98 98
## P-value (Chi-square) 0.000 0.000
## Scaling correction factor 1.544
## Yuan-Bentler correction (Mplus variant)
##
## Model Test Baseline Model:
##
## Test statistic 4181.179 2448.785
## Degrees of freedom 78 78
## P-value 0.000 0.000
## Scaling correction factor 1.707
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.911 0.915
## Tucker-Lewis Index (TLI) 0.929 0.932
##
## Robust Comparative Fit Index (CFI) 0.921
## Robust Tucker-Lewis Index (TLI) 0.937
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -10548.899 -10548.899
## Scaling correction factor 0.611
## for the MLR correction
## Loglikelihood unrestricted model (H1) -10317.370 -10317.370
## Scaling correction factor 1.560
## for the MLR correction
##
## Akaike (AIC) 21109.799 21109.799
## Bayesian (BIC) 21138.340 21138.340
## Sample-size adjusted Bayesian (SABIC) 21119.286 21119.286
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.066 0.049
## 90 Percent confidence interval - lower 0.060 0.044
## 90 Percent confidence interval - upper 0.072 0.054
## P-value H_0: RMSEA <= 0.050 0.000 0.624
## P-value H_0: RMSEA >= 0.080 0.000 0.000
##
## Robust RMSEA 0.074
## 90 Percent confidence interval - lower 0.064
## 90 Percent confidence interval - upper 0.084
## P-value H_0: Robust RMSEA <= 0.050 0.000
## P-value H_0: Robust RMSEA >= 0.080 0.179
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.068 0.068
##
## Parameter Estimates:
##
## Standard errors Sandwich
## Information bread Observed
## Observed information based on Hessian
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## i =~
## comp_eoc_1 1.000 0.714 0.707
## comp_eoc_2 1.000 0.714 0.714
## comp_eoc_3 1.000 0.714 0.718
## comp_eoc_4 1.000 0.714 0.719
## comp_eoc_5 1.000 0.714 0.717
## comp_eoc_6 1.000 0.714 0.712
## comp_eoc_7 1.000 0.714 0.704
## comp_eoc_8 1.000 0.714 0.694
## comp_eoc_9 1.000 0.714 0.681
## comp_eoc_10 1.000 0.714 0.667
## comp_eoc_11 1.000 0.714 0.651
## comp_eoc_12 1.000 0.714 0.634
## comp_eoc_13 1.000 0.714 0.616
## s =~
## comp_eoc_1 0.000 0.000 0.000
## comp_eoc_2 1.000 0.065 0.065
## comp_eoc_3 2.000 0.131 0.131
## comp_eoc_4 3.000 0.196 0.197
## comp_eoc_5 4.000 0.261 0.262
## comp_eoc_6 5.000 0.326 0.326
## comp_eoc_7 6.000 0.392 0.386
## comp_eoc_8 7.000 0.457 0.444
## comp_eoc_9 8.000 0.522 0.498
## comp_eoc_10 9.000 0.587 0.549
## comp_eoc_11 10.000 0.653 0.595
## comp_eoc_12 11.000 0.718 0.637
## comp_eoc_13 12.000 0.783 0.676
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## i ~~
## s -0.012 0.003 -3.956 0.000 -0.259 -0.259
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## i 5.448 0.029 191.160 0.000 7.631 7.631
## s -0.041 0.003 -12.958 0.000 -0.626 -0.626
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .comp_eoc_1 (r) 0.509 0.021 24.800 0.000 0.509 0.500
## .comp_eoc_2 (r) 0.509 0.021 24.800 0.000 0.509 0.510
## .comp_eoc_3 (r) 0.509 0.021 24.800 0.000 0.509 0.516
## .comp_eoc_4 (r) 0.509 0.021 24.800 0.000 0.509 0.517
## .comp_eoc_5 (r) 0.509 0.021 24.800 0.000 0.509 0.514
## .comp_eoc_6 (r) 0.509 0.021 24.800 0.000 0.509 0.507
## .comp_eoc_7 (r) 0.509 0.021 24.800 0.000 0.509 0.496
## .comp_eoc_8 (r) 0.509 0.021 24.800 0.000 0.509 0.481
## .comp_eoc_9 (r) 0.509 0.021 24.800 0.000 0.509 0.464
## .comp_ec_10 (r) 0.509 0.021 24.800 0.000 0.509 0.444
## .comp_ec_11 (r) 0.509 0.021 24.800 0.000 0.509 0.423
## .comp_ec_12 (r) 0.509 0.021 24.800 0.000 0.509 0.401
## .comp_ec_13 (r) 0.509 0.021 24.800 0.000 0.509 0.379
## i 0.510 0.032 15.844 0.000 1.000 1.000
## s 0.004 0.000 9.226 0.000 1.000 1.000
#Unconditional Models for Cost - Linear Intercept & Slope: CFI = 0.946
#Intercept only constrained residuals
model <- '
#intercept and slope with fixed coefficients
i =~ 1*cost_eoc_1 + 1*cost_eoc_2 + 1*cost_eoc_3 + 1*cost_eoc_4 + 1*cost_eoc_5 + 1*cost_eoc_6 + 1*cost_eoc_7 + 1*cost_eoc_8 + 1*cost_eoc_9 + 1*cost_eoc_10 + 1*cost_eoc_11 + 1*cost_eoc_12 + 1*cost_eoc_13
s =~ 0*cost_eoc_1 + 1*cost_eoc_2 + 2*cost_eoc_3 + 3*cost_eoc_4 + 4*cost_eoc_5 + 5*cost_eoc_6 + 6*cost_eoc_7 + 7*cost_eoc_8 + 8*cost_eoc_9 + 9*cost_eoc_10 + 10*cost_eoc_11 + 11*cost_eoc_12 + 12*cost_eoc_13
#residual variances
cost_eoc_1 ~~ r*cost_eoc_1
cost_eoc_2 ~~ r*cost_eoc_2
cost_eoc_3 ~~ r*cost_eoc_3
cost_eoc_4 ~~ r*cost_eoc_4
cost_eoc_5 ~~ r*cost_eoc_5
cost_eoc_6 ~~ r*cost_eoc_6
cost_eoc_7 ~~ r*cost_eoc_7
cost_eoc_8 ~~ r*cost_eoc_8
cost_eoc_9 ~~ r*cost_eoc_9
cost_eoc_10 ~~ r*cost_eoc_10
cost_eoc_11 ~~ r*cost_eoc_11
cost_eoc_12 ~~ r*cost_eoc_12
cost_eoc_13 ~~ r*cost_eoc_13
'
fit <- growth(model, missing = "fiml", estimator = "MLR", data = chem_diary_wide_control)
## Warning: lavaan->lav_data_full():
## some cases are empty and will be ignored: 852.
summary(fit, fit.measures = TRUE, standardized = TRUE)
## lavaan 0.6-19 ended normally after 43 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 18
## Number of equality constraints 12
##
## Used Total
## Number of observations 860 861
## Number of missing patterns 426
##
## Model Test User Model:
## Standard Scaled
## Test Statistic 555.082 336.934
## Degrees of freedom 98 98
## P-value (Chi-square) 0.000 0.000
## Scaling correction factor 1.647
## Yuan-Bentler correction (Mplus variant)
##
## Model Test Baseline Model:
##
## Test statistic 8617.415 4469.555
## Degrees of freedom 78 78
## P-value 0.000 0.000
## Scaling correction factor 1.928
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.946 0.946
## Tucker-Lewis Index (TLI) 0.957 0.957
##
## Robust Comparative Fit Index (CFI) 0.950
## Robust Tucker-Lewis Index (TLI) 0.960
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -9763.733 -9763.733
## Scaling correction factor 0.651
## for the MLR correction
## Loglikelihood unrestricted model (H1) -9486.192 -9486.192
## Scaling correction factor 1.665
## for the MLR correction
##
## Akaike (AIC) 19539.466 19539.466
## Bayesian (BIC) 19568.008 19568.008
## Sample-size adjusted Bayesian (SABIC) 19548.953 19548.953
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.074 0.053
## 90 Percent confidence interval - lower 0.068 0.048
## 90 Percent confidence interval - upper 0.080 0.058
## P-value H_0: RMSEA <= 0.050 0.000 0.132
## P-value H_0: RMSEA >= 0.080 0.041 0.000
##
## Robust RMSEA 0.083
## 90 Percent confidence interval - lower 0.073
## 90 Percent confidence interval - upper 0.094
## P-value H_0: Robust RMSEA <= 0.050 0.000
## P-value H_0: Robust RMSEA >= 0.080 0.721
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.078 0.078
##
## Parameter Estimates:
##
## Standard errors Sandwich
## Information bread Observed
## Observed information based on Hessian
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## i =~
## cost_eoc_1 1.000 1.005 0.854
## cost_eoc_2 1.000 1.005 0.863
## cost_eoc_3 1.000 1.005 0.868
## cost_eoc_4 1.000 1.005 0.869
## cost_eoc_5 1.000 1.005 0.867
## cost_eoc_6 1.000 1.005 0.861
## cost_eoc_7 1.000 1.005 0.852
## cost_eoc_8 1.000 1.005 0.840
## cost_eoc_9 1.000 1.005 0.826
## cost_eoc_10 1.000 1.005 0.809
## cost_eoc_11 1.000 1.005 0.790
## cost_eoc_12 1.000 1.005 0.770
## cost_eoc_13 1.000 1.005 0.749
## s =~
## cost_eoc_1 0.000 0.000 0.000
## cost_eoc_2 1.000 0.075 0.064
## cost_eoc_3 2.000 0.149 0.129
## cost_eoc_4 3.000 0.224 0.194
## cost_eoc_5 4.000 0.299 0.258
## cost_eoc_6 5.000 0.373 0.320
## cost_eoc_7 6.000 0.448 0.380
## cost_eoc_8 7.000 0.523 0.437
## cost_eoc_9 8.000 0.598 0.491
## cost_eoc_10 9.000 0.672 0.541
## cost_eoc_11 10.000 0.747 0.587
## cost_eoc_12 11.000 0.822 0.630
## cost_eoc_13 12.000 0.896 0.669
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## i ~~
## s -0.016 0.004 -3.839 0.000 -0.216 -0.216
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## i 3.110 0.037 84.868 0.000 3.095 3.095
## s 0.041 0.003 12.866 0.000 0.556 0.556
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .cost_eoc_1 (r) 0.373 0.016 23.780 0.000 0.373 0.270
## .cost_eoc_2 (r) 0.373 0.016 23.780 0.000 0.373 0.275
## .cost_eoc_3 (r) 0.373 0.016 23.780 0.000 0.373 0.279
## .cost_eoc_4 (r) 0.373 0.016 23.780 0.000 0.373 0.279
## .cost_eoc_5 (r) 0.373 0.016 23.780 0.000 0.373 0.278
## .cost_eoc_6 (r) 0.373 0.016 23.780 0.000 0.373 0.274
## .cost_eoc_7 (r) 0.373 0.016 23.780 0.000 0.373 0.269
## .cost_eoc_8 (r) 0.373 0.016 23.780 0.000 0.373 0.261
## .cost_eoc_9 (r) 0.373 0.016 23.780 0.000 0.373 0.252
## .cost_ec_10 (r) 0.373 0.016 23.780 0.000 0.373 0.242
## .cost_ec_11 (r) 0.373 0.016 23.780 0.000 0.373 0.231
## .cost_ec_12 (r) 0.373 0.016 23.780 0.000 0.373 0.219
## .cost_ec_13 (r) 0.373 0.016 23.780 0.000 0.373 0.208
## i 1.010 0.048 20.855 0.000 1.000 1.000
## s 0.006 0.001 9.650 0.000 1.000 1.000
#Conditional Models for Value - Linear Intercept & Slope
#Intercept only constrained residuals
model <- '
#intercept and slope with fixed coefficients
i =~ 1*val_eoc_1 + 1*val_eoc_2 + 1*val_eoc_3 + 1*val_eoc_4 + 1*val_eoc_5 + 1*val_eoc_6 + 1*val_eoc_7 + 1*val_eoc_8 + 1*val_eoc_9 + 1*val_eoc_10 + 1*val_eoc_11 + 1*val_eoc_12 + 1*val_eoc_13
s =~ 0*val_eoc_1 + 1*val_eoc_2 + 2*val_eoc_3 + 3*val_eoc_4 + 4*val_eoc_5 + 5*val_eoc_6 + 6*val_eoc_7 + 7*val_eoc_8 + 8*val_eoc_9 + 9*val_eoc_10 + 10*val_eoc_11 + 11*val_eoc_12 + 12*val_eoc_13
i ~ hs_gpa_scaled + urm + female + fg + fg_x_urm + urm_x_female
s ~ hs_gpa_scaled + urm + female + fg + fg_x_urm + urm_x_female
#residual variances
val_eoc_1 ~~ r*val_eoc_1
val_eoc_2 ~~ r*val_eoc_2
val_eoc_3 ~~ r*val_eoc_3
val_eoc_4 ~~ r*val_eoc_4
val_eoc_5 ~~ r*val_eoc_5
val_eoc_6 ~~ r*val_eoc_6
val_eoc_7 ~~ r*val_eoc_7
val_eoc_8 ~~ r*val_eoc_8
val_eoc_9 ~~ r*val_eoc_9
val_eoc_10 ~~ r*val_eoc_10
val_eoc_11 ~~ r*val_eoc_11
val_eoc_12 ~~ r*val_eoc_12
val_eoc_13 ~~ r*val_eoc_13
'
fit <- growth(model, missing = "fiml", estimator = "MLR", data = chem_diary_wide_control)
## Warning: lavaan->lav_data_full():
## 80 cases were deleted due to missing values in exogenous variable(s),
## while fixed.x = TRUE.
summary(fit, fit.measures = TRUE, standardized = TRUE)
## lavaan 0.6-19 ended normally after 94 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 30
## Number of equality constraints 12
##
## Used Total
## Number of observations 781 861
## Number of missing patterns 387
##
## Model Test User Model:
## Standard Scaled
## Test Statistic 567.464 408.553
## Degrees of freedom 164 164
## P-value (Chi-square) 0.000 0.000
## Scaling correction factor 1.389
## Yuan-Bentler correction (Mplus variant)
##
## Model Test Baseline Model:
##
## Test statistic 8636.125 6003.255
## Degrees of freedom 156 156
## P-value 0.000 0.000
## Scaling correction factor 1.439
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.952 0.958
## Tucker-Lewis Index (TLI) 0.955 0.960
##
## Robust Comparative Fit Index (CFI) 0.955
## Robust Tucker-Lewis Index (TLI) 0.957
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -8344.915 -8344.915
## Scaling correction factor 0.799
## for the MLR correction
## Loglikelihood unrestricted model (H1) -8061.182 -8061.182
## Scaling correction factor 1.383
## for the MLR correction
##
## Akaike (AIC) 16725.829 16725.829
## Bayesian (BIC) 16809.720 16809.720
## Sample-size adjusted Bayesian (SABIC) 16752.561 16752.561
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.056 0.044
## 90 Percent confidence interval - lower 0.051 0.039
## 90 Percent confidence interval - upper 0.061 0.048
## P-value H_0: RMSEA <= 0.050 0.022 0.990
## P-value H_0: RMSEA >= 0.080 0.000 0.000
##
## Robust RMSEA 0.064
## 90 Percent confidence interval - lower 0.056
## 90 Percent confidence interval - upper 0.072
## P-value H_0: Robust RMSEA <= 0.050 0.002
## P-value H_0: Robust RMSEA >= 0.080 0.000
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.048 0.048
##
## Parameter Estimates:
##
## Standard errors Sandwich
## Information bread Observed
## Observed information based on Hessian
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## i =~
## val_eoc_1 1.000 1.042 0.878
## val_eoc_2 1.000 1.042 0.888
## val_eoc_3 1.000 1.042 0.895
## val_eoc_4 1.000 1.042 0.899
## val_eoc_5 1.000 1.042 0.900
## val_eoc_6 1.000 1.042 0.898
## val_eoc_7 1.000 1.042 0.892
## val_eoc_8 1.000 1.042 0.884
## val_eoc_9 1.000 1.042 0.873
## val_eoc_10 1.000 1.042 0.859
## val_eoc_11 1.000 1.042 0.844
## val_eoc_12 1.000 1.042 0.827
## val_eoc_13 1.000 1.042 0.808
## s =~
## val_eoc_1 0.000 0.000 0.000
## val_eoc_2 1.000 0.069 0.059
## val_eoc_3 2.000 0.138 0.119
## val_eoc_4 3.000 0.207 0.179
## val_eoc_5 4.000 0.277 0.239
## val_eoc_6 5.000 0.346 0.298
## val_eoc_7 6.000 0.415 0.355
## val_eoc_8 7.000 0.484 0.411
## val_eoc_9 8.000 0.553 0.463
## val_eoc_10 9.000 0.622 0.513
## val_eoc_11 10.000 0.691 0.560
## val_eoc_12 11.000 0.760 0.603
## val_eoc_13 12.000 0.830 0.643
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## i ~
## hs_gpa_scaled -0.135 0.101 -1.339 0.181 -0.130 -0.048
## urm 0.137 0.150 0.914 0.361 0.132 0.048
## female 0.489 0.084 5.815 0.000 0.470 0.231
## fg 0.029 0.126 0.229 0.818 0.028 0.010
## fg_x_urm -0.165 0.298 -0.553 0.580 -0.158 -0.030
## urm_x_female -0.277 0.219 -1.265 0.206 -0.266 -0.064
## s ~
## hs_gpa_scaled 0.032 0.009 3.750 0.000 0.467 0.173
## urm 0.004 0.011 0.377 0.706 0.061 0.022
## female -0.014 0.007 -2.105 0.035 -0.205 -0.101
## fg -0.025 0.011 -2.359 0.018 -0.359 -0.126
## fg_x_urm 0.009 0.022 0.398 0.691 0.128 0.024
## urm_x_female 0.000 0.017 0.000 1.000 0.000 0.000
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .i ~~
## .s -0.016 0.004 -4.177 0.000 -0.235 -0.235
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .i 5.178 0.377 13.745 0.000 4.970 4.970
## .s -0.142 0.032 -4.388 0.000 -2.059 -2.059
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .val_eoc_1 (r) 0.322 0.014 22.544 0.000 0.322 0.229
## .val_eoc_2 (r) 0.322 0.014 22.544 0.000 0.322 0.234
## .val_eoc_3 (r) 0.322 0.014 22.544 0.000 0.322 0.238
## .val_eoc_4 (r) 0.322 0.014 22.544 0.000 0.322 0.240
## .val_eoc_5 (r) 0.322 0.014 22.544 0.000 0.322 0.240
## .val_eoc_6 (r) 0.322 0.014 22.544 0.000 0.322 0.239
## .val_eoc_7 (r) 0.322 0.014 22.544 0.000 0.322 0.236
## .val_eoc_8 (r) 0.322 0.014 22.544 0.000 0.322 0.232
## .val_eoc_9 (r) 0.322 0.014 22.544 0.000 0.322 0.226
## .val_eoc_10 (r) 0.322 0.014 22.544 0.000 0.322 0.219
## .val_eoc_11 (r) 0.322 0.014 22.544 0.000 0.322 0.211
## .val_eoc_12 (r) 0.322 0.014 22.544 0.000 0.322 0.203
## .val_eoc_13 (r) 0.322 0.014 22.544 0.000 0.322 0.194
## .i 1.033 0.059 17.609 0.000 0.952 0.952
## .s 0.005 0.000 10.233 0.000 0.945 0.945