Predict from a brsmm model
Arguments
- object
A fitted
"brsmm"object.- newdata
Optional data frame.
- type
Character:
"response"(default),"link","precision","variance","quantile","score"or"expected_score"."score"is the latent score of the fit'sintervalat the conditional mean (support \((0, K)\), \((0, K + 1)\) or \((-1, K)\); about 0.5 above/below the expected recorded score under"right"/"left");"expected_score"is the expected recorded score \(\sum_s s\, P(S = s)\). Details:predict.brs.- at
Numeric vector of probabilities for quantile predictions (default 0.5).
- ...
Currently ignored.
Value
Numeric vector, except when type = "quantile" and
at has length greater than 1, in which case a numeric matrix
with one column per requested quantile (named q_<value>, e.g.
"q_0.5") and one row per observation.
Examples
# \donttest{
dat <- data.frame(
y = c(
0, 5, 20, 50, 75, 90, 100, 30, 60, 45,
10, 40, 55, 70, 85, 25, 35, 65, 80, 15
),
x1 = rep(c(1, 2), 10),
id = factor(rep(1:4, each = 5))
)
prep <- brs_prep(dat, ncuts = 100)
#> brs_prep: n = 20 | exact = 0, left = 1, right = 1, interval = 18
fit <- brsmm(y ~ x1, random = ~ 1 | id, data = prep)
head(predict(fit))
#> [1] 0.3856053 0.3093261 0.3856053 0.3093261 0.3856053 0.5713284
head(predict(fit, type = "precision"))
#> [1] 0.3588037 0.3588037 0.3588037 0.3588037 0.3588037 0.3588037
# }
