3
votes

I am trying to create a prediction interval based on a linear model in SAS. My SAS code is

proc reg data=datain.aswells alpha=0.01;
model arsenic = latitude longitude depth_ft / clb;
run;

I wish to make a 95% prediction interval with latitude=23.75467, longitude=90.66169, and depth_ft=25. This data point does not exist in the data set, but it is in the range of values used to compute the model. Is there an easy way of accomplishing this in SAS? Shouldn't there be a way to compute this prediction interval in SAS easily?

1
Look into proc score. Because this is a PREDICTION interval, not a confidence interval other methods will give different answers. If you want solely the confidence interval simply add the data points without the arsenic value to the data set and the output sample will produce the predicted value and confidence interval (not prediction interval).Reeza
You can get both confidence and prediction intervals from the OUTPUT statement. See the SAS doc on PROC REG (support.sas.com/documentation/cdl/en/statug/67523/HTML/default/…).DomPazz

1 Answers

3
votes

The easiest thing to do is to add it to your input data set with a missing value for ARSENIC. Then use the OUTPUT statement to output the prediction intervals.

Here is an example:

data test;
do i=1 to 100;
    x1 = rannor(123);
    x2 = rannor(123)*2 + 1;
    y = 1*x1 + 2*x2 + 4*rannor(123);
    output;
end;
run;

data test;
set test end=last;
output;
if last then do;
    y = .;
    x1 = 1.5;
    x2 = -1;
    output;
end;
run;

proc reg data=test alpha=.01;
model y = x1 x2;
output out=test_out(where=(y=.)) p=predicted ucl=UCL_Pred lcl=LCL_Pred;
run;
quit;

The WHERE clause on the output filters the resulting set to just the missing value to be predicted. You can remove it and get all predicted values and prediction intervals.