Allan,

Thank you.  I tried to adapt your suggestion to my situation and it still
does not work [as an aside, I'm new to R, so I may be overlooking something
simple].  Using your example below, I want my lower model to reflect only
an intercept (i.e., medv ~ 1), I want my upper model to reflect all
predictors in the data set (which I believe is indicated by medv ~ .).
I've provided the updated code, and the error I received upon running it.

> data(BostonHousing, package = "mlbench")> lmFit <- train(medv ~ 1, data = 
> BostonHousing, "lmStepAIC", +                scope = list(lower = ~1, upper = 
> ~.), +                direction = "forward")Error in { : task 1 failed - "'.' 
> in formula and no 'data' argument"



On Mon, Mar 5, 2012 at 5:01 AM, Allan Engelhardt <all...@cybaea.com> wrote:

> Not sure I really like stepwise variable selection, but the function
> should work, of course.  Compare
>
> data(BostonHousing, package = "mlbench")
> lmFit <- train(medv ~ ., data = BostonHousing, "lmStepAIC", scope =
> list(lower = ~., upper = ~.^2), direction = "forward")
>
> with
>
> lmFit <- train(medv ~ ., data = BostonHousing, "lmStepAIC", scope =
> list(lower = ~., upper = ~.^2), direction = "backward")
>
> and also the version without the "direction" argument where the code tries
> to do the right thing.
>
> In summary, my understanding is that your call first fits a y ~ . type
> model from which you cannot step backwards with constraints and then it
> tries to do 'what you might have meant'.
>
> Hope this helps a little.
>
> Allan
>
>
> On 05/03/12 01:14, Dan Putka wrote:
>
>> I'm looking for guidance on how to implement forward stepwise regression
>> using lmStepAIC in Caret.
>>
>> The stepwise "direction" appears to default to "backward". When I try to
>> use "scope" to provide a lower and upper model,  Caret still seems to
>> default to "backward".
>>
>> Any thoughts on how I can make this work?
>>
>> Here is what I tried:
>>
>> itemonly<- susbstitute(~i1+i2+i3+i4+i5+**i6+i7+i8+i9+i10)  #this is my
>> full
>> model
>> #I want my "lower" model to consist of the intercept only
>>
>> stepLmFit.i<- train(xtraindata.i, ytraindata,"lmStepAIC",
>> scope=list(upper=itemonly,**lower=~1),direction="forward")
>>
>> Any guidance on how I can make this work would be greatly appreciated.
>>
>> Dan
>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________**________________
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>> PLEASE do read the posting guide http://www.R-project.org/**
>> posting-guide.html <http://www.R-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to