Data
library(tidyverse)
library(magrittr)
tab4 <- read_csv("G:/My Drive/homework/Jenna S/oliverwoodtab4.csv")
tab4 %<>% select(!X1)
tab4 %>%
pivot_longer(names_to = "Variable", values_to = "value", cols = everything()) %>%
ggplot(aes(value)) +
geom_boxplot() +
facet_wrap(vars(Variable), scales = "free")

tab4 %>%
select(!psc) %>%
pivot_longer(names_to = "Variable", values_to = "value", cols = everything()) %>%
ggplot(aes(value)) +
geom_bar() +
facet_wrap(vars(Variable), scales = "free")

tab4 %>%
ggplot(aes(psc)) +
geom_histogram()

tab4 %>%
select(!c(paranormscale, psc, inteff, exteffic)) %>%
mutate(across(.cols = everything(), as_factor)) %>%
summary()
## theolscale goodevil endtimes2 cabal ednumeric female black hispanic
## 1 :128 1 : 94 1 :281 1 : 43 1: 30 0:455 0:912 0:947
## 1.5: 46 2 :233 1.5:192 2 :144 2:352 1:545 1: 88 1: 53
## 2 :195 3 :311 2 :274 3 :248 3:216
## 2.5: 79 4 :250 2.5:136 4 :339 4: 89
## 3 :552 5 :110 3 :117 5 :224 5:217
## NA's: 2 NA's: 2 6: 96
## libdum consdum demdum gopdum polintnum trustind1 RWA imprelnum
## 0:693 0:577 0:537 0:633 1 : 69 1:544 0 :219 1:143
## 1:307 1:423 1:463 1:367 2 :105 2:456 0.5:376 2:166
## 3 :248 1 :405 3:258
## 4 :561 4:433
## NA's: 17
##
tab4 %>%
pivot_longer(names_to = "Variable", values_to = "Value", cols = everything()) %>%
group_by(Variable) %>%
summarize(Mean = mean(Value, na.rm = TRUE),
Std.Dev. = sd(Value, na.rm = TRUE),
Minimum = min(Value, na.rm = TRUE),
Maximum = max(Value, na.rm = TRUE),
NAs = sum(is.na(Value)
)
)
## # A tibble: 20 x 6
## Variable Mean Std.Dev. Minimum Maximum NAs
## * <chr> <dbl> <dbl> <dbl> <dbl> <int>
## 1 black 8.80e- 2 0.283 0 1 0
## 2 cabal 3.56e+ 0 1.12 1 5 2
## 3 consdum 4.23e- 1 0.494 0 1 0
## 4 demdum 4.63e- 1 0.499 0 1 0
## 5 ednumeric 3.40e+ 0 1.46 1 6 0
## 6 endtimes2 1.81e+ 0 0.666 1 3 0
## 7 exteffic 2.32e+ 0 0.978 1 5 0
## 8 female 5.45e- 1 0.498 0 1 0
## 9 goodevil 3.05e+ 0 1.14 1 5 2
## 10 gopdum 3.67e- 1 0.482 0 1 0
## 11 hispanic 5.30e- 2 0.224 0 1 0
## 12 imprelnum 2.98e+ 0 1.08 1 4 0
## 13 inteff 3.30e+ 0 1.02 1 5 0
## 14 libdum 3.07e- 1 0.461 0 1 0
## 15 paranormscale 2.91e+ 0 1.20 1 5 0
## 16 polintnum 3.32e+ 0 0.924 1 4 17
## 17 psc 2.00e-11 0.929 -1.86 1.09 0
## 18 RWA 5.93e- 1 0.384 0 1 0
## 19 theolscale 2.44e+ 0 0.720 1 3 0
## 20 trustind1 1.46e+ 0 0.498 1 2 0
Supernateral
# try scaling all data first?
model.fit <-
tab4 %>%
select(theolscale, ednumeric:imprelnum) %>%
lm(theolscale ~ ., data = .)
model.fit %>% summary()
##
## Call:
## lm(formula = theolscale ~ ., data = .)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.81710 -0.32348 0.05551 0.31658 1.46319
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.732864 0.124228 13.949 < 2e-16 ***
## ednumeric -0.041931 0.012732 -3.293 0.001026 **
## female 0.077338 0.036538 2.117 0.034546 *
## black 0.167011 0.064870 2.575 0.010185 *
## hispanic -0.005636 0.076715 -0.073 0.941452
## libdum -0.095031 0.050550 -1.880 0.060416 .
## consdum -0.005215 0.048778 -0.107 0.914883
## demdum -0.075361 0.053312 -1.414 0.157804
## gopdum 0.132670 0.056345 2.355 0.018742 *
## polintnum -0.051789 0.024760 -2.092 0.036729 *
## psc 0.007387 0.025492 0.290 0.772042
## trustind1 -0.075257 0.035870 -2.098 0.036160 *
## inteff -0.007986 0.021180 -0.377 0.706205
## exteffic -0.027544 0.017844 -1.544 0.123001
## RWA 0.165535 0.048690 3.400 0.000702 ***
## imprelnum 0.363514 0.017418 20.870 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5264 on 967 degrees of freedom
## (17 observations deleted due to missingness)
## Multiple R-squared: 0.4786, Adjusted R-squared: 0.4705
## F-statistic: 59.17 on 15 and 967 DF, p-value: < 2.2e-16
model.fit %>% coefficients() %>% scale
## [,1]
## (Intercept) 3.60717579
## ednumeric -0.41524415
## female -0.14493231
## black 0.05830388
## hispanic -0.33298461
## libdum -0.53559033
## consdum -0.33203049
## demdum -0.49101174
## gopdum -0.01952613
## polintnum -0.43758625
## psc -0.30346915
## trustind1 -0.49077417
## inteff -0.33831201
## exteffic -0.38263845
## RWA 0.05495917
## imprelnum 0.50366097
## attr(,"scaled:center")
## [1] 0.1412855
## attr(,"scaled:scale")
## [1] 0.4412256
Manichean
model.fit <-
tab4 %>%
select(goodevil, ednumeric:imprelnum) %>%
lm(goodevil ~ ., data = .)
model.fit %>% summary()
##
## Call:
## lm(formula = goodevil ~ ., data = .)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.9746 -0.7373 -0.0462 0.7729 2.6095
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.47672 0.24873 13.978 < 2e-16 ***
## ednumeric -0.08741 0.02550 -3.428 0.000633 ***
## female 0.17857 0.07312 2.442 0.014784 *
## black 0.27217 0.12977 2.097 0.036220 *
## hispanic 0.17003 0.15500 1.097 0.272950
## libdum -0.03213 0.10138 -0.317 0.751388
## consdum 0.20337 0.09787 2.078 0.037975 *
## demdum -0.06561 0.10672 -0.615 0.538846
## gopdum -0.10058 0.11286 -0.891 0.373030
## polintnum 0.07404 0.04953 1.495 0.135308
## psc -0.09526 0.05105 -1.866 0.062327 .
## trustind1 -0.25218 0.07188 -3.508 0.000472 ***
## inteff -0.07262 0.04246 -1.710 0.087558 .
## exteffic -0.16659 0.03579 -4.655 3.7e-06 ***
## RWA 0.30714 0.09743 3.152 0.001669 **
## imprelnum 0.10059 0.03485 2.886 0.003986 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.053 on 965 degrees of freedom
## (19 observations deleted due to missingness)
## Multiple R-squared: 0.1608, Adjusted R-squared: 0.1477
## F-statistic: 12.33 on 15 and 965 DF, p-value: < 2.2e-16
model.fit %>% coefficients() %>% scale
## [,1]
## (Intercept) 3.68407470
## ednumeric -0.37816621
## female -0.07502014
## black 0.03166000
## hispanic -0.08475724
## libdum -0.31516244
## consdum -0.04675047
## demdum -0.35332512
## gopdum -0.39318224
## polintnum -0.19416250
## psc -0.38712202
## trustind1 -0.56597161
## inteff -0.36131428
## exteffic -0.46841616
## RWA 0.07151591
## imprelnum -0.16390015
## attr(,"scaled:center")
## [1] 0.24439
## attr(,"scaled:scale")
## [1] 0.8773793
End Times
model.fit <-
tab4 %>%
select(endtimes2, ednumeric:imprelnum) %>%
lm(endtimes2 ~ ., data = .)
model.fit %>% summary()
##
## Call:
## lm(formula = endtimes2 ~ ., data = .)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.31342 -0.33750 -0.02618 0.39038 1.44529
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.38426 0.12572 11.010 < 2e-16 ***
## ednumeric -0.05166 0.01289 -4.009 6.56e-05 ***
## female 0.05289 0.03698 1.430 0.152930
## black 0.42225 0.06565 6.432 1.98e-10 ***
## hispanic -0.01123 0.07764 -0.145 0.885074
## libdum -0.03555 0.05116 -0.695 0.487301
## consdum 0.21247 0.04937 4.304 1.85e-05 ***
## demdum -0.17088 0.05395 -3.167 0.001588 **
## gopdum -0.02053 0.05702 -0.360 0.718865
## polintnum 0.03004 0.02506 1.199 0.230963
## psc -0.10711 0.02580 -4.152 3.59e-05 ***
## trustind1 -0.12008 0.03630 -3.308 0.000975 ***
## inteff -0.02018 0.02144 -0.941 0.346777
## exteffic 0.01361 0.01806 0.753 0.451345
## RWA 0.13587 0.04928 2.757 0.005937 **
## imprelnum 0.19061 0.01763 10.813 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5327 on 967 degrees of freedom
## (17 observations deleted due to missingness)
## Multiple R-squared: 0.371, Adjusted R-squared: 0.3613
## F-statistic: 38.03 on 15 and 967 DF, p-value: < 2.2e-16
model.fit %>% coefficients() %>% scale
## [,1]
## (Intercept) 3.43795011
## ednumeric -0.46386980
## female -0.17976384
## black 0.82388785
## hispanic -0.35399249
## libdum -0.42008784
## consdum 0.25384753
## demdum -0.78781973
## gopdum -0.37928564
## polintnum -0.24187554
## psc -0.61453579
## trustind1 -0.64977244
## inteff -0.37831950
## exteffic -0.28651668
## RWA 0.04571161
## imprelnum 0.19444219
## attr(,"scaled:center")
## [1] 0.1190487
## attr(,"scaled:scale")
## [1] 0.3680127
Secret Cabal
model.fit <-
tab4 %>%
select(cabal, ednumeric:imprelnum) %>%
lm(cabal ~ ., data = .)
model.fit %>% summary()
##
## Call:
## lm(formula = cabal ~ ., data = .)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.4256 -0.6499 0.1530 0.7080 2.6415
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.247871 0.239261 17.754 < 2e-16 ***
## ednumeric -0.063421 0.024523 -2.586 0.00985 **
## female 0.220297 0.070380 3.130 0.00180 **
## black 0.086569 0.125406 0.690 0.49017
## hispanic -0.042081 0.147566 -0.285 0.77558
## libdum 0.139917 0.097406 1.436 0.15120
## consdum 0.168977 0.093847 1.801 0.07208 .
## demdum 0.110832 0.102553 1.081 0.28009
## gopdum -0.142007 0.108423 -1.310 0.19059
## polintnum 0.102593 0.047669 2.152 0.03163 *
## psc -0.035657 0.049077 -0.727 0.46768
## trustind1 -0.070242 0.069039 -1.017 0.30920
## inteff -0.008075 0.040941 -0.197 0.84369
## exteffic -0.425772 0.034343 -12.398 < 2e-16 ***
## RWA 0.133549 0.093690 1.425 0.15435
## imprelnum -0.001612 0.033518 -0.048 0.96165
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.012 on 965 degrees of freedom
## (19 observations deleted due to missingness)
## Multiple R-squared: 0.1843, Adjusted R-squared: 0.1716
## F-statistic: 14.53 on 15 and 965 DF, p-value: < 2.2e-16
model.fit %>% coefficients() %>% scale
## [,1]
## (Intercept) 3.71091208
## ednumeric -0.31748414
## female -0.05238262
## black -0.17733641
## hispanic -0.29754433
## libdum -0.12748836
## consdum -0.10033557
## demdum -0.15466558
## gopdum -0.39091364
## polintnum -0.16236348
## psc -0.29154195
## trustind1 -0.32385790
## inteff -0.26576941
## exteffic -0.65605877
## RWA -0.13343880
## imprelnum -0.25973112
## attr(,"scaled:center")
## [1] 0.2763586
## attr(,"scaled:scale")
## [1] 1.070225
Paranormal
model.fit <-
tab4 %>%
select(paranormscale, ednumeric:imprelnum) %>%
lm(paranormscale ~ ., data = .)
model.fit %>% summary()
##
## Call:
## lm(formula = paranormscale ~ ., data = .)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.68608 -0.89758 -0.02112 0.87631 2.97541
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.099337 0.266750 11.619 < 2e-16 ***
## ednumeric -0.111225 0.027339 -4.068 5.12e-05 ***
## female 0.399989 0.078457 5.098 4.12e-07 ***
## black -0.193257 0.139292 -1.387 0.16563
## hispanic -0.114785 0.164728 -0.697 0.48609
## libdum -0.003602 0.108544 -0.033 0.97353
## consdum -0.087073 0.104740 -0.831 0.40600
## demdum -0.126752 0.114475 -1.107 0.26847
## gopdum -0.054936 0.120988 -0.454 0.64989
## polintnum 0.045437 0.053165 0.855 0.39297
## psc -0.241022 0.054737 -4.403 1.19e-05 ***
## trustind1 -0.040492 0.077022 -0.526 0.59921
## inteff 0.022143 0.045480 0.487 0.62645
## exteffic -0.092054 0.038315 -2.403 0.01647 *
## RWA -0.269906 0.104550 -2.582 0.00998 **
## imprelnum 0.109222 0.037400 2.920 0.00358 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.13 on 967 degrees of freedom
## (17 observations deleted due to missingness)
## Multiple R-squared: 0.1228, Adjusted R-squared: 0.1092
## F-statistic: 9.022 on 15 and 967 DF, p-value: < 2.2e-16
model.fit %>% coefficients() %>% scale
## [,1]
## (Intercept) 3.6781854
## ednumeric -0.3207819
## female 0.3159689
## black -0.4229580
## hispanic -0.3252159
## libdum -0.1867308
## consdum -0.2906987
## demdum -0.3401214
## gopdum -0.2506698
## polintnum -0.1256497
## psc -0.4824527
## trustind1 -0.2326790
## inteff -0.1546630
## exteffic -0.2969026
## RWA -0.5184301
## imprelnum -0.0462008
## attr(,"scaled:center")
## [1] 0.1463141
## attr(,"scaled:scale")
## [1] 0.8028477