我对如何为以下模型的多个预测变量设置先验有点困惑:
require(rstanarm)
wi_prior <- normal(0, sd(train$attendance))
SEED <- 101
fmla <- attendance ~ (1 + W + W1 + W2 + W3 + DivWin1 + DivWin2 + DivWin3 +
WSWin1 | franchID)
baylm <- stan_glmer(fmla,
data = train,
family = "gaussian",
algorithm = "sampling",
adapt_delta = .95,
prior_intercept = wi_prior, seed = SEED)
根据请求,这是火车中的第一次观察。
train <- structure(list(franchID = structure(25L, .Label = c("ANA", "ARI",
"ATL", "BAL", "BOS", "CHC", "CHW", "CIN", "CLE", "COL", "DET",
"FLA", "HOU", "KCR", "LAD", "MIL", "MIN", "NYM", "NYY", "OAK",
"PHI", "PIT", "SDP", "SEA", "SFG", "STL", "TBD", "TEX", "TOR",
"WSN"), class = "factor"), yearID = 1999L, name = "San Francisco Giants",
park = "3Com Park", attendance = 2078399L, W = 86L, W1 = 89L,
W2 = 90L, W3 = 68L, WCWin1 = FALSE, WCWin2 = FALSE, WCWin3 = FALSE,
DivWin1 = FALSE, DivWin2 = TRUE, DivWin3 = FALSE, LgWin1 = FALSE,
LgWin2 = FALSE, LgWin3 = FALSE, WSWin1 = FALSE, WSWin2 = FALSE,
WSWin3 = FALSE), .Names = c("franchID", "yearID", "name",
"park", "attendance", "W", "W1", "W2", "W3", "WCWin1", "WCWin2",
"WCWin3", "DivWin1", "DivWin2", "DivWin3", "LgWin1", "LgWin2",
"LgWin3", "WSWin1", "WSWin2", "WSWin3"), row.names = c(NA, -1L
), class = "data.frame")