1

Hey so I am developing a multiple regression model and using the forward subset selection method to reduce the number of parameters and using "mallows Cp" as a selection criterion. However this is an engineering problem and it does not make sense to have an intercept,, i.e. when all the predictors are zero, the prediction will be 0. Hence I want to remove the intercept from my regression equation. I know that in case of just regression a "lm(y~x+z-1)" will do , however this does not seem to work with my code.

#Fitting Using Model Selection
library(leaps)
a.fit<- regsubsets(ROP~.-1,data=dat1,nvmax=10)
summary(a.fit)
plot(summary(a.fit)$cp,xlab="No. of variables", ylab="Cp")
which.min((summary(a.fit)$cp))
plot(a.fit,scale="Cp")
coef(a.fit,6)

##Forward Stepwise Selection
f.fit<- regsubsets(ROP~.,data=dat1)
summary(f.fit)
plot(summary(f.fit)$cp,xlab="No. of variables", ylab="Cp")
which.min((summary(f.fit)$cp))
plot(f.fit,scale="Cp")
coef(f.fit,5)

1 Answers1

1

I haven't used regsubsets() before, but the way I see it you can simply set the intercept parameter to FALSE, check ?regsubsets. Example:

data(swiss)
a.fit <- regsubsets(Fertility ~ ., data = swiss, nvmax = 10,  intercept = F)
minimum <- which.min((summary(a.fit)$cp)) # 4

coef(a.fit, minimum)    
     Agriculture        Education         Catholic Infant.Mortality 
      0.11714390      -0.44750066       0.07508021       3.27420789 
thie1e
  • 3,588
  • 22
  • 22