Homework 02

Due Friday, Feb 3

Instructions

For this homework, you should create a new folder in your homework directory. Call it HW3 or something similar that you can keep track of. Download the homework markdown template file Student_HW_template.Rmd from the course webpage, and put a copy in this folder. Rename it something like HW3_YourName.Rmd. This markdown document will be where you will answer each of the questions below.

The Assignment

As you read through TMWR Chapters 4 - 9, the concepts are illustrated with the Ames dataset. As you read, you are to create a Markdown document that fits a linear model to the Ames dataset (with outcomes and predictors as specified in the text). You will not include all the code in these chapters. The authors change code as they go to get to a completed analysis by the end.

This homework should be fairly simple if you are reading the text and coding as you go along. The point is to get into a greater level of detail as you read.

Include/do the following steps. This is not necessarily an exhaustive list; ou may need more steps as you go. You can find the code for all of this as you read through the chapters.

  • 1 plot of your choosing (maybe save this until the end) - include a description of what you are showing

  • log transform the outcome variable (base 10)

  • make a training and test set, stratified by Sale Price

  • use the predictors in section 8.1 (there are 4)

  • in your recipe include steps to

    • declare the roles of the variables
    • log the Gross Living Area (base 10)
    • take the bottom 1% of represented neighborhoods and call them “Other” (explain WHY you need to do this)
    • make all nominal predictors dummy variables
    • create an interaction term for Gross Living Area and Building Type
  • fit a linear model to the data using workflows and recipes

  • Calculate the RMSE and \(R^2\) for your model as calculated on the TEST set with the model trained on the TRAINING set. Comment on the results.

  • Don’t put all your code in one code chunk. Separate the code in an organized fashion and use Headers and/or text to briefly describe what you are doing in each code chunk.

Submitting HW

When you’ve successfully answered all the questions, knit your document to a PDF file. Look through it to make sure everything worked the way you expect it to. You will submit both your .Rmd and .pdf files to Schoology.