Page 1 of 1

logmvskew

Posted: Wed Mar 21, 2012 4:11 am
by chiade
Dear all,

I am facing problems trying to use %logmvskewt and i had read the article by Luc Bauwens and Sebastien Laurent for many times and tried numerous ways to solve it for many days but still failed. Can anyone guide me as to how I can solve it? i always get this command,"## SR10. Missing Values And/Or SMPL Options Leave No Usable Data Points". I tried changing the dates to gstart+1 or 2 or even 20 but to no avail. something must be wrong with the z value which is y-mean/st.deviation whihc is tried to decipher using set testlog start end = logl(t). There are only NAs....Thanks a lot.

Code: Select all

*
* GARCHMVMAX.RPF
* RATS Version 8, User's Guide, Example from Section 9.9
*
open data g10xrate.xls
data(format=xls,org=columns) 1 6237 usxjpn usxfra usxsui
*
set xjpn = 100.0*log(usxjpn/usxjpn{1})
set xfra = 100.0*log(usxfra/usxfra{1})
set xsui = 100.0*log(usxsui/usxsui{1})
*
* Estimation using MAXIMIZE
* The initial few lines of this set the estimation range, which needs to
* be done explicitly, and the number of variables. Then, vectors for the
* dependent variables, residuals and residuals formulas are set up. The
* SET instructions copy the dependent variables over into the slots in
* the vector of series.
*
compute gstart=2,gend=6237
compute n=3
dec vect[series] y(n) u(n) z(n)
dec vect[frml] resid(n)
set y(1) = xjpn
set y(2) = xfra
set y(3) = xsui
*
* This is specific to a mean-only model. It sets up the formulas (the &i
* are needed in the formula definitions when the FRML is defined in a
* loop), and estimates them using NLSYSTEM. This both initializes the
* mean parameters, and computes the unconditional covariance matrix. If
* you want more general mean equations, the simplest way to do that
* would be to define each FRML separately.
*
dec vect b(n)
nonlin(parmset=meanparms) b
do i=1,n
   frml resid(i) = (y(&i)-b(&i))
end do i
nlsystem(parmset=meanparms,resids=u) gstart gend resid
compute rr=%sigma
*
* The paths of the covariance matrices and uu' are saved in the
* SERIES[SYMM] names H and UU. UX and HX are used to pull in residuals
* and H matrices.
*
declare series[symm] h uu
*
* ux is used when extracting a u vector
*
declare symm hx(n,n)
declare vect ux(n)
*
* These are used to initialize pre-sample variances.
*
gset h  * gend = rr
gset uu * gend = rr
*
* This is a standard (normal) log likelihood formula for any
* multivariate GARCH model. The difference among these will be in the
* definitions of HF and RESID. The function %XT pulls information out of
* a matrix of SERIES.
*
declare frml[symm] hf
*
source logmvskewt.src
dec vector xi(2)
nonlin(parmset=distparms) nu xi
compute nu=10.0, xi=||0.01,0.01||
*
do i=1,n
  set z(i) * gend = u(i)/sqrt((h(t)(i,i)))
end do i

frml logl = $
    hx = hf(t) , $
    %do(i,1,n,u(i)=resid(i)) , $
    ux = %xt(z,t), $
        h(t)=hx, uu(t)=%outerxx(ux), $
    %logmvskewt(ux,xi,nu)

*****************************************************
*
* Standard GARCH(1,1)
*
dec symm vcs(n,n) vas(n,n) vbs(n,n)
compute vcs=rr,vbs=%const(0.80),vas=%const(0.05)
nonlin(parmset=garchparms) vcs vas vbs
nonlin(parmset=distparms) nu xi
frml hf = vcs+vbs.*h{1}+vas.*uu{1}
maximize(parmset=meanparms+garchparms+distparms,pmethod=simplex,piters=10,$
   iters=400) logl gstart+1 gend

Re: logmvskew

Posted: Thu Mar 22, 2012 11:02 am
by TomDoan
You have your xi vector dimensioned wrong, and your guess values are way out of range. Under their parameterization xi is positive, with xi=1 symmetric so .01 is grotesquely skewed. Also, you haven't made any adjustment for the covariance matrix not being the identity. (The derivation of the densities in the paper is done entirely with identity covariance matrices, but they do point out that you need to adjust if that's not the case). Your "Z"'s are standardizing the variance, but they aren't a formula, so they won't change as the variance evolution changes, and they don't take into account the non-diagonal nature of the covariance matrix---instead, you have to standardize by premultiplying by the inverse of a factor of the covariance matrix (and add an adjustment for the Jacobian).

In addition, you really need to estimate a simpler GARCH model first to nail down guess values for the GARCH parameters. There's too much going on in the skew-t with the t tails and the skewness to estimate all the parameters simultaneously from arbitrary guess values.

There's an updated copy of the function at:

http://www.estima.com/forum/viewtopic.php?f=7&t=1391

And this will do the estimation using the RATS sample data set:
mvskewt_example.rpf
Example file
(3.01 KiB) Downloaded 939 times

Re: logmvskew

Posted: Fri Mar 23, 2012 3:43 am
by chiade
Dear Sir,

Thank you for your kind reply. I would like to clarify about the updated %logmvskewt command. Is the highlighted correct with addition of a +? The formula works with a + but do not converge without it.

function %logmvskewt z xi nu
type real %logmvskewt nu
type vector z xi
local integer i k
local real lic zistar zistarsq mi si
*
compute k=%rows(z)
*
* Compute invariate parts of the integrating constant
*
compute lic=k*log(2.0/sqrt(%pi))+%lngamma(.5*(nu+k))-%lngamma(.5*nu)-.5*k*log(nu-2)
compute zistarsq=0.0
do i=1,k
compute mi=%gamma(.5*(nu-1))*sqrt(nu-2)/(sqrt(%pi)*%gamma(.5*nu))*(xi(i)-1.0/xi(i))
compute si=sqrt((xi(i)^2+1.0/xi(i)^2-1)-mi^2)
compute zistar=(si*z(i)+mi)*%if(z(i)>=-mi/si,1.0/xi(i),xi(i))
compute lic=lic+log(xi(i)*si/(1+xi(i)^2))
compute zistarsq+=zistar^2
end do i
compute %logmvskewt=lic-.5*(k+nu)*log(1+zistarsq/(nu-2))
end

Re: logmvskew

Posted: Fri Mar 23, 2012 9:52 am
by TomDoan
chiade wrote:Dear Sir,

Thank you for your kind reply. I would like to clarify about the updated %logmvskewt command. Is the highlighted correct with addition of a +? The formula works with a + but do not converge without it.

function %logmvskewt z xi nu
type real %logmvskewt nu
type vector z xi
local integer i k
local real lic zistar zistarsq mi si
*
compute k=%rows(z)
*
* Compute invariate parts of the integrating constant
*
compute lic=k*log(2.0/sqrt(%pi))+%lngamma(.5*(nu+k))-%lngamma(.5*nu)-.5*k*log(nu-2)
compute zistarsq=0.0
do i=1,k
compute mi=%gamma(.5*(nu-1))*sqrt(nu-2)/(sqrt(%pi)*%gamma(.5*nu))*(xi(i)-1.0/xi(i))
compute si=sqrt((xi(i)^2+1.0/xi(i)^2-1)-mi^2)
compute zistar=(si*z(i)+mi)*%if(z(i)>=-mi/si,1.0/xi(i),xi(i))
compute lic=lic+log(xi(i)*si/(1+xi(i)^2))
compute zistarsq+=zistar^2
end do i
compute %logmvskewt=lic-.5*(k+nu)*log(1+zistarsq/(nu-2))
end
I'm confused about what you're asking. The += is how the file reads already.

Re: logmvskew

Posted: Sat Mar 24, 2012 8:17 am
by chiade
Hi Sir,

I thought it was zistarsq=zistar^2 rather than zistarsq+=zistar^2 which according to the user's guide meant (Increment and assign (a += b same as “a= a+b”)). Just to confirm that the formula is right. Incidentally, the latter produces results whereas no results were produced by the former.

When xi>1.0 or <1.0, it means positive/negatively skewed. How do I find out whether skewness is significant? As the xi value is slways near 1.0, it wil always be signifciant. I tested with the %logskewtdensity with one dependent variable, confirming that it is postively skewed but insignificant since the results were near 0.0.

Many thanks for your kind replies.

Re: logmvskew

Posted: Sat Mar 24, 2012 12:42 pm
by TomDoan
chiade wrote:Hi Sir,

I thought it was zistarsq=zistar^2 rather than zistarsq+=zistar^2 which according to the user's guide meant (Increment and assign (a += b same as “a= a+b”)). Just to confirm that the formula is right. Incidentally, the latter produces results whereas no results were produced by the former.
Yes. It needs to be summed across i, which is what the += does. I'm not surprised it doesn't work when it's done wrong.
chiade wrote: When xi>1.0 or <1.0, it means positive/negatively skewed. How do I find out whether skewness is significant? As the xi value is slways near 1.0, it wil always be signifciant. I tested with the %logskewtdensity with one dependent variable, confirming that it is postively skewed but insignificant since the results were near 0.0.

Many thanks for your kind replies.
Test whether they are significantly different from 1 rather than 0.