library(haven)
anes2020<-read_dta("C:\\Users\\USER\\Downloads\\anes2020.dta")
anes2020$V202143[anes2020$V202143 <0] <- NA
anes2020$V202144[anes2020$V202144 <0] <- NA
library(ggplot2)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
ggplot(anes2020) + geom_point(mapping = aes(x=V202143, y=V202144))+
ggtitle(label="Political Thermometer")+
xlab(label="Feelings Toward Biden")+
ylab(label = "Feelings Toward Trump")
## Don't know how to automatically pick scale for object of type haven_labelled/vctrs_vctr/double. Defaulting to continuous.
## Don't know how to automatically pick scale for object of type haven_labelled/vctrs_vctr/double. Defaulting to continuous.
## Warning: Removed 957 rows containing missing values (geom_point).
scatter.smooth(anes2020$V202143,anes2020$V202144)
cor(anes2020$V202143, anes2020$V202144, use = "complete.obs")
## [1] -0.816032
lmTrump = lm(V202144~V202143, data = anes2020)
summary(lmTrump)
##
## Call:
## lm(formula = V202144 ~ V202143, data = anes2020)
##
## Residuals:
## Min 1Q Median 3Q Max
## -86.915 -9.258 4.446 13.085 104.446
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 86.915259 0.486131 178.8 <2e-16 ***
## V202143 -0.913617 0.007563 -120.8 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 23.16 on 7321 degrees of freedom
## (957 observations deleted due to missingness)
## Multiple R-squared: 0.6659, Adjusted R-squared: 0.6659
## F-statistic: 1.459e+04 on 1 and 7321 DF, p-value: < 2.2e-16
The scatter plot shows a strong negative correlation, meaning people who rated Trump high rated Biden poorly and vice verse. The intercept of this data is 86.91, which is the average rating of Donald Trump when Joe Biden is rated zero. This slope is v202143, which shows that for every point that Biden increased you get a decreased in Trumps score by -.913617. This is a strong score that demonstrates the polarization in today’s political climate. The R-squared of .6659 means that 67% if the variation in the feeling for Trump is accounted for by the regression of feelings towards Biden.