predict.gtReg {binGroup2}R Documentation

Predict method for gtReg

Description

Obtains predictions for individual observations and optionally computes the standard errors of those predictions from objects of class "gtReg" returned by gtReg.

Usage

## S3 method for class 'gtReg'
predict(
  object,
  newdata,
  type = c("link", "response"),
  se.fit = FALSE,
  conf.level = NULL,
  na.action = na.pass,
  ...
)

Arguments

object

a fitted object of class "gtReg".

newdata

an optional data frame in which to look for variables with which to predict. If omitted, the fitted linear predictors are used.

type

the type of prediction required. The "link" option is on the scale of the linear predictors. The "response" option is on the scale of the response variable. Thus, for the logit model, the "link" predictions are of log-odds (probabilities on the logit scale) and type = "response" gives the predicted probabilities.

se.fit

a logical value indicating whether standard errors are required.

conf.level

the confidence level of the interval for the predicted values.

na.action

a function determining what should be done with missing values in newdata. The default is to predict NA.

...

currently not used.

Details

If newdata is omitted, the predictions are based on the data used for the fit. When newdata is present and contains missing values, how the missing values will be dealt with is determined by the na.action argument. In this case, if na.action = na.omit, omitted cases will not appear, whereas if na.action = na.exclude, omitted cases will appear (in predictions and standard errors) with value NA.

Value

If se = FALSE, a vector or matrix of predictions. If se = TRUE, a list containing:

fit

predictions.

se.fit

estimated standard errors.

lower

the lower bound of the confidence interval, if calculated (i.e., conf.level is specified).

upper

the upper bound of the confidence interval, if calculated (i.e., conf.level is specified).

Author(s)

Boan Zhang

Examples

data(hivsurv)
fit1 <- gtReg(formula = groupres ~ AGE + EDUC.,
              data = hivsurv, groupn = gnum,
              sens = 0.9, spec = 0.9,
              linkf = "logit", method = "V")
pred.data <- data.frame(AGE = c(15, 25, 30),
                        EDUC. = c(1, 3, 2))
predict(object = fit1, newdata = pred.data,
        type = "link", se.fit = TRUE)
predict(object = fit1, newdata = pred.data,
        type = "response", se.fit = TRUE,
        conf.level = 0.9)
predict(object = fit1, type = "response",
        se.fit = TRUE, conf.level = 0.9)

[Package binGroup2 version 1.3.1 Index]