BookmarkSubscribeRSS Feed
sasprog
Calcite | Level 5
Anyone can help with following question? Thanks.

In the logistic regression model, b1 is the coefficient of natural log transformed variable x, it is not the coefficient of original scale of x.

logit (p/(1-p)) = b0+ b1 In (x)

If b1=0.1,

What is the OR for one unit increase in the natural log of x (e^0.1)? What is the OR for one unit increase in original scale of X?

What is the OR for 5-unit increase in natural log of x ( ? What is the OR for 5-unit increase in X?
4 REPLIES 4
FreelanceReinh
Jade | Level 19

Hello @sasprog,


@sasprog wrote:
In the logistic regression model, ...
logit (p/(1-p)) = b0+ b1 In (x)

First of all, I assume you mean logit(p) or, equivalently, ln(p/(1-p)) on the left-hand side of the model equation.

 

If b1=0.1,

What is the OR for one unit increase in the natural log of x (e^0.1)?

Correct, the odds ratio is (in SAS notation) exp(0.1).

 


What is the OR for 5-unit increase in natural log of x ( ?

This is exp(0.5) by the same reasoning (i.e., exponentiating the difference of the log odds).

 

What is the OR for one unit increase in original scale of X?

Similarly, but depending on x, this is exp(0.1*(log(x+1)-log(x))) = (1+1/x)**0.1.

 

Now it's your turn.

What is the OR for 5-unit increase in X?
Spoiler
It is exp(0.1*(log(x+5)-log(x))) = (1+5/x)**0.1.
StatDave
SAS Super FREQ

If you want to do this as part of an analysis of observed data and obtain estimates of the odds ratio at various values of X (since the odds ratio changes with X) along with tests that the odds ratio equals 1 and confidence intervals, you can use the NLEST macro. That macro is needed since, as has been shown, the odds ratio on X is a nonlinear function of the model parameters. Following is an example with random data from known model logit(p)=a+bX with a and b values as specified. The model on log(x) is estimated and saved with PROC LOGISTIC and then the NLEST macro is used to evaluate the model at log(x+1) and log(x), for various x, and exponentiating their difference. As noted, the evaluating expressions in the FDATA= data set could be simplified to [(x+1)/x]**b. Change the "+1" in the expressions to another value if you want to evaluate an increase of other than 1 unit. Alternatively, you could use the macro to estimate the increase in risk (event probability) using data lines like
at x=1 , logistic(b_p1+log(1+1)*b_p2) - logistic(b_p1+log(1)*b_p2)
or even to evaluate the risk ratio for increasing X with data lines like
at x=1 , logistic(b_p1+log(1+1)*b_p2) / logistic(b_p1+log(1)*b_p2)

data a;
n=10000; a=-2.5; b=2;
do lnx=0 to 1 by .1;
   x=exp(lnx);
   logit=a+b*lnx;
   truodds=exp(logit);
   truodxp1=exp(a+b*log(x+1));
   truor=truodxp1/truodds;
   p=logistic(logit);
   y=rand("binomial",p,n);
   output;
end;
run;

proc logistic data=a;
   model y/n = lnx;
   effectplot / link;
   store log;
   run;

data fd; 
   length label f $32767; 
   infile datalines delimiter=',';
   input label f; 
   datalines;
at x=1   , exp( (b_p1+log(1+1)*b_p2) - (b_p1+log(1)*b_p2) )
at x=1.5 , exp( (b_p1+log(1.5+1)*b_p2) - (b_p1+log(1.5)*b_p2) )
at x=2   , exp( (b_p1+log(2+1)*b_p2) - (b_p1+log(2)*b_p2) )
at x=2.5 , exp( (b_p1+log(2.5+1)*b_p2) - (b_p1+log(2.5)*b_p2) )
;
%nlest(instore=log, fdata=fd, null=1, title=ORs at various X values)
sasprog
Calcite | Level 5

This is exactly what I am looking for. Thank you!

I am also wondering if the estimate statement can be use in proc logistic to achieve the same goal:

ln(5)=1.609 ln(10)=2.303

proc logistic data=a;

model y=ln(x);

estimate “5-unit increase” ln(x) 1.609 / exp cl;

estimate “10-unit increase” ln(x) 2.303 / exp cl;

run;

StatDave
SAS Super FREQ

No, the ESTIMATE statement cannot be used. As I noted and as you can see in the expressions in each line of the FDATA= data set, the odds ratio estimate for increasing X by u units is computed by evaluating the model at x+u and at x and then differencing the results and finally exponentiating the difference. Each evaluation is a log odds, so their difference is a log odds ratio. Exponentiating then gives the odds ratio estimate. This computation is a nonlinear function of the model parameters. The ESTIMATE statement can only compute linear functions of the model parameters.

 

I believe what you suggest with the ESTIMATE statement actually estimates the odds ratio for multiplying X by 5 or 10, not for adding 5 or 10 units:

 

logit(5x)=a+b(log(5x)=a+b(log(x)+log(5))
-logit(x)=                         a+b(log(x))
= b*log(5)

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 4 replies
  • 722 views
  • 10 likes
  • 3 in conversation