[R] Problem fitting GAM
Gesmann, Markus
Markus.Gesmann at lloyds.com
Tue Sep 10 17:09:19 CEST 2013
Hi Lucas,
A similar question was raised on R-help about 10 years ago.
Take a look at David Firth's amended "quasipoisson" function here:
https://stat.ethz.ch/pipermail/r-help/2003-January/028743.html
I hope this helps
Markus
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Lucas Holland
Sent: 10 September 2013 09:53
To: r-help at R-project.org
Subject: [R] Problem fitting GAM
Hey all,
I've got some data of the form:
> head(df)
claims accident_year development_year
1 45630 1 1
2 53025 2 1
3 67318 3 1
4 93489 4 1
5 80517 5 1
6 68690 6 1
where accident_year is a factor (development_year is not).
with one entry in "claims" being negative. I'm trying to follow a paper on claims reserving, fitting a GAM (using the GAM package) to the data with a model of the form:
g <- gam(claims ~ s(development_year,5) + accident_year, data=df, family=quasi(link="log", variance="mu"))
The paper specifies an over dispersed Poisson model with logarithmic link function. It also states that the one negative value is not a problem.
However, when I run the above code I get an error:
Error in if (!(validmu(mu) && valideta(eta))) stop("Can't find valid starting values: please specify some") :
missing value where TRUE/FALSE needed
In addition: Warning message:
In log(mu) : NaNs produced
I don't understand what exactly that means and what the problem is since in the paper (granted, it doesn't show any implementation detail) it seems to work fine.
If you need the complete code or any other information I'll be happy to provide that.
Thanks!
______________________________________________
R-help at r-project.org mailing list
https://urldefense.proofpoint.com/v1/url?u=https://stat.ethz.ch/mailman/listinfo/r-help&k=VTIXiGvdT7U4yPSpeHcrHQ%3D%3D%0A&r=dUkLGPeM%2BYkyyiRRq50yGs%2BmEf8kG%2FyCNQPwZn%2FaQD0%3D%0A&m=7a8qJHimzZrXoL0T1j4mF%2BgSPqGLT%2Bzk%2BTIU5bqqdm0%3D%0A&s=892bd469ab64880d20fa885aae982d33442d29650695dd773300f07762573ff2
PLEASE do read the posting guide https://urldefense.proofpoint.com/v1/url?u=http://www.r-project.org/posting-guide.html&k=VTIXiGvdT7U4yPSpeHcrHQ%3D%3D%0A&r=dUkLGPeM%2BYkyyiRRq50yGs%2BmEf8kG%2FyCNQPwZn%2FaQD0%3D%0A&m=7a8qJHimzZrXoL0T1j4mF%2BgSPqGLT%2Bzk%2BTIU5bqqdm0%3D%0A&s=8b87892a4a68507989ac498e2906e4604f18adad73b84e420874b21ad211a26a
and provide commented, minimal, self-contained, reproducible code.
----------------------------------------------------------------------
The information in this E-Mail and in any attachments is...{{dropped:19}}
More information about the R-help
mailing list