Am 27.10.2017 um 13:27 schrieb Filipe Rodrigues da Costa:
> T = $nobs
>
> scalar window_size = 20
> scalar k = $nobs - window_size + 1
> series b = NA
>
> smpl 1 window_size
> loop i = window_size .. T
> ols AMZN const SP500
> if i < T
> smpl +1 +1
> endif
> endloop
>
> smpl full
So far so good, this works quite well. But let's say the data covers 100
periods for SP500 but only 60 for AMZN (no data for the last 40).
My question is as follows: Is there a simple way of imposing the
routine
to only estimate OLS when we have the full 20 data points for AMZN and
20 for SP500?
There are various possibilities. For example, check for any missings in
the sample like this (untested, bugs likely!):
<hansl>
open denmark
T = $nobs
window_size = 20
list all = LRM LRY
loop i=window_size..T
start = i - window_size + 1
smpl start i
if sum(missing(all)) == 0
ols LRM const LRY
endif
endloop
</hansl>
hth,
sven