glmChange.Rd
For objects of class glm
, it calculates the change in predicted
responses, for maximal discrete changes in all covariates holding all other
variables constant at typical values.
glmChange( obj, data, typical.dat = NULL, diffchange = c("range", "sd", "unit"), sim = FALSE, R = 1000 )
obj | A model object of class |
---|---|
data | Data frame used to fit |
typical.dat | Data frame with a single row containing values at which
to hold variables constant when calculating first differences. These values
will be passed to |
diffchange | A string indicating the difference in predictor values to
calculate the discrete change. |
sim | Logical indicating whether simulated confidence bounds on the difference should be calculated and presented. |
R | Number of simulations to perform if |
A list with the following elements:
A matrix of calculated first differences
A matrix of values that were used to calculate the predicted changes
The function calculates the changes in predicted responses for maximal
discrete changes in the covariates, for objects of class glm
. This
function works with polynomials specified with the poly
function. It
also works with multiplicative interactions of the covariates by virtue of
the fact that it holds all other variables at typical values. By default,
typical values are the median for quantitative variables and the mode for
factors. The way the function works with factors is a bit different. The
function identifies the two most different levels of the factor and
calculates the change in predictions for a change from the level with the
smallest prediction to the level with the largest prediction.
data(france) left.mod <- glm(voteleft ~ male + age + retnat + poly(lrself, 2), data=france, family=binomial) typical.france <- data.frame( retnat = factor(1, levels=1:3, labels=levels(france$retnat)), age = 35 ) glmChange(left.mod, data=france, typical.dat=typical.france)#> $diffs #> min max diff #> male 0.7120876 0.5385140465 -0.17357352 #> age 0.8134544 0.3421119251 -0.47134247 #> retnat 0.7120876 0.7650298249 0.05294226 #> lrself 0.9978678 0.0002658493 -0.99760191 #> #> $minmax #> male age retnat lrself #> typical 0 35 1 5 #> min 0 15 Better 1 #> max 1 90 Same 10 #> #> attr(,"class") #> [1] "change"