[R] predict.glm and predict.gam output

0 views
Skip to first unread message

Anke Konrad

unread,
Jun 18, 2009, 3:23:54 PM6/18/09
to r-h...@r-project.org
Hi all,

I am currently trying to compare different plant occurrence prediction
maps generated in R and exported into GRASS. One of these maps was
generated from a glm fitted to some data, and subsequently applying this
glm model to a wider region using predict.glm. The outcome here was a
probability of occurrence. The second map I generated using a gam
(mgcv), however, this map seems to have assigned something like a
negative log-likelihood of occurrence to each raster cell in the region.
Since I would like to compare the two, I would like to figure out a way
of having the same kind of output from the "predict" functions (either
probability OR negative log-likelihood). Does anyone know of a way of
changing the output options? And if not, does anyone have any
suggestions of how I could deal with this issue?

Thank you!

______________________________________________
R-h...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

David Winsemius

unread,
Jun 18, 2009, 3:38:07 PM6/18/09
to Anke Konrad, r-h...@r-project.org

On Jun 18, 2009, at 3:23 PM, Anke Konrad wrote:

> Hi all,
>
> I am currently trying to compare different plant occurrence
> prediction maps generated in R and exported into GRASS. One of these
> maps was generated from a glm fitted to some data, and subsequently
> applying this glm model to a wider region using predict.glm. The
> outcome here was a probability of occurrence. The second map I
> generated using a gam (mgcv), however, this map seems to have
> assigned something like a negative log-likelihood of occurrence to
> each raster cell in the region. Since I would like to compare the
> two, I would like to figure out a way of having the same kind of
> output from the "predict" functions (either probability OR negative
> log-likelihood). Does anyone know of a way of changing the output
> options? And if not, does anyone have any suggestions of how I could
> deal with this issue?

Have you actually read the help pages for predict.glm and
mgcv::predict.gam?

--
David Winsemius, MD
Heritage Laboratories
West Hartford, CT

Gavin Simpson

unread,
Jun 19, 2009, 6:15:23 AM6/19/09
to Anke Konrad, r-h...@r-project.org
On Thu, 2009-06-18 at 13:23 -0600, Anke Konrad wrote:
> Hi all,
>
> I am currently trying to compare different plant occurrence prediction
> maps generated in R and exported into GRASS. One of these maps was
> generated from a glm fitted to some data, and subsequently applying this
> glm model to a wider region using predict.glm. The outcome here was a
> probability of occurrence. The second map I generated using a gam
> (mgcv), however, this map seems to have assigned something like a
> negative log-likelihood of occurrence to each raster cell in the region.
> Since I would like to compare the two, I would like to figure out a way
> of having the same kind of output from the "predict" functions (either
> probability OR negative log-likelihood). Does anyone know of a way of
> changing the output options? And if not, does anyone have any
> suggestions of how I could deal with this issue?

Did you set type = "response" in both predict.glm and predict.gam?

It sounds like the gam predictions are still on the scale of the link
function...

G

>
> Thank you!
>
> ______________________________________________
> R-h...@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Dr. Gavin Simpson [t] +44 (0)20 7679 0522
ECRC, UCL Geography, [f] +44 (0)20 7679 0565
Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/
UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

signature.asc

sw...@bath.ac.uk

unread,
Jun 19, 2009, 5:32:44 AM6/19/09
to Anke Konrad, r-h...@r-project.org
Anke,

mgcv:predict.gam certainly didn't produce `something like a
negative log-likelihood of occurrence', but is it possible that one of
your maps is on the probability scale and the other on the linear
predictor scale?
If you used predict.glm(model1,type="response"), but
predict.gam(model2,type="link"), then you'd get the sort of difference
that you are maybe describing. ?predict.gam and ?predict.glm give more
details.
If that doesn't resolve the issue, then a few more details about the
models actually being fitted are probably needed.

best,
Simon

Reply all
Reply to author
Forward
0 new messages