Hello, I'm new to Gretl, and while I think I've picked things up pretty quickly I'm stumped with what is probably a simple problem for regular users. When I execute the muhat function in script below I get a "Data types not conformable for operation" error message. It appears that the second function doesn't like the matrix reference arguments, but I don't see why that would be a problem. I've searched the archives for similar problems but haven't found a solution to my problem. (FYI I'm running Gretl 1.8.4 on an XP machine.) Your help would be greatly appreciated.
Script: function matrix local_level (series y) /* starting values */ scalar s1 = 1 scalar s2 = 1 /* set up Kalman matrices */ matrix H = {1 ; 1} matrix F = {1, 0 ; 0, 0.97} matrix Q = {s1, 0 ; 0, s2} /* Kalman filter set-up */ kalman obsy y obsymat H statemat F statevar Q end kalman --diffuse /* ML estimation */ mle ll = ERR ? NA : $kalman_llt Q[1,1] = s1 Q[2,2] = s2 ERR = kfilter() params s1 s2 end mle return s1 ~ s2 end function function list loclev_sm (series y, scalar s1, scalar s2) kalman obsy y obsymat H statemat F statevar Q end kalman --diffuse matrix ret = ksmooth() series wt = ret[,1] series xt = ret[,2] list components = wt xt return components */ end function /* -------------------- execute -------------------- */ matrix Vars = local_level(y) list muhat = loclev_sm(y, Vars[,1], Vars[,2]) Output: gretl version 1.8.4 Current session: 2009-09-18 20:25 ? function matrix local_level (series y) > /* starting values */ > scalar s1 = 1 > scalar s2 = 1 > /* set up Kalman matrices */ > matrix H = {1 ; 1} > matrix F = {1, 0 ; 0, 0.97} > matrix Q = {s1, 0 ; 0, s2} > /* Kalman filter set-up */ > kalman > obsy y > obsymat H > statemat F > statevar Q > end kalman --diffuse > /* ML estimation */ > mle ll = ERR ? NA : $kalman_llt > Q[1,1] = s1 > Q[2,2] = s2 > ERR = kfilter() > params s1 s2 > end mle > return s1 ~ s2 > end function ? function list loclev_sm (series y, scalar s1, scalar s2) > kalman > obsy y > obsymat H > statemat F > statevar Q > end kalman --diffuse > matrix ret = ksmooth() > series wt = ret[,1] > series xt = ret[,2] > list components = wt xt > return components */ > end function /* -------------------- execute -------------------- */ ? matrix Vars = local_level(y) Using numerical derivatives Tolerance = 1.81899e-012 Function evaluations: 67 Evaluations of gradient: 15 Model 1: ML, using observations 2001:10-2009:06 (T = 93) ll = ERR ? NA : $kalman_llt Standard errors based on Outer Products matrix estimate std. error t-ratio p-value ---------------------------------------------------- s1 4.08513 16.8057 0.2431 0.8079 s2 4.12376 16.5388 0.2493 0.8031 Log-likelihood -241.2759 Akaike criterion 486.5518 Schwarz criterion 491.6170 Hannan-Quinn 488.5970 Generated matrix Vars ? list muhat = loclev_sm(y, Vars[,1], Vars[,2]) Data types not conformable for operation Error executing script: halting > list muhat = loclev_sm(y, Vars[,1], Vars[,2])