Application Exercise
- Open Rstudio Server Pro
- Create a new project
- Click File > New File > R Markdown
- Delete everything except for
---
title: "Untitled"
output: html_document
---
- Give your work a sensible title
- When you’ve finished, upload the .html file to Canvas
Generate some “fake” residuals under the following scenarios and plot the Q-Q plot and histogram for each. Describe what you see.
- Left-skewed data
- Right-skewed data
- Data generated under a lognormal distribution (use the
rlnorm()
function)
- Data generated under a t-distribution with 2 degrees of freedom (use the
rt()
function)
Copy the code below to create a design matrix, X
and an outcome, y.
set.seed(1)
X <- matrix(c(rep(1, 100),
rnorm(100)), ncol = 2)
y <- 2 + 3 * X[, 2] + 2 * X[, 2]^2 + 0.5 * X[, 2]^3 + rnorm(100)
- Add to this design matrix so you can fit a model with a 3rd degree polynomial.
- Fit this model using linear regression
- Calculate the expected change in Y given a change from the 25th percentile to the 75th percentile