focus_fns: Built-in focus functions and their derivatives

Description Usage Arguments Value See Also Examples

Description

Built-in focus functions and their derivatives

Usage

1
2
3
4
5
6
7

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## 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)

fic documentation built on May 1, 2019, 7:55 p.m.