I am trying to figure out how to plot the profile likelihood curve of a GLM
parameter with 95% pLCI’s on the same plot. The example I have been trying
with is below. The plots I am getting are not the likelihood curves that I
was expecting. The y-axis of the plots is tau and I would like that axis
to be the likelihood so that I have a curve that maxes at the parameter
estimate. I am not sure where I find those likelihood values? I may just
be misinterpreting the theory behind this. Thanks for any help you can give.
Max
clotting <- data.frame(
u = c(5,10,15,20,30,40,60,80,100),
lot1 = c(118,58,42,35,27,25,21,19,18),
lot2 = c(69,35,26,21,18,16,13,12,12))
glm2<-glm(lot2 ~ log(u), data=clotting, family=Gamma)
prof<-profile(glm2)
plot(prof)
Regenerate your example:
The
profile.glmfunction actually lives in theMASSpackage:In order to figure out what
profile.glmandplot.profileare doing, see?profile.glmand?plot.profile. However, in order to dig into theprofileobject it may also be useful to examine the code ofMASS:::profile.glmandMASS:::plot.profile… basically, what these tell you is thatprofileis returning the signed square root of the difference between the deviance and the minimum deviance, scaled by the dispersion parameter. The reason that this is done is so that the profile for a perfectly quadratic profile will appear as a straight line (it’s much easier to detect deviations from a straight line than from a parabola by eye).The other thing that may be useful to know is how the profile is stored. Basically, it’s a list of data frames (one for each parameter profiled), except that the individual data frames are a little bit weird (containing one vector component and one matrix component).
It also contains attributes
summaryandoriginal.fitthat you can use to recover the dispersion and minimum deviance:Now reverse the transformation for parameter 1:
Plot:
(This is the plot of the deviance. You can multiply by 0.5 to get the negative log-likelihood, or -0.5 to get the log-likelihood …)
edit: some more general functions to transform the profile into a useful format for
lattice/ggplotplotting …Now plot it with lattice:
Or with ggplot2: