View source: R/predict.maxlogL.R
predict.maxlogL | R Documentation |
maxlogL
FitsThis function computes predictions and optionally the estimated standard errors
of those predictions from a model fitted with maxlogLreg
.
## S3 method for class 'maxlogL' predict( object, parameter = NULL, newdata = NULL, type = c("link", "response", "terms"), se.fit = FALSE, terms = NULL, ... )
object |
an object of |
parameter |
a character which specifies the parameter to predict. |
newdata |
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. |
type |
a character with the type of prediction required. The default
( |
se.fit |
logical switch indicating if standard errors of predictions are required. |
terms |
A character vector that specifies which terms are required if
|
... |
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 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.
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, jmosquerag@unal.edu.co
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") #--------------------------------------------------------------------------------
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.