Get startedGet started for free

Fitting a linear regression model

The parsnip package provides a unified syntax for the model fitting process in R.

With parsnip, it is easy to define models using the various packages, or engines, that exist in the R ecosystem.

In this exercise, you will define a parsnip linear regression object and train your model to predict selling_price using home_age and sqft_living as predictor variables from the home_sales data.

The home_training and home_test tibbles that you created in the previous lesson have been loaded into this session.

This exercise is part of the course

Modeling with tidymodels in R

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Initialize a linear regression object, linear_model
linear_model <- ___ %>% 
  # Set the model engine
  ___ %>% 
  # Set the model mode
  ___
Edit and Run Code