fic (version 1.0.0)

focus_fns: Built-in focus functions and their derivatives

Description

Built-in focus functions and their derivatives

Usage

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 \(p\), or a \(n x p\) matrix, where \(p\) is the number of covariate effects, and \(n\) is the number of alternative sets of covariate values at which the focus function is to be evaluated.

Value

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

See Also

fic

Examples

Run this code
# NOT RUN {
## 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)

# }

Run the code above in your browser using DataCamp Workspace