I have the following SAS code that uses PROC FORECAST that I would like to replicated with the Python Pandas pandas.stats.moments.ewma
proc forecast data=ewma method=expo
interval=weekday weight=(0.05) /*i.e. lambda=0.95*/
nstart=20 lead=0
out=out_ewma outfull;
id date;
var sq_gspc cross_returns;
run;
My DataFrame in Pandas is set up to mimic the ewma
dataset in SAS -- same column names and everything, including same starting values. However, I can't seem to get the same values calculated with Pandas, probably due to a lack of understanding of the SAS options and how to set up the same calculation with Pandas. For example, to add the sq_gspc
and cross_returns
columns to my Pandas DataFrame, I'm doing the following:
ewmadf['f_sq_gspc'] = pd.ewma(ewmadf["sq_gspc"], span=20, freq="D")
ewmadf['f_cross_returns'] = pd.ewma(ewmadf["cross_returns"], span=20, freq="D")
How do I replicate the PROC FORECAST here with the Python parameters?
Edit: SAS documentation provides the following:
For METHOD=EXPO, n beginning values of the series are used in forming the exponentially smoothed values S1, S2, and S3, where n is the value of the NSTART= option. The parameters are initialized by fitting a time trend regression to the first n nonmissing values of the series.