library(poliscidata)
## Registered S3 method overwritten by 'gdata':
##   method         from  
##   reorder.factor gplots

Q1

Q1A

wtd.cor(cbind(states$demhr11, states$demstate13, states$union10))
## Warning in summary.lm(lm(stdz(y, weight = weight) ~ stdz(x, weight = weight), :
## essentially perfect fit: summary may be unreliable

## Warning in summary.lm(lm(stdz(y, weight = weight) ~ stdz(x, weight = weight), :
## essentially perfect fit: summary may be unreliable

## Warning in summary.lm(lm(stdz(y, weight = weight) ~ stdz(x, weight = weight), :
## essentially perfect fit: summary may be unreliable
## $correlation
##           V1        V2        V3
## V1 1.0000000 0.8101339 0.4889759
## V2 0.8101339 1.0000000 0.6107600
## V3 0.4889759 0.6107600 1.0000000
## 
## $std.err
##              V1           V2           V3
## V1 9.432950e-17 8.461717e-02 1.259053e-01
## V2 8.461717e-02 4.988511e-17 1.142888e-01
## V3 1.259053e-01 1.142888e-01 7.610520e-17
## 
## $t.value
##              V1           V2           V3
## V1 1.060114e+16 9.574108e+00 3.883681e+00
## V2 9.574108e+00 2.004606e+16 5.344008e+00
## V3 3.883681e+00 5.344008e+00 1.313971e+16
## 
## $p.value
##              V1           V2           V3
## V1 0.000000e+00 1.032423e-12 3.142987e-04
## V2 1.032423e-12 0.000000e+00 2.474964e-06
## V3 3.142987e-04 2.474964e-06 0.000000e+00

Q1B

Increases

Q1C

Decreases

Q1D

Yes. The percentage of workers who are union members is more highly correlated with percent state legislators who are Democratic (0.61) than it is with U.S. representatives who are Democratic (0.49).

Q2

Q2A

A negative sign on permit’s regression coefficient. (The more the public thinks abortion should be always be permitted the fewer restrictions the legislature should pass).

Q2B

summary(lm(states$abortlaw10 ~ states$permit))
## 
## Call:
## lm(formula = states$abortlaw10 ~ states$permit)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -3.768 -1.126  0.066  1.108  3.717 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    13.1709     1.0900  12.083 1.38e-14 ***
## states$permit  -0.1839     0.0287  -6.407 1.57e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.785 on 38 degrees of freedom
##   (10 observations deleted due to missingness)
## Multiple R-squared:  0.5193, Adjusted R-squared:  0.5067 
## F-statistic: 41.05 on 1 and 38 DF,  p-value: 1.575e-07

Q2C

summary(lm(states$abortlaw10 ~ states$permit + states$womleg_2015))
## 
## Call:
## lm(formula = states$abortlaw10 ~ states$permit + states$womleg_2015)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.6642 -1.1509  0.2625  1.1423  3.1513 
## 
## Coefficients:
##                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)        13.63712    1.14677  11.892 3.33e-14 ***
## states$permit      -0.15608    0.03634  -4.295 0.000121 ***
## states$womleg_2015 -0.06388    0.05182  -1.233 0.225448    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.773 on 37 degrees of freedom
##   (10 observations deleted due to missingness)
## Multiple R-squared:  0.5383, Adjusted R-squared:  0.5133 
## F-statistic: 21.57 on 2 and 37 DF,  p-value: 6.18e-07

Q2D

0.0001, 0.23

Q2E

No. Controlling for the percentage of women in the state legislature, the percentage of the public that thinks abortion should be always be permitted still has a significantly negative effect on the number of abortion restrictions passed into law.

Q3

Q3A

summary(svyglm(femrole ~ age, design=gssD))
## 
## Call:
## svyglm(formula = ..1, design = ..2)
## 
## Survey design:
## survey::svydesign(id = ~1, data = gss, weights = ~wtss)
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  6.04604    0.18060  33.477  < 2e-16 ***
## age         -0.01279    0.00351  -3.644 0.000279 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 3.635285)
## 
## Number of Fisher Scoring iterations: 2
fit.svyglm(svyglm(femrole ~ age, design=gssD))
##               R-Squared      Adjusted R-Squared 
##                   0.013                   0.012

Q3B

summary(svyglm(femrole ~ age + authoritarianism, design=gssD))
## 
## Call:
## svyglm(formula = ..1, design = ..2)
## 
## Survey design:
## survey::svydesign(id = ~1, data = gss, weights = ~wtss)
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       6.873458   0.273175  25.161  < 2e-16 ***
## age              -0.015206   0.004893  -3.107  0.00197 ** 
## authoritarianism -0.251422   0.044381  -5.665 2.22e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 3.319108)
## 
## Number of Fisher Scoring iterations: 2
fit.svyglm(svyglm(femrole ~ age + authoritarianism, design=gssD))
##               R-Squared      Adjusted R-Squared 
##                   0.080                   0.077

Correct. The regression coefficient for the age variable in the bivariate regression above is negative and statistically significant. As age increases, support for non-traditional female roles tends to decrease.

Q3C

Q3D

Correct. The regression coefficient for the authoritarianism variable in the bivariate regression above is negative and statistically significant. As support for authoritarianism increases, support for non-traditional female roles tends to decrease.

Q3E

Incorrect. The partial regression coefficient for the age variable in the multiple regression shows the effect of age on support for non-traditional female roles controlling for support for authoritarianism. The partial regression coefficient for age is negative and statistically significant

Q4

Q4A

# Note: The directions don't say whether the regression should be weighted
# so code for both unweighted and weighted regressions appears below.
 summary(lm(fedspend_scale ~ owngun_owngun, data=nes))
## 
## Call:
## lm(formula = fedspend_scale ~ owngun_owngun, data = nes)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -10.729  -2.135   0.271   2.271   6.865 
## 
## Coefficients:
##                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)         9.13498    0.07993  114.29   <2e-16 ***
## owngun_owngun2. No  1.59401    0.09701   16.43   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.37 on 5536 degrees of freedom
##   (378 observations deleted due to missingness)
## Multiple R-squared:  0.04651,    Adjusted R-squared:  0.04633 
## F-statistic:   270 on 1 and 5536 DF,  p-value: < 2.2e-16
# Expected support of non-gun owner = 9.13 + 1.59 = 10.72
 summary(svyglm(fedspend_scale ~ owngun_owngun, design=nesD))
## 
## Call:
## svyglm(formula = ..1, design = ..2)
## 
## Survey design:
## survey::svydesign(id = ~1, data = nes, weights = ~wt)
## 
## Coefficients:
##                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)          9.0366     0.1038   87.05   <2e-16 ***
## owngun_owngun2. No   1.3401     0.1259   10.64   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 10.84832)
## 
## Number of Fisher Scoring iterations: 2
# Expected support of non-gun owner = 9.04 + 1.34 = 10.38

Q4B

Weighted: support for spending = 10.38 – 1.34*(own gun)

Unweighted: support for spending = 10.73 – 1.59*(own gun)

Q4C

Yes. According to the bivariate regression results, gun owners have significantly lower support for federal spending than non-gun owners. Based on the sample weighted regression results, the probability of observing a 1.34 point difference on the federal spending scale by random chance when the null hypothesis is true is less than 0.001.

Q4D

# Note: This is only needed for weighted regression, the unweighted
# lm summary reports the R-squared statistic
 fit.svyglm(svyglm(fedspend_scale ~ owngun_owngun, design=nesD))
##               R-Squared      Adjusted R-Squared 
##                   0.036                   0.036