inst/doc/bookMatrix-tex.R

### R code from vignette source 'bookMatrix-tex.Rnw'

###################################################
### code chunk number 1: bookMatrix-tex.Rnw:31-33
###################################################
library("bookMatrix")
library("memisc")


###################################################
### code chunk number 2: bookMatrix-tex.Rnw:58-61
###################################################
data("hoteldataRandom", package = "bookMatrix")
hotelData <- findHorizon(hoteldataRandom)
hist(hotelData$horizon, breaks = 100, main = "Figure 1: Horizon of the Bookings")


###################################################
### code chunk number 3: bookMatrix-tex.Rnw:75-79
###################################################
cumBookMat <- fitCumuBookMat(hotelData=hotelData)
plot(cumBookMat$date, cumBookMat$target, type="l", ylab="# Arrivals", 
     xlab="Time", main = "Figure 2: Hotel Demand on Target Date")
abline(h=mean(cumBookMat$target), col ="red")


###################################################
### code chunk number 4: bookMatrix-tex.Rnw:89-90
###################################################
cumBookMat <- fitOneYearVar(cumBookMat)


###################################################
### code chunk number 5: bookMatrix-tex.Rnw:113-122
###################################################
linReg <- runRegressions(cumBookMat, lag = 56, season=TRUE, wdayyes=FALSE, 
                          monthyes = FALSE, bayernholiday=FALSE, 
                          publicholiday=FALSE)
linReg2 <- runRegressions(cumBookMat, lag = 56, monthyes=FALSE, 
                          bayernholiday=FALSE, publicholiday=FALSE)
linReg1 <- runRegressions(cumBookMat, lag = 56, wdayyes=FALSE, 
                          monthyes = FALSE, bayernholiday=FALSE, 
                          publicholiday=FALSE)



###################################################
### code chunk number 6: bookMatrix-tex.Rnw:128-129
###################################################
mtable(linReg, linReg1, linReg2, summary.stats = c("R-squared", "sigma", "N") )


###################################################
### code chunk number 7: bookMatrix-tex.Rnw:138-140
###################################################
AIC(linReg, linReg1, linReg2)
BIC(linReg, linReg1, linReg2)


###################################################
### code chunk number 8: bookMatrix-tex.Rnw:151-170
###################################################
rsq0 <- rsq_by_lag(cumBookMat, oneyear = TRUE)
rsq1 <- rsq_by_lag(cumBookMat, oneyear = TRUE, season = TRUE)
rsq2 <- rsq_by_lag(cumBookMat, oneyear = TRUE, monthyes = TRUE)
par(mfrow=c(1,3))
plot(rsq ~ lag, data = rsq0, ylab = "R-squared", xlab = "Lag", type = "l", lwd = 2)
legend("topright", "linReg",
       lty = 1 , col = "black",
       lwd = 2, bty = "n"
)
plot(rsq ~ lag, data = rsq1, ylab = "R-squared", xlab = "Lag", type = "l", lwd = 2)
legend("topright", "linReg1",
       lty = 1 , col = "black",
       lwd = 2, bty = "n"
)
plot(rsq ~ lag, data = rsq2, ylab = "R-squared", xlab = "Lag", type = "l", lwd = 2)
legend("topright", "linReg2",
       lty = 1 , col = "black",
       lwd = 2, bty = "n"
)

Try the bookMatrix package in your browser

Any scripts or data that you put into this service are public.

bookMatrix documentation built on May 2, 2019, 5:46 p.m.