library(rio)
sm.pa <- import("https://github.com/marctrussler/IIS-Data/raw/main/PAFinalWeeks.csv")Problem Set 4
Problem Set Due XXXXXXXX at 7pm on Canvas.
You will hand in a .Rmd file and a knitted html output.
I have provided the raw RMD of this problem set you can use as a template for answering.
For this problem set we are going to use the SurveyMonkey data on Pennsylvania voters from the last two weeks before the 2022 election. While this is not a perfect random sample of Pennsylvanians (or of PA voters, in particular), we can pretend like it is for the purposes of this assignment.
We are going to investigate the variable predicted.vote.prob. This is a variable that we generated which gives each individual in the data set a probability of voting from 0 to 1 based on their demographics and stated likelihood of voting.
Without using the
t.test()function, perform the 5-step hypothesis test discussed in class on the null hypothesis thatpredicted.vote.probis equal to .8. (This test should be a two-tailed hypothesis test). Confirm your answer with thet.test()function.Again, without using the
t.test()function, perform the 5-step hypothesis test discussed in class on the null hypothesis that those who identify as Democrats and Republicans have equal predicted probabilities of voting. (So you don’t have to calculate it with a terrible equation, the degrees of freedom for the t-test will be 3543.9.) Confirm your calculated answer using thet.test()function.Assume that the difference in the predicted probability of turning out in Democrats vs. Republicans (about 3.2%) is the truth in the population. Using the methodology from class, visualize and calculate \(\beta\), the probability of a false negative, for the hypothesis test from (2). Similar to what I did in class, you can assume (for this question, not above) that the sampling distribution of the difference in means is normally distributed, as opposed to \(t\) distributed. Describe briefly what you see in your visualization and how it relates to your calculated \(\beta\).
Having seen the results of (3), I might be concerned that I have wasted my money getting so many respondents. Calculate and visualize \(\beta\) for sample sizes ranging from 100 to 10000. Eye-balling it, what sample size would result in a \(\beta\) of 20%? You can again assume that the difference of means in the sample is representative of the true population difference in means. You can further assume that the sample variances for each of the groups is representative of the true variances in the population. Finally, for simplicity assume that each sample is 50/50 Democrats and Republicans.
We now want to investigate the relationship between
ageandpredicted.vote.prob. Create a scatterplot withageon the x-axis andpredicted.vote.probon the y-axis. Briefly describe what you see.Without using the
cov()andcor()functions, calculate the covariance and correlation ofageandpredicted.vote.prob. Confirm your answers using thecov()andcor()functions. In political terms, what do these numbers mean?Is the correlation you found in (6) statistically distinguishable from 0? Use the bootstrap to generate a sampling distribution around this correlation, and determine the 95% confidence interval using the
quantile()function.