[R] adding variable

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Nov 18 22:14:51 CET 2003


Are you looking for something like add1 then?

We do need a much clearer explanation of what you are trying to do to be 
able to help you: and not with y used in two separate senses!

On Tue, 18 Nov 2003, Martin Wegmann wrote:

> On Tuesday 18 November 2003 19:32, Prof Brian Ripley wrote:
> > On Tue, 18 Nov 2003, Martin Wegmann wrote:
> > > I have count data of animals (here y, y1, y2...) and env. variables (x,
> > > x1, x2 ,....).
> > >
> > > I used a glm
> > >
> > > glm(y~x1+x2+x3....)
> > >
> > > glm(y1~x1+x2+x3....)
> > >
> > > and now I would like to add the count data of other species to
> > > investigate if they might have a bigger impact than the env. variables:
> > >
> > > #x? are the selected var from the first glm run
> > >
> > > glm(y~x?+x?+y1)
> > >
> > > glm(y~x?+x?+x?+y2)
> > >
> > > ....
> > >
> > > I wonder if there is a more elegant method to do this than adding (and
> > > removing) each y by hand.
> >
> > Do you mean each x?  In either case, see ?update.
> 
> update looks good but with update and with adding the y I have to do it 
> manually. 
> 
> I thought something like doing 
> 
> glm(y~x+x1+x2+....+y§) 
> 
> where y§ is: grep y1 out of df.y run glm and name it
> grep y2 out of df.y run glm .....
> 
> until all y's of df.y has been onced included in the model.
> every time only one y§ has to be included
> 
> the included x's have to be kept. I only want to look if one species variables 
> has more explanation power than the env. variables.
> 
> perhaps this helps to understand what I am looking for:
> I think bash scripts are not possible in R but it would look like such a bash 
> script for GRASS:
> 
> for variable in y1 y2 y3  ....; do
> 
> glm(y~x+x1+x2....+$variable)->glm.$variable
> ; done
> 
> #where $variable refers to the name of read in y's.
> 
> 
> Martin
> 
> 
> 
> 

-- 
Brian D. Ripley,                  ripley at 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




More information about the R-help mailing list