@@ -40,10 +40,10 @@ data("movies", package = "BayesianLearningCode")
4040## Section 6.2.1 Bayesian Learning Under Improper Priors
4141### Example 6.2: Movie data
4242
43- We use as response ` y ` the variable ` OpenBoxOffice ` , which contains
44- the box office sales at the opening weekend in Mio.$, and as
45- covariates the budget (` Budget ` , in Mio.$) and the number of screens
46- (` Screens ` , in 1000) the film was forecast to be in theaters six weeks
43+ We use as response ` y ` the variable _ OpenBoxOffice _ , which contains
44+ the box office sales at the opening weekend in Mio.\ $ , and as
45+ covariates the budget (_ Budget _ , in Mio.$) and the number of screens
46+ (_ Screens _ , in 1000) the film was forecast to be in theaters six weeks
4747prior to opening.
4848
4949We center the covariates _ Budget_ and _ Screens_ at their means in the
@@ -797,11 +797,15 @@ X_new[3, "PG13"] <- 1
797797X_new[4, "R"] <- 1
798798X_new[, "Budget"] <- 10
799799
800- ypred.sc <- X_new %*% t(beta.sc) + rnorm(sqrt(sigma2.sc))
800+ ypred.sc <- X_new %*% t(beta.sc) +
801+ rep(rnorm(length(sigma2.sc), sd = sqrt(sigma2.sc)), each = nrow(X_new))
801802pred.int.sc <- apply(ypred.sc,1, quantile, probs = c(0.025, 0.5, 0.975))
802803pred.mean.sc <- rowMeans(ypred.sc)
803804
804- ypred.hs <- X_new %*% t(beta.hs) + rnorm(sqrt(sigma2.hs))
805+ ypred.hs <- X_new %*% t(beta.hs) +
806+ rep(rnorm(length(sigma2.hs), sd = sqrt(sigma2.hs)), each = nrow(X_new))
807+
808+
805809pred.int.hs <- apply(ypred.hs,1, quantile, probs = c(0.025, 0.5, 0.975))
806810pred.mean.hs <- rowMeans(ypred.hs)
807811```
@@ -818,7 +822,7 @@ if (pdfplots) {
818822par(mfrow = c(1, 1))
819823matplot(x = t(matrix(1:nf, ncol = 3, nrow = nf)),
820824 y = pred.int.sc, col = "blue", type = "l", pch = 16, lty = 1,
821- ylim = c(8, 32 ), xlim = c(0.5, nf+0.5),
825+ ylim = c(0, 40 ), xlim = c(0.5, nf+0.5),
822826 xlab = "Scenarios", ylab = "Predicted box office sales", xaxt = "n")
823827points(x = 1:nf, y = pred.int.sc[2, ], pch = 19, col = "blue", cex = 1.2)
824828points(x = 1:nf, y = pred.mean.sc, pch = 16, col = "red")
0 commit comments