The personality_scores dataset

Load the dataset reprores::personality_scores.

personality_scores <- NULL

Question 1

Use ggplot2 to visualise the relationship between extraversion (Ex) on the horizontal axis and neuroticism (Ne) on the vertical axis.

ggplot()

Question 2

Run a regression model that predicts neuroticism from extraversion, and store the model object in the variable personality_mod. End the block by printing out the summary of the model.

personality_mod <- NULL

Question 3

Make a histogram of the residuals of the model using ggplot2.

residuals <- NULL

Question 4

Write code to predict the neuroticism score for the minimum, mean, and maximum extraversion scores. Store the vector of predictions in the variable personality_pred.

personality_pred <- NULL

Simulating data from the linear model

Question 5

NOTE: You can knit this file to html to see formatted versions of the equations below (which are enclosed in $ characters); alternatively, if you find it easier, you can hover your mouse pointer over the $ in the code equations to see the formatted versions.

Write code to randomly generate 10 Y values from a simple linear regression model with an intercept of 3 and a slope of -7. Recall the form of the linear model:

\(Y_i = \beta_0 + \beta_1 X_i + e_i\)

The residuals (\(e_i\)s) are drawn from a normal distribution with mean 0 and variance \(\sigma^2 = 4\), and \(X\) is the vector of integer values from 1 to 10. Store the 10 observations in the variable Yi below. (NOTE: the standard deviation is the square root of the variance, i.e. \(\sigma\); rnorm() takes the standard deviation, not the variance, as its third argument).

X <- NULL
err <- NULL
Yi <- NULL