Re: [R] How can one make stepAIC and lme

2008-05-13 Thread Prof Brian Ripley
You are using subset() as a function -- lme has a subset argument, and subset() has non-standard semantics. The dataset you are using is subset(D1,age!=14): it is that which you need to make sure is visible. You didn't make D1 visible, just its columns. On Tue, 13 May 2008, Jorunn Slagstad w

Re: [R] How can one make stepAIC and lme

2008-05-13 Thread Jorunn Slagstad
Hi again, I've tried using with() inside my function in the following manner: library(nlme) library(MASS) PredRes<-function(D1) { with(D1, {lmemod<-lme(distance~age*Sex, random=~1|Subject, data=subset(D1,age!=14), method="ML") themod<-stepAIC(lmemod,dir="both") summary(themod) prs=predict(themod,

Re: [R] How can one make stepAIC and lme

2008-05-09 Thread Prof Brian Ripley
It's a known scoping issue in lme -- you are doing this from a function. Make sure your dataset is visible -- e.g. use with(). On Fri, 9 May 2008, Jorunn Slagstad wrote: Dear R-help I'm working on a large dataset which I have divided into 20 subsets based on similar features. Each subset cons

[R] How can one make stepAIC and lme

2008-05-09 Thread Jorunn Slagstad
Dear R-help I'm working on a large dataset which I have divided into 20 subsets based on similar features. Each subset consists of observations from different locations and I wish to use the location as a random effect. For each group I want to select regressors by a stepwise procedure and inclu