Internal Code: MAS7050
R Homework Assignment
1. Problem Set 1:
(a) How many observations are in the data frame?
(b) What are the names of the variables in the data frame?
(c) Create a tidy bar plot of the vote variable.
(d) Create a bivariate table of the gender variable with the Conservative Party dummy variable, with column percentages.
(e) Using the example in the Lab Instructions, go through the 5-step hypothesis testing procedure to determine whether there is a causal relationship between gender and
voting for the Conservative Party. This means
i. Generating the null (H0) and alternative (Ha) hypotheses.
ii. Choosing the level of significance.
iii. Finding the critical value(s).
iv. Calculating the appropriate test statistic.
v. Stating your conclusion about whether to reject, or fail to reject, the null hypothesis.
2. Problem Set 2:
(a) What are the mean and standard deviation of the PTS A and PTS H variables?
(b) Draw a box plot comparing these two variables (make the plot tidy, including adding labels and a title).
(c) Draw density curves (on the same plot) for these two variables (make the plot tidy, including adding labels and a title).
(d) Perform a difference-of-means hypothesis test on the two variables, to answer the question are the means of PTS A and PTS H significantly different from each other.
3. Problem Set 3:
(a) What are the variable names in the data frame and what do they measure?
(b) Create a scatterplot of the religious variable with the immigrant variable (make it tidy, and make the dots red)
(c) Create a different scatterplot of the religious variable with the homosexual variable (make the plot tidy, and make the dots blue).
(d) Perform a hypothesis test to determine if there is a strong and statistically significant relationship between the religious variable and the immigrant variable.
(e) Perform a correlation test only (you do not have to go through the five-step hypothesis testing procedure; only the final step is necessary for this question) to determine if there is a strong and statistically significant relationship between the religion variable and the immigrant variable.