Learn R Programming

glmtrans (version 2.1.0)

predict.glmtrans: Predict for new data from a "glmtrans" object.

Description

Predict from a "glmtrans" object based on new observation data. There are various types of output available.

Usage

# S3 method for glmtrans
predict(
  object,
  newx,
  type = c("link", "response", "class", "integral response"),
  ...
)

Value

the predicted result on new data, which depends on type.

Arguments

object

an object from class "glmtrans", which comes from the output of function glmtrans.

newx

the matrix of new values for predictors at which predictions are to be made. Should be in accordance with the data for training object.

type

the type of prediction. Default = "link".

...

additional arguments.

  • "link": the linear predictors. When family = "gaussian", it is the same as the predicited responses.

  • "response": gives the predicited probabilities when family = "binomial", the predicited mean when family = "poisson", and the predicited responses when family = "gaussian".

  • "class": the predicited 0/1 responses for lositic distribution. Applies only when family = "binomial".

  • "integral response": the predicited integral response for Poisson distribution. Applies only when family = "poisson".

References

Tian, Y., & Feng, Y. (2023). Transfer learning under high-dimensional generalized linear models. Journal of the American Statistical Association, 118(544), 2684-2697.

See Also

glmtrans.

Examples

Run this code
set.seed(1, kind = "L'Ecuyer-CMRG")

# fit a logistic model
D.training <- models("binomial", type = "all", K = 1, p = 500)
D.test <- models("binomial", type = "target", n.target = 10, p = 500)
fit.binomial <- glmtrans(D.training$target, D.training$source, family = "binomial")

predict(fit.binomial, D.test$target$x, type = "link")
predict(fit.binomial, D.test$target$x, type = "response")
predict(fit.binomial, D.test$target$x, type = "class")

# \donttest{
# fit a Poisson model
D.training <- models("poisson", type = "all", K = 1, p = 500)
D.test <- models("poisson", type = "target", n.target = 10, p = 500)
fit.poisson <- glmtrans(D.training$target, D.training$source, family = "poisson")

predict(fit.poisson, D.test$target$x, type = "response")
predict(fit.poisson, D.test$target$x, type = "integral response")
# }

Run the code above in your browser using DataLab