one sided HP Filter

February 14, 2019
Posted in Info
February 14, 2019 annenk


In the past many user repeatedly requested an one sided HP Filter in VBA. With just a few extra lines of code it is possible to extend my implementation of the HP Filter. It is a serial implementation. You have only have to add the code in the add-in or in your Excel sheet.


Best Kurt

'* Kurt Annen                                     *
'* 02.06.19                                       *
'* One Sided HP filter                            *
'* serial implementation                          *
'* © 2019 [web:reg] Kurt Annen -   *
Function HP_OS_S(data As Range, lambda As Double)
Dim nobs As Long, i As Long, j As Long, tmp1 As Variant, tmp2 As Variant, rng As Range
nobs = data.Rows.Count
ReDim tmp1(1 To nobs, 1 To 1)
' loop through time series
For i = 1 To nobs
Set rng = data.Resize(i, 1)
tmp2 = HP(rng, lambda)
tmp1(i, 1) = tmp2(i, 1)
Next i
Set rng = Nothing
HP_OS_S= tmp1
End Function

Comment (1)

Leave a Reply

Your email address will not be published. Required fields are marked *