[R] Question about GAMs

David Winsemius dwinsemius at comcast.net
Thu Oct 13 18:37:40 CEST 2011


On Oct 13, 2011, at 11:20 AM, pigpigmeow wrote:

> I'm confused...
> I type ..
> predict.gam(ozonea,type=s(ratio,bs="cr"))
>
>  pressure      maxtemp   s(avetemp)     s(ratio)
> 1   -0.0459102290 -0.185178463  0.263358446 -0.164558673
> 2   -0.0286464652 -0.194731320  0.199315027  0.727823293
> 3    0.0478073459 -0.013227033  0.002228896  0.342373202
> 4   -0.0089164494  0.082301539 -0.037331159 -0.067260889
> 5    0.0675373617  0.024984396 -0.047067786 -0.357569389
> 6    0.0823348735  0.101407254 -0.075884852 -1.485036738
> 7   -0.0977015204  0.177830112 -0.094755158  0.236575309
> 8   -0.0903027645  0.225594398 -0.113346667  0.435141242
> 9    0.0206785742  0.187382969 -0.066346157 -0.256133513
> 10  -0.1371615520  0.101407254 -0.131656887  0.145057584
> 11  -0.0477674066 -0.181001505  0.260279546  0.180513043
> 12  -0.0921599421 -0.009050075 -0.020511366  0.281470433
> 13   0.0681464361 -0.219212934  0.335348247  0.270813178
> ......
>
> I want to show s(ratio,bs="cr") term, and show the warning message
> Warning message:
> In predict.gam(ozonea, type = s(ratio, bs = "cr")) :
>  Unknown type, reset to terms.
>
> I don't understand what does it mean.
>
> By the way, i use log-link function,
> should I convert log-link function of newozone to fitted value of  
> newozone?
> 1. log(newozone) - s(ratio,bs="cr") = x
> then   exp(x)

Perhaps. I do not see 'newozone' defined anywhere above and can only  
speculateo speculate. I'm pretty sure Wood's uncopied comment was  
intended to remind you that differences in the log (regression) scale  
are equivalent to ratios on the measured scales.

So either :
exp( diff(coef, log(measured_or_external_baseline)  ) )
# OR
exp(coef)/measured_or_external_baseline

How that is properly calculated in pkg:mgcv is a separate issue and  
Simpson has suggested you read the help pages more carefully.

>
> 2. exp(newozone) - s(ratio,bs="cr") =X
> then x

Probably incorrect.

>
> which one is correct?
> so confused
>

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list