[R] adding variable

Martin Wegmann mailinglist2_wegmann at web.de
Tue Nov 18 21:53:04 CET 2003


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




More information about the R-help mailing list