inverse_link: Compute the Inverses of Binomial Link Functions

View source: R/helper_functions.R

inverse_linkR Documentation

Compute the Inverses of Binomial Link Functions

Description

inverse_link returns the inverse of logit, cloglog and probit link functions for a linear predictor

Usage

inverse_link(lp = NULL, link = c("logit", "cloglog", "probit"))

Arguments

lp

numeric vector containing the estimated link.

link

(character) name of the link function (one of "logit", "cloglog" or "probit").

Details

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.

Value

inverse_link returns a numeric vector containing the inverse of the link function for the linear predictor.

See Also

predict.logreg_screenr

Examples

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

sgutreuter/screenr documentation built on Nov. 20, 2022, 2:41 a.m.