Programming the statistical procedures from SAS

Proc Logistic & Confidence Intervals....Contrast vs Estimate??

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 16
Accepted Solution

Proc Logistic & Confidence Intervals....Contrast vs Estimate??

Hello-

 

I have a fairly basic logisitic regression model looking at the effect of time on bacterial growth. This model also includes a simple spline term, where the spline term begins at time= 10, and for all values after time=10 the spline= (time - 10).

What I want is the slope after time= 10, which =exp(β1+ β2).

 

How do I get a confidence interval for this particular slope. I do not want to compare the slope from time < 10, I only want the confidence interval for exp(β1+ β2). Am I wrong that the contrast and estimate statements will provide me with odds ratio values, as opposed to just the isolated slope of the combined terms??

 

For what it's worth, here's the basic model in SAS:

proc logistic data= growth_data descending;

model growth= time spline

run;

 

Log(odds)= β0 + β1(time) + β2(spline term for time)

 

As a visual, what I'm interested in is the slope and confidence interval for the blue section

Picture1.png

 

 

 

 

 

 


Accepted Solutions
Solution
‎11-18-2015 12:19 PM
Super Contributor
Posts: 271

Re: Proc Logistic & Confidence Intervals...Contrast vs Estimate??

I was mayto to quick when I read your question. I just noted that you asked for the slope. The slope estimate comes automatically.
Maybe you can use this code to get confidence intervals around the line:

data mydata;
do i=1 to 100000;
time=rand('uniform',0,20);
spline=max(time-10,0);
logodds=0.75-0.05*spline;
p=1/(1+exp(-logodds));
y=rand('bernoulli',p);
output;
end;
keep y spline;
run;

*you get automatically estimates of the slope (approximately -0.05);
proc logistic data=mydata desc;
model y=spline;
run;

*if you want the estimate at a specific value for time you can use estimate statement:;
proc logistic data=mydata desc;
model y=spline;
estimate 'value at time=15' intercept 1 spline 5/exp;
run;
*(its "spline 5" because 15-10=5);


*its also possible to get the confidence intervals by use of the "store statement" and proc plm;
proc logistic data=mydata desc;
model y=spline;
store result;
run;
data spline;
do spline=0 to 10 by 0.1;
time=10+spline;
output;
end;
run;
proc plm restore=result;
score data=spline out=spline2 predicted=p lclm uclm lcl ucl;
run;

View solution in original post


All Replies
Super Contributor
Posts: 271

Re: Proc Logistic & Confidence Intervals....Contrast vs Estimate??

Make this variable
Spline=max(time-10,0);
and add it in the model statement.

Estimate and confidence intervals then comes automatically.
Occasional Contributor
Posts: 16

Re: Proc Logistic & Confidence Intervals...Contrast vs Estimate??

Hi-

 

Thanks for the response! I currently have the spline term already constructed and in the model, and can find the confidence interval for that term alone, but need the combined confidence interval.

 

What I should add is that I can currently use the outest= covout option and then use the variance and covariance values to calculate the standard error and then use that to calculate the upper and lower confidence limits...but it's extremely clunky and I imagine SAS has a better way.

 

However, I was not aware that you could code values using the comma to indicate an 'other' value. That's way simpler than writing if then/ else statements. Many thanks for the new info!!

Solution
‎11-18-2015 12:19 PM
Super Contributor
Posts: 271

Re: Proc Logistic & Confidence Intervals...Contrast vs Estimate??

I was mayto to quick when I read your question. I just noted that you asked for the slope. The slope estimate comes automatically.
Maybe you can use this code to get confidence intervals around the line:

data mydata;
do i=1 to 100000;
time=rand('uniform',0,20);
spline=max(time-10,0);
logodds=0.75-0.05*spline;
p=1/(1+exp(-logodds));
y=rand('bernoulli',p);
output;
end;
keep y spline;
run;

*you get automatically estimates of the slope (approximately -0.05);
proc logistic data=mydata desc;
model y=spline;
run;

*if you want the estimate at a specific value for time you can use estimate statement:;
proc logistic data=mydata desc;
model y=spline;
estimate 'value at time=15' intercept 1 spline 5/exp;
run;
*(its "spline 5" because 15-10=5);


*its also possible to get the confidence intervals by use of the "store statement" and proc plm;
proc logistic data=mydata desc;
model y=spline;
store result;
run;
data spline;
do spline=0 to 10 by 0.1;
time=10+spline;
output;
end;
run;
proc plm restore=result;
score data=spline out=spline2 predicted=p lclm uclm lcl ucl;
run;

Occasional Contributor
Posts: 16

Re: Proc Logistic & Confidence Intervals...Contrast vs Estimate??

Thanks for the help! I wasn't familiar with proc plm, always great to learn something new!

SAS Super FREQ
Posts: 3,306

Re: Proc Logistic & Confidence Intervals...Contrast vs Estimate??

PROC PLM is awesome. See the article "Tecniques for scoring a regression model" for another example.

Occasional Contributor
Posts: 16

Re: Proc Logistic & Confidence Intervals...Contrast vs Estimate??

Rick-

 

Thanks for the link. I've heavily relied on your blog posts for many, many of my SAS questions!

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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