############################################################################################### ############################### ASSUMPTION TESTING FOR POSS ################################### ############################################################################################### # Load packages library(Amelia) library(biotools) library(car) library(corrplot) library(MBESS) library(MVN) library(olsrr) ############################################################################################## ################################# A priori power analysis #################################### ############################################################################################## # Calculate R^2 from F(3, 285) = 5.3 (Abele-Brehm et al., 2019, p. 4) r_squared <- 1 - (1 / (1 + 5.3 * 3 / 285)) r_squared # USE PREPROCESSED DATA FILE: SAMPLE FOR HYPOTHESES TESTS "SAMPLE_HYP" (SEE S6 PREPROCESSING SCRIPT) ############################################################################################### ################################# GENERAL INSPECTION OF DATA ################################## ############################################################################################### # Missing plot of data missmap(sample_hyp, col=c("blue", "red"), main = "Missing vs observed") # Histograms of scales hist(sample_hyp$A_score) hist(sample_hyp$SN_score) hist(sample_hyp$PBC_score) hist(sample_hyp$intention) hist(sample_hyp$M_score) hist(sample_hyp$O_score) ############################################################################################### ################### ASSUMPTION TEST FOR HYPOTHESIS 1: MODERATED REGRESSION #################### ############################################################################################### # Assumptions of this model: # 1. Linearity # 2. Uncorrelated predictors # 3. Independence of residuals # 4. Normality of residuals # 5. Homogeneity of variance ############################################################################################### # Calculations # Calculate interaction term sample_hyp$interaction_A_importance <- sample_hyp$A_score * sample_hyp$importance # Regression model lm_hyp1 <- lm(intention ~ A_score + importance + interaction_A_importance + SN_score + PBC_score + prereg_experience, data = sample_hyp) ############################################################################################### # 1. Linearity # Assumed on a theoretical basis ############################################################################################### # 2. Uncorrelated predictors # Potential multicollinearity is tested: # Correlation plot for A-score, importance, A-score*importance, SN-score, and PBC-score correlations <- cor(sample_hyp[ , c("A_score", "importance", "interaction_A_importance", "SN_score", "PBC_score", "prereg_experience")]) corrplot(correlations, method="circle") cor(sample_hyp[ , c("A_score", "importance", "interaction_A_importance", "SN_score", "PBC_score", "prereg_experience")]) # biggest correlations around ...? # Test for multicollinearity ols_vif_tol(lm_hyp1) # If the multicollinearity is too high (variance inflation factor > 10), importance will be aggregated with the attitudes scale instead of including it as a moderator, since it might be just another aspect of attitudes # If high multicollinearity appears, this will be reported as limitation ############################################################################################### # 3. Independence of residuals # Achieved by the survey design ############################################################################################### # 4. Normality of residuals # Histogram of residuals (to test for normality of residuals) hist(lm_hyp1$residuals) # QQ plot of residuals qqnorm(lm_hyp1$residuals) qqline(lm_hyp1$residuals) # A violation of the normality of residuals is not impactful with high N, as it is the case with our sample, thus a violation would not be problematic # But would be reported ############################################################################################### # 5. Homogeneity variance # Plotting residuals plot(lm_hyp1$residuals) # If the assumption of homogeneity of variance is violated, weighted least squares regression will be used instead of ordinary least squares ############################################################################################### #################### ASSUMPTION TEST FOR HYPOTHESIS 2: MULTPLE REGRESSIONS #################### ############################################################################################### # Assumptions of this model: # 1. Linearity # 2. Uncorrelated predictors # 3. Independence of residuals # 4. Normality of residuals # 5. Homogeneity of variance ############################################################################################### # Calculations # Regression model 1: Attitudes lm_hyp2_attitudes <- lm(A_score ~ years_in_research + prereg_experience, data = sample_hyp) # Regression model 2: Motivations lm_hyp2_motivations <- lm(M_score ~ years_in_research + prereg_experience, data = sample_hyp) # Regression model 3: Obstacles lm_hyp2_obstacles <- lm(O_score ~ years_in_research + prereg_experience, data = sample_hyp) ############################################################################################### # 1. Linearity # Assumed on a theoretical basis ############################################################################################### # 2. Uncorrelated predictors # Potential multicollinearity is tested: cor(sample_hyp$years_in_research, sample_hyp$prereg_experience) # Correlation plot for preregistration experience and years worked in research # correlation around ...? # Test for multicollinearity ols_vif_tol(lm_hyp2_attitudes) ols_vif_tol(lm_hyp2_motivations) ols_vif_tol(lm_hyp2_obstacles) # If high multicollinearity appears, this will be reported as limitation ############################################################################################### # 3. Independence of residuals # Achieved by the survey design ############################################################################################### # 4. Normality of residuals # Histogram of residuals (to test for normality of residuals) hist(lm_hyp2_attitudes$residuals) hist(lm_hyp2_motivations$residuals) hist(lm_hyp2_obstacles$residuals) # QQ plot of residuals qqnorm(lm_hyp2_attitudes$residuals) qqline(lm_hyp2_attitudes$residuals) qqnorm(lm_hyp2_motivations$residuals) qqline(lm_hyp2_motivations$residuals) qqnorm(lm_hyp2_obstacles$residuals) qqline(lm_hyp2_obstacles$residuals) # A violation of the normality of residuals is not impactful with high N, as it is the case with our sample, thus a violation would not be problematic # But would be reported ############################################################################################### # 5. Homogeneity variance # Plotting residuals plot(lm_hyp2_attitudes$residuals) plot(lm_hyp2_motivations$residuals) plot(lm_hyp2_obstacles$residuals) # If the assumption of homogeneity of variance is violated, weighted least squares regression will be used instead of ordinary least squares ################################################################################################ ###################### ASSUMPTION TESTING FOR SENSITIVITY ANALYSES ############################# ################################################################################################ ####### Sample that did indicate faithful participation, but did not complete the survey ####### #################################### HYPOTHESIS 1 ############################################## # Calculations # Calculate interaction term sample_desc$interaction_A_importance <- sample_desc$A_score * sample_desc$importance # Regression model lm_hyp1_incomplete <- lm(intention ~ A_score + importance + interaction_A_importance + SN_score + PBC_score + prereg_experience, data = sample_desc) # Uncorrelated predictors # Correlation plot for A-score, importance, A-score*importance, SN-score, and PBC-score correlations_incomplete <- cor(sample_desc[ , c("A_score", "importance", "interaction_A_importance", "SN_score", "PBC_score", "prereg_experience")]) corrplot(correlations_incomplete, method="circle") cor(sample_desc[ , c("A_score", "importance", "interaction_A_importance", "SN_score", "PBC_score", "prereg_experience")]) # Normality of residuals # Histogram of residuals (to test for normality of residuals) hist(lm_hyp1_incomplete$residuals) # QQ plot of residuals qqnorm(lm_hyp1_incomplete$residuals) qqline(lm_hyp1_incomplete$residuals) # Homogeneity variance # Plotting residuals plot(lm_hyp1_incomplete$residuals) #################################### HYPOTHESIS 2 ############################################## # Calculations # Regression model 1: Attitudes lm_hyp2_attitudes_incomplete <- lm(A_score ~ years_in_research + prereg_experience, data = sample_desc) # Regression model 2: Motivations lm_hyp2_motivations_incomplete <- lm(M_score ~ years_in_research + prereg_experience, data = sample_desc) # Regression model 3: Obstacles lm_hyp2_obstacles_incomplete <- lm(O_score ~ years_in_research + prereg_experience, data = sample_desc) # Uncorrelated predictors cor(sample_desc$years_in_research, sample_desc$prereg_experience) # Test for multicollinearity ols_vif_tol(lm_hyp2_attitudes_incomplete) ols_vif_tol(lm_hyp2_motivations_incomplete) ols_vif_tol(lm_hyp2_obstacles_incomplete) # Normality of residuals # Histogram of residuals (to test for normality of residuals) hist(lm_hyp2_attitudes_incomplete$residuals) hist(lm_hyp2_motivations_incomplete$residuals) hist(lm_hyp2_obstacles_incomplete$residuals) # QQ plot of residuals qqnorm(lm_hyp2_attitudes_incomplete$residuals) qqline(lm_hyp2_attitudes_incomplete$residuals) qqnorm(lm_hyp2_motivations_incomplete$residuals) qqline(lm_hyp2_motivations_incomplete$residuals) qqnorm(lm_hyp2_obstacles_incomplete$residuals) qqline(lm_hyp2_obstacles_incomplete$residuals) # Homogeneity variance # Plotting residuals plot(lm_hyp2_attitudes_incomplete$residuals) plot(lm_hyp2_motivations_incomplete$residuals) plot(lm_hyp2_obstacles_incomplete$residuals)