Instructions

Please complete this assignment using the RMarkdown file provided. Once you download the RMarkdown file please (1) include your name in the preamble, (2) rename the file to include your last name (e.g., “weston-homework-1.Rmd”). When you turn in the assignment, include both the .Rmd and knitted .html files.

To receive full credit on this homework assignment, you must earn 30 points. You may notice that the total number of points available to earn on this assignment is 65 – this means you do not have to answer all of the questions. You may choose which questions to answer. You cannot earn more than 30 points, but it may be worth attempting many questions for learning’s sake. Here are a couple things to keep in mind:

  1. Points are all-or-nothing, meaning you cannot receive partial credit if you correctly answer only some of the bullet points for a question. All must be answered correctly.

  2. After the homework has been graded, you may retry questions to earn full credit, but you may only retry the questions you attempted on the first round.

  3. The first time you complete this assignment, it must be turned in by 9am on the due date. Late assignments will receive 50% of the points earned. For example, if you correctly answer questions totaling 27 points, the assignment will receive 13.5 points. If you resubmit this assignment with corrected answers (a total of 30 points), the assignment will receive 15 points.

  4. You may discuss homework assignments with your classmates; however, it is important that you complete each assignment on your own and do not simply copy someone else’s code. If we believe one student has copied another’s work, both students will receive a 0 on the homework assignment and will not be allowed to resubmit the assignment for points.

Data: Some of the questions in this homework assignment use the dataset referred to as homework-anxiety. [Link to data goes here.] In this dataset, you’ll find four variables: - id - numeric, refers to participant ID - Anxiety - participant’s average levels of anxiety over a week; Stress – the participant’s average level of stress over a week - Support – the participant’s perceived social support over a week - group – categorical, whether the participant was randomly assigned to a treatment group in which they given mediation instructions and were required to meditate for 10 minutes each day during the week.

Some questions refer to the dataset homework-dawtry.csv This dataset comes from Study 1a in the article by Dawtry et al. (2015), which examines the relationship between wealth and perception of wealth. Study 1a is an observational study in which American participants indicated their own household income and estimated how incomes are distributed across both their immediate social circles and the wider population. Participants then indicated how fair and satisfactory they perceived society to be and whether they supported redistribution efforts, as well as their political orientation. You may need to refer to the article to complete the questions associated with this dataset.

The 20-point question refers to the dataset homework-robin.csv. These data were collected by Taylor Guthrie and Rob Chavez. A longer description of these data can be found in the question problem.

2-point Questions

Question 1

X Y
1 1
5 18
5 13
5 17
3 14
5 20
3 3
4 13
1 1
4 13
4 7
1 7
3 17
4 8
4 3

Calculate the correlation between X and Y.

Question 2

Using the homework-dawtry dataset, answer the following questions:

  • What is the correlation between age and the mean income of one’s social circle?

  • Is that correlation statistically significant?

  • Use the corrplot package to create a figure of the correlation matrix of the variables in the dataset. Describe one thing you find interesting in this figure.

Question 3

You are contacted by the Dean’s office. They ran a correlation between UO undergraduate SAT scores and happiness and found a correlation of r = .21061 with a sample of \(N = 600\). They want to know if this is lower than a published meta-analytic estimate (.2554)?

  • Is the correlation found in the UO sample significantly different from the population parameter? Do this “by hand”. Treat the meta-analytic estimate as the “population.”

  • Calculate a 95% confidence interval around the estimate correlation “by hand.”

  • What would the 95% confidence interval around this estimate be if the sample size were only \(N = 60\)?

Question 4

You are given data with two variables, X and Y. The mean of X is 3 with a SD .75. Y has a mean of 4 with a SD of .50. The correlation between the two is r = .3.

  • “By hand”, calculate the regression equation. Interpret each term in equation.

  • “By hand,” convert the equation into a standardized regression equation. Interpret each term.

Question 5

Refer to the data provided in Question 2.1.

  • Calculate the unstandardized regression equation (use Y as the outcome). You may use whatever functions you want.

  • Calculate the standardized regression equation. You may use whatever functions you want.

5-point Questions

Question 1

  • Given a sample size of 40 participants, what is the smallest correlation we are able to detect as being significantly different from 0? Use a two-tailed test and \(\alpha = .05\). (Do not use the pwr package for this problem – there is an answer that does not depend on power.)

  • Given a sample size of 40 participants, what is the smallest correlation we are able to detect as being significantly different from .3? Use a two-tailed test and \(\alpha = .05\). (Do not use the pwr package for this problem – there is an answer that does not depend on power.)

Question 2

t-tests are a simple form of regression, where there is only one predictor variable and it is binary. In the process of estimating this model, R takes the character variable associated with X and creates a new variable of 0’s and 1’s. 0’s correspond to a reference group and 1’s correspond to the other group.

  • Using the homework-anxiety, estimate the regression model with Support as the outcome and group as the predictor. Which level of group was made the reference group? How can you tell?

  • Create your own variable inside the homework-anxiety data frame of 1’s and 0’s that make the other level the reference group. Estimate the regression model with this new variable. How are the two models the same and how are they different?

  • Now create a new variable with 0 (reference group) and 5 (other group). (You can choose which level is the reference group.) Run the regression model with this variable. What do the intercept and slope represent?

  • Now create a new variable where the reference group is represented by -1 and the other group is represented by 1. Run the regression model with this variable. What do the intercept and slope represent? (Hint: it may help to run descriptive statistics on your data frame to figure this out).

Question 3

  • Use the homework-anxiety data. Run a regression with Social Support (X) predicting Anxiety (Y). Then run a regression with Anxiety predicting Social Support. What is similar and different between these analyses?

  • Graph the regression with Anxiety as the DV. Include a confidence band and raw data points. Be sure your figure includes a title and caption.

  • For the regression of Social Support predicting Anxiety, correlate the fitted values with: a. residuals, b. Social Support, c., Anxiety. Explain the patterns you find.

  • Using the anova function for the model output, calculate R squared “by hand” using numbers in the anova table.

  • For the same model, interpret the residual standard error.

10-point Questions

Question 1

Choices that individuals make in the voting booth, such as whether to support a more conservative or liberal candidate, may be affected by a number of factors. In their research, Beall, Hofer, and Schaller (2016) sought to examine the role of outbreaks of infectious diseases on voting behavior. The authors hypothesized that an outbreak of a disease, such as Ebola, may increase support for more conservative political candidates. To test this hypothesis, the authors examined the frequency of Google searches for “Ebola” during the weeks prior to and after the outbreak of Ebola that occurred in 2014. The authors also examined support for the conservative Republican party in the US.

Below is an image of the output from a regression analysis, using their data: republican is a measure of support for the republican party; ebola is an index of the number of searches for Ebola on Google. Each observation was a day leading up to the national election. (Note, if this image does not load, you may need to download it from GitHub and save it in the same location as your homework file.)

There are some missing values in the output, labeled with red letters. Complete the output by computing the missing values (A-M).

Question 2

  • Using the data from Dawtry et al. (2015)), replicate the correlation matrix part of Table 1. (Note: you will have to create at least one composite to do so, and some of the items may need to be reverse scored.)

  • Calculate the means and standard deviations for Table 1 variables.

  • Graph the distributions of Household Income, Fairness and Satisfaction, Social circle mean income, population mean income, and political preference. Comment on anything you find irregular or interesting.

  • Run a regression where political preferences predict redistribution. Interpret the intercept, the regression coefficient and \(R^2\). Then create a scatter plot with a best fit line between redistribution and political preference variables. Be sure your figure includes a title and a caption.

  • Dichotomize the political preferences data into a dichotomous conservative and liberal variable, assuming the midpoint is conservative. Then run a linear model with this new binary variable predicting redistribution. What are the conceptual differences between the two regression models. Which one would you prefer?

20-point Questions

Question 1

Round robin designs are great tools in perception research. A round-robin design is when each member of a group rates every other member. Taylor Guthrie, a UO grad student in the Computational Social Neuroscience Lab, spearheaded one such study in 2019. Taylor recruited groups of 6 people that all somewhat knew each other. Groups included those from Greek life, academic organizations,coworkers and friend groups. Each person came in individually for a behavioral session in which they rated both themselves and all of the other members of their group on a variety of survey measures. We’ll be using the ratings on the Big Five personality traits for this question.

You’ll find the homework-robin dataset is organized as follows: each row is the rating of one person by one person. The group indicates which group the two people – subject (judge) and target – belong to, as well as columns indicating the specific subject and target. Note that when the subject number is the same as the target number, the ratings are self-ratings. The remaining 5 columns hold the ratings of each trait. Your task is to calculate the following for each trait:

  • The correlation between targets’ self-reports and the ratings of the target by other people.

  • The correlation between targets’ self-reports and the average rating of the target across the group. How do these values compare to the ones estimated above? What do you conclude about the agreement between self- and other-ratings?

  • The correlation between targets’ self-reports and the other people by the target.

  • The correlation between targets’ self-reports and the target’s average rating of other people. How do these values compare to the values estimated above? What do you conclude about the relationship between ratings of the self and ratings of others?

Note, this is primarily a data cleaning problem. You may not solve this problem by rewriting vectors by hand (e.g., target = c(1, 2, 3)) or indexing values based on position (e.g., target[c(1,2,3)]). I recommend the use of the tidyverse suite of packages, but there are many other ways to solve this problem. You can ignore the issue of dependency in this problem.