12-05-2015 05:01 PM - edited 12-05-2015 05:02 PM
I am not very clear on how to apply forward stepwise procedure by using AIC in SAS to select a model, and of which is highly recommended by my professor, so I want to try to apply it.
e.g.performing forward stepwise procedure in model selection.
model (1): y=x1
model (2): y=x1+x2
My reasoning for the codes: (1) performing forward stepwise selection and getting AIC value of model (1)
(2) performing forward stepwise selection and getting AIC value of model (2)
(3) comparing the AIC value output form model (1) and (2), and choosing the model corresponding to a lower AIC value
Could anybody check whether my thingking path is correct or not?
If it is correct, I think the codes are also not well-formulated, because actually I have five more predictor variables. If checking the AIC value one by one, there will be too much repeated work. In this case, I will consider writting a macro, but I don't know how to do currently, could anyone offer me a similiar example on writting a macro for a model selection?
If my thingking path is wrong, could anyone tell me the correct solution of using stepwise procedure to make a model selection by checking the AIC?
Another question is that, in my dataset, there are both categorical variables and continuous variables and I want to make a model selection containing both cases of variables. My initial idea is to convert categorical variables to numeric, for example, male=0; female=1, but after convertion, the log came up with:
WARNING: No variables specified for an SSCP matrix. Execution terminating.
I suspect my solution is wrong, so could anyone offer me some information on how to deal with categorical variable in a multiple regression model?
*performing forward stepwise selection and getting AIC value of model (1) proc reg data=have_1 outest=want_1; model y = x1 /selection=forward aic; run; *print AIC value; proc print data=want_1; run; *performing forward stepwise selection and getting AIC value of model (2) proc reg data=have_2 outest=want_2; model y = x1, x2 /selection=forward aic; run; *print AIC value; proc print data=want_2; run;
12-05-2015 06:39 PM
12-06-2015 04:23 AM
12-05-2015 10:12 PM
You can do forward model selection based on AIC with proc glmselect. Name your categorical variables in the class statement, as in this outline:
proc glmselect data=have;
model y = x1 x2 gender / selection=forward(choose=aicc);
Check the documentation for many more options.