Print

Print


It should be 

garchsimul(const nobs, const coeff, const p, const q)
{

}

Victor.

Den 23/11/2012 kl. 00.33 skrev ctrucios <[log in to unmask]>:

Dear,

My name is Carlos and I'm starting to program in Ox. I'm trying sumular a model GARCH (p, q) but I can not make it run, an error that I am not able to take, if any of you can give me some help I will thank. Follow the code.

Thank you.

Here the error messages.
'p' expression must be constant
'q' expression must be constant


# include <oxstd.h>
// Step 1: Simulated univariate GARCH

garchsimul (nobs, coeff, p, q)   {
decl r, sigma2, e, d, i;
r = sigma2 = zeros(1,nobs);
d = max(p,q);
e = rann(1,nobs) ;
sigma2[0][0:d] = coeff[0]/(1-sumr(coeff[1:])) ;
  r[0][0:d] = sqrt(sigma2[0][0])*e[0][0:d];
     for (i = (d+1); i < nobs; ++i) {
     sigma2[0][i] = coeff * (1 | r[0][i - <1:p>]^2 | sigma2[0][i - <1:q>]) ;
          r[0][i] = sqrt(sigma2[0][i])*e[0][i] ;
 
     }
return r' ~ sigma2';
}




main(){
decl nobs, coeff, garch1, garch2, e, p, q;
     nobs = 10;
     coeff = <0.01,0.15,0.82>;
p = 1;
q = 1;
garch1 = garchsimul(nobs,coeff,p,q);
garch2 = garchsimul(nobs,coeff,p,q);
print(garch1);
print(garch2);
}

Carlos Trucíos Maza
*     : [log in to unmask]" target="_blank">[log in to unmask]