Problem 1

A (Row total x column total)/Total sample size

B (200, 200)

Problem 2 A

z = 1.155 

pnorm(z, lower.tail = F)
## [1] 0.1240452

B (1)

Draws <- rpois(40, 5)
t.test(Draws, alternative = "two.sided", mu = 5, conf.level=0.95)
## 
##  One Sample t-test
## 
## data:  Draws
## t = 0.62072, df = 39, p-value = 0.5384
## alternative hypothesis: true mean is not equal to 5
## 95 percent confidence interval:
##  4.491808 5.958192
## sample estimates:
## mean of x 
##     5.225
t.test(Draws, alternative = "two.sided", mu = 8, conf.level=0.95)
## 
##  One Sample t-test
## 
## data:  Draws
## t = -7.6555, df = 39, p-value = 2.745e-09
## alternative hypothesis: true mean is not equal to 8
## 95 percent confidence interval:
##  4.491808 5.958192
## sample estimates:
## mean of x 
##     5.225

Problem 3 A

library(ggplot2)
library(haven)
library(stargazer)
## 
## Please cite as:
##  Hlavac, Marek (2022). stargazer: Well-Formatted Regression and Summary Statistics Tables.
##  R package version 5.2.3. https://CRAN.R-project.org/package=stargazer
library(ggExtra)
## Warning: package 'ggExtra' was built under R version 4.2.2
library(sjPlot)
## Warning: package 'sjPlot' was built under R version 4.2.2
## Learn more about sjPlot with 'browseVignettes("sjPlot")'.
Data1 <- read_dta("C:\\Users\\Chandler\\Downloads\\apsrfinaldata.dta")
lm1 <- lm(Data1$pg ~ Data1$betweenstd + Data1$lngdpstd)
stargazer(lm1, type = 'html')
Dependent variable:
pg
betweenstd -0.228***
(0.075)
lngdpstd 0.800***
(0.075)
Constant 0.000
(0.070)
Observations 46
R2 0.793
Adjusted R2 0.783
Residual Std. Error 0.473 (df = 43)
F Statistic 82.249*** (df = 2; 43)
Note: p<0.1; p<0.05; p<0.01

B

summary(lm1)
## 
## Call:
## lm(formula = Data1$pg ~ Data1$betweenstd + Data1$lngdpstd)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.44477 -0.26331 -0.00354  0.15106  1.30639 
## 
## Coefficients:
##                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       8.047e-10  6.976e-02   0.000  1.00000    
## Data1$betweenstd -2.283e-01  7.521e-02  -3.036  0.00406 ** 
## Data1$lngdpstd    7.997e-01  7.521e-02  10.633  1.3e-13 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4732 on 43 degrees of freedom
## Multiple R-squared:  0.7928, Adjusted R-squared:  0.7831 
## F-statistic: 82.25 on 2 and 43 DF,  p-value: 2.013e-15

The standard error for betweenstd is 7.521e-02 and for lngdpstd it is also 7.521e-02.

C The t-statistc for betweenstd is -3.036 the absolute value of which is larger than the t critical values for .9, .95, and .99. This is thus associated with a p-value smaller than .01. We therefore reject H0: that betweenstd has no effect on the mean outcome of public goods. The t-statistc for lngdpstd is 10.633 the absolute value of which is much larger than the t critical values for .9, .95, and .99. This is thus associated with a p-value smaller than .01. We therefore reject H0: that lngdpstd has no effect on the mean outcome of public goods.

Problem 4

A

Data2 <- read_dta("C:\\Users\\Chandler\\Downloads\\MAR_2006.dta")

Polgr_P <- ggplot(Data2, aes(x=POLGR)) +
      geom_histogram() +
      theme(legend.position="none")
Excerp_P <- ggplot(Data2, aes(x=EXECREP)) +
      geom_histogram() +
      theme(legend.position="none")
Groupcon_P <- ggplot(Data2, aes(x=GROUPCON)) +
      geom_histogram() +
      theme(legend.position="none")
Polgr_P
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Excerp_P
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Groupcon_P
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

B

Data2$POLGR <- as.factor(Data2$POLGR)
Data2$EXECREP <- as.factor(Data2$EXECREP)

Chisq <- chisq.test(Data2$POLGR, Data2$EXECREP)
Chisqs <- summary(Chisq)
Chisq
## 
##  Pearson's Chi-squared test
## 
## data:  Data2$POLGR and Data2$EXECREP
## X-squared = 11.53, df = 4, p-value = 0.02121
Chisqs
##           Length Class  Mode     
## statistic  1     -none- numeric  
## parameter  1     -none- numeric  
## p.value    1     -none- numeric  
## method     1     -none- character
## data.name  1     -none- character
## observed  10     table  numeric  
## expected  10     -none- numeric  
## residuals 10     table  numeric  
## stdres    10     table  numeric
tab_xtab(
  var.row = Data2$POLGR, 
  var.col = Data2$EXECREP, 
  show.row.prc = T)
POLGR EXECREP Total
0 1
0 24
45.3 %
29
54.7 %
53
100 %
1 43
60.6 %
28
39.4 %
71
100 %
2 9
42.9 %
12
57.1 %
21
100 %
3 28
58.3 %
20
41.7 %
48
100 %
4 46
73 %
17
27 %
63
100 %
Total 150
58.6 %
106
41.4 %
256
100 %
χ2=11.530 · df=4 · Cramer’s V=0.212 · p=0.021