library(QRMon) library(splines) library(quantreg) library(purrr) library(magrittr) library(ggplot2)
In this sub-section we compute the conditional distribution of tomorrow's temperature given today's temperature.
weVec <- dfTemperatureData$Temperature qDF <- data.frame( YesterdayValue = weVec[-length(weVec)], TodayValue = weVec[-1] ) qs <- c(0.01,seq(0.1,0.9,0.1),0.99) qrTempObj <- QRMonUnit( setNames( qDF, c("Regressor", "Value") ) ) %>% QRMonQuantileRegression( df = 6, degree = 3, probabilities = qs )
qrTempObj <- qrTempObj %>% QRMonPlot
Here is an example of a prediction for tomorrow's temperature given that the temperature today is [8^{\circ}C].
res <- qrTempObj %>% QRMonPredict( newdata = c(8) ) %>% QRMonTakeValue res <- setNames( dplyr::bind_rows( res, .id = "Quantile" ), c("Quantile", "TodayTemperature", "TomorrowTemperture") ) res$Quantile <- as.numeric(res$Quantile) res
qrTempObj2 <- qrTempObj %>% QRMonConditionalCDFPlot(8, echoQ = F) (qrTempObj2 %>% QRMonTakeValue) + ggplot2::geom_vline( xintercept = 8, color = "blue" )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.