Run full regression diagnostics on the second regression model. These include diagnostics for functional form, heteroscedasticity, normality, multicollinearity, and influential data points. Attempt to make corrections for any violations.

Using the 2016 ANES, replicate the analysis with feelings towards Trump using feelings towards Hillary
Clinton. The variable for Clinton is V161086 and use the same 8 predictor variables.


Functional Form



x11()

plot(y=model.2$residuals,x=model.2$fitted.values, xlab="Fitted Values", ylab="Residuals")

abline(h=0, col="red")





It does not look like the local means are 0, thus we may have violated functional form.

library(lmtest)

Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

as.Date, as.Date.numeric

resettest(model.2, power=2:3, type="fitted")

RESET test

data: model.2

RESET = 9.5918, df1 = 2, df2 = 1202, p-value = 7.366e-05

We find that p  .05, thus rejecting the null and concluding we have violated the functional form assumptions.

x11()

crPlots(model.2)



It appears that education and partisan identification are the least linearly related to our outcome variable.

dwtest(model.2, order.by=nes2$gender)

Durbin-Watson test

data: model.2

DW = 1.9785, p-value = 0.3426

alternative hypothesis: true autocorrelation is greater than 0

dwtest(model.2, order.by=nes2$education)

Durbin-Watson test

data: model.2

DW = 1.9288, p-value = 0.1014

alternative hypothesis: true autocorrelation is greater than 0

dwtest(model.2, order.by=nes2$pid.num)

Durbin-Watson test

data: model.2

DW = 1.9279, p-value = 0.09921

alternative hypothesis: true autocorrelation is greater than 0

wtest(model.2, order.by=nes2$ideology.num)

Durbin-Watson test

data: model.2

DW = 2.0368, p-value = 0.7294

alternative hypothesis: true autocorrelation is greater than 0

dwtest(model.2, order.by=nes2$hc.law.num)

Durbin-Watson test

data: model.2

DW = 1.9537, p-value = 0.2012

alternative hypothesis: true autocorrelation is greater than 0

dwtest(model.2, order.by=nes2$economy.num)

Durbin-Watson test

data: model.2

DW = 2.0153, p-value = 0.5931

alternative hypothesis: true autocorrelation is greater than 0

dwtest(model.2, order.by=nes2$wall.num)

Durbin-Watson test

data: model.2

DW = 1.9788, p-value = 0.3455

alternative hypothesis: true autocorrelation is greater than 0

dwtest(model.2, order.by=nes2$isis.num)

Durbin-Watson test

data: model.2

DW = 2.0122, p-value = 0.5721

alternative hypothesis: true autocorrelation is greater than 0

According to the DW tests, none of our predictors appear problematic. But, let’s use a Box-Tidwell test to check education and partisan identification.

We need to create a new Clinton variable that does not have 0. 1

nes2$clinton2 <- nes2$clinton +1

boxTidwell(clinton2 ~ education + pid.num, data=nes2, na.action=na.exclude)

Warning in boxTidwell.default(y, X1, X2, max.iter = max.iter, tol = tol, :

1Notice the warning message that the maximum iterations were exceeded and thus the test did not converge on a final set of estimates. We can set the maximum number of iterations by including max.iter=. In this specific case, there was still a warning message after increasing the number of iterations mutiple times, but in all scenarios the results wind-up roughly the same.

maximum iterations exceeded

MLE of lambda Score Statistic (z) Pr(>|z|)

education 10.97818 1.8484 0.064547 .

pid.num 0.74844 2.6679 0.007633 **

---

Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

iterations = 26

We see that we do not need to transform education, but we do need to transform pid.num. We need to

raise pid.num by .748.

summary(model.2a <- lm(clinton ~ gender + education + pid.num + I(pid.num^.748) +

ideology.num + hc.law.num + economy.num + wall.num + isis.num,

data=nes2))

Call:

lm(formula = clinton ~ gender + education + pid.num + I(pid.num^0.748) +

ideology.num + hc.law.num + economy.num + wall.num + isis.num,

data = nes2)

Residuals:

Min 1Q Median 3Q Max

-76.782 -12.464 -0.868 12.149 98.315

Coefficients:

Estimate Std. Error t value Pr(>|t|)

(Intercept) 74.1997 7.2859 10.184 < 2e-16 ***

gender1. Female 2.4292 1.1804 2.058 0.039809 *

education -0.3420 0.2657 -1.287 0.198315

pid.num 8.6415 4.4493 1.942 0.052345 .

I(pid.num^0.748) -28.4419 8.0732 -3.523 0.000443 ***

ideology.num -0.6363 0.5473 -1.163 0.245243

hc.law.num 3.4649 0.3160 10.964 < 2e-16 ***

economy.num 3.8339 0.6712 5.712 1.40e-08 ***

wall.num -1.7655 0.3110 -5.676 1.73e-08 ***

isis.num -0.3671 0.3007 -1.221 0.222395

---

Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 20.12 on 1203 degrees of freedom

Multiple R-squared: 0.6439, Adjusted R-squared: 0.6413

F-statistic: 241.7 on 9 and 1203 DF, p-value: < 2.2e-16

The transformed partisan identification is significant, but the coefficient is very strange. This indicates that

we should be suspicious of using this model.

x11()

crPlots(model.2a)



9.2 Heteroscedasticity



x11()

plot(y=model.2$residuals,x=model.2$fitted.values, xlab="Fitted Values", ylab="Residuals")

abline(h=0, col="red")



As you may have concluded when we first created the plot, there appears to be heteroscedasticity present; the downwards-slanting residuals clearly make for a pattern.



bptest(model.2, studentize=FALSE)



Breusch-Pagan test

data: model.2

BP = 45.018, df = 8, p-value = 3.651e-07

Since p  .05, we reject the null of constant error variance and conclude that we have heteroscedasticity. To

deal with heteroscedasticity, we will re-run our model with robust standard errors using the coeftest()

function from the sandwich library.



library(sandwich)

coeftest(model.2, vcov = vcovHC)



t test of coefficients:

Estimate Std. Error t value Pr(>|t|)

(Intercept) 56.32244 5.70546 9.8717 < 2.2e-16 ***

gender1. Female 2.90697 1.17780 2.4681 0.01372 *

education -0.30113 0.27013 -1.1148 0.26517

pid.num -6.96075 0.51496 -13.5170 < 2.2e-16 ***

ideology.num -0.45376 0.62835 -0.7221 0.47035

hc.law.num 3.53857 0.37419 9.4566 < 2.2e-16 ***

economy.num 3.86514 0.70384 5.4915 4.857e-08 ***

wall.num -1.65448 0.36514 -4.5311 6.451e-06 ***

isis.num -0.29145 0.32757 -0.8897 0.37380

---

Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

We find the same significance results as we did before.

9.3 Normality

x11()

hist(model.2$residuals,xlab="Residuals",main="")



The residuals are somewhat normally distributed, but there are long tails. This suggests we may have

violated the normality assumption.



x11()

qqnorm(model.2$residuals)

qqline(model.2$residuals,col="red")

Social Work & Human Services

You might also like to view...

Potential disadvantages of giving members decision making authority do not include

a) The amount of time spent in group decision making b) Expectations that future decisions will also be made through group participation c) The possibility that group decision could cause conflict among members who have to work together every day d) The fact that group decisions could be better than individual decisions

Social Work & Human Services

Identify and describe the 4 types of sampling methods that can be used in qualitative research. Give an example of each type of sampling method.

What will be an ideal response?

Social Work & Human Services

In the task-centered model, the task implementation sequence is complete when a social worker and his or her client:

A) ?summarize the task plan. B) ?review progress of the tasks. C) ?develop general tasks. D) ?specify a level of change.

Social Work & Human Services

The home-based model:

a. Relies upon a theoretical view that says problems occurring with an individual family member are an indication of problems in the whole family. b. Believes that families experiencing difficulty can only improve when all members of the family are engaged in the change process. c. Operates on the assumption that families are more likely to be open to change during a crisis when they are experiencing extreme discomfort and discovering that family coping mechanisms can no longer maintain family stability and independence. d. Both A and B

Social Work & Human Services