- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Please i need help with writing a code to calculate the equation below ...
It is a rank inverse-weighting scheme that assigns higher weights to more recent observations.
For each fund j and quarter t , i want to compute the weighted average of β j,t during the fund’s history up to quarter t, with weights that vary inversely with the distance of the coefficients from quarter t . Thank you.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello @Princeelvisa,
If your input dataset is sorted by j and t , where t=1, 2, 3, ... (cf. below test dataset HAVE), you can use the code suggested below (creating dataset WANT) for the computation of FHj,t.
/* Create sample data */
data have;
input j t beta;
cards;
1 1 100
1 2 110
1 3 108
1 4 117
1 5 120
2 1 200
2 2 222
2 3 212
2 4 228
;
/* Compute FH values */
data want(drop=_:);
array _b[999] _temporary_;
call missing(of _b[*]);
do until(last.j);
set have;
by j;
_b[t]=beta;
end;
do until(last.j);
set have;
by j;
FH=0; _w=0;
do _h=1 to t;
FH+_b[t-_h+1]/_h;
_w+1/_h;
end;
FH=FH/_w;
output;
end;
run;
This assumes at most 999 quarters per fund (see array dimension).
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello @Princeelvisa,
If your input dataset is sorted by j and t , where t=1, 2, 3, ... (cf. below test dataset HAVE), you can use the code suggested below (creating dataset WANT) for the computation of FHj,t.
/* Create sample data */
data have;
input j t beta;
cards;
1 1 100
1 2 110
1 3 108
1 4 117
1 5 120
2 1 200
2 2 222
2 3 212
2 4 228
;
/* Compute FH values */
data want(drop=_:);
array _b[999] _temporary_;
call missing(of _b[*]);
do until(last.j);
set have;
by j;
_b[t]=beta;
end;
do until(last.j);
set have;
by j;
FH=0; _w=0;
do _h=1 to t;
FH+_b[t-_h+1]/_h;
_w+1/_h;
end;
FH=FH/_w;
output;
end;
run;
This assumes at most 999 quarters per fund (see array dimension).
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content