predict.glmtrans {glmtrans}R Documentation

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 class 'glmtrans'
predict(
  object,
  newx,
  type = c("link", "response", "class", "integral response"),
  ...
)

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".

Value

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

References

Tian, Y. and Feng, Y., 2021. Transfer learning with high-dimensional generalized linear models. Submitted.

See Also

glmtrans.

Examples

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


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


[Package glmtrans version 2.0.0 Index]