Last active
October 10, 2017 00:19
-
-
Save jmg/40ba43abdc514db6ebc9fe1528726441 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(quantreg) | |
airq <- airquality | |
#fit the quantile regression with Ozone formula | |
fit <- rq(Ozone ~ ., data=airquality) | |
#create a new dataframe with the values to forecast the Ozone | |
newdata <- data.frame(Solar.R=201:203, Wind=8:10, Temp=82:84, Month=9, Day=20:22) | |
#newdata is the parameter to tell the predict function to use the values for making the forecast | |
fore <- predict(fit, newdata=newdata) | |
#add the forecasted to the initial dataframe | |
newdata$Ozone <- fore | |
fore_newdata <- rbind(airq, newdata) | |
#show forecast tables | |
show(fore_newdata) | |
show(newdata) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment