Learn R Programming

modelbased (version 0.5.1)

estimate_response.glm: Generates predictions for Frequentist models

Description

Generates predictions for Frequentist models

Usage

# S3 method for glm
estimate_response(
  model,
  data = NULL,
  transform = "response",
  include_smooth = TRUE,
  include_random = TRUE,
  length = 25,
  preserve_range = TRUE,
  predict = "response",
  ci = 0.95,
  ...
)

# S3 method for glm estimate_link( model, data = "grid", transform = "response", include_smooth = TRUE, include_random = FALSE, length = 25, preserve_range = TRUE, predict = "link", ci = 0.95, ... )

Arguments

model

A statistical model.

data

A data frame with model's predictors to estimate the response. If NULL, the model's data is used. If "grid", the model matrix is obtained (through visualisation_matrix).

transform

Can be "none" (default for contrasts), "response" (default for means), "mu", "unlink", "log". "none" will leave the values on scale of the linear predictors. "response" will transform them on scale of the response variable. Thus for a logistic model, "none" will give estimations expressed in log-odds (probabilities on logit scale) and "response" in terms of probabilities.

include_smooth

Should the smooth terms (in General Additive Models - GAM) be included?

include_random

Should it take the random effects into account? Can be TRUE, FALSE or a formula indicating which group-level parameters to condition on when making predictions. The data argument may include new levels of the grouping factors that were specified when the model was estimated, in which case the resulting posterior predictions marginalize over the relevant variables (see posterior_predict.stanreg).

length

Passed to visualisation_matrix if data = "grid".

preserve_range

Passed to visualisation_matrix if data = "grid".

predict

Can be "response" (default) or "link". The former predicts the the outcome per se, while the latter predicts the link function (i.e., the regression "line"), equivalent to estimating the fit. In other words, estimate_response(model, predict="link") is equivalent to estimate_link(model).

ci

Credible Interval (CI) level. Default to 0.89 (89%). See ci for further details.

...

Arguments passed to or from other methods.

Value

A dataframe of predicted values.

Examples

Run this code
# NOT RUN {
library(modelbased)

model <- lm(Sepal.Width ~ Species * Petal.Length, data = iris)
estimate_response(model)
estimate_link(model)

if (require("lme4")) {
  model <- lmer(Sepal.Width ~ Petal.Length + (1 | Species), data = iris)
  estimate_response(model)
  estimate_link(model)
}
# }

Run the code above in your browser using DataLab