Hi - hope this is the right location so here goes.
I am interested in calculating the predicted probabilities for a binary-level outcome and using a categorical predictor (4-levels from 0-3).
The Margins Macro appears to have what I need but, when I run the macro, the output does not include a Predictive Margins Table and there is a note that the "algorithm converged". Also no errors noted in the Log file.
Any ideas on what I'm doing wrong?
Program and output below.
Many thanks.
PROGRAM:
%Margins (data = ecg.ECG_only_final,
response = lad_axis,*BINARY VARIABLE WITH VALUES OF 1, 2;
roptions = events='1',
class = bp_htn,*MULTI-LEVEL VARIABLE WITH VALUES OF 0,1,2,3;
model = bp_htn,
dist = binomial,
margins = bp_htn,
options = diff cl);
run;
The GENMOD Procedure
Model Information | ||
Data Set | WORK._EXPDATA |
|
Distribution | Binomial |
|
Link Function | Logit |
|
Dependent Variable | LAD_axis | LAD_axis |
Number of Observations Read | 729 |
Number of Observations Used | 729 |
Number of Events | 38 |
Number of Trials | 729 |
Response Profile | ||
Ordered | LAD_axis | Total |
1 | 1 | 38 |
2 | 0 | 691 |
PROC GENMOD is modeling the probability that LAD_axis='1'. One way to change this to model the probability that LAD_axis='0' is to specify the DESCENDING option in the PROC statement. |
Criteria For Assessing Goodness Of Fit | |||
Criterion | DF | Value | Value/DF |
Log Likelihood |
| -147.6443 |
|
Full Log Likelihood |
| -147.6443 |
|
AIC (smaller is better) |
| 303.2885 |
|
AICC (smaller is better) |
| 303.3438 |
|
BIC (smaller is better) |
| 321.6552 |
|
Algorithm converged. |
Analysis Of Maximum Likelihood Parameter Estimates | |||||||
Parameter | DF | Estimate | Standard | Wald 95% Confidence Limits | Wald Chi-Square | Pr > ChiSq | |
Intercept | 1 | -2.6741 | 0.2585 | -3.1808 | -2.1675 | 107.04 | <.0001 |
bp_htn_0 | 1 | -0.6217 | 0.4129 | -1.4310 | 0.1876 | 2.27 | 0.1322 |
bp_htn_1 | 1 | 0.0351 | 0.4171 | -0.7824 | 0.8525 | 0.01 | 0.9329 |
bp_htn_2 | 1 | -0.5245 | 0.7663 | -2.0264 | 0.9774 | 0.47 | 0.4937 |
bp_htn_3 | 0 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | . | . |
Scale | 0 | 1.0000 | 0.0000 | 1.0000 | 1.0000 |
|
|
Note: | The scale parameter was held fixed. |
What output tables are you getting? According to this (http://support.sas.com/kb/63/038.html#use), the margins should be in and output table bp_htn_margins.
-unison
What output tables are you getting? According to this (http://support.sas.com/kb/63/038.html#use), the margins should be in and output table bp_htn_margins.
-unison
@closetcoer wrote:
FYI, there was no sample data file but I think one can be created with the frequency information in the macro documentation. Thanks for yoru time.
http://support.sas.com/kb/63/038.html#use
They provide the data to run the examples, which should be a first step when testing code/macros.
EXAMPLE 1: Predictive margins in a binary logistic modelThe following statements estimate and test predictive margins for the Neuralgia data set presented in the example titled "Logistic Modeling with Categorical Predictors" in the LOGISTIC documentation. Treatment predictive margins are computed for males and females. Since the Margins macro requires a numeric response variable, the NoPain variable is created with value 1 when Pain='No' and 0 otherwise. The probability of no pain is modeled as a result of roptions=event='1'. Confidence intervals are requested by options=cl.
data Neur; set Neuralgia; NoPain=(pain='No'); run; %Margins(data = Neur, class = Treatment Sex, response = NoPain, roptions = event='1', dist = binomial, model = Treatment Sex Treatment*Sex Age Duration, margins = Treatment, at = Sex, options = cl )
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.