Calculates predicted probabilities for any combination of x-variable values holding all other variables constant at either typical values (average case approach) or at observed values (average effect approach).

probci(
  obj,
  data,
  .b = NULL,
  .vcov = NULL,
  changeX = NULL,
  numQuantVals = 5,
  xvals = NULL,
  type = c("aveEff", "aveCase")
)

Arguments

obj

A model of class glm, particularly those with binomial family.

data

Data frame used to estimate obj.

.b

A vector of coefficients to be passed down to the simulation. If NULL, coef() will be used to obtain coefficients from obj.

.vcov

A parameter variance covariance matrix to be passed to the simulation. If NULL, vcov() will be used to obtain the variance-covariance matrix of the parameters.

changeX

A vector of strings giving the names of variables for which changes are desired.

numQuantVals

For quantitative variables, if no x-values are specified in xvals, then numQuantVals gives the number of values used across the range of the variable.

xvals

A named list of values used to make the predictions. The names in the list should correspond with the variable names specified in changeX.

type

Type of effect to be generated. aveEff produces the average first difference across all observed values of X, while aveCase gives the first difference holding all other variables constant at typical values.

Value

An data frame with the following variables:

variables

The variables and the values at which they are held constant. For example, tmp1 would be the first value of tmp used in the probability calculation and tmp2 would be the second value of tmp used in the probability calculation.

pred_prob

The difference in predicted probability given the following change in X: tmp2-tmp1.

lower, upper

The lower and upper 95% confidence bounds.

Details

Calculates predicted probabilities for any combination of x-variable values holding all other variables constant at either typical values (average case approach) or at observed values (average effect approach). The function uses a parametric bootstrap to provide generate confidence bounds for predicted probabilities and their differences. The confidence intervals produced are raw percentile interviews (at the 5% level).

Examples

data(france) left.mod <- glm(voteleft ~ male + age + retnat + poly(lrself, 2, raw=TRUE), data=france, family=binomial) out <- probci(left.mod, france, changeX="retnat") out
#> retnat1 retnat2 pred_prob lower upper #> 1 Better Same 0.0249 -0.0390 0.0919 #> 2 Better Worse 0.0043 -0.0644 0.0788 #> 3 Same Worse -0.0206 -0.0782 0.0402
out2 <- probci(left.mod, france, changeX="lrself", xvals = list(lrself = c(1,10))) out2
#> lrself1 lrself2 pred_prob lower upper #> 1 1 10 -0.9942 -0.9987 -0.9570
out3 <- probci(left.mod, france, changeX=c("lrself", "retnat"), xvals = list(lrself = c(1,10))) out3
#> lrself1 retnat1 lrself2 retnat2 pred_prob lower upper #> 1 1 Better 10 Better -0.9940 -0.9986 -0.9533 #> 2 1 Better 1 Same 0.0009 -0.0035 0.0167 #> 3 1 Better 10 Same -0.9936 -0.9986 -0.9521 #> 4 1 Better 1 Worse 0.0002 -0.0082 0.0136 #> 5 1 Better 10 Worse -0.9939 -0.9987 -0.9533 #> 6 10 Better 1 Same 0.9951 0.9634 0.9989 #> 7 10 Better 10 Same 0.0000 -0.0004 0.0031 #> 8 10 Better 1 Worse 0.9942 0.9570 0.9987 #> 9 10 Better 10 Worse 0.0000 -0.0012 0.0019 #> 10 1 Same 10 Same -0.9948 -0.9988 -0.9626 #> 11 1 Same 1 Worse -0.0006 -0.0119 0.0044 #> 12 1 Same 10 Worse -0.9951 -0.9989 -0.9633 #> 13 10 Same 1 Worse 0.9938 0.9559 0.9985 #> 14 10 Same 10 Worse -0.0000 -0.0028 0.0006 #> 15 1 Worse 10 Worse -0.9941 -0.9986 -0.9566