Skip to content

Almost a GAM?

4 messages · Michael Roberts, vito muggeo, Simon Wood

#
Hello:

I sent this question the other day with the wrong subject
heading and couple typos, with no response.  So, 
here I go again, having made those corrections.

I would like to estimate, for lack of a better description,
a partially additive non-parametric model with the following
structure:

z~ f(x,y):w1 + g(x,y):w2 + e

In other words, I'd like to estimate the marginals with 
respect to w1 and w2 as nonparametric functions of 
x and y.    

I'm not positive, but I think I recall being able to estimate
a model like this using Splus gam function a couple years
ago (I no longer have Splus).  Although, I can
see that this would be a bit more difficult to do than a standard
gam with univariate partials and no interaction terms. The mgcv
gam function doesn't seem to like a function of this form.

Is there an R package that can estimate a model like this that
someone can point me toward?

Many thanks


Michael J. Roberts

Resource Economics Division
Production, Management, and Technology
USDA-ERS
(202) 694-5557 (phone)
(202) 694-5775 (fax)
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
I don't know of a package that will do this easily, sorry! It's on the
mgcv "to do" list, but involves a fair bit of work. In principle you can
do it yourself by manipulating the design matrix G$X that you'd get by
calling 
G<-gam.setup(z~s(x,y)+s(x,y))
G<-GAMsetup(G)
.. you just need to multiply the columns of the design matrix relating to
the first smooth by w1 and the columns relating to the second by w2, then
gam.fit() can do the rest... the easiest way to do this would be to modify
gam() [just after GAMsetup() is called].... but obviously this is a
nuisance (and will hopefully not be necessary in mgcv 0.8!)
Simon
  ______________________________________________________________________
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Hi all,
This model should be a "univariate version" to fit interaction between a
variate, x and a factor w, say:
z~ f(x, df1):w1 + g(x, df2):w2 + e
To fit this model a possible solution is

1)build the variate x in each level of w
xw1<-x*w1
xw2<-x*w2

2)then fit gam, by:
z~ w1+w2-1+f(xw1, df1)+ g(xw2, df2)

I am not able to find any theoretical difficulty in this model and
furthermore it seems to work with gam().
However recent works by M.P. Wand et al. use mixed models (GLMM) to fit
additive models with interactions between a smooth variate and factor.
(Actually I don't remember exactly the references but if you want I can look
for it). Although understanding the connections between GAMs and GLMMs may
be not difficult, I really don't understand why I have to fit GLMMs to model
interactions in GAMs.
Any comment is coming?
regards,
vito

PS (for Michael): If I remember well, the S-Plus gam() function never
handled interactions "s(x):w". Just it fitted the linear term "x:w"


----- Original Message -----
From: "Simon Wood" <snw at mcs.st-and.ac.uk>
To: "Michael Roberts" <mroberts at ers.usda.gov>
Cc: <r-help at stat.math.ethz.ch>
Sent: Monday, January 28, 2002 7:34 PM
Subject: Re: [R] Almost a GAM?
-.-.-
http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
- This often seems to work quite well, but the problem is that f(0) and
g(0) are not equal to zero - so it doesn't do exactly what you would like
*and* all those zero covariate values will influence the smoothing
parameter selection. [Of course if the model of interest is really this
simple then one way to proceed is just to split the dataset up by levels
of the single factor and fit smooths to the data for each level].

cheers,
Simon

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._