(a) For the 2020 election in particular, explain why this
analysis of variance might be more appropriate than just taking
Income as a numerical variable in a linear regression. Hint: You
can find the average partisanship of each income group as
follows:
```{r setup, include=FALSE}
aggregate(Party ~ Income, FUN = mean, data = ANES2020)
```
Is the result consistent with the assumptions of linear
regression?
(b) Calculate the F-statistic and the P-value for this analysis
of variance’s F-test(in r code). What does your analysis of
variance tell you?
8 - {r setup, include=FALSE} 9 knitr::opts_chunk$set(echo = TRUE) 10 library(ggplot2) 11 library(broom) 12 library(knitr) 13 library(tidyverse) 14 15 16 '{r setup, include=FALSE} 17 ANES.df <- read.table("ANES1960-2020.txt", header = TRUE) 18 ANES2020 <- subset(ANES.df, Year 2020) 19 summary(ANES2020) 20
150 4. We could also treat Income as a categorical variable (while continuing to take Party as numerical.) Then if the 2020 election is in a data frame called ANES2020, we could perform an analysis of variance as follows: 151 '{r setup, include=FALSE} 152 anova(Im(Party ~ factor(Income), data ANES2020) 153 154 155 (a) For the 2020 election in particular, explain why this analysis of variance might be more appropriate than just taking Income as a numerical variable in a linear regression. Hint: You can find the average partisanship of each income group as follows: 156 - '{r setup, include=FALSE} 157 aggregate(Party ~ Income, FUN mean, data = ANES2020) 158 - 159 Is the result consistent with the assumptions of linear regression? 160 152:18 C Chunk 11: setup - R Markdown Console Terminal Jobs R R 4.1.2 :~/> > anova(Im(Party- factor(Income), data Analysis of Variance Table = ANES2020) Response: Party Df Sum Sq Mean Sq F value Pr(>F) factor(Income) 4 89 22.2818 4.3822 0.001537 ** Residuals 7953 40438 5.0847 Signif. codes: 0 6*** 0.001 "**' 0.01 "*' 0.05 0.1 ''1
8 - {r setup, include=FALSE} 9 knitr::opts_chunk$set(echo = TRUE) 10 library(ggplot2) 11 library(broom) 12 library(knitr
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
8 - {r setup, include=FALSE} 9 knitr::opts_chunk$set(echo = TRUE) 10 library(ggplot2) 11 library(broom) 12 library(knitr
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!