[R] Problem fitting GAM

Lucas Holland hollandlucas at gmail.com
Tue Sep 10 10:53:00 CEST 2013


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!


More information about the R-help mailing list