Programming the statistical procedures from SAS

GLMSELECT display all candidate models in a table

Reply
Occasional Contributor
Posts: 13

GLMSELECT display all candidate models in a table

Hi there--

I am a new SAS user, and I'm trying to use GLMSELECT to select a best model for my data. I want to calculate Akaike weights for each candidate model to average parameter estimates for a best fit model, but in order to do this I need to get a table of estimated parameters for all of my candidate models with AICC displayed for each model. I hope that makes sense.

I can get a very long output that shows each model separately, but I would have to manually enter the parameter estimates into a separate table, which would be extremely time consuming. I tried using the TABLES option in the MODELAVERAGE statement to get this table, but I haven't figured out a way to do that.

I can get this information easily from R, but the analysis in R is actually giving me slightly different results from SAS (for reasons I can't determine right now), so I'd like to stick with SAS and get that table from SAS. Any help would be much appreciated. Thanks!

Lizzie

Respected Advisor
Posts: 2,655

Re: GLMSELECT display all candidate models in a table

Let's start off with a disclaimer: I have never done this, so what I am suggesting may only be possible in my mind.

I think you will need to use ODS OUTPUT to get all of the information.  The experimental MODELAVERAGE statement does a bootstrap to average, without weighting.  So, you will need to pull from several ODS tables to get the information you want. So ODS TRACE ON before, ODS TRACE OFF after to identify exactly which tables carry the variables you need for re-arranging into the table you are looking for.

Steve Denham

Occasional Contributor
Posts: 13

Re: GLMSELECT display all candidate models in a table

Thanks for the tip. I was able to use that to get the parameter estimates, but I'm still working on getting the AICC for each model into that table. I'm new at this, so the ODS output is kind of confusing. I will let you know if I work it out. Thanks again!

SAS Super FREQ
Posts: 3,547

Re: GLMSELECT display all candidate models in a table

I could provide more information if I knew what options you were using, but see if this example helps you head in the right direction:

ods output SelectionSummary = Summary   ParameterEstimates = PE;
proc glmselect data=sashelp.baseball;
   model logSalary = nAtBat nHits nHome nRuns nRBI nBB
                     yrMajor crAtBat crHits crHome crRuns crRbi
                     crBB nOuts nAssts nError
                   / details=all;
run;

data All;
merge Summary PE(where=(Step^=.));
by Step;
run;

proc print data=All;
var Step Effect Estimate AICC;
run;

Occasional Contributor
Posts: 13

Re: GLMSELECT display all candidate models in a table

OKAY, I'm being an idiot (I think!). In stepwise selection I cannot get an AICC value for all possible models, because SAS is building the model in a stepwise fashion. I can only get AICC for each step. Sorry about that. I'm working on using PROC REG to get all possible models and their AICC values, but I'm having issues there as PROC REG does not have a class statement, and I do have several categorized variables. I might end up asking for help on that in a separate thread. Thanks to both of you though--that code did get me AICC in a table for each step and I might end up using it if I stick with stepwise selection.

Respected Advisor
Posts: 2,655

Re: GLMSELECT display all candidate models in a table

Stop and think this over.  An all possible models approach that includes categorical models has an inherent drawback in that a variable that is (for instance) dichotomous would be represented with one variable, but any that have more than two levels (say N) will be represented by N-1 variables that are exclusive.  You then run into the problem of trying to interpret a model that only includes <N-1 of these indicator variables.

Steve Denham

Occasional Contributor
Posts: 13

Re: GLMSELECT display all candidate models in a table

Right. My dichotomous variables are basically on a size scale, with small=0 and large=1, and there are only two categories, so I think I will be able to interpret the models, but thanks for pointing that out.

Ask a Question
Discussion stats
  • 6 replies
  • 417 views
  • 6 likes
  • 3 in conversation