From ripley at stats.ox.ac.uk  Fri Jul  2 17:15:45 2004
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Fri Jul  2 17:15:51 2004
Subject: [Rd] Guidelines for writing model term functions (?)
In-Reply-To: <40E56E9E.1060805@jhsph.edu>
Message-ID: <Pine.LNX.4.44.0407021610310.27303-100000@gannet.stats>

Well, there are examples like log, too, and poly() is a good one.

poly, ns and bs are special because they participate in the safe 
prediction scheme (?SafePrediction). If you don't need that, just return a 
vector or matrix (whose columns will be treated as a set of vectors).


On Fri, 2 Jul 2004, Roger D. Peng wrote:

> Are there any general guidelines for writing functions that appear in 
> model formulas for functions like lm()/glm()?  The ones I can think of 
> are ns()/bs() in `splines' and s() in `mgcv'.  It seems that ns()/bs() 
> basically create matrix with a number of attributes and a class, while 
> s() returns a list of parameters.  It seems that gam() in `mgcv' has 
> its own way of dealing with formulas so maybe that's not a great 
> example, but are there any suggestions for writing a function that 
> might appear in the formula for, say, lm() or glm()?

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


[Rd] Guidelines for writing model term functions (?)
Prof Brian Ripley