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

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

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
JacobSimonsen
Barite | Level 11
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

6 REPLIES 6
JacobSimonsen
Barite | Level 11
Make this variable
Spline=max(time-10,0);
and add it in the model statement.

Estimate and confidence intervals then comes automatically.
ECO918
Obsidian | Level 7

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!!

JacobSimonsen
Barite | Level 11
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;

ECO918
Obsidian | Level 7

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

Rick_SAS
SAS Super FREQ

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

ECO918
Obsidian | Level 7

Rick-

 

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

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
  • 6 replies
  • 2072 views
  • 3 likes
  • 3 in conversation