Defining the trend and seasonal variables, we would be able to build the linear models. We would build three linear models here:
- with the trend variable,
- with the seasonable variable, and
- with both variables:
- Create R objects osv_time and osv_mths for the trend and seasonal variables:
osv_time <- 1 : length (osv) osv_mths <- as.factor ( rep (month.abb, times= 19 ))
Using the length function, we now have a numeric vector with values starting from 1 and ending at 228. The seasonal variable is created with the rep function, which repeats the month name 19 times successively. The month.abb is a standard character vector in R that has the month abbreviations as its content.
- Create the linear model using the trend variable ...