Construct a linear model
Create some linear model to predict arrival delays.
This exercise is part of the course
Big Data Analysis with Revolution R Enterprise
Exercise instructions
Use rxLinMod to create a simple linear model
The structure to a call to rxLinMod() is very similar to the lm() function in the stats package. The syntax is: rxLinMod(formula, data, …)
- formula - The model specification.
- data - The data in which you want to search for variables in formula.
- … - Additional arguments
Using the data set myAirlineXdf, go ahead and start by creating a simple linear model predicting arrival delay by day of the week.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
## predict arrival delay by day of the week:
myLM1 <- rxLinMod( ___, data = ___)
## summarize the model
summary(___)
## Use the transforms argument to create a factor variable associated with departure time "on the fly,"
## predict Arrival Delay by the interaction between Day of the week and that new factor variable.
myLM2 <- rxLinMod( ArrDelay ~ ___, ___ = myAirlineXdf,
___ = list(
catDepTime = cut(CRSDepTime, breaks = seq(from = 5, to = 23, by = 2))
),
cube = TRUE
)
## summarize the model
summary(myLM2)