Specifying the packages
library(tidyverse)
## ── 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.3 ✔ tidyr 1.3.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(haven)
library(psych)
##
## Attaching package: 'psych'
##
## The following objects are masked from 'package:ggplot2':
##
## %+%, alpha
library(knitr)
library(kableExtra)
##
## Attaching package: 'kableExtra'
##
## The following object is masked from 'package:dplyr':
##
## group_rows
library(lavaan)
## This is lavaan 0.6-18
## lavaan is FREE software! Please report any bugs.
##
## Attaching package: 'lavaan'
##
## The following object is masked from 'package:psych':
##
## cor2cov
library(apaTables)
library(semPlot)
library(questionr)
##
## Attaching package: 'questionr'
##
## The following object is masked from 'package:psych':
##
## describe
library(corrplot)
## corrplot 0.92 loaded
This block of code brings in the data from spss and renames the variables for easier interpretation.
Carly_MA_Data <- read_sav("MA Thesis Quant Data_With Missing Data_Recoded.sav")
names(Carly_MA_Data)
## [1] "ParticipantID" "Progress"
## [3] "ResponseID" "Consent"
## [5] "ConsentForQuotes" "OConnorAndCasey_1"
## [7] "OConnorAndCasey_2" "OConnorAndCasey_3"
## [9] "OConnorAndCasey_4" "OConnorAndCasey_5"
## [11] "OConnorAndCasey_6" "OConnorAndCasey_7"
## [13] "OConnorAndCasey_8" "OConnorAndCasey_9"
## [15] "OConnorAndCasey_10" "OConnorAndCasey_11"
## [17] "OConnorAndCasey_12" "OConnorAndCasey_13"
## [19] "OConnorAndCasey_14" "OConnorAndCasey_15"
## [21] "OConnorAndCasey_16" "OConnorAndCasey_17"
## [23] "OConnorAndCasey_18" "OConnorAndCasey_19"
## [25] "OConnorAndCasey_20" "OConnorAndCasey_21"
## [27] "OConnorAndCasey_22" "OConnorAndCasey_23"
## [29] "OConnorAndCasey_24" "OConnorAndCasey_25"
## [31] "OConnorAndCasey_26" "OConnorAndCasey_27"
## [33] "OConnorAndCasey_28" "OConnorAndCasey_29"
## [35] "OConnorAndCasey_30" "OConnorAndCasey_31"
## [37] "OConnorAndCasey_32" "OConnorAndCasey_33"
## [39] "OConnorAndCasey_34" "OConnorAndCasey_35"
## [41] "Vogel_1" "Vogel_2"
## [43] "Vogel_3" "Vogel_4"
## [45] "Vogel_5" "Vogel_6"
## [47] "Vogel_7" "Vogel_8"
## [49] "Vogel_9" "Vogel_10"
## [51] "FischerAndFarina_1" "FischerAndFarina_2"
## [53] "FischerAndFarina_3" "FischerAndFarina_4"
## [55] "FischerAndFarina_5" "FischerAndFarina_6"
## [57] "FischerAndFarina_7" "FischerAndFarina_8"
## [59] "FischerAndFarina_9" "FischerAndFarina_10"
## [61] "Cash_1" "Cash_2"
## [63] "Cash_3" "Cash_4"
## [65] "Cash_5" "Cash_6"
## [67] "Cash_7" "Cash_8"
## [69] "Cash_9" "Cash_10"
## [71] "Cash_11" "Cash_12"
## [73] "Cash_13" "Cash_14"
## [75] "Cash_15" "Cash_16"
## [77] "Cash_17" "Tomczyk_1"
## [79] "Tomczyk_2" "Tomczyk_3"
## [81] "Kessler_1" "Kessler_2"
## [83] "Kessler_3" "Kessler_4"
## [85] "Kessler_5" "Kessler_6"
## [87] "Kessler_7" "Kessler_8"
## [89] "Kessler_9" "Kessler_10"
## [91] "AGE" "GENDER"
## [93] "SEXUALORIENTATION" "SEXUALORIENTATION_7_TEXT"
## [95] "RACE" "RACE_11_TEXT"
## [97] "LANGUAGE" "LANGUAGE_2_TEXT"
## [99] "LIVINGAREA" "LIVINGSITUATION"
## [101] "LIVINGSITUATION_9_TEXT" "RELATIONSHIP"
## [103] "RELATIONSHIP_8_TEXT" "INCOME"
## [105] "EMPLOYMENT" "EMPLOYMENT_10_TEXT"
## [107] "STUDENTTYPE" "CANADA"
## [109] "STUDENTSTATUS" "STUDENTSTATUS_13_TEXT"
## [111] "FACULTY" "DISABILITY"
## [113] "PASTTHERAPY" "CURRENTTHERAPY"
## [115] "PASTMEDS" "CURRENTMEDS"
## [117] "OConnorAndCasey_10_R" "OConnorAndCasey_12_R"
## [119] "OConnorAndCasey_15_R" "OConnorAndCasey_20_R"
## [121] "OConnorAndCasey_21_R" "OConnorAndCasey_22_R"
## [123] "OConnorAndCasey_23_R" "OConnorAndCasey_24_R"
## [125] "OConnorAndCasey_25_R" "OConnorAndCasey_26_R"
## [127] "OConnorAndCasey_27_R" "OConnorAndCasey_28_R"
## [129] "Vogel_2_R" "Vogel_4_R"
## [131] "Vogel_5_R" "Vogel_7_R"
## [133] "Vogel_9_R" "FischerAndFarina_2_R"
## [135] "FischerAndFarina_4_R" "FischerAndFarina_8_R"
## [137] "FischerAndFarina_9_R" "FischerAndFarina_10_R"
## [139] "MHLS_TOTAL_OConnorAndCasey" "SSOSH_TOTAL_Vogel"
## [141] "ATSPPHS_TOTAL_FischerAndFarina" "ISCI_TOTAL_Cash"
## [143] "PBC_TOTAL_Tomczyk" "K10_TOTAL_Kessler"
colnames(Carly_MA_Data)[6] = "MHLS_1"
colnames(Carly_MA_Data)[7] = "MHLS_2"
colnames(Carly_MA_Data)[8] = "MHLS_3"
colnames(Carly_MA_Data)[9] = "MHLS_4"
colnames(Carly_MA_Data)[10] = "MHLS_5"
colnames(Carly_MA_Data)[11] = "MHLS_6"
colnames(Carly_MA_Data)[12] = "MHLS_7"
colnames(Carly_MA_Data)[13] = "MHLS_8"
colnames(Carly_MA_Data)[14] = "MHLS_9"
colnames(Carly_MA_Data)[15] = "MHLS_10"
colnames(Carly_MA_Data)[16] = "MHLS_11"
colnames(Carly_MA_Data)[17] = "MHLS_12"
colnames(Carly_MA_Data)[18] = "MHLS_13"
colnames(Carly_MA_Data)[19] = "MHLS_14"
colnames(Carly_MA_Data)[20] = "MHLS_15"
colnames(Carly_MA_Data)[21] = "MHLS_16"
colnames(Carly_MA_Data)[22] = "MHLS_17"
colnames(Carly_MA_Data)[23] = "MHLS_18"
colnames(Carly_MA_Data)[24] = "MHLS_19"
colnames(Carly_MA_Data)[25] = "MHLS_20"
colnames(Carly_MA_Data)[26] = "MHLS_21"
colnames(Carly_MA_Data)[27] = "MHLS_22"
colnames(Carly_MA_Data)[28] = "MHLS_23"
colnames(Carly_MA_Data)[29] = "MHLS_24"
colnames(Carly_MA_Data)[30] = "MHLS_25"
colnames(Carly_MA_Data)[31] = "MHLS_26"
colnames(Carly_MA_Data)[32] = "MHLS_27"
colnames(Carly_MA_Data)[33] = "MHLS_28"
colnames(Carly_MA_Data)[34] = "MHLS_29"
colnames(Carly_MA_Data)[35] = "MHLS_30"
colnames(Carly_MA_Data)[36] = "MHLS_31"
colnames(Carly_MA_Data)[37] = "MHLS_32"
colnames(Carly_MA_Data)[38] = "MHLS_33"
colnames(Carly_MA_Data)[39] = "MHLS_34"
colnames(Carly_MA_Data)[40] = "MHLS_35"
colnames(Carly_MA_Data)[41] = "SSOH_1"
colnames(Carly_MA_Data)[42] = "SSOH_2"
colnames(Carly_MA_Data)[43] = "SSOH_3"
colnames(Carly_MA_Data)[44] = "SSOH_4"
colnames(Carly_MA_Data)[45] = "SSOH_5"
colnames(Carly_MA_Data)[46] = "SSOH_6"
colnames(Carly_MA_Data)[47] = "SSOH_7"
colnames(Carly_MA_Data)[48] = "SSOH_8"
colnames(Carly_MA_Data)[49] = "SSOH_9"
colnames(Carly_MA_Data)[50] = "SSOH_10"
colnames(Carly_MA_Data)[51] = "ATSPPHS_1"
colnames(Carly_MA_Data)[52] = "ATSPPHS_2"
colnames(Carly_MA_Data)[53] = "ATSPPHS_3"
colnames(Carly_MA_Data)[54] = "ATSPPHS_4"
colnames(Carly_MA_Data)[55] = "ATSPPHS_5"
colnames(Carly_MA_Data)[56] = "ATSPPHS_6"
colnames(Carly_MA_Data)[57] = "ATSPPHS_7"
colnames(Carly_MA_Data)[58] = "ATSPPHS_8"
colnames(Carly_MA_Data)[59] = "ATSPPHS_9"
colnames(Carly_MA_Data)[60] = "ATSPPHS_10"
colnames(Carly_MA_Data)[61] = "ISCI_1"
colnames(Carly_MA_Data)[62] = "ISCI_2"
colnames(Carly_MA_Data)[63] = "ISCI_3"
colnames(Carly_MA_Data)[64] = "ISCI_4"
colnames(Carly_MA_Data)[65] = "ISCI_5"
colnames(Carly_MA_Data)[66] = "ISCI_6"
colnames(Carly_MA_Data)[67] = "ISCI_7"
colnames(Carly_MA_Data)[68] = "ISCI_8"
colnames(Carly_MA_Data)[69] = "ISCI_9"
colnames(Carly_MA_Data)[70] = "ISCI_10"
colnames(Carly_MA_Data)[71] = "ISCI_11"
colnames(Carly_MA_Data)[72] = "ISCI_12"
colnames(Carly_MA_Data)[73] = "ISCI_13"
colnames(Carly_MA_Data)[74] = "ISCI_14"
colnames(Carly_MA_Data)[75] = "ISCI_15"
colnames(Carly_MA_Data)[76] = "ISCI_16"
colnames(Carly_MA_Data)[77] = "ISCI_17"
colnames(Carly_MA_Data)[78] = "TPBQ_1"
colnames(Carly_MA_Data)[79] = "TPBQ_2"
colnames(Carly_MA_Data)[80] = "TPBQ_3"
colnames(Carly_MA_Data)[81] = "K10_1"
colnames(Carly_MA_Data)[82] = "K10_2"
colnames(Carly_MA_Data)[83] = "K10_3"
colnames(Carly_MA_Data)[84] = "K10_4"
colnames(Carly_MA_Data)[85] = "K10_5"
colnames(Carly_MA_Data)[86] = "K10_6"
colnames(Carly_MA_Data)[87] = "K10_7"
colnames(Carly_MA_Data)[88] = "K10_8"
colnames(Carly_MA_Data)[89] = "K10_9"
colnames(Carly_MA_Data)[90] = "K10_10"
colnames(Carly_MA_Data)[117] = "MHLS_10_R"
colnames(Carly_MA_Data)[118] = "MHLS_12_R"
colnames(Carly_MA_Data)[119] = "MHLS_15_R"
colnames(Carly_MA_Data)[120] = "MHLS_20_R"
colnames(Carly_MA_Data)[121] = "MHLS_21_R"
colnames(Carly_MA_Data)[122] = "MHLS_22_R"
colnames(Carly_MA_Data)[123] = "MHLS_23_R"
colnames(Carly_MA_Data)[124] = "MHLS_24_R"
colnames(Carly_MA_Data)[125] = "MHLS_25_R"
colnames(Carly_MA_Data)[126] = "MHLS_26_R"
colnames(Carly_MA_Data)[127] = "MHLS_27_R"
colnames(Carly_MA_Data)[128] = "MHLS_28_R"
colnames(Carly_MA_Data)[129] = "SSOH_2_R"
colnames(Carly_MA_Data)[130] = "SSOH_4_R"
colnames(Carly_MA_Data)[131] = "SSOH_5_R"
colnames(Carly_MA_Data)[132] = "SSOH_7_R"
colnames(Carly_MA_Data)[133] = "SSOH_9_R"
colnames(Carly_MA_Data)[134] = "ATSPPHS_2_R"
colnames(Carly_MA_Data)[135] = "ATSPPHS_4_R"
colnames(Carly_MA_Data)[136] = "ATSPPHS_8_R"
colnames(Carly_MA_Data)[137] = "ATSPPHS_9_R"
colnames(Carly_MA_Data)[138] = "ATSPPHS_10_R"
colnames(Carly_MA_Data)[139] = "MHLS_Total"
colnames(Carly_MA_Data)[140] = "SSOSH_Total"
colnames(Carly_MA_Data)[141] = "ATSPPHS_Total"
colnames(Carly_MA_Data)[142] = "ISCI_Total"
colnames(Carly_MA_Data)[143] = "PBC_Total"
colnames(Carly_MA_Data)[144] = "K10_Total"
The next block creates the subscale variables from the Intention Scale
Carly_MA_Data$Psy_Int <-(Carly_MA_Data$ISCI_3+Carly_MA_Data$ISCI_4+Carly_MA_Data$ISCI_5+
Carly_MA_Data$ISCI_6+Carly_MA_Data$ISCI_8+Carly_MA_Data$ISCI_10+
Carly_MA_Data$ISCI_12+Carly_MA_Data$ISCI_14+Carly_MA_Data$ISCI_16+
Carly_MA_Data$ISCI_17)/10
Carly_MA_Data$Acad_Int <-(Carly_MA_Data$ISCI_7+ Carly_MA_Data$ISCI_9+Carly_MA_Data$ISCI_13+
Carly_MA_Data$ISCI_15)/4
Carly_MA_Data$Drugs_Int <-(Carly_MA_Data$ISCI_2 + Carly_MA_Data$ISCI_11)/2
This section creates a new analysis dataset from the original data and restructures past therapy and gender variables
Carly_Analysis_Data <-Carly_MA_Data[,c(91:93,95,97,99,100,102,104,105,107:109,111,112:116,139:147)]
recode.na(Carly_Analysis_Data$PASTTHERAPY, "-8")
## Recoded 7 values to NA.
## Recoded variable contains only numeric characters. Consider using as.numeric = TRUE.
## [1] 1 1 0 1 0 1 1 0 1 0 1 1 0 1 1
## [16] 1 1 0 0 1 <NA> 1 1 0 0 0 1 1 1 1
## [31] <NA> <NA> 1 1 1 0 0 1 0 1 1 <NA> 1 0 1
## [46] 1 1 0 1 1 1 1 1 0 0 0 0 1 1 0
## [61] 0 <NA> <NA> 0 0 1 1 0 0 <NA> <NA> 0 1 1 1
## [76] <NA> 0 0 0 0 0 0 0 0 1 <NA> <NA> 0 1 1
## [91] 1 0 0 1 1 1 1 1 0 1 <NA> <NA> 1 1 0
## [106] <NA> 0 1 0 1 1 1 1 0 1 1 1 0 0 <NA>
## [121] 1 0
## Levels: 0 1
Carly_Analysis_Data$GENDER<- factor(Carly_Analysis_Data$GENDER,
levels = c(1:7),
labels = c("Cis Female","Trans Female","Cis Male","Trans Male","Indigenous or Other Cultural Gender Identity","Non-Binary","Prefer Not to Answer"))
levels(Carly_Analysis_Data$GENDER)[levels(Carly_Analysis_Data$GENDER) == 'Prefer Not to Answer'] <- NA
Then we have the code for the descriptive statistics for the study variables
table(Carly_Analysis_Data$GENDER)
##
## Cis Female
## 75
## Trans Female
## 2
## Cis Male
## 21
## Trans Male
## 1
## Indigenous or Other Cultural Gender Identity
## 0
## Non-Binary
## 10
table(Carly_Analysis_Data$PASTTHERAPY)
##
## -8 0 1
## 7 45 62
table(Carly_Analysis_Data$CURRENTTHERAPY)
##
## -8 0 1
## 3 85 26
describe(Carly_Analysis_Data)%>%
knitr::kable(digits = 3, format="html", booktabs=TRUE, caption="Table 1. Carly Thesis Descriptives")%>%
kable_classic(full_width = F, html_font = "Cambria")
x |
---|
[122 obs. x 28 variables] tbl_df tbl data.frame $AGE: numeric: 21 19 21 19 19 25 20 19 21 18 … min: 18 - max: 28 - NAs: 14 (11.5%) - 11 unique values $GENDER: nominal factor: “Cis Female” “Trans Female” “Cis Female” “Cis Female” “Cis Female” “Cis Female” “Cis Male” “Cis Female” “Cis Female” “Cis Female” … 6 levels: Cis Female | Trans Female | Cis Male | Trans Male | Indigenous or Other Cultural Gender Identity | Non-Binary NAs: 13 (10.7%) $SEXUALORIENTATION: numeric: 3 2 1 1 1 1 1 1 3 1 … min: 1 - max: 9 - NAs: 8 (6.6%) - 9 unique values $RACE: numeric: 10 10 10 10 1 10 10 10 10 9 … min: 1 - max: 12 - NAs: 15 (12.3%) - 11 unique values $LANGUAGE: numeric: 1 1 1 1 1 1 1 1 1 2 … min: 1 - max: 3 - NAs: 8 (6.6%) - 4 unique values $LIVINGAREA: numeric: 1 2 2 2 1 1 2 2 1 1 … min: 1 - max: 4 - NAs: 8 (6.6%) - 5 unique values $LIVINGSITUATION: numeric: 7 NA 7 5 1 2 5 NA NA 6 … min: 1 - max: 10 - NAs: 44 (36.1%) - 8 unique values $RELATIONSHIP: numeric: 1 3 3 2 1 4 1 1 3 1 … min: 1 - max: 9 - NAs: 8 (6.6%) - 7 unique values $INCOME: numeric: 2 12 12 12 5 7 12 2 12 12 … min: 1 - max: 13 - NAs: 8 (6.6%) - 14 unique values $EMPLOYMENT: numeric: 1 NA 3 NA 2 3 3 NA NA NA … min: 1 - max: 11 - NAs: 63 (51.6%) - 8 unique values $STUDENTTYPE: numeric: 1 1 1 1 2 1 1 1 1 2 … min: 1 - max: 3 - NAs: 8 (6.6%) - 4 unique values $CANADA: numeric: 5 5 5 5 2 5 5 5 5 1 … min: 1 - max: 6 - NAs: 9 (7.4%) - 7 unique values $STUDENTSTATUS: numeric: 7 1 7 3 5 11 5 5 5 1 … min: 1 - max: 13 - NAs: 8 (6.6%) - 9 unique values $FACULTY: numeric: 2 7 1 8 1 2 3 8 6 1 … min: 1 - max: 9 - NAs: 8 (6.6%) - 10 unique values $DISABILITY: numeric: 2 1 2 2 2 2 2 2 1 2 … min: 1 - max: 3 - NAs: 8 (6.6%) - 4 unique values $PASTTHERAPY: labelled double: 1 1 0 1 0 1 1 0 1 0 … min: -8 - max: 1 - NAs: 8 (6.6%) - 4 unique values 3 value labels: [-8] Prefer Not to Answer [0] No [1] Yes $CURRENTTHERAPY: numeric: 0 0 0 1 0 1 0 0 0 0 … min: -8 - max: 1 - NAs: 8 (6.6%) - 4 unique values $PASTMEDS: numeric: 1 1 0 0 0 1 0 0 1 0 … min: -8 - max: 1 - NAs: 8 (6.6%) - 4 unique values $CURRENTMEDS: numeric: 0 1 0 0 0 1 0 0 1 0 … min: -8 - max: 1 - NAs: 8 (6.6%) - 4 unique values $MHLS_Total: numeric: 133 141 138 138 113 141 133 140 149 131 … min: 90 - max: 157 - NAs: 4 (3.3%) - 46 unique values $SSOSH_Total: numeric: 20 21 15 24 15 24 16 27 11 13 … min: 9 - max: 36 - NAs: 1 (0.8%) - 29 unique values $ATSPPHS_Total: numeric: 28 37 38 30 26 35 29 31 34 34 … min: 17 - max: 39 - NAs: 2 (1.6%) - 23 unique values $ISCI_Total: numeric: 44 40 47 36 23 39 40 40 43 50 … min: 21 - max: 68 - NAs: 2 (1.6%) - 39 unique values $PBC_Total: numeric: 9 20 17 21 21 21 19 15 21 19 … min: 9 - max: 21 - NAs: 1 (0.8%) - 13 unique values $K10_Total: numeric: 25 36 25 38 13 30 14 22 12 36 … min: 10 - max: 48 - NAs: 1 (0.8%) - 36 unique values $Psy_Int: numeric: 2.5 2.6 3.1 2 1.2 2.6 2.3 2.3 2.3 2.7 … min: 1 - max: 4 - NAs: 2 (1.6%) - 31 unique values $Acad_Int: numeric: 2.25 1.75 1.75 1.75 1 1 1.75 2 2.75 3.5 … min: 1 - max: 4 - NAs: 0 (0%) - 13 unique values $Drugs_Int: numeric: 3.5 3 3.5 3 3 3 3.5 4 4 4 … min: 1 - max: 4 - NAs: 0 (0%) - 7 unique values |
names(Carly_Analysis_Data)
## [1] "AGE" "GENDER" "SEXUALORIENTATION"
## [4] "RACE" "LANGUAGE" "LIVINGAREA"
## [7] "LIVINGSITUATION" "RELATIONSHIP" "INCOME"
## [10] "EMPLOYMENT" "STUDENTTYPE" "CANADA"
## [13] "STUDENTSTATUS" "FACULTY" "DISABILITY"
## [16] "PASTTHERAPY" "CURRENTTHERAPY" "PASTMEDS"
## [19] "CURRENTMEDS" "MHLS_Total" "SSOSH_Total"
## [22] "ATSPPHS_Total" "ISCI_Total" "PBC_Total"
## [25] "K10_Total" "Psy_Int" "Acad_Int"
## [28] "Drugs_Int"
apa.cor.table(Carly_Analysis_Data [,c(20:28)], filename = "Carly_Thesis_Desc.doc")
##
##
## Means, standard deviations, and correlations with confidence intervals
##
##
## Variable M SD 1 2 3
## 1. MHLS_Total 133.06 12.62
##
## 2. SSOSH_Total 19.25 6.31 -.33**
## [-.48, -.16]
##
## 3. ATSPPHS_Total 30.39 4.90 .54** -.54**
## [.39, .66] [-.66, -.40]
##
## 4. ISCI_Total 45.08 10.25 .45** -.36** .51**
## [.29, .58] [-.51, -.19] [.36, .63]
##
## 5. PBC_Total 17.71 3.00 .21* -.25** .17
## [.03, .38] [-.41, -.08] [-.02, .34]
##
## 6. K10_Total 26.21 8.85 .10 .16 .06
## [-.08, .28] [-.02, .33] [-.12, .24]
##
## 7. Psy_Int 2.71 0.69 .48** -.35** .53**
## [.32, .61] [-.50, -.18] [.39, .65]
##
## 8. Acad_Int 2.43 0.74 .26** -.23* .24**
## [.08, .42] [-.39, -.06] [.06, .40]
##
## 9. Drugs_Int 3.12 0.92 .18* -.20* .29**
## [.00, .35] [-.37, -.02] [.11, .44]
##
## 4 5 6 7 8
##
##
##
##
##
##
##
##
##
##
##
## .04
## [-.14, .22]
##
## .18 -.20*
## [-.00, .34] [-.37, -.02]
##
## .95** .03 .16
## [.93, .97] [-.15, .21] [-.02, .33]
##
## .80** .00 .10 .64**
## [.72, .86] [-.18, .18] [-.08, .28] [.52, .74]
##
## .50** .11 .11 .35** .28**
## [.35, .62] [-.07, .28] [-.07, .28] [.18, .50] [.11, .44]
##
##
## Note. M and SD are used to represent mean and standard deviation, respectively.
## Values in square brackets indicate the 95% confidence interval.
## The confidence interval is a plausible range of population correlations
## that could have caused the sample correlation (Cumming, 2014).
## * indicates p < .05. ** indicates p < .01.
##
Carly_Analysis_Data_no_Missing <-na.omit(Carly_Analysis_Data)
res <- cor(Carly_Analysis_Data_no_Missing[,c(20:28)])
round(res, 2)
## MHLS_Total SSOSH_Total ATSPPHS_Total ISCI_Total PBC_Total
## MHLS_Total 1.00 -0.23 0.61 0.70 0.03
## SSOSH_Total -0.23 1.00 -0.49 -0.41 -0.25
## ATSPPHS_Total 0.61 -0.49 1.00 0.70 0.18
## ISCI_Total 0.70 -0.41 0.70 1.00 0.08
## PBC_Total 0.03 -0.25 0.18 0.08 1.00
## K10_Total 0.43 -0.01 0.34 0.43 -0.09
## Psy_Int 0.73 -0.47 0.76 0.96 0.12
## Acad_Int 0.54 -0.18 0.37 0.82 -0.09
## Drugs_Int 0.22 -0.08 0.26 0.50 0.11
## K10_Total Psy_Int Acad_Int Drugs_Int
## MHLS_Total 0.43 0.73 0.54 0.22
## SSOSH_Total -0.01 -0.47 -0.18 -0.08
## ATSPPHS_Total 0.34 0.76 0.37 0.26
## ISCI_Total 0.43 0.96 0.82 0.50
## PBC_Total -0.09 0.12 -0.09 0.11
## K10_Total 1.00 0.40 0.30 0.38
## Psy_Int 0.40 1.00 0.69 0.37
## Acad_Int 0.30 0.69 1.00 0.33
## Drugs_Int 0.38 0.37 0.33 1.00
corrplot(res, type = "lower", order = "hclust",
tl.col = "black", tl.srt = 45)
This block runs the initial model that did not fit.
Model_initial <- '
ISCI_Total ~ ATSPPHS_Total
ATSPPHS_Total ~ SSOSH_Total + MHLS_Total
SSOSH_Total ~ MHLS_Total
'
Model_initial_fit <- sem(Model_initial, estimator= "MLR", data=Carly_Analysis_Data, mimic = "Mplus", missing = "FIML", fixed.x=TRUE)
## Warning: lavaan->lav_data_full():
## 4 cases were deleted due to missing values in exogenous variable(s), while
## fixed.x = TRUE.
summary(Model_initial_fit, fit.measures = TRUE, rsquare = TRUE, standardized=TRUE)
## lavaan 0.6-18 ended normally after 28 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 10
##
## Used Total
## Number of observations 118 122
## Number of missing patterns 4
##
## Model Test User Model:
## Standard Scaled
## Test Statistic 8.805 8.546
## Degrees of freedom 2 2
## P-value (Chi-square) 0.012 0.014
## Scaling correction factor 1.030
## Yuan-Bentler correction (Mplus variant)
##
## Model Test Baseline Model:
##
## Test statistic 122.587 113.792
## Degrees of freedom 6 6
## P-value 0.000 0.000
## Scaling correction factor 1.077
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.942 0.939
## Tucker-Lewis Index (TLI) 0.825 0.818
##
## Robust Comparative Fit Index (CFI) 0.940
## Robust Tucker-Lewis Index (TLI) 0.821
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -1109.954 -1109.954
## Scaling correction factor 1.009
## for the MLR correction
## Loglikelihood unrestricted model (H1) -1105.552 -1105.552
## Scaling correction factor 1.012
## for the MLR correction
##
## Akaike (AIC) 2239.909 2239.909
## Bayesian (BIC) 2267.616 2267.616
## Sample-size adjusted Bayesian (SABIC) 2236.003 2236.003
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.170 0.167
## 90 Percent confidence interval - lower 0.067 0.065
## 90 Percent confidence interval - upper 0.291 0.286
## P-value H_0: RMSEA <= 0.050 0.031 0.033
## P-value H_0: RMSEA >= 0.080 0.930 0.925
##
## Robust RMSEA 0.172
## 90 Percent confidence interval - lower 0.069
## 90 Percent confidence interval - upper 0.295
## P-value H_0: Robust RMSEA <= 0.050 0.030
## P-value H_0: Robust RMSEA >= 0.080 0.932
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.053 0.053
##
## Parameter Estimates:
##
## Standard errors Sandwich
## Information bread Observed
## Observed information based on Hessian
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## ISCI_Total ~
## ATSPPHS_Total 1.043 0.170 6.149 0.000 1.043 0.496
## ATSPPHS_Total ~
## SSOSH_Total -0.320 0.060 -5.317 0.000 -0.320 -0.414
## MHLS_Total 0.157 0.031 5.094 0.000 0.157 0.402
## SSOSH_Total ~
## MHLS_Total -0.165 0.043 -3.824 0.000 -0.165 -0.327
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .ISCI_Total 13.306 5.151 2.583 0.010 13.306 1.291
## .ATSPPHS_Total 15.630 4.598 3.399 0.001 15.630 3.187
## .SSOSH_Total 41.309 5.911 6.989 0.000 41.309 6.509
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .ISCI_Total 80.048 11.060 7.238 0.000 80.048 0.754
## .ATSPPHS_Total 13.437 1.612 8.335 0.000 13.437 0.559
## .SSOSH_Total 35.965 4.471 8.044 0.000 35.965 0.893
##
## R-Square:
## Estimate
## ISCI_Total 0.246
## ATSPPHS_Total 0.441
## SSOSH_Total 0.107
This block runs the final model and provides a table with the regression coefficients and a path diagrame with standardized path coeffients
Model_final <- '
Drugs_Int ~ ATSPPHS_Total
Acad_Int ~ ATSPPHS_Total
Psy_Int ~ ATSPPHS_Total
ATSPPHS_Total ~ SSOSH_Total + MHLS_Total
SSOSH_Total ~ MHLS_Total
'
Model_final_fit <- sem(Model_final, estimator= "MLR", data=Carly_Analysis_Data, mimic = "Mplus", missing = "FIML", fixed.x=TRUE)
## Warning: lavaan->lav_data_full():
## 4 cases were deleted due to missing values in exogenous variable(s), while
## fixed.x = TRUE.
summary(Model_final_fit, fit.measures = TRUE, rsquare=TRUE, standardized=TRUE)
## lavaan 0.6-18 ended normally after 66 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 19
##
## Used Total
## Number of observations 118 122
## Number of missing patterns 4
##
## Model Test User Model:
## Standard Scaled
## Test Statistic 11.109 10.174
## Degrees of freedom 6 6
## P-value (Chi-square) 0.085 0.118
## Scaling correction factor 1.092
## Yuan-Bentler correction (Mplus variant)
##
## Model Test Baseline Model:
##
## Test statistic 215.319 199.229
## Degrees of freedom 15 15
## P-value 0.000 0.000
## Scaling correction factor 1.081
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.974 0.977
## Tucker-Lewis Index (TLI) 0.936 0.943
##
## Robust Comparative Fit Index (CFI) 0.976
## Robust Tucker-Lewis Index (TLI) 0.941
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -1039.667 -1039.667
## Scaling correction factor 1.001
## for the MLR correction
## Loglikelihood unrestricted model (H1) -1034.113 -1034.113
## Scaling correction factor 1.023
## for the MLR correction
##
## Akaike (AIC) 2117.335 2117.335
## Bayesian (BIC) 2169.978 2169.978
## Sample-size adjusted Bayesian (SABIC) 2109.914 2109.914
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.085 0.077
## 90 Percent confidence interval - lower 0.000 0.000
## 90 Percent confidence interval - upper 0.162 0.152
## P-value H_0: RMSEA <= 0.050 0.197 0.243
## P-value H_0: RMSEA >= 0.080 0.603 0.534
##
## Robust RMSEA 0.082
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.164
## P-value H_0: Robust RMSEA <= 0.050 0.230
## P-value H_0: Robust RMSEA >= 0.080 0.578
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.053 0.053
##
## Parameter Estimates:
##
## Standard errors Sandwich
## Information bread Observed
## Observed information based on Hessian
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## Drugs_Int ~
## ATSPPHS_Total 0.057 0.016 3.591 0.000 0.057 0.310
## Acad_Int ~
## ATSPPHS_Total 0.034 0.014 2.432 0.015 0.034 0.225
## Psy_Int ~
## ATSPPHS_Total 0.073 0.011 6.482 0.000 0.073 0.515
## ATSPPHS_Total ~
## SSOSH_Total -0.320 0.060 -5.297 0.000 -0.320 -0.414
## MHLS_Total 0.157 0.031 5.092 0.000 0.157 0.401
## SSOSH_Total ~
## MHLS_Total -0.165 0.043 -3.824 0.000 -0.165 -0.327
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .Drugs_Int ~~
## .Acad_Int 0.162 0.058 2.799 0.005 0.162 0.261
## .Psy_Int 0.135 0.052 2.589 0.010 0.135 0.266
## .Acad_Int ~~
## .Psy_Int 0.273 0.047 5.775 0.000 0.273 0.631
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .Drugs_Int 1.405 0.502 2.798 0.005 1.405 1.559
## .Acad_Int 1.372 0.421 3.260 0.001 1.372 1.841
## .Psy_Int 0.501 0.348 1.440 0.150 0.501 0.722
## .ATSPPHS_Total 15.644 4.597 3.403 0.001 15.644 3.192
## .SSOSH_Total 41.309 5.911 6.989 0.000 41.309 6.509
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .Drugs_Int 0.734 0.102 7.209 0.000 0.734 0.904
## .Acad_Int 0.528 0.058 9.125 0.000 0.528 0.949
## .Psy_Int 0.354 0.050 7.019 0.000 0.354 0.735
## .ATSPPHS_Total 13.424 1.605 8.364 0.000 13.424 0.559
## .SSOSH_Total 35.965 4.471 8.044 0.000 35.965 0.893
##
## R-Square:
## Estimate
## Drugs_Int 0.096
## Acad_Int 0.051
## Psy_Int 0.265
## ATSPPHS_Total 0.441
## SSOSH_Total 0.107
parameterEstimates(Model_final_fit, standardized=TRUE) %>%
filter(op == "~") %>%
select('LV1'=lhs, 'LV2'=rhs, B=est, SE=se, Z=z, 'p-value'=pvalue, Beta=std.all,CI_Lower=ci.lower, CI_Upper=ci.upper) %>%
knitr::kable(digits = 3, format="html", booktabs=TRUE, caption="Path Model Regression Coefficients")%>%
kable_classic(full_width = F, html_font = "Cambria")
LV1 | LV2 | B | SE | Z | p-value | Beta | CI_Lower | CI_Upper |
---|---|---|---|---|---|---|---|---|
Drugs_Int | ATSPPHS_Total | 0.057 | 0.016 | 3.591 | 0.000 | 0.310 | 0.026 | 0.088 |
Acad_Int | ATSPPHS_Total | 0.034 | 0.014 | 2.432 | 0.015 | 0.225 | 0.007 | 0.062 |
Psy_Int | ATSPPHS_Total | 0.073 | 0.011 | 6.482 | 0.000 | 0.515 | 0.051 | 0.095 |
ATSPPHS_Total | SSOSH_Total | -0.320 | 0.060 | -5.297 | 0.000 | -0.414 | -0.438 | -0.201 |
ATSPPHS_Total | MHLS_Total | 0.157 | 0.031 | 5.092 | 0.000 | 0.401 | 0.096 | 0.217 |
SSOSH_Total | MHLS_Total | -0.165 | 0.043 | -3.824 | 0.000 | -0.327 | -0.250 | -0.081 |
semPaths(Model_final_fit, whatLabels = "std", edge.label.cex = .5, layout = "tree2",
rotation = 2, style = "lisrel", intercepts = FALSE, residuals = TRUE,
curve = 1, curvature = 3, nCharNodes = 8, sizeMan = 6, sizeMan2 = 3,
optimizeLatRes = TRUE, edge.color = "#000000")