Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plot the Profile Deviance for a GLM fit in R

Tags:

plot

r

glm

I would like to be able to plot the profile deviance for a parameter estimate fitted using the function glm() in R. The profile Deviance is the deviance function for different values of the parameter estimate in question, after estimating all other parameters. I need to plot the deviance for several values around the fitted parameter, to check the assumption of quadratic deviance function.

My model is predicting reconviction of offenders. The formula is of the form: reconv ~ [other variables] + sex, where reconv is a binary yes/no factor, and sex is binary male/female factor. I'd like to plot the profile deviance of the parameter estimated for sex=female (sex=male is the reference level).

The glm() function estimated the parameter as -0.22, with std error 0.12.

[I'm asking this question because there was no answer I could find, but I worked it out, and wanted to post a solution to be of use to others. Of course, additional help is welcome. :-)]

like image 468
MatW Avatar asked Mar 20 '12 13:03

MatW


2 Answers

See the profileModel package by Ioannis Kosmidis. He had a paper in the R Journal (R News it would appear) illustrating the package:

Ioannis Kosmidis. The profilemodel R package: Profiling objectives for models with linear predictors. R News, 8(2):12-18, October 2008.

The PDF is here (entire newsletter).

like image 194
Gavin Simpson Avatar answered Oct 15 '22 09:10

Gavin Simpson


See ?profile.glm (and example("profile.glm")) in the MASS package -- I think it will do everything you want (this is not loaded by default, but it is mentioned in ?profile, which might have been the first place you looked ...) (Note that the profiles are generally plotted on a signed-square-root scale, so that a truly quadratic profile will appear as a straight line.)

like image 41
Ben Bolker Avatar answered Oct 15 '22 10:10

Ben Bolker