10-28-2016 07:09 AM
I am using proc sgplot to calculate the best fit regression line as well as the 95% prediction limits. I want the equation for all three lines plotted on the graph (or showed in the results). Now I can only see the the Parameter estimates for the best fit line.
This is my code:
data _null_; set outputds; if variable eq 'Intercept' then call symput('Int', put(estimate, BEST.)); else call symput('Slope', put(estimate, BEST.)); ods output outputds; run; proc sgplot data=diffs noautolegend; title "Regression Line with Slope and Intercept"; reg y=diff x=mean / cli; ods output parameterestimates=outputds; inset "Intercept = &Int" "Slope = &Slope" / border title="Parameter Estimates" position=topleft; run;
10-28-2016 08:04 AM
Not entireley sure on the spefics in this question - where the "equation" comes from. Is that part of an output table from proc reg or something you hard code in? As for plotting it, well that pretty simple. Add into your plot data, the text you want to show, at the places you want to show, then have another statement in your sgplot:
scatter y=dif x=mean / markechars=(<variable>)
10-28-2016 12:22 PM
Thank you! I was maybe a little bit unclear in my explanation: I already have the intercept and slope (with this I mean equation) for the fit-line in my Parameter Estimates, but I also need the intercept and slope for the upper and lower 95 % prediction limits. I can not see this in the example and I am also not very good at programming in SAS so it would be great if you know a code for this.
10-28-2016 01:12 PM
> I also need the intercept and slope for the upper and lower 95 % prediction limits.
Unfortunately, the prediction limits are not linear, so they do not have an intercept or slope. Run the following code. The graph that is produced shows that the prediction limits are wide at the extreme of the X variable and narrow in the middle. There is no simple equation for those curves in terms of X.
ods graphics on; proc reg data=sashelp.class plots(only)=fitplot; model weight = height; run;
10-28-2016 09:28 AM - edited 10-28-2016 09:44 AM
To show the estimated slope and intercept, see the article "How to use PROC SGPLOT to display the slope and intercept of a regression line", which gives complete step-by-step code and an example.
In particular, you are trying to use the REG statement in PROC SGPLOT, but you need to use PROC REG if you want to use ODS OUTPUT to capture the ParameterEstimates table.
The title of your question is "show equation of 95% prediction limits," which different from the slope/intercept equation that you seem to want. See the documentation for "Statistical Background in Linear Regression" if you want to see the formulas used to compute those limits.