turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Stat Procs
- /
- Code for a table with AIC and AICc in Proc logisti...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-04-2012 04:54 PM

Could anyone please forward me code for generating a table with AIC and AICc values in Proc logistic in SAS 9.2?

Thanks in advance!

Accepted Solutions

Solution

03-05-2012
03:24 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Swainsons

03-05-2012 03:24 PM

The AICC is produced in response to the request :

**score out=drop fitstat;**

in version 9.3...

I just checked the FITSTAT documentation in version 9.2 :

and only the four statistics that you got are produced.

If you are using the AIC to compare models built on the same number of observations then it is very unlikely that you would get a different model ordering with AIC and AICC.

Best of luck.

PG

PG

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Swainsons

03-04-2012 05:20 PM

You can get AIC into dataset myAIC by adding the statement

ods output FitStatistics=myAIC(where=(criterion="AIC"));

to your proc logistic.

PG

PG

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to PGStats

03-04-2012 05:41 PM

PG,

Thanks for your response! Could you please show me in the code below where to place the statement: ods output FitStatistics=myAIC(where=(criterion="AIC"));

Do I need to create "myAIC"?

options formdlim = '-';

PROC IMPORT OUT= WORK.BHCO

DATAFILE= "C:\Users\nacharti\Desktop\PhD\Nest survival analysis\Logistic regression BHCO\Data\bhco5.jmp"

DBMS=JMP REPLACE;

RUN;

Proc logistic data=BHCO desc;

Class ;

model Parisitized = CaneStemAvg;

run;

Proc logistic data=BHCO desc;

Class ;

model Parisitized = CanCovAvg;

run;

Proc logistic data=BHCO desc;

Class ;

model Parisitized = ForbAvg;

run;

Proc logistic data=BHCO desc;

Class ;

model Parisitized = TreeLg CanCovAvg;

run;

Proc logistic data=BHCO desc;

Class ;

model Parisitized = DenVerCV DenHorCV;

run;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Swainsons

03-04-2012 08:32 PM

options formdlim = '-';

PROC IMPORT OUT= WORK.BHCO

DATAFILE= "C:\Users\nacharti\Desktop\PhD\Nest survival analysis\Logistic regression BHCO\Data\bhco5.jmp"

DBMS=JMP REPLACE;

RUN;

Proc logistic data=BHCO desc;

Class ;

model Parisitized = CaneStemAvg;

ods output FitStatistics=AIC_CaneStemAvg(where=(criterion="AIC"));

run;

Proc logistic data=BHCO desc;

Class ;

model Parisitized = CanCovAvg;

ods output FitStatistics=AIC_CanCovAvg(where=(criterion="AIC"));

run;

Proc logistic data=BHCO desc;

Class ;

model Parisitized = ForbAvg;

ods output FitStatistics=AIC_ForbAvg(where=(criterion="AIC"));

run;

Proc logistic data=BHCO desc;

Class ;

model Parisitized = TreeLg CanCovAvg;

ods output FitStatistics=AIC_TreeLgCanCovAvg(where=(criterion="AIC"));

run;

Proc logistic data=BHCO desc;

Class ;

model Parisitized = DenVerCV DenHorCV;

ods output FitStatistics=AIC_DenVerCVDenHorCV(where=(criterion="AIC"));

run;

data allAIC;

set AIC_: INDSNAME=modelVars;

run;

proc print; run;

PG

PG

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Swainsons

03-04-2012 09:16 PM

Wait! You can do better! This way, you should get AIC, AICC and BIC :

options formdlim = '-';

PROC IMPORT OUT= WORK.BHCO

DATAFILE= "C:\Users\nacharti\Desktop\PhD\Nest survival analysis\Logistic regression BHCO\Data\bhco5.jmp"

DBMS=JMP REPLACE;

RUN;

Proc logistic data=BHCO desc;

model Parisitized = CaneStemAvg;

score out=drop fitstat;

ods output ScoreFitStat=AIC_CaneStemAvg;

run;

Proc logistic data=BHCO desc;

model Parisitized = CanCovAvg;

score out=drop fitstat;

ods output ScoreFitStat=AIC_CanCovAvg;

run;

Proc logistic data=BHCO desc;

model Parisitized = ForbAvg;

score out=drop fitstat;

ods output ScoreFitStat=AIC_ForbAvg;

run;

Proc logistic data=BHCO desc;

model Parisitized = TreeLg CanCovAvg;

score out=drop fitstat;

ods output ScoreFitStat=AIC_TreeLgCanCovAvg;

run;

Proc logistic data=BHCO desc;

model Parisitized = DenVerCV DenHorCV;

score out=drop fitstat;

ods output ScoreFitStat=AIC_DenVerCVDenHorCV;

run;

data allAIC;

set AIC_: INDSNAME=modelVars;

run;

proc print; run;

PG

PG

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to PGStats

03-05-2012 01:46 PM

PG,

Thank you very much for your time with my question.

When I ran the code in your reply of Mar 4, 2012 7:32 PM, this is the output:

The SAS System 12:15 Monday, March 5, 2012 76

Intercept

Intercept And

Obs Criterion Only Covariates

1 AIC 81.670 81.761

2 AIC 81.670 83.574

3 AIC 81.670 84.493

4 AIC 81.670 83.587

5 AIC 81.670 83.448

Obviously, I can see that it has produced AIC values. However, the AIC values for Obs 1-5 do not correspond to the sequential order of the models, so one needs to go to the output and see which AIC values correspond with each model? It would be great if there was a way to list the model "name" instead of just numerical values (1-5) for each Obs.

When I ran the code in your second reply of Mar 4, 2012 8:16 PM, for which you said I should get you should get AIC, AICC and BIC, this is the output:

The SAS System 12:15 Monday, March 5, 2012 65

Obs DataSet Freq LogLike MisClass

1 WORK.BHCO 109 -38.8803 0.1193

2 WORK.BHCO 109 -39.7868 0.1193

3 WORK.BHCO 109 -39.2466 0.1193

4 WORK.BHCO 109 -39.7934 0.1193

5 WORK.BHCO 109 -38.7239 0.1193

Unfortunately, it does not show values for AIC, AICC and BIC?

Can you please assist further?

Thanks!

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Swainsons

03-05-2012 02:17 PM

I'm working without being able to run complete tests. But we are making progress.

To correct the absence of reference to which model the AIC refers to, replace the last datastep by:

data allAIC;

set AIC_: INDSNAME=_modelVars;

modelVars = substr(_modelVars, 10);

run;

Were there any errors or warnings when you ran the program from my second reply?

PG

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to PGStats

03-05-2012 02:34 PM

Progress!

Here is the output from you reply of Mar 5, 2012 1:17 PM, which has solved the reference problem.

The SAS System 12:15 Monday, March 5, 2012 151

Obs DataSet Freq LogLike MisClass modelVars

1 WORK.BHCO 109 -38.8803 0.1193 CANCOVAVG

2 WORK.BHCO 109 -39.7868 0.1193 CANESTEMAVG

3 WORK.BHCO 109 -39.2466 0.1193 DENVERCVDENHORCV

4 WORK.BHCO 109 -39.7934 0.1193 FORBAVG

5 WORK.BHCO 109 -38.7239 0.1193 TREELGCANCOVAVG

There were no errors or warnings.

All that remains is to generate a value for AIC and AICC.

Thanks!

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Swainsons

03-05-2012 02:57 PM

The same correction with my first reply will get you the AICs (but not the AICCs).

What version of SAS are you using? I'm using version 9.3 and getting all the stats described in

in the output datasets.

PG

PG

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to PGStats

03-05-2012 03:05 PM

I'm using 9.2 and not getting AICC.

Here is what I get:

Model Fit Statistics

Intercept

Intercept and

Criterion Only Covariates

AIC 81.670 84.493

SC 84.362 92.567

-2 Log L 79.670 78.493

Solution

03-05-2012
03:24 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Swainsons

03-05-2012 03:24 PM

The AICC is produced in response to the request :

**score out=drop fitstat;**

in version 9.3...

I just checked the FITSTAT documentation in version 9.2 :

and only the four statistics that you got are produced.

If you are using the AIC to compare models built on the same number of observations then it is very unlikely that you would get a different model ordering with AIC and AICC.

Best of luck.

PG

PG

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to PGStats

03-05-2012 03:30 PM

OK...I was afraid of that. I will use the AIC values to compute AICC in Excel...just trying to avoid that step.

Thanks for getting me this far!