Dear Carlos
<1:5> is a matrix *** constant ***, which means the expression is evaluated at
compile time.
Using <1:p> violates this, because p is a local variable (next time keep the
line numbers of the error message).
The solution is to use
range(1, p)
instead.
Jurgen
oxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxox
oxoxoxox 13th OxMetrics user conference 2013
oxoxoxox Creates, Aarhus, 5-6 September
oxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxox
Dr Jurgen A Doornik
James Martin Fellow, Institute for New Economic Thinking
at the Oxford Martin School, University of Oxford
http://www.doornik.com
http://www.oxmetrics.net
oxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxox
On 2012-11-22 23:49, ctrucios wrote:
> Hi Victor,
>
> Thanks for the help, I ran the program with what they suggested but it gave this
> error "constant expression must be integer or double"
>
> *Carlos Trucíos Maza
> **: [log in to unmask]
> <[log in to unmask]" target="_blank">http:[log in to unmask]>
>
>
>
>
> 2012/11/22 Victor Elleskov Christensen <[log in to unmask]
> <mailto:[log in to unmask]>>
>
> 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]
> <mailto:[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]
>> <[log in to unmask]" target="_blank">http:[log in to unmask]>
>>
>>
>>
>
>
|