library(readxl)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.2.1 ✔ readr 2.2.0
## ✔ forcats 1.0.1 ✔ stringr 1.6.0
## ✔ ggplot2 4.0.3 ✔ tibble 3.3.1
## ✔ lubridate 1.9.5 ✔ tidyr 1.3.2
## ✔ purrr 1.2.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(ggplot2)
RLS<-read.csv("RLS Public Use File Feb.csv")
RLS_Example<-lm(RLS$QB2C~RLS$RELTRAD)
summary(RLS_Example)
##
## Call:
## lm(formula = RLS$QB2C ~ RLS$RELTRAD)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.735 -2.730 -1.734 -1.687 95.702
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.735e+00 8.069e-02 46.29 <2e-16 ***
## RLS$RELTRAD -4.853e-07 7.240e-07 -0.67 0.503
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 14.04 on 36906 degrees of freedom
## Multiple R-squared: 1.218e-05, Adjusted R-squared: -1.492e-05
## F-statistic: 0.4494 on 1 and 36906 DF, p-value: 0.5026
In this above data set we see that the depdent variable QB2C, which is support for environmentalist polcies, and the indepedent variable RELTRAD, the religious tradition that a person identifies with, have a p-value 0.50, which means there is a standard devation of 50. The Estimated realtion is -4.853e-07, which also shows a large number with a negative correlation. From the above data, the results of this linear model show that the correlation between religious tradition and support for environmental related policy is not strong.
plot(RLS_Example, which=1)
This do not meet the linear regression model at all. This chart would
assume that there is no correlation between the two variables.
RLS_Example2<-lm(QB2C~RELTRAD+RELIMP+RELPER, data=RLS)
summary(RLS_Example2)
##
## Call:
## lm(formula = QB2C ~ RELTRAD + RELIMP + RELPER, data = RLS)
##
## Residuals:
## Min 1Q Median 3Q Max
## -13.434 -2.571 -1.755 -1.643 96.778
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.462e+00 8.646e-02 40.038 < 2e-16 ***
## RELTRAD -1.500e-06 7.330e-07 -2.047 0.0407 *
## RELIMP 6.821e-02 1.095e-02 6.230 4.70e-10 ***
## RELPER 4.263e-02 8.508e-03 5.010 5.45e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 14.02 on 36904 degrees of freedom
## Multiple R-squared: 0.002081, Adjusted R-squared: 0.002
## F-statistic: 25.66 on 3 and 36904 DF, p-value: < 2.2e-16
The above chart shows that RELTRAD, one’s religious tradition has a low correlation while RELIMP & RELPER, which represent levels of religiosity show high correlation to the dependent variable in question. Overall, the p-value for the entire model shows high accuracy since it is 2.23-16.
plot(RLS_Example2, which=1)
The line above does showe a correlation between two of the variables,
RELIMP & RELPER.