Jesse001 Jesse001 - 2 months ago 9x
R Question

step$anova following stepAIC() not subsettable?

I'm trying to run a simple backwards stepwise multiple linear regression in R using the stepAIC function from the MASS package. The model runs fine, but I can't seem to get the results. When I run "step$anova" I get

Error in step$anova : object of type 'closure' is not subsettable

I've used this exact code many times and never gotten this error before, but I also see no issues in my data matrix or any difference between this and what I usually do. Any tips on this error would be greatly appreciated.

My code is:

PCBstep<- stepAIC(PCBiomass, direction="backward")

the data are attached and useable (earlier in the code they're used in an RDA)


Oops, It should be PCBstep$anova in the final line. You can not subset step, because that is an R's built-in function. (You know the stats::step function, right?) A function is a closure; that is what the error is complaining about.