Re: [R] help with step()

From: Sundar Dorai-Raj <sundar.dorai-raj_at_pdf.com>
Date: Tue 28 Feb 2006 - 04:33:54 EST

Smith, Phil wrote:
> Folks:
>
> I'm having trouble doing a forward variable selection using step()
>
> First, I fit an initial model:
>
> fit0 <- glm ( est~1 , data=all, subset=c(n>=25) )
>
> then I invoke step():
>
> fit1 <- step( fit0 , scope=list(upper=est~ pcped + pchosp + pfarm
> ,lower=est~1))
>
>
> I get the error message: Error in eval(expr, envir, enclos) : invalid
> 'envir' argument
>
> I looked at the documention on step(). There is no 'envir' arguement.
>
> Can anyone shed light on what I'm doing wrong?
>
> Thanks,
> Phil Smith
> CDC
>
>
>

Could be your "data" argument. ?all is a base function. Try re-naming to something else. Here's an example:

set.seed(1)
z <- all <- data.frame(x = rnorm(10), y = rnorm(10))

glm.all <- glm(y ~ 1, data = all)
step(glm.all, list(upper = y ~ x, lower = y ~ 1))

# Start:  AIC= 32.67
# y ~ 1
#
# Error in eval(expr, envir, enclos) : invalid 'envir' argument

glm.z <- glm(y ~ 1, data = z)
step(glm.z, list(upper = y ~ x, lower = y ~ 1))

# Start:  AIC= 32.67
#  y ~ 1
#
#        Df Deviance    AIC
# <none>      10.295 32.669
# + x     1    8.834 33.139
#
# Call:  glm(formula = y ~ 1, data = z)
#
# Coefficients:
# (Intercept)
#      0.2488
#
# Degrees of Freedom: 9 Total (i.e. Null);  9 Residual
# Null Deviance:      10.29
# Residual Deviance: 10.29        AIC: 32.67

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Feb 28 04:43:24 2006

This archive was generated by hypermail 2.1.8 : Tue 28 Feb 2006 - 06:08:49 EST