Data/.Rhistory View(dta) Data/Ch8_Exercise1_Presidential_approval.dta __MACOSX/Data/._Ch8_Exercise1_Presidential_approval.dta Data/Ch8_Exercise1_Presidential_approval.RData...

1 answer below »

View more »
Answered 9 days AfterNov 03, 2021

Answer To: Data/.Rhistory View(dta) Data/Ch8_Exercise1_Presidential_approval.dta...

Mohd answered on Nov 13 2021
117 Votes
-
-
-
11/13/2021
library(readr)
library(magrittr)
library(dplyr)
library(ggplot2)
library(rmarkdown)
library(MASS)
library(skimr)
library(ggeffects)
library(haven)
Ch8_Exercise<- read_dta("~/data/Ch8_Exercise1_Presidential_approval.dta")
View(Ch8_Exercise)
mod_pres<-lm(PresApprov~UnemPct,data=Ch8_Exercise)
summary(mod_pres)
##
## Call:
## lm(formula = PresApprov ~ UnemPct, data = Ch8_Exercise)
##
## Residuals:
## Min 1Q Median 3Q Max
## -40.654 -9.320 -1.654 7.576 49.374
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)

## (Intercept) 42.1773 0.8745 48.232 <2e-16 ***
## UnemPct 0.2786 0.1650 1.688 0.0914 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 12.97 on 3510 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.0008115, Adjusted R-squared: 0.0005269
## F-statistic: 2.851 on 1 and 3510 DF, p-value: 0.09142
mod_pres2<-lm(PresApprov~UnemPct+South,data=Ch8_Exercise)
summary(mod_pres2)
##
## Call:
## lm(formula = PresApprov ~ UnemPct + South, data = Ch8_Exercise)
##
## Residuals:
## Min 1Q Median 3Q Max
## -40.015 -9.035 -1.915 7.766 50.005
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 41.9603 0.8722 48.108<2e-16 ***
## UnemPct 0.1990 0.1651 1.205 0.228
## South 2.7058 0.5193 5.210 2e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 12.92 on 3509 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.008482, Adjusted R-squared: 0.007917
## F-statistic: 15.01 on 2 and 3509 DF, p-value: 3.232e-07
Presapp_demeaned <- with(Ch8_Exercise,
data.frame(PresApprov = PresApprov - ave(PresApprov, South),
UnemPct = UnemPct - ave(UnemPct, South)))
# estimate the regression
summary(lm(PresApprov ~ UnemPct - 1, data = Presapp_demeaned))
##
## Call:
## lm(formula = PresApprov ~ UnemPct - 1, data = Presapp_demeaned)
##
## Residuals:
## Min 1Q Median 3Q Max
## -36.383 -7.479 -1.578 5.532 45.422
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## UnemPct 0.9957 0.2523 3.947 8.6e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 10.78 on 811 degrees of freedom
## (2701 observations deleted due to missingness)
## Multiple R-squared: 0.01885, Adjusted R-squared: 0.01764
## F-statistic: 15.58 on 1 and 811 DF, p-value: 8.604e-05
summary(lm(PresApprov ~ factor(UnemPct), data = Ch8_Exercise))
##
## Call:
## lm(formula = PresApprov ~ factor(UnemPct), data = Ch8_Exercise)
##
## Residuals:
## Min 1Q Median 3Q Max
## -39.633 -8.521 -1.653 7.336 49.075
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 57.5000 6.1168 9.400< 2e-16 ***
## factor(UnemPct)2.5 -18.5000 6.9949 -2.645 0.008211 **
## factor(UnemPct)2.6 -8.0000 7.8968 -1.013 0.311098
## factor(UnemPct)2.7 -2.5476 6.6740 -0.382 0.702690
## factor(UnemPct)2.8 -5.1923 6.9949 -0.742 0.457954
## factor(UnemPct)2.9 -3.2333 6.8843 -0.470 0.638620
## factor(UnemPct)3 -10.6538 6.3022 -1.690 0.091025 .
## factor(UnemPct)3.1 -9.7000 6.7006 -1.448 0.147814
## factor(UnemPct)3.2 -12.1250 6.8388 -1.773 0.076322 .
## factor(UnemPct)3.3 -4.3605 6.3950 -0.682 0.495376
## factor(UnemPct)3.4 -14.5750 6.4154 -2.272 0.023155 *
## factor(UnemPct)3.5 -17.8426 6.2291 -2.864 0.004203 **
## factor(UnemPct)3.6 -10.0429 6.4569 -1.555 0.119950
## factor(UnemPct)3.7 -11.7250 6.2679 -1.871 0.061479 .
## factor(UnemPct)3.8 -13.6333 6.2513 -2.181 0.029259 *
## factor(UnemPct)3.9 -9.3000 6.4569 -1.440 0.149868
## factor(UnemPct)4 -17.4474 6.4307 -2.713 0.006698 **
## factor(UnemPct)4.1 -16.3919 6.2261 -2.633 0.008507 **
## factor(UnemPct)4.2 -12.7414 6.3242 -2.015 0.044015 *
## factor(UnemPct)4.3 -14.8333 6.2179 -2.386 0.017106 *
## factor(UnemPct)4.4 -18.4406 6.2368 -2.957 0.003130 **
## factor(UnemPct)4.5 -13.8333 6.1783 -2.239 0.025218 *
## factor(UnemPct)4.6 -18.0707 6.1783 -2.925 0.003469 **
## factor(UnemPct)4.7 -15.6649 6.2417 -2.510 0.012128 *
## factor(UnemPct)4.8 -16.5476 6.2608 -2.643 0.008253 **
## factor(UnemPct)4.9 -15.1225 6.1973 -2.440 0.014730 *
## factor(UnemPct)5 -16.3396 6.2312 -2.622 0.008774 **
## factor(UnemPct)5.1 -18.2558 6.2575 -2.917 0.003552 **
## factor(UnemPct)5.2 -9.9786 6.2205 -1.604 0.108772
## factor(UnemPct)5.3 -14.9532 6.2042 -2.410 0.015997 *
## factor(UnemPct)5.4 -19.9719 6.1852 -3.229 0.001254 **
## factor(UnemPct)5.5 -17.8467 6.2778 -2.843 0.004498 **
## factor(UnemPct)5.6 -11.9521 6.2822 -1.903 0.057185 .
## factor(UnemPct)5.7 1.1327 6.3616 0.178 0.858698
## factor(UnemPct)5.8 -11.6778 6.3829 -1.830 0.067405 .
## factor(UnemPct)5.9 -6.5600 6.3568 -1.032 0.302160
## factor(UnemPct)6 -1.2778 6.5543 -0.195 0.845441
## factor(UnemPct)6.1 -15.7766 6.3718 -2.476 0.013334 *
## factor(UnemPct)6.2 -10.7347 6.2404 -1.720 0.085488 .
## factor(UnemPct)6.3 -10.1415 6.3434 -1.599 0.109971
## factor(UnemPct)6.4 -13.8896 6.2737 -2.214 0.026898 *
## factor(UnemPct)6.5 -13.6948 6.2737 -2.183 0.029111 *
## factor(UnemPct)6.6 -9.9286 6.6740 -1.488 0.136935
## factor(UnemPct)6.7 -6.0682 6.3888 -0.950 0.342274
## factor(UnemPct)6.8 -13.5345 ...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here
April
January
February
March
April
May
June
July
August
September
October
November
December
2025
2025
2026
2027
SunMonTueWedThuFriSat
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
00:00
00:30
01:00
01:30
02:00
02:30
03:00
03:30
04:00
04:30
05:00
05:30
06:00
06:30
07:00
07:30
08:00
08:30
09:00
09:30
10:00
10:30
11:00
11:30
12:00
12:30
13:00
13:30
14:00
14:30
15:00
15:30
16:00
16:30
17:00
17:30
18:00
18:30
19:00
19:30
20:00
20:30
21:00
21:30
22:00
22:30
23:00
23:30