View source: R/helper_functions.R
inverse_link | R Documentation |
inverse_link
returns the inverse of logit, cloglog and
probit link functions for a linear predictor
inverse_link(lp = NULL, link = c("logit", "cloglog", "probit"))
lp |
numeric vector containing the estimated link. |
link |
(character) name of the link function (one of |
inverse_link
returns the inverses of logit, cloglog and probit link
functions, and is provided as a (laborious) way to compute predicted values
from the ModelFit
component of logreg_screenr
-class objects.
The predict
methods are a better way to obtain predicted values.
inverse_link
returns a numeric vector containing the inverse
of the link function for the linear predictor.
predict.logreg_screenr
## Make predictions of probability of infection from new observations attach(uniobj2) new_corns <- data.frame(ID = c("Alice D.", "Bernie P."), testresult = c(NA, NA), Q1 = c(0, 0), Q2 = c(0, 0), Q3 = c(0, 0), Q4 = c(0, 0), Q5 = c(0, 1), Q6 = c(0, 1 ), Q7 = c(0, 1)) mfit <- get_what(from = uniobj2 , what = "ModelFit") coefs <- mfit$coefficients lp <- as.matrix(cbind(rep(1, nrow(new_corns)), new_corns[, 3:8])) %*% as.matrix(coefs, ncol = 1) (preds <- inverse_link(lp, link = "logit")) ## Note that only the predicted values are returned.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.