This document presents all analyses conducted in the creation of the article. All analyses were performed using R 4.1.2 (R Core Team, 2021) with tidyverse package (Wickham et al., 2019). The confirmatory factor analyses were performed using lavaan package (Rosseel, 2012).
2 Data preparation
The data was loaded with sjlabelled package (Lüdecke, 2018).
cp_exp - experience with being corporally punished as a child
acp1 - acp9 - items for the Attitudes towards Corporal Punishment scale
2.2 Data balancing
Since the data was severely unbalanced by participants sex the female participants were sampled to be equal by number with male participants. The resulting data frame is called df_s.
Code
#create sample for Fset.seed(123456) #for reproducibilitydf_s=dplyr::sample_n(df[df$part_gen==1,], size=291)df_s=rbind(df[df$part_gen==0,], df_s)#create table with Nor_part=as.data.frame(table(df$part_gen))colnames(or_part)=c("Gender", "Before")or_part$Gender=c("Male", "Female")sh_part=as.data.frame(table(df_s$part_gen))colnames(sh_part)=c("Gender", "After")or_part$After=sh_part$Afterflextable::flextable(or_part) %>% flextable::add_header(Gender="Gender", Before="N", After="N") %>% flextable::merge_h(i=1, part="header") %>% flextable::merge_v(j=1, part="header") %>% flextable::align(align="center", part="header") %>% flextable::set_caption("Participant distribution by gender before and after sampling of female participants")
Participant distribution by gender before and after sampling of female participants
Gender
N
Before
After
Male
291
291
Female
571
291
3 CFA
3.1 Basic CFA
The presumed structure for the Attitudes towards Coproral Punishment - Short Situational Scale was single factor solution. The model was assessed using lavaan package using diagonally weighted least squares estimator that is more appropriate to the data(Li, 2016). The model showed an excellent theoretical fit and the standardized estimates with model fit indices are shown below.
The measurement invariance was assessed for three variables related to the participant gender, parent gender and child gender. The primary method of the invariance testing was to create models for each group (group parameter in cfa function) and then to use constraints for loadings and intercepts. The invariance was assessed by the difference in 𝛘² provided by anova function and changes in cfi, rmsea and srmr parameters. The function for creating the table with the fit parameters is in the code below.
The results show that all three models fit the data well. Although the difference in the models is statistically significant based on the \(\chi^2\) tests, the difference in cfi parameter is less than 0.002, which is the most strict cut-off value as recommended by Kline (2016, p. 401). Regarding the \(\chi^2\) tests it has to be noted that the model fit indices based on the \(\chi^2\) tests show adequate fit of the each model to the data.
3.2.2 Parent gender
The same method was applied to the parent gender variable.
The results show no significant changes between models, even when using the \(\chi^2\) tests.
We can conclude that the Attitudes towards Coproral Punishment - Short Situational Scale is functionally invariant regarding the participant gender and the parent’s and child’s gender described in the vignette.
3.3 Scale score calculation
The final step was to assess the method for the creation of the total scale score. The preferred method was to use average result (mean score) on the scale items. This includes the reversal of items 5, 6, 7 and 9. This score was compared to the factor scores as predicted with CFA.
Code
#factor scoresdf_s=cbind(df_s, lavaan::predict(fit))# calculation of total score as items mean# function for item reversalrev.code=function(item){ item=(item-6)*-1return(item)}df_s$acp5_r=rev.code(df_s$acp5)df_s$acp6_r=rev.code(df_s$acp6)df_s$acp7_r=rev.code(df_s$acp7)df_s$acp9_r=rev.code(df_s$acp9)#calculate total score as row meandf_s$acp_mean=rowMeans(df_s%>%select(acp1, acp2, acp3, acp4, acp5_r, acp6_r, acp7_r, acp8, acp9_r))#correlation of item means with factor scoresscore_cor=cor.test(df_s$att_cp, df_s$acp_mean)
The results show that the correlation of scores calculated as items mean and the factor scores is 0.997, thus indicating that the items mean as the scale score calculation method is functionally equal to factor scores and because of practical use the preferred method for the total score calculation.
4 References
References
Kline, R. B. (2016). Principles and practice of structural equation modeling (Fourth edition). The Guilford Press.
Li, C.-H. (2016). The performance of ML, DWLS, and ULS estimation with robust corrections in structural equation models with ordinal variables. Psychological Methods, 21(3), 369–387. https://doi.org/10.1037/met0000093
R Core Team. (2021). R: A language and environment for statistical computing. R Foundation for Statistical Computing.
Rosseel, Y. (2012). Lavaan: AnRPackage for Structural Equation Modeling. Journal of Statistical Software, 48(2). https://doi.org/10.18637/jss.v048.i02
Wickham, H., Averick, M., Bryan, J., Chang, W., McGowan, L., François, R., Grolemund, G., Hayes, A., Henry, L., Hester, J., Kuhn, M., Pedersen, T., Miller, E., Bache, S., Müller, K., Ooms, J., Robinson, D., Seidel, D., Spinu, V., … Yutani, H. (2019). Welcome to the Tidyverse. Journal of Open Source Software, 4(43), 1686. https://doi.org/10.21105/joss.01686