aveEffPlot.Rd
For objects of class glm
, it calculates the change the average
predicted probability (like the one calculated by glmChange2
) for a
hypothetical candidate set of values of a covariate.
aveEffPlot( obj, varname, data, R = 1500, nvals = 25, plot = TRUE, returnSim = FALSE, ... )
obj | A model object of class |
---|---|
varname | Character string giving the variable name for which average effects are to be calculated. |
data | Data frame used to fit |
R | Number of simulations to perform. |
nvals | Number of evaluation points at which the average probability will be calculated. |
plot | Logical indicating whether plot should be returned, or just data
(if |
returnSim | Logical indicating whether simulated predicted probabilities should be returned. |
... | Other arguments to be passed down to |
A plot or a data frame
The function plots the average effect of a model covariate, for objects of
class glm
. The function does not work with poly
unless the
coefficients are provided as arguments to the command in the model (see
example below).
data(france) p <- poly(france$lrself, 2) left.mod <- glm(voteleft ~ male + age + retnat + poly(lrself, 2, coefs=attr(p, "coefs")), data=france, family=binomial) aveEffPlot(left.mod, "age", data=france, plot=FALSE)#> s mean lower upper #> 1 15.000 0.6765131 0.6319245 0.7239427 #> 2 18.125 0.6695036 0.6277574 0.7137513 #> 3 21.250 0.6623682 0.6238755 0.7038904 #> 4 24.375 0.6551057 0.6189568 0.6936023 #> 5 27.500 0.6477150 0.6146938 0.6833190 #> 6 30.625 0.6401962 0.6097107 0.6727805 #> 7 33.750 0.6325496 0.6029008 0.6630809 #> 8 36.875 0.6247764 0.5970974 0.6530135 #> 9 40.000 0.6168786 0.5902648 0.6441606 #> 10 43.125 0.6088590 0.5825996 0.6358514 #> 11 46.250 0.6007210 0.5745658 0.6268975 #> 12 49.375 0.5924688 0.5639790 0.6194394 #> 13 52.500 0.5841072 0.5523231 0.6129205 #> 14 55.625 0.5756416 0.5399007 0.6069629 #> 15 58.750 0.5670779 0.5275635 0.6013725 #> 16 61.875 0.5584223 0.5148466 0.5970502 #> 17 65.000 0.5496811 0.5026301 0.5933379 #> 18 68.125 0.5408611 0.4895473 0.5894384 #> 19 71.250 0.5319689 0.4764357 0.5859694 #> 20 74.375 0.5230111 0.4617739 0.5822526 #> 21 77.500 0.5139942 0.4466346 0.5783165 #> 22 80.625 0.5049249 0.4318476 0.5745233 #> 23 83.750 0.4958093 0.4180289 0.5717735 #> 24 86.875 0.4866540 0.4027480 0.5679848 #> 25 90.000 0.4774650 0.3870172 0.5636187