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 |
newx |
the matrix of new values for predictors at which predictions are to be made. Should be in accordance with the data for training |
type |
the type of prediction. Default = "link". |
... |
additional arguments.
|
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
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")