- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
How do I run weighted least squares on the data below using PROC REG where the weights are chosen to account for unequal variances?
data one;
input X @;
do i= 1 to 4;
input Y @;
output;
end;
drop i;
datalines;
2.5 7.5 9.5 8.0 8.5
5.0 11.0 12.0 9.0 10.0
7.5 11.0 16.0 12.5 14.0
10.0 16.5 14.5 21.5 19.0
;
run;
proc reg data=one plots=all;
model Y=X / p r clm cli influence;
run;
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
It's fairly simple to do when you have replicates, as in your example data:
/* Compute variance estimates of dependent variable Y for each value of X */
proc sql;
create table three as
select *,
1/var(y) as invVar
from one
group by x;
quit;
/* Weighted regression */
proc reg data=three plots=all;
model Y=X / p r clm cli influence;
weight invVar;
run;
quit;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Use the WEIGHT statement in PROC REG.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I think this is all explained in the documentation.
A WEIGHT statement names a variable in the input data set with values that are relative weights for a weighted least squares fit. If the weight value is proportional to the reciprocal of the variance for each observation, then the weighted estimates are the best linear unbiased estimates (BLUE).
Of course, for the VERY SIMPLE data set you provide, there is no such variable. You could compute the variance for each observation, and then make a new variable to use in the WEIGHT statement which is the reciprocal of the variance.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
It's fairly simple to do when you have replicates, as in your example data:
/* Compute variance estimates of dependent variable Y for each value of X */
proc sql;
create table three as
select *,
1/var(y) as invVar
from one
group by x;
quit;
/* Weighted regression */
proc reg data=three plots=all;
model Y=X / p r clm cli influence;
weight invVar;
run;
quit;