Hello I am using the step function in order to do backward selection for a linear model of 52 variables with the following commands:
object<-lm(vars[,1] ~ (vars[,2:(ncol(predictors)+1)]-1)) BackS<-step(object,direction="backward") but it isn't dropping any if the variables in the model, but there are lots of not significant variables as you can see here > object<-lm(vars[,1] ~ (vars[,2:(ncol(predictors)+1)]-1)) > summary(object) Call: lm(formula = vars[, 1] ~ (vars[, 2:(ncol(predictors) + 1)] - 1)) Residuals: Min 1Q Median 3Q Max -0.56388 -0.10762 -0.01433 0.08495 0.82477 Coefficients: Estimate Std. Error t value Pr(>|t|) vars[, 2:(ncol(predictors) + 1)]SS.1 0.028772 0.025458 1.130 0.260896 vars[, 2:(ncol(predictors) + 1)]Precio.Promedio.Bolsa[1] -0.308076 0.096243 -3.201 0.001795 ** vars[, 2:(ncol(predictors) + 1)]Precio.Promedio.Bolsa[2] 0.130134 0.101734 1.279 0.203559 vars[, 2:(ncol(predictors) + 1)]Precio.Promedio.Bolsa[3] 0.014345 0.106282 0.135 0.892887 vars[, 2:(ncol(predictors) + 1)]Precio.Promedio.Bolsa[4] -0.175958 0.107097 -1.643 0.103268 vars[, 2:(ncol(predictors) + 1)]Precio.Promedio.Bolsa[5] 0.016270 0.106081 0.153 0.878391 vars[, 2:(ncol(predictors) + 1)]Precio.Promedio.Bolsa[6] -0.089018 0.091132 -0.977 0.330834 vars[, 2:(ncol(predictors) + 1)]Precio.Promedio.Bolsa[7] -0.270550 0.075537 -3.582 0.000512 *** vars[, 2:(ncol(predictors) + 1)]Precio.Promedio.Bolsa[8] -0.106691 0.074448 -1.433 0.154694 vars[, 2:(ncol(predictors) + 1)]Precio.Promedio.Bolsa[9] 0.118962 0.076886 1.547 0.124699 vars[, 2:(ncol(predictors) + 1)]Precio.Promedio.Bolsa[10] -0.055112 0.076225 -0.723 0.471218 vars[, 2:(ncol(predictors) + 1)]Precio.Promedio.Bolsa[11] -0.135113 0.076307 -1.771 0.079415 . vars[, 2:(ncol(predictors) + 1)]Precio.Promedio.Bolsa[12] 0.082478 0.075130 1.098 0.274707 vars[, 2:(ncol(predictors) + 1)]Anomalia[0] 0.123054 0.213980 0.575 0.566426 vars[, 2:(ncol(predictors) + 1)]Anomalia[1] 0.078511 0.507544 0.155 0.877353 vars[, 2:(ncol(predictors) + 1)]Anomalia[2] -0.399726 0.581594 -0.687 0.493357 vars[, 2:(ncol(predictors) + 1)]Anomalia[3] -0.002103 0.583109 -0.004 0.997129 vars[, 2:(ncol(predictors) + 1)]Anomalia[4] 0.596937 0.678115 0.880 0.380640 vars[, 2:(ncol(predictors) + 1)]Anomalia[5] -0.547555 0.710687 -0.770 0.442695 vars[, 2:(ncol(predictors) + 1)]Anomalia[6] -0.142452 0.678536 -0.210 0.834106 vars[, 2:(ncol(predictors) + 1)]Anomalia[7] 0.506431 0.692960 0.731 0.466455 vars[, 2:(ncol(predictors) + 1)]Anomalia[8] -0.117177 0.662596 -0.177 0.859958 vars[, 2:(ncol(predictors) + 1)]Anomalia[9] -0.550570 0.563421 -0.977 0.330638 vars[, 2:(ncol(predictors) + 1)]Anomalia[10] 0.799499 0.555007 1.441 0.152587 vars[, 2:(ncol(predictors) + 1)]Anomalia[11] -0.577416 0.504046 -1.146 0.254485 vars[, 2:(ncol(predictors) + 1)]Anomalia[12] 0.204479 0.221030 0.925 0.356948 vars[, 2:(ncol(predictors) + 1)]demanda.nacional[0] -0.572351 1.303885 -0.439 0.661561 vars[, 2:(ncol(predictors) + 1)]demanda.nacional[1] 0.270387 1.715912 0.158 0.875082 vars[, 2:(ncol(predictors) + 1)]demanda.nacional[2] 1.939207 1.806931 1.073 0.285549 vars[, 2:(ncol(predictors) + 1)]demanda.nacional[3] 1.501964 1.779253 0.844 0.400432 vars[, 2:(ncol(predictors) + 1)]demanda.nacional[4] 1.292790 1.759802 0.735 0.464147 vars[, 2:(ncol(predictors) + 1)]demanda.nacional[5] 1.197978 1.760600 0.680 0.497670 vars[, 2:(ncol(predictors) + 1)]demanda.nacional[6] 0.338068 1.720709 0.196 0.844608 vars[, 2:(ncol(predictors) + 1)]demanda.nacional[7] -2.197186 1.616212 -1.359 0.176805 vars[, 2:(ncol(predictors) + 1)]demanda.nacional[8] -2.050263 1.542936 -1.329 0.186687 vars[, 2:(ncol(predictors) + 1)]demanda.nacional[9] -0.103823 1.541956 -0.067 0.946441 vars[, 2:(ncol(predictors) + 1)]demanda.nacional[10] 0.349220 1.545823 0.226 0.821693 vars[, 2:(ncol(predictors) + 1)]demanda.nacional[11] -0.654607 1.476141 -0.443 0.658313 vars[, 2:(ncol(predictors) + 1)]demanda.nacional[12] -0.254144 1.193506 -0.213 0.831772 vars[, 2:(ncol(predictors) + 1)]Nivel.Embalse[0] -1.500119 0.428395 -3.502 0.000671 *** vars[, 2:(ncol(predictors) + 1)]Nivel.Embalse[1] -1.058775 0.475011 -2.229 0.027869 * vars[, 2:(ncol(predictors) + 1)]Nivel.Embalse[2] 0.818735 0.497920 1.644 0.102994 vars[, 2:(ncol(predictors) + 1)]Nivel.Embalse[3] 0.057331 0.528216 0.109 0.913769 vars[, 2:(ncol(predictors) + 1)]Nivel.Embalse[4] -0.529271 0.519284 -1.019 0.310350 vars[, 2:(ncol(predictors) + 1)]Nivel.Embalse[5] -0.649193 0.508210 -1.277 0.204171 vars[, 2:(ncol(predictors) + 1)]Nivel.Embalse[6] 0.511649 0.490911 1.042 0.299605 vars[, 2:(ncol(predictors) + 1)]Nivel.Embalse[7] -0.545404 0.473994 -1.151 0.252392 vars[, 2:(ncol(predictors) + 1)]Nivel.Embalse[8] -0.314593 0.489687 -0.642 0.521939 vars[, 2:(ncol(predictors) + 1)]Nivel.Embalse[9] -0.091112 0.510613 -0.178 0.858712 vars[, 2:(ncol(predictors) + 1)]Nivel.Embalse[10] -0.030684 0.492553 -0.062 0.950442 vars[, 2:(ncol(predictors) + 1)]Nivel.Embalse[11] 0.162751 0.488237 0.333 0.739515 vars[, 2:(ncol(predictors) + 1)]Nivel.Embalse[12] 0.370126 0.458473 0.807 0.421250 --- Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 Residual standard error: 0.2159 on 109 degrees of freedom Multiple R-squared: 0.566, Adjusted R-squared: 0.359 F-statistic: 2.734 on 52 and 109 DF, p-value: 5.24e-06 do you know how can I do this? how can I do backward selection on a regression without an intercept? Thank you Felipe Parra [[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.