diff --git a/Case-Study-3-CodeSup.rmd b/Case-Study-3-CodeSup.rmd index dcab8de..cc09a8c 100644 --- a/Case-Study-3-CodeSup.rmd +++ b/Case-Study-3-CodeSup.rmd @@ -142,6 +142,23 @@ plot(glm.base$residuals) The residuals plot shows that our model generally fits the data. +```{r, message = F, warning = F} +infIndexPlot(stp.inter.fwd, vars = c("hat", "cook")) +anova(stp.inter.fwd, test = "Chisq") +qqnorm(stp.inter.fwd$residuals) +``` + +Our p-values indicate that none of our coefficients are non-significant at the 0.05 level. + +Despite the qqplot indicating a potential lack of normality, this is typical for multiple regression and our model does fit the data as indicated by the Loess smoother on our Deviance residuals plots. + +```{r, message = F, warning = F} +residualPlots(stp.inter.fwd, tests = false, type = "response") +residualPlots(stp.inter.fwd, tests = false, type = "pearson") +residualPlots(stp.inter.fwd, tests = false, type = "deviance") +``` + + diff --git a/Case-Study-3-WriteUp.pdf b/Case-Study-3-WriteUp.pdf index 56304f3..2101e42 100644 Binary files a/Case-Study-3-WriteUp.pdf and b/Case-Study-3-WriteUp.pdf differ diff --git a/Case-Study-3-WriteUp.rmd b/Case-Study-3-WriteUp.rmd index 2dbe9d2..9843833 100644 --- a/Case-Study-3-WriteUp.rmd +++ b/Case-Study-3-WriteUp.rmd @@ -28,10 +28,37 @@ colnames(m) <- c(" ", "Estimate", "Standard error", "z value", "P-value") pander(m, caption = "Important Coefficients of our Logistic Regression Model") ``` -The following set of plots represent what is essentially the relationship between our estimated model and the data for the years 1980 and 2000. +The following set of plots represent what is essentially the relationship between our binary model and the data for the years 1980 and 2000. + +```{r, message = F, warning = F, echo = F, fig.height = 3, fig.width = 6} +library(Sleuth3) +library(dplyr) +library(ggformula) +library(pander) +library(knitr) +library(stargazer) +library(car) +library(pander) +library(gridExtra) +library(broom) +library(ggthemes) +library(MASS) +library(leaps) +library(GGally) +nes <- read.csv("http://aloy.rbind.io/data/NES.csv") -```{r, message = F, warning = F, echo = F} library(ggformula) +library(car) +glm.basic <- glm(dem ~ 1, data = nes, family = binomial) +stp.inter.fwd <- stepAIC(glm.basic, scope = list(lower = ~1, upper = ~ year + region + union + income + educ + gender + race + age + I(age^2) + + age * year + age * region + age * union + age * income + age * educ + age * gender + age * race), + direction = "both", k = log(nrow(nes)), trace = 0) + +par(mfrow=c(1, 2)) +p2 <- crPlot(stp.inter.fwd, variable = "union") +p1 <- crPlot(stp.inter.fwd, variable = "gender") + + ```