[R] Almost a GAM?

Michael Roberts mroberts at ers.usda.gov
Tue Jan 29 18:09:29 CET 2002


I don't think I can solve my problem in this way because w1
and w2 are continuous variables.

A second problem is that my f(x,y) is not f(x, df), i.e., I'd
like to have a sum of *two* dimensional smoothers interacted
with other variables.

After my first post I did find a discussion of this problem on the 
S archive, which suggested the same appraoch as Vito did.  S can
fit 2-d smooths, but still can't handle the interaction terms.

If nothing else is out there I thought I might try the following.
(Please let me know if this is a crazy thing to do).

It seems to me that I can fit this model by backfitting each smoother,
being careful to re-weight each smooth fit according to the
interaction
term.  So estimate

( z - ghat(x,y):w2 )/w1 ~ f(x,y) + e/w1

to get fhat(x,y), then similarly estimate ghat, then fhat, and so on 
until convergence.  The idea was to use smoothers already
out there (such as loess in modreg).

In principle this doesn't seem like a big job to me.  If it is, please
let me know, because I'm not a heavy programmer either.  And 
really prefer not to "reinvent the wheel."

Thanks for your help!

Mike






Michael J. Roberts

Resource Economics Division
Production, Management, and Technology
USDA-ERS
(202) 694-5557 (phone)
(202) 694-5775 (fax)

>>> Simon Wood <snw at mcs.st-and.ac.uk> 01/29/02 04:39AM >>>
> > > 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.
> 
> 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().

- 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 
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list