BookmarkSubscribeRSS Feed
econdon
Calcite | Level 5

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

6 REPLIES 6
SteveDenham
Jade | Level 19

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

econdon
Calcite | Level 5

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!

Rick_SAS
SAS Super FREQ

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;

econdon
Calcite | Level 5

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.

SteveDenham
Jade | Level 19

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

econdon
Calcite | Level 5

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 1564 views
  • 6 likes
  • 3 in conversation