BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Bautista
Calcite | Level 5

I am running proc logistic with observations weighted, as shown below.

title 'Logistic regression analysis of the dataset using backward elimination';

proc logistic data=RE_apids ;

class   RACE (ref='1') FEMALE (ref='0') / param=ref;

model nir(EVENT='1')= race sex

  / selection=backward

  expb /* For each parameter estimate, also display the odds ratio in the output */

  fast

  slentry=0.1  /* For a variable to be allow to enter the model,

              a significance level of 0.1 was required (SLENTRY=0.1) */

  slstay=0.05  /* For a variable to be allow to stay in the model,

              a significance level of 0.05 was required (SLSTAY=0.05) */

  details

  lackfit

  CTABLE PPROB=(0.05 TO 0.5 BY 0.05);

weight adjwgt;

run;

For my proc logistic output, I have requested a classification table.  However, there are two problems.

1) Some of the cells in the classification table show values in scientific notation and I need them to be displayed in non-scientific notation.  How can I do that?

2) The classification table is giving me unweighted statistics, but I need the counts displayed in the CTABLE to be weighted by the variable I provided (which is adjwgt).  How can I do that?  I have already specified weight adjwgt; (as you can see above) but that only affected the selection of variables for the logistic model.  It didn't affect how the CTABLE calculated the overall percentage of correct predictions, sensitivity, specificity, the false positive percentage or the false negative percentage.  The CTABLE is giving me all those percentages based on unweighted numbers of observations in the dataset.     , ation

1 ACCEPTED SOLUTION

Accepted Solutions
StatDave
SAS Super FREQ

This note deals generally with using different formats in results -- it uses the example of changing precision, but the general idea of saving the data with ODS OUTPUT and printing with the desired formats applies generally.

http://support.sas.com/kb/37106

Note that if your weights are sampling weights, then only the procedures whose names start with SURVEY (such as SURVEYLOGISTIC) have the necessary variance estimators to provide a proper analysis.  The WEIGHT statement in PROC LOGISTIC is not appropriate for modeling survey data.  That being said, the OUTROC= option provides sensitivities and specificities.  You can use the ROCOPTIONS(WEIGHTED) option in the PROC LOGISTIC statement to have the weights multiply the counts as shown in the "Details: Receiver Operating Characteristic Curves: ROC Computations" section of the LOGISTIC documentation.

View solution in original post

5 REPLIES 5
lvm
Rhodochrosite | Level 12 lvm
Rhodochrosite | Level 12

I get different CTABLE results when I use WEIGHT versus when I do not use a weight. It is using the fitted logistic model to make the predictions, which depends on the weights. The procedure does not weight the actual observations, however, in the table; I don't think I would want to do that.

Bautista
Calcite | Level 5

Yes, you will get different CTABLE results when you do not use the weight, because you will be creating an entirely different model with its own intercept, coefficients, goodness of fit, statistical significance, etc, and so the predicted probabilities shown in the CTABLE will also be different. 

It is important for the data shown in the CTABLE to reflect the predictions that were made by the model for the weighted dataset.

lvm
Rhodochrosite | Level 12 lvm
Rhodochrosite | Level 12

Yes, I agree with you. That was the point I was trying to make (but probably not clearly). You should, and do, get different results with a weight versus no weight. I see no point in weighting the counts in the table.

By the way, many statisticians strongly dislike the use of stepwise variable selection procedures (including backward selection). You can find many posts on this website about this.

Astounding
PROC Star

Regarding the scientific notation, ODS lets you control that.  You could start by adding this statement just before the PROC LOGISTIC:

ODS TRACE ON;

That will show you the different pieces that ODS is generating.  You may want a solution that changes the template for one of those pieces, or my preference is to use ODS to capture one of the pieces as a SAS data set.  Run a PROC CONTENTS, perhaps a PROC PRINT if the piece is small enough.  That would give you enough information about what to print, what formats to change, etc.

That's the overview ... time is short and I'm not sure I can commit to following up.  But there are plenty of posters here who can answer questions if you have them.

Good luck.

StatDave
SAS Super FREQ

This note deals generally with using different formats in results -- it uses the example of changing precision, but the general idea of saving the data with ODS OUTPUT and printing with the desired formats applies generally.

http://support.sas.com/kb/37106

Note that if your weights are sampling weights, then only the procedures whose names start with SURVEY (such as SURVEYLOGISTIC) have the necessary variance estimators to provide a proper analysis.  The WEIGHT statement in PROC LOGISTIC is not appropriate for modeling survey data.  That being said, the OUTROC= option provides sensitivities and specificities.  You can use the ROCOPTIONS(WEIGHTED) option in the PROC LOGISTIC statement to have the weights multiply the counts as shown in the "Details: Receiver Operating Characteristic Curves: ROC Computations" section of the LOGISTIC documentation.

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
  • 5 replies
  • 2138 views
  • 1 like
  • 4 in conversation