View source: R/hurdle-methods.R
| predict.beezdemand_hurdle | R Documentation |
Returns predictions from a fitted hurdle demand model.
## S3 method for class 'beezdemand_hurdle'
predict(
object,
newdata = NULL,
type = c("response", "link", "parameters", "probability", "demand"),
prices = NULL,
se.fit = FALSE,
interval = c("none", "confidence"),
level = 0.95,
...
)
object |
An object of class |
newdata |
Optional data frame containing a price column matching the fitted
object's |
type |
One of:
|
prices |
Optional numeric vector of prices used only when |
se.fit |
Logical; if |
interval |
One of |
level |
Confidence level when |
... |
Unused. |
For type = "parameters", a tibble of subject-level parameters.
Otherwise, a tibble containing the newdata columns plus .fitted and
helper columns predicted_log_consumption, predicted_consumption,
prob_zero, and expected_consumption. When requested, .se.fit and
.lower/.upper are included.
data(apt)
fit <- fit_demand_hurdle(apt, y_var = "y", x_var = "x", id_var = "id")
# Get subject-specific parameters
pars <- predict(fit, type = "parameters")
# Predict demand at specific prices
demand <- predict(fit, type = "demand", prices = c(0, 0.5, 1, 2, 5))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.