1

I'm working on developing a regression relationship with stepwise approach. Following is my code and the error message:

step(nls(q50 ~ aXarea^a1Xslope^a2Xpcp^a3Xforest^a4, 
  start=list(a=6, a1=0.2, a2=1, a3=10, a4=-0.5), direction='backward'))

Error in model.frame.default(formula = ~q50 + area + slope + pcp + forest,  : 
  variable lengths differ (found for '(direction)')

Could not figure out what is the error.

MrFlick
  • 195,160
  • 17
  • 277
  • 295
  • 1
    Please show a small reproducible example – akrun Jul 04 '20 at 20:32
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Jul 04 '20 at 20:32
  • 2
    I don't think `step` supports `nls`. – user2554330 Jul 04 '20 at 20:38
  • Adding or deleting a variable to such a formula has no meaning so how could it possibly perform stepwise regression. Define your submodels manually and compare them using anova. – G. Grothendieck Jul 04 '20 at 21:00

0 Answers0