
Last chance! 50% off unlimited learning
Sale ends in
maxlogL
FitsThis function computes predictions and optionally the estimated standard errors
of those predictions from a model fitted with maxlogLreg
.
# S3 method for maxlogL
predict(
object,
parameter = NULL,
newdata = NULL,
type = c("link", "response", "terms"),
se.fit = FALSE,
terms = NULL,
...
)
If se.fit = FALSE
, a vector of predictions is returned.
For type = "terms"
, a matrix with a column per term and an attribute "constant"
is returned.
If se.fit = TRUE
, a list with the following components is obtained:
fit
: Predictions.
se.fit
: Estimated standard errors.
an object of maxlogL
class generated by maxlogLreg
function.
a character which specifies the parameter to predict.
a data frame with covariates with which to predict. It is an optional argument, if omitted, the fitted linear predictors or the (distribution) parameter predictions are used.
a character with the type of prediction required. The default
(type = "link"
) is on the scale of the linear predictors;
the alternative type = "response"
is on the scale of the
distribution parameter.
logical switch indicating if standard errors of predictions are required.
A character vector that specifies which terms are required if
type = "terms"
. All terms are returned by default.
further arguments passed to or from other methods.
Jaime Mosquera Gutiérrez, jmosquerag@unal.edu.co
This predict
method computes predictions for values of any
distribution parameter in link or original scale.
library(EstimationTools)
#--------------------------------------------------------------------------------
# Example 1: Predictions from a model using a simulated normal distribution
n <- 1000
x <- runif(n = n, -5, 6)
y <- rnorm(n = n, mean = -2 + 3 * x, sd = exp(1 + 0.3* x))
norm_data <- data.frame(y = y, x = x)
# It does not matter the order of distribution parameters
formulas <- list(sd.fo = ~ x, mean.fo = ~ x)
norm_mod <- maxlogLreg(formulas, y_dist = y ~ dnorm, data = norm_data,
link = list(over = "sd", fun = "log_link"))
predict(norm_mod)
#--------------------------------------------------------------------------------
# Example 2: Predictions using new values for covariates
predict(norm_mod, newdata = data.frame(x=0:6))
#--------------------------------------------------------------------------------
# Example 3: Predictions for another parameter
predict(norm_mod, newdata = data.frame(x=0:6), param = "sd",
type = "response")
#--------------------------------------------------------------------------------
# Example 4: Model terms
predict(norm_mod, param = "sd", type = "terms")
#--------------------------------------------------------------------------------
Run the code above in your browser using DataLab