predict.maxlogL {EstimationTools}R Documentation

Predict Method for maxlogL Fits



This function computes predictions and optionally the estimated standard errors of those predictions from a model fitted with maxlogLreg.


## S3 method for class 'maxlogL'
  parameter = NULL,
  newdata = NULL,
  type = c("link", "response", "terms"), = FALSE,
  terms = NULL,



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.


This predict method computes predictions for values of any distribution parameter in link or original scale.


If = FALSE, a vector of predictions is returned. For type = "terms", a matrix with a column per term and an attribute "constant" is returned.

If = TRUE, a list with the following components is obtained:

  1. fit: Predictions.

  2. Estimated standard errors.


Variables are first looked for in newdata argument and then searched in the usual way (which will include the environment of the formula used in the fit). A warning will be given if the variables found are not of the same length as those in newdata if it is supplied.


Jaime Mosquera GutiƩrrez,



# 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( = ~ x, = ~ x)

norm_mod <- maxlogLreg(formulas, y_dist = y ~ dnorm, data = norm_data,
                       link = list(over = "sd", fun = "log_link"))

# 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")


[Package EstimationTools version 4.0.0 Index]