Skip to contents

Predict from a brsmm model

Usage

# S3 method for class 'brsmm'
predict(
  object,
  newdata = NULL,
  type = c("response", "link", "precision", "variance", "quantile"),
  at = 0.5,
  ...
)

Arguments

object

A fitted "brsmm" object.

newdata

Optional data frame.

type

Character: "response" (default), "link", "precision", "variance", or "quantile".

at

Numeric vector of probabilities for quantile predictions (default 0.5).

...

Currently ignored.

Value

Numeric vector.

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         2         3         4         5         6 
#> 0.3856183 0.3093696 0.3856183 0.3093696 0.3856183 0.5713190 
head(predict(fit, type = "precision"))
#> [1] 0.3588181 0.3588181 0.3588181 0.3588181 0.3588181 0.3588181
# }