focus_fns function

Built-in focus functions and their derivatives

Built-in focus functions and their derivatives

prob_logistic(par, X) prob_logistic_deriv(par, X) mean_normal(par, X) mean_normal_deriv(par, X)

Arguments

  • par: Vector of parameter estimates, including the intercept.
  • X: Vector or matrix of covariate values, including the intercept. This can either be a vector of length pp, or a nxpn x p matrix, where pp is the number of covariate effects, and nn is the number of alternative sets of covariate values at which the focus function is to be evaluated.

Returns

prob_logistic returns the probability of the outcome in a logistic regression model, and mean_normal returns the mean outcome in a normal linear regression. The _deriv functions return the vector of partial derivatives of the focus with respect to each parameter (or matrix, if there are multiple foci).

Examples

## Model and focus from the main vignette wide.glm <- glm(low ~ lwtkg + age + smoke + ht + ui + smokeage + smokeui, data=birthwt, family=binomial) vals.smoke <- c(1, 58.24, 22.95, 1, 0, 0, 22.95, 0) vals.nonsmoke <- c(1, 59.50, 23.43, 0, 0, 0, 0, 0) X <- rbind("Smokers" = vals.smoke, "Non-smokers" = vals.nonsmoke) prob_logistic(coef(wide.glm), X=X) prob_logistic_deriv(coef(wide.glm), X=X) ## Mean mpg for a particular covariate category in the Motor Trend data ## See the "fic" linear models vignette for more detail wide.lm <- lm(mpg ~ am + wt + qsec + disp + hp, data=mtcars) cmeans <- colMeans(model.frame(wide.lm)[,c("wt","qsec","disp","hp")]) X <- rbind( "auto" = c(intercept=1, am=0, cmeans), "manual" = c(intercept=1, am=1, cmeans) ) mean_normal(coef(wide.lm), X) mean_normal_deriv(coef(wide.lm), X)

See Also

fic

  • Maintainer: Christopher Jackson
  • License: GPL-3
  • Last published: 2025-03-27