This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
library(readr)
black <- read_csv("/Users/niyah/Desktop/BlackData_FINAL_Dataset.csv")
## New names:
## Rows: 259 Columns: 32
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (4): AHELP, GEN_8_TEXT, ETH_6_TEXT, BORN_1 dbl (27): ...1, PRE_HELP, AGE, GEN,
## EDU, EMP, INS_1, INS_2, ETH, INC, BORN, ... lgl (1): EDU_11_TEXT
## ℹ 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.
## • `` -> `...1`
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
black <- data.frame(black$JH, black$MHSAS, black$SSOSH, black$SSRPH)
black <- rename(black, henryism = black.JH, help_seeking_attitudes = black.MHSAS, self_stigma = black.SSOSH, public_stigma = black.SSRPH)
library(lavaan)
## This is lavaan 0.6-16
## lavaan is FREE software! Please report any bugs.
library(semPlot)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.4.4 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.0
## ✔ 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(psych)
##
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
##
## %+%, alpha
## The following object is masked from 'package:lavaan':
##
## cor2cov
library(jtools)
library(interactions)
library(ggplot2)
library(tidySEM)
## Loading required package: OpenMx
## OpenMx may run faster if it is compiled to take advantage of multiple cores.
##
## Attaching package: 'OpenMx'
## The following object is masked from 'package:psych':
##
## tr
## Registered S3 method overwritten by 'tidySEM':
## method from
## predict.MxModel OpenMx
##
## Attaching package: 'tidySEM'
## The following object is masked from 'package:jtools':
##
## get_data
table <- apaTables::apa.cor.table(black, table.number = 1, show.sig.stars = TRUE,
landscape = TRUE, filename = "table.doc")
## Registered S3 methods overwritten by 'broom':
## method from
## tidy.glht jtools
## tidy.summary.glht jtools
print(table)
##
##
## Table 1
##
## Means, standard deviations, and correlations with confidence intervals
##
##
## Variable M SD 1 2 3
## 1. henryism 3.70 0.64
##
## 2. help_seeking_attitudes 5.66 1.34 .21**
## [.09, .33]
##
## 3. self_stigma 2.23 0.75 -.16** -.62**
## [-.28, -.04] [-.69, -.54]
##
## 4. public_stigma 2.10 0.69 -.12 -.41** .44**
## [-.24, .01] [-.51, -.30] [.33, .53]
##
##
## 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.
##
psych::pairs.panels(black)
table <- apaTables::apa.cor.table(black, table.number = 1, show.sig.stars = TRUE,
landscape = TRUE, filename = "Lewis_Corr.doc")
print(table)
##
##
## Table 1
##
## Means, standard deviations, and correlations with confidence intervals
##
##
## Variable M SD 1 2 3
## 1. henryism 3.70 0.64
##
## 2. help_seeking_attitudes 5.66 1.34 .21**
## [.09, .33]
##
## 3. self_stigma 2.23 0.75 -.16** -.62**
## [-.28, -.04] [-.69, -.54]
##
## 4. public_stigma 2.10 0.69 -.12 -.41** .44**
## [-.24, .01] [-.51, -.30] [.33, .53]
##
##
## 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.
##
psych::describe(black)
## vars n mean sd median trimmed mad min max range
## henryism 1 259 3.70 0.64 3.75 3.72 0.62 1.25 5.0 3.75
## help_seeking_attitudes 2 257 5.66 1.34 6.00 5.84 1.48 1.00 7.0 6.00
## self_stigma 3 258 2.23 0.75 2.10 2.18 0.74 1.00 4.8 3.80
## public_stigma 4 259 2.10 0.69 2.00 2.09 0.89 1.00 4.0 3.00
## skew kurtosis se
## henryism -0.55 0.75 0.04
## help_seeking_attitudes -0.99 0.31 0.08
## self_stigma 0.69 0.30 0.05
## public_stigma 0.22 -0.28 0.04
##MODERATION
Mod_a_path <- lm(self_stigma ~ public_stigma * henryism, data = black)
jtools::summ(Mod_a_path, digits = 3)
## MODEL INFO:
## Observations: 258 (1 missing obs. deleted)
## Dependent Variable: self_stigma
## Type: OLS linear regression
##
## MODEL FIT:
## F(3,254) = 21.660, p = 0.000
## R² = 0.204
## Adj. R² = 0.194
##
## Standard errors: OLS
## --------------------------------------------------------------
## Est. S.E. t val. p
## ---------------------------- -------- ------- -------- -------
## (Intercept) 2.198 0.729 3.016 0.003
## public_stigma 0.248 0.317 0.783 0.434
## henryism -0.245 0.185 -1.323 0.187
## public_stigma:henryism 0.054 0.081 0.666 0.506
## --------------------------------------------------------------
interactions::interact_plot(Mod_a_path, pred = public_stigma, modx = henryism) +
ylim(1, 10)
interactions::sim_slopes(Mod_a_path, pred = public_stigma, modx = henryism)
## JOHNSON-NEYMAN INTERVAL
##
## When henryism is INSIDE the interval [1.81, 8.05], the slope of
## public_stigma is p < .05.
##
## Note: The range of observed values of henryism is [1.25, 5.00]
##
## SIMPLE SLOPES ANALYSIS
##
## Slope of public_stigma when henryism = 3.053231 (- 1 SD):
##
## Est. S.E. t val. p
## ------ ------ -------- ------
## 0.41 0.09 4.69 0.00
##
## Slope of public_stigma when henryism = 3.696163 (Mean):
##
## Est. S.E. t val. p
## ------ ------ -------- ------
## 0.45 0.06 7.24 0.00
##
## Slope of public_stigma when henryism = 4.339095 (+ 1 SD):
##
## Est. S.E. t val. p
## ------ ------ -------- ------
## 0.48 0.07 6.61 0.00
Mod_b_path <- lm(help_seeking_attitudes ~ public_stigma * henryism, data = black)
jtools::summ(Mod_b_path, digits = 3)
## MODEL INFO:
## Observations: 257 (2 missing obs. deleted)
## Dependent Variable: help_seeking_attitudes
## Type: OLS linear regression
##
## MODEL FIT:
## F(3,253) = 21.190, p = 0.000
## R² = 0.201
## Adj. R² = 0.191
##
## Standard errors: OLS
## --------------------------------------------------------------
## Est. S.E. t val. p
## ---------------------------- -------- ------- -------- -------
## (Intercept) 4.487 1.307 3.432 0.001
## public_stigma -0.070 0.569 -0.123 0.902
## henryism 0.728 0.332 2.193 0.029
## public_stigma:henryism -0.178 0.145 -1.221 0.223
## --------------------------------------------------------------
interactions::interact_plot(Mod_b_path, pred = public_stigma, modx = henryism) +
ylim(1, 10)
interactions::sim_slopes(Mod_b_path, pred = public_stigma, modx = henryism)
## JOHNSON-NEYMAN INTERVAL
##
## When henryism is INSIDE the interval [2.33, 10.64], the slope of
## public_stigma is p < .05.
##
## Note: The range of observed values of henryism is [1.25, 5.00]
##
## SIMPLE SLOPES ANALYSIS
##
## Slope of public_stigma when henryism = 3.050816 (- 1 SD):
##
## Est. S.E. t val. p
## ------- ------ -------- ------
## -0.61 0.16 -3.87 0.00
##
## Slope of public_stigma when henryism = 3.694319 (Mean):
##
## Est. S.E. t val. p
## ------- ------ -------- ------
## -0.73 0.11 -6.54 0.00
##
## Slope of public_stigma when henryism = 4.337822 (+ 1 SD):
##
## Est. S.E. t val. p
## ------- ------ -------- ------
## -0.84 0.13 -6.42 0.00
##ANALYSIS 3
LMedModel <- "
help_seeking_attitudes ~ b*self_stigma + c_p*public_stigma
self_stigma ~a*public_stigma
#intercepts
self_stigma ~ self_stigma.mean*1
help_seeking_attitudes ~ help_seeking_attitudes.mean*1
indirect := a*b
direct := c_p
total_c := c_p + (a*b)
"
set.seed(230925) #required for reproducible results because lavaan introduces randomness into the calculations
LMed_fit <- lavaan::sem(LMedModel, data = black, se = "bootstrap", missing = "fiml")
LMed_Sum <- lavaan::summary(LMed_fit, standardized = T, rsq = T, ci = TRUE)
LMed_ParEsts <- lavaan::parameterEstimates(LMed_fit, boot.ci.type = "bca.simple",
standardized = TRUE)
LMed_Sum
## lavaan 0.6.16 ended normally after 16 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 7
##
## Number of observations 259
## Number of missing patterns 3
##
## Model Test User Model:
##
## Test statistic 0.000
## Degrees of freedom 0
##
## Parameter Estimates:
##
## Standard errors Bootstrap
## Number of requested bootstrap draws 1000
## Number of successful bootstrap draws 1000
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) ci.lower
## help_seeking_attitudes ~
## slf_stgm (b) -0.980 0.092 -10.598 0.000 -1.152
## pblc_stg (c_p) -0.325 0.101 -3.218 0.001 -0.532
## self_stigma ~
## pblc_stg (a) 0.473 0.069 6.862 0.000 0.334
## ci.upper Std.lv Std.all
##
## -0.787 -0.980 -0.550
## -0.135 -0.325 -0.169
##
## 0.604 0.473 0.437
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## .slf_stg (sl_.) 1.239 0.139 8.948 0.000 0.987 1.520
## .hlp_sk_ (h__.) 8.532 0.206 41.393 0.000 8.115 8.931
## Std.lv Std.all
## 1.239 1.659
## 8.532 6.411
##
## Variances:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## .hlp_skng_tttds 1.041 0.117 8.875 0.000 0.806 1.285
## .self_stigma 0.451 0.038 11.912 0.000 0.375 0.521
## Std.lv Std.all
## 1.041 0.588
## 0.451 0.809
##
## R-Square:
## Estimate
## hlp_skng_tttds 0.412
## self_stigma 0.191
##
## Defined Parameters:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## indirect -0.464 0.085 -5.473 0.000 -0.634 -0.298
## direct -0.325 0.101 -3.217 0.001 -0.532 -0.135
## total_c -0.788 0.113 -7.007 0.000 -0.999 -0.578
## Std.lv Std.all
## -0.464 -0.241
## -0.325 -0.169
## -0.788 -0.409
LMed_ParEsts
## lhs op rhs label
## 1 help_seeking_attitudes ~ self_stigma b
## 2 help_seeking_attitudes ~ public_stigma c_p
## 3 self_stigma ~ public_stigma a
## 4 self_stigma ~1 self_stigma.mean
## 5 help_seeking_attitudes ~1 help_seeking_attitudes.mean
## 6 help_seeking_attitudes ~~ help_seeking_attitudes
## 7 self_stigma ~~ self_stigma
## 8 public_stigma ~~ public_stigma
## 9 public_stigma ~1
## 10 indirect := a*b indirect
## 11 direct := c_p direct
## 12 total_c := c_p+(a*b) total_c
## est se z pvalue ci.lower ci.upper std.lv std.all std.nox
## 1 -0.980 0.092 -10.598 0.000 -1.161 -0.793 -0.980 -0.550 -0.550
## 2 -0.325 0.101 -3.218 0.001 -0.518 -0.125 -0.325 -0.169 -0.244
## 3 0.473 0.069 6.862 0.000 0.336 0.611 0.473 0.437 0.633
## 4 1.239 0.139 8.948 0.000 0.974 1.511 1.239 1.659 1.659
## 5 8.532 0.206 41.393 0.000 8.120 8.938 8.532 6.411 6.411
## 6 1.041 0.117 8.875 0.000 0.832 1.313 1.041 0.588 0.588
## 7 0.451 0.038 11.912 0.000 0.386 0.539 0.451 0.809 0.809
## 8 0.477 0.000 NA NA 0.477 0.477 0.477 1.000 0.477
## 9 2.103 0.000 NA NA 2.103 2.103 2.103 3.044 2.103
## 10 -0.464 0.085 -5.473 0.000 -0.648 -0.306 -0.464 -0.241 -0.348
## 11 -0.325 0.101 -3.217 0.001 -0.518 -0.125 -0.325 -0.169 -0.244
## 12 -0.788 0.113 -7.007 0.000 -0.996 -0.569 -0.788 -0.409 -0.592
##MODERATED MEDIATION
Combined <- '
#equations
self_stigma ~ a1*public_stigma + a2*henryism + a3*public_stigma:henryism
help_seeking_attitudes ~ c_p1*public_stigma + c_p2*henryism + c_p3*public_stigma:henryism + b*self_stigma
#intercepts
self_stigma ~ self_stigma.mean*1
help_seeking_attitudes ~ help_seeking_attitudes.mean*1
#means, variances of W for simple slopes
henryism ~ henryism.mean*1
henryism ~~ henryism.var*henryism
#index of moderated mediation, there will be an a and b path in the product
#if the a and/or b path is moderated, select the label that represents the moderation
imm := a3*b
#Note that we first create the indirect product, then add to it the product of the imm and the W level
indirect.SDbelow := a1*b + imm*(henryism.mean - sqrt(henryism.var))
indirect.mean := a1*b + imm*(henryism.mean)
indirect.SDabove := a1*b + imm*(henryism.mean + sqrt(henryism.var))
#direct effect is also moderated so calculate with c_p1 + c_p3
direct.SDbelow := c_p1 + c_p3*(henryism.mean - sqrt(henryism.var))
direct.Smean := c_p1 + c_p3*(henryism.mean)
direct.SDabove := c_p1 + c_p3*(henryism.mean + sqrt(henryism.var))
'
set.seed(230925) #required for reproducible results because lavaan introduces randomness into the calculations
Combined_fit <- lavaan::sem(Combined, data = black, se = "bootstrap", missing = 'fiml', bootstrap = 1000)
## Warning in lav_partable_vnames(FLAT, "ov.x", warn = TRUE): lavaan WARNING:
## model syntax contains variance/covariance/intercept formulas
## involving (an) exogenous variable(s): [henryism]; These variables
## will now be treated as random introducing additional free
## parameters. If you wish to treat those variables as fixed, remove
## these formulas from the model syntax. Otherwise, consider adding
## the fixed.x = FALSE option.
cFITsum <- lavaan::summary(Combined_fit, standardized = TRUE, rsq=T, ci=TRUE)
cParamEsts <- lavaan::parameterEstimates(Combined_fit, boot.ci.type = "bca.simple", standardized=TRUE)
cFITsum
## lavaan 0.6.16 ended normally after 29 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 13
##
## Number of observations 259
## Number of missing patterns 3
##
## Model Test User Model:
##
## Test statistic 542.551
## Degrees of freedom 2
## P-value (Chi-square) 0.000
##
## Parameter Estimates:
##
## Standard errors Bootstrap
## Number of requested bootstrap draws 1000
## Number of successful bootstrap draws 1000
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) ci.lower
## self_stigma ~
## pblc_st (a1) 0.253 0.369 0.686 0.493 -0.400
## henrysm (a2) -0.244 0.200 -1.222 0.222 -0.579
## pblc_s: (a3) 0.054 0.096 0.558 0.577 -0.157
## help_seeking_attitudes ~
## pblc_st (c_p1) 0.173 0.487 0.355 0.723 -0.976
## henrysm (c_p2) 0.497 0.245 2.024 0.043 -0.062
## pblc_s: (c_p3) -0.127 0.123 -1.029 0.303 -0.321
## slf_stg (b) -0.950 0.093 -10.222 0.000 -1.121
## ci.upper Std.lv Std.all
##
## 1.079 0.253 0.232
## 0.206 -0.244 -0.207
## 0.220 0.054 0.205
##
## 0.965 0.173 0.086
## 0.905 0.497 0.228
## 0.160 -0.127 -0.263
## -0.750 -0.950 -0.514
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## .slf_stg (sl_.) 2.189 0.788 2.780 0.005 0.417 3.496
## .hlp_sk_ (h__.) 6.564 0.972 6.750 0.000 4.865 8.804
## henrysm (hnr.) 3.696 0.039 93.661 0.000 3.613 3.773
## Std.lv Std.all
## 2.189 2.901
## 6.564 4.711
## 3.696 5.771
##
## Variances:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## henrysm (hnr.) 0.410 0.042 9.793 0.000 0.334 0.499
## .slf_stg 0.444 0.037 11.912 0.000 0.368 0.508
## .hlp_sk_ 1.017 0.118 8.589 0.000 0.773 1.260
## Std.lv Std.all
## 0.410 1.000
## 0.444 0.779
## 1.017 0.524
##
## R-Square:
## Estimate
## self_stigma 0.221
## hlp_skng_tttds 0.476
##
## Defined Parameters:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## imm -0.051 0.091 -0.561 0.575 -0.213 0.143
## indirect.SDblw -0.396 0.105 -3.765 0.000 -0.609 -0.196
## indirect.mean -0.429 0.086 -5.011 0.000 -0.596 -0.265
## indirect.SDabv -0.461 0.101 -4.556 0.000 -0.666 -0.266
## direct.SDbelow -0.215 0.141 -1.528 0.126 -0.520 0.029
## direct.Smean -0.297 0.100 -2.953 0.003 -0.503 -0.114
## direct.SDabove -0.378 0.113 -3.337 0.001 -0.596 -0.153
## Std.lv Std.all
## -0.051 -0.105
## -0.396 -0.622
## -0.429 -0.727
## -0.461 -0.832
## -0.215 -1.169
## -0.297 -1.432
## -0.378 -1.695
cParamEsts
## lhs op rhs
## 1 self_stigma ~ public_stigma
## 2 self_stigma ~ henryism
## 3 self_stigma ~ public_stigma:henryism
## 4 help_seeking_attitudes ~ public_stigma
## 5 help_seeking_attitudes ~ henryism
## 6 help_seeking_attitudes ~ public_stigma:henryism
## 7 help_seeking_attitudes ~ self_stigma
## 8 self_stigma ~1
## 9 help_seeking_attitudes ~1
## 10 henryism ~1
## 11 henryism ~~ henryism
## 12 self_stigma ~~ self_stigma
## 13 help_seeking_attitudes ~~ help_seeking_attitudes
## 14 public_stigma ~~ public_stigma
## 15 public_stigma ~~ public_stigma:henryism
## 16 public_stigma:henryism ~~ public_stigma:henryism
## 17 public_stigma ~1
## 18 public_stigma:henryism ~1
## 19 imm := a3*b
## 20 indirect.SDbelow := a1*b+imm*(henryism.mean-sqrt(henryism.var))
## 21 indirect.mean := a1*b+imm*(henryism.mean)
## 22 indirect.SDabove := a1*b+imm*(henryism.mean+sqrt(henryism.var))
## 23 direct.SDbelow := c_p1+c_p3*(henryism.mean-sqrt(henryism.var))
## 24 direct.Smean := c_p1+c_p3*(henryism.mean)
## 25 direct.SDabove := c_p1+c_p3*(henryism.mean+sqrt(henryism.var))
## label est se z pvalue ci.lower ci.upper
## 1 a1 0.253 0.369 0.686 0.493 -0.402 1.063
## 2 a2 -0.244 0.200 -1.222 0.222 -0.593 0.163
## 3 a3 0.054 0.096 0.558 0.577 -0.153 0.226
## 4 c_p1 0.173 0.487 0.355 0.723 -0.855 1.015
## 5 c_p2 0.497 0.245 2.024 0.043 -0.001 0.965
## 6 c_p3 -0.127 0.123 -1.029 0.303 -0.333 0.131
## 7 b -0.950 0.093 -10.222 0.000 -1.130 -0.765
## 8 self_stigma.mean 2.189 0.788 2.780 0.005 0.557 3.582
## 9 help_seeking_attitudes.mean 6.564 0.972 6.750 0.000 4.668 8.472
## 10 henryism.mean 3.696 0.039 93.661 0.000 3.617 3.775
## 11 henryism.var 0.410 0.042 9.793 0.000 0.338 0.502
## 12 0.444 0.037 11.912 0.000 0.385 0.534
## 13 1.017 0.118 8.589 0.000 0.813 1.296
## 14 0.477 0.000 NA NA 0.477 0.477
## 15 1.721 0.000 NA NA 1.721 1.721
## 16 8.317 0.000 NA NA 8.317 8.317
## 17 2.103 0.000 NA NA 2.103 2.103
## 18 7.720 0.000 NA NA 7.720 7.720
## 19 imm -0.051 0.091 -0.561 0.575 -0.224 0.135
## 20 indirect.SDbelow -0.396 0.105 -3.765 0.000 -0.623 -0.208
## 21 indirect.mean -0.429 0.086 -5.011 0.000 -0.616 -0.285
## 22 indirect.SDabove -0.461 0.101 -4.556 0.000 -0.684 -0.292
## 23 direct.SDbelow -0.215 0.141 -1.528 0.126 -0.486 0.052
## 24 direct.Smean -0.297 0.100 -2.953 0.003 -0.485 -0.095
## 25 direct.SDabove -0.378 0.113 -3.337 0.001 -0.605 -0.158
## std.lv std.all std.nox
## 1 0.253 0.232 0.336
## 2 -0.244 -0.207 -0.223
## 3 0.054 0.205 0.071
## 4 0.173 0.086 0.124
## 5 0.497 0.228 0.246
## 6 -0.127 -0.263 -0.091
## 7 -0.950 -0.514 -0.514
## 8 2.189 2.901 2.901
## 9 6.564 4.711 4.711
## 10 3.696 5.771 5.771
## 11 0.410 1.000 1.000
## 12 0.444 0.779 0.779
## 13 1.017 0.524 0.524
## 14 0.477 1.000 0.477
## 15 1.721 0.864 1.721
## 16 8.317 1.000 8.317
## 17 2.103 3.044 2.103
## 18 7.720 2.677 7.720
## 19 -0.051 -0.105 -0.037
## 20 -0.396 -0.622 -0.347
## 21 -0.429 -0.727 -0.383
## 22 -0.461 -0.832 -0.420
## 23 -0.215 -1.169 -0.311
## 24 -0.297 -1.432 -0.402
## 25 -0.378 -1.695 -0.493