Hi all,

I run the code with 2 different data sets, the first one is fine, but the second one the parameter result was missing and the beta is the same for all observation, result is shown below;

------------------------------------------------------------------------

II------------------ Parameter Estimates ------------------II

Starting values: 0.001870984817638 0.013969936604091

-0.000000000009175

b0: 0.001870984817638 .

SMA1: 0.013969936604091 .

SMA2: 0.000000000109175 .

II----------- Smoothed Beta (t) ----------------II

0.023197

0.023197

0.023197

0.023197

0.023197

....

---------------------------------------------------------------------------

However, the only suggestion I have got is there must be something wrong with the starting values that I have no idea how to correct it.

@-- starting values--@

b0 = .1;

sma1 = .12;

sma2 = 0.12; @-- variance of transition eq. --@

parms = b0|sma1|sma2;

@ Do the Estimation and output results @

_cml_Algorithm = 1;

_cml_Linesearch = 2;

_cml_CovPar = 2;

_cml_DirTol = 1e-5;

@ load parms; @

{parms,f,g,h,retcode} = CML(data,0,&LL,parms); save parms;

## 1 Answer

0

First, it appears to me that there's a serious scaling problem here:

Starting values: 0.001393011920857 0.014084283178608 0.000001824200129 b0: 0.001393011920857 1.040977841766207 SMA1: 0.014084283178608 30.020553274851288 SMA2: 0.000001824300129 0.000000015132629

In the Kalman filter, `SMA1` and `SMA2` are `Q` and `H` respectively. When numbers that small are used in operations with larger numbers serious loss of precision occurs.

I think in the Smooth function, it looks like it's smoothing a straight line. In the code below

@ Construct the P Star Matrix @ Ps = Pu * T ' invpd(Pp); @ Construct Smooth State Vector for period i @ BVec[i,.] = (Bvec[i,.]' + Ps * (Bvec[i+1,.]' - T*BVec[i,.]'))';

`Ps` and `T` are always 1.0, and it appears that the difference between `BVec[i+1]` and `BVec[i]` is always the same, suggesting that `BVec` is a straight line. I think the Kalman filter is failing due to catastrophic failure of precision. It would take some more work to figure that out exactly. I can take a look tomorrow.

## Your Answer

## 1 Answer

First, it appears to me that there's a serious scaling problem here:

Starting values: 0.001393011920857 0.014084283178608 0.000001824200129 b0: 0.001393011920857 1.040977841766207 SMA1: 0.014084283178608 30.020553274851288 SMA2: 0.000001824300129 0.000000015132629

In the Kalman filter, `SMA1` and `SMA2` are `Q` and `H` respectively. When numbers that small are used in operations with larger numbers serious loss of precision occurs.

I think in the Smooth function, it looks like it's smoothing a straight line. In the code below

@ Construct the P Star Matrix @ Ps = Pu * T ' invpd(Pp); @ Construct Smooth State Vector for period i @ BVec[i,.] = (Bvec[i,.]' + Ps * (Bvec[i+1,.]' - T*BVec[i,.]'))';

`Ps` and `T` are always 1.0, and it appears that the difference between `BVec[i+1]` and `BVec[i]` is always the same, suggesting that `BVec` is a straight line. I think the Kalman filter is failing due to catastrophic failure of precision. It would take some more work to figure that out exactly. I can take a look tomorrow.