[R] multidimensional function fitting

Simon Wood simon at stats.gla.ac.uk
Mon Mar 3 11:44:04 CET 2003


> On Thu, 27 Feb 2003 13:52:50 -0500, "Wiener, Matthew" <matthew_wiener at merck.com> wrote regarding
> "[despammed] RE: [R] multidimensional function fitting"
> 
> 8-) Take a look at package mgcv.  Hope this helps.  --Matt
> 8-) 
> 
> Thank you, I just did. It may indeed be what I'm looking for (I haven't 
>quite understood everything about it...), but:
> 
> 1) The best fits I obtain with a formula like z~s(x,y) ; but this I cannot 
> possibly transport into the C programme where I need it! Maybe I wasn't
> clear on this aspect?
- Yes, this won't be entirely straightforward, but note that the
underlying code in mgcv is written in C, so it would be possible...

> 
> 2) It is very memory hungry, esp. when using the s() function: I have 
> 192Mb with 256Mb swap (not a lot, but reasonable I'd say), and I've
> never had to kill R as often as when trying gam()...
> 
- do you have a very large number of data? The way mgcv works it first
finds an "optimal" basis for smoothing and this will involve formation of
a matrix of size n^2 where n is your number of data.... The last couple of
examples in the ?gam help file show how to avoid this using the "knots"
argument to gam: basically you find a "near optimal" basis for a random
subset of your data, and then use this basis to do the smoothing on the
whole data set. (Can you let me know if this solves the problem/isn't the 
issue). 

best,
Simon

_____________________________________________________________________
> Simon Wood simon at stats.gla.ac.uk        www.stats.gla.ac.uk/~simon/
>>  Department of Statistics, University of Glasgow, Glasgow, G12 8QQ
>>>   Direct telephone: (0)141 330 4530          Fax: (0)141 330 4814




More information about the R-help mailing list