d <-subset(df, select=c(15:79,200:248))# total percentage of missing data# mean(is.na(d))# total number of participants (rows) with any missing data# (sum(rowSums(is.na(d)) > 0))/nrow(d)d <-na.omit(subset(df, select=c(id,15:79,200:248)))backup <- dfdf <-subset(df, df$id %in% d$id)
df[paste0("Q27_", 1:6)] <-lapply(df[paste0("Q27_", 1:6)], as.numeric)df[paste0("Q94_", 1:3)] <-lapply(df[paste0("Q94_", 1:3)], as.numeric)d <-subset(df, select=c(grep("Q27_", colnames(df)),grep("Q94_", colnames(df))))# mapping of labels to textlabels <-c(Q27_1 ="Unintelligent : Intelligent",Q27_2 ="Untrained : Trained",Q27_3 ="Inexpert : Expert",Q27_4 ="Uninformed : Informed",Q27_5 ="Incompetent : Competent",Q27_6 ="Stupid : Bright",Q94_1 ="Dishonest : Honest",Q94_2 ="Untrustworthy : Trustworthy",Q94_3 ="Dishonorable : Honorable")# shorten labels to max 40 characters (you can adjust the number)labels <-str_trunc(labels, width =60, side ="right")# replace column namesnames(d) <-ifelse(names(d) %in%names(labels), labels[names(d)],names(d))ev <-eigen(cor(d)) # get eigenvaluesap <-parallel(subject=nrow(d),var=ncol(d),rep=100,cent=.05) # run the parallel analysis, gives us another perspective on how many factors should be used in the modelnS <-nScree(x=ev$values, aparallel=ap$eigen$qevpea) # creates the scree plotplotnScree(nS) # shows us the scree plot, look for the elbows
Call:
factanal(x = d, factors = 2, rotation = "promax")
Uniquenesses:
Unintelligent : Intelligent Untrained : Trained
0.217 0.372
Inexpert : Expert Uninformed : Informed
0.408 0.200
Incompetent : Competent Stupid : Bright
0.220 0.202
Dishonest : Honest Untrustworthy : Trustworthy
0.155 0.055
Dishonorable : Honorable
0.234
Loadings:
Factor1 Factor2
Unintelligent : Intelligent 0.916
Uninformed : Informed 0.753
Incompetent : Competent 0.859
Stupid : Bright 0.917
Dishonest : Honest 0.835
Untrustworthy : Trustworthy 1.019
Dishonorable : Honorable 0.731
Untrained : Trained 0.465
Inexpert : Expert 0.497
Factor1 Factor2
SS loadings 3.489 2.526
Proportion Var 0.388 0.281
Cumulative Var 0.388 0.668
Factor Correlations:
Factor1 Factor2
Factor1 1.000 0.829
Factor2 0.829 1.000
Test of the hypothesis that 2 factors are sufficient.
The chi square statistic is 156.68 on 19 degrees of freedom.
The p-value is 1.12e-23
Code
d <-subset(df, select=c(grep("Q27_", colnames(df)),grep("Q94_", colnames(df))))d <-subset(d, select=-c(Q27_2, Q27_3))# mapping of labels to textlabels <-c(Q27_1 ="Unintelligent : Intelligent",Q27_4 ="Uninformed : Informed",Q27_5 ="Incompetent : Competent",Q27_6 ="Stupid : Bright",Q94_1 ="Dishonest : Honest",Q94_2 ="Untrustworthy : Trustworthy",Q94_3 ="Dishonorable : Honorable")# shorten labels to max 40 characters (you can adjust the number)labels <-str_trunc(labels, width =60, side ="right")# replace column namesnames(d) <-ifelse(names(d) %in%names(labels), labels[names(d)],names(d))ev <-eigen(cor(d)) # get eigenvaluesap <-parallel(subject=nrow(d),var=ncol(d),rep=100,cent=.05) # run the parallel analysis, gives us another perspective on how many factors should be used in the modelnS <-nScree(x=ev$values, aparallel=ap$eigen$qevpea) # creates the scree plotplotnScree(nS) # shows us the scree plot, look for the elbows
# Specify CFA modelmodel <-' ppl =~ Q29_1 + Q29_2 eli =~ Q29_3 + Q29_4 dec =~ Q29_5 + Q29_6 tru =~ Q29_7 + Q29_8'# Fit CFA modelfit <-cfa(model, data = df, std.lv =TRUE)# View summary with fit indices and standardized loadingssummary(fit, fit.measures =TRUE, standardized =TRUE)
lavaan 0.6-21 ended normally after 29 iterations
Estimator ML
Optimization method NLMINB
Number of model parameters 22
Number of observations 184
Model Test User Model:
Test statistic 24.826
Degrees of freedom 14
P-value (Chi-square) 0.036
Model Test Baseline Model:
Test statistic 490.930
Degrees of freedom 28
P-value 0.000
User Model versus Baseline Model:
Comparative Fit Index (CFI) 0.977
Tucker-Lewis Index (TLI) 0.953
Loglikelihood and Information Criteria:
Loglikelihood user model (H0) -1594.557
Loglikelihood unrestricted model (H1) -1582.144
Akaike (AIC) 3233.114
Bayesian (BIC) 3303.843
Sample-size adjusted Bayesian (SABIC) 3234.163
Root Mean Square Error of Approximation:
RMSEA 0.065
90 Percent confidence interval - lower 0.016
90 Percent confidence interval - upper 0.106
P-value H_0: RMSEA <= 0.050 0.251
P-value H_0: RMSEA >= 0.080 0.301
Standardized Root Mean Square Residual:
SRMR 0.036
Parameter Estimates:
Standard errors Standard
Information Expected
Information saturated (h1) model Structured
Latent Variables:
Estimate Std.Err z-value P(>|z|) Std.lv Std.all
ppl =~
Q29_1 0.511 0.205 2.497 0.013 0.511 0.774
Q29_2 0.252 0.110 2.296 0.022 0.252 0.376
eli =~
Q29_3 0.640 0.059 10.910 0.000 0.640 0.803
Q29_4 0.704 0.070 10.125 0.000 0.704 0.746
dec =~
Q29_5 0.808 0.067 12.023 0.000 0.808 0.856
Q29_6 0.801 0.068 11.703 0.000 0.801 0.835
tru =~
Q29_7 0.747 0.063 11.824 0.000 0.747 0.820
Q29_8 0.692 0.061 11.268 0.000 0.692 0.785
Covariances:
Estimate Std.Err z-value P(>|z|) Std.lv Std.all
ppl ~~
eli -0.067 0.109 -0.614 0.539 -0.067 -0.067
dec 0.152 0.111 1.363 0.173 0.152 0.152
tru 0.154 0.115 1.346 0.178 0.154 0.154
eli ~~
dec 0.532 0.074 7.213 0.000 0.532 0.532
tru 0.726 0.062 11.735 0.000 0.726 0.726
dec ~~
tru 0.628 0.064 9.811 0.000 0.628 0.628
Variances:
Estimate Std.Err z-value P(>|z|) Std.lv Std.all
.Q29_1 0.175 0.206 0.848 0.396 0.175 0.401
.Q29_2 0.385 0.064 6.013 0.000 0.385 0.858
.Q29_3 0.225 0.049 4.633 0.000 0.225 0.355
.Q29_4 0.396 0.066 6.000 0.000 0.396 0.444
.Q29_5 0.237 0.066 3.574 0.000 0.237 0.267
.Q29_6 0.279 0.067 4.148 0.000 0.279 0.303
.Q29_7 0.272 0.055 4.946 0.000 0.272 0.328
.Q29_8 0.297 0.051 5.834 0.000 0.297 0.383
ppl 1.000 1.000 1.000
eli 1.000 1.000 1.000
dec 1.000 1.000 1.000
tru 1.000 1.000 1.000
# write.csv(df, file="forshin.csv", row.names = F)# ppl = conceptions of the ordinary people# eli = conceptions of the academic elite# dec = demands for decision making sovereignty# tru = demands for truth speaking sovereigntydf$source_cred <-rowMeans(subset(df, select=c(source_exp, source_comp, source_trust)))corrout1 <-corr.test(subset(df, select=c(mis_rating, acc_rating, grep("scipop_",colnames(df)),grep("tpe_",colnames(df)),grep("source_cred",colnames(df)))))corrplot( corrout1$r,p.mat = corrout1$p, # add p-valuessig.level =0.05, # hide correlations above this p-valueinsig ="blank", # or "pch" to mark nonsignificant onesmethod ="color",type ="upper",tl.col ="black",tl.srt =45,addCoef.col ="black",number.cex =0.8)
Paired t-test
data: df$tpe_self and df$tpe_othr
t = -9.0498, df = 183, p-value < 2.2e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-1.3007631 -0.8351065
sample estimates:
mean of the differences
-1.067935
Call:
lm(formula = source_cred ~ tpe_diff + samp, data = df)
Residuals:
Min 1Q Median 3Q Max
-2.36809 -0.50817 0.02176 0.58227 2.26239
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.34249 0.07987 4.288 2.93e-05 ***
tpe_diff -0.20218 0.05330 -3.793 0.000202 ***
sampSONA -0.63685 0.13280 -4.796 3.37e-06 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.8268 on 181 degrees of freedom
Multiple R-squared: 0.1959, Adjusted R-squared: 0.187
F-statistic: 22.04 on 2 and 181 DF, p-value: 2.707e-09
Plot
Code
p <-plot_model(regout4, type ="eff")p[[1]] +ylim(-2, 2)
Code
# get the effect data from plot_modeleffect_data <- p[[1]]$dataggplot() +# raw data points behindgeom_point(data = df, aes(x = tpe_diff, y = source_cred),alpha =0.3, color ="gray40", size =3) +# regression line + CI ribbongeom_ribbon(data = effect_data, aes(x = x, ymin = conf.low, ymax = conf.high),alpha =0.2, fill ="#E6B10E") +geom_line(data = effect_data, aes(x = x, y = predicted),color ="#E6B10E", linewidth =1) +ylim(-2, 2) +labs(x ="Third Person Effect", y ="Source Credibility",title ="Effect of Third Person Effect on Source Credibility") +theme_minimal()
p <-plot_model(regout4, type ="eff")# p[[3]] + ylim(-2, 2)# get the effect data from plot_modeleffect_data <- p[[3]]$dataggplot() +# raw data points behindgeom_point(data = df, aes(x = scipop_dec, y = source_cred),alpha =0.3, color ="gray40", size =3) +# regression line + CI ribbongeom_ribbon(data = effect_data, aes(x = x, ymin = conf.low, ymax = conf.high),alpha =0.2, fill ="#E6B10E") +geom_line(data = effect_data, aes(x = x, y = predicted),color ="#E6B10E", linewidth =1) +ylim(-2, 2) +labs(x ="Science Populism - Decision Making", y ="Source Credibility",title ="Effect of Science Populism on Source Credibility") +theme_minimal()