Examples of Gretl scripts
by Carlos Andrade

Dear All,
Where to get examples of Gretl scripts for different types of analysis?
--
Atenciosamente,
Prof. Carlos A. S. de Andrade
LAPEA - Laboratório de Pesquisa em Economia Aplicada e Engenharia de
Produção
Universidade Federal de Campina Grande.
Centro de Humanidades
Unidade Acadêmica de Economia
9 years, 8 months

Re: [Gretl-users] GARCH, Forecasting
by Allin Cottrell

On Mon, 17 Jan 2011, [ISO-8859-1] Alejandro Mosi�o wrote:
> Maybe i was not too much specific last time:
>
> I have a variable "y" that follows a GARCH(1,1) process. Then, i Gretl i
> type:
>
> garch 1 1 ; y const
>
> Then i got the result and forecasting the out-of-sample values of y can
> be done in the usual way. However, i'm interested in forecasting the
> out-of-sample variance. I don't know if such a function exists in Gretl.
There is no built-in function to do this, but you can compute a
one-step ahead forecast of the variance from the model data, as
hown in the following example script.
<script>
open b-g.gdt
garch 1 1 ; Y
series e = $uhat
series h = $h
dataset addobs 10
a0 = $coeff[2]
a1 = $coeff[3]
b1 = $coeff[4]
series hfc = h
# set future errors to their expectation
e = misszero(e)
# forecast the variance
hfc = a0 + a1 * e(-1)^2 + b1 * hfc(-1)
smpl 1970 ;
print e h hfc --byobs
</script>
Allin Cottrell
10 years, 1 month

Sample size and ADF test in gretl and R
by Grzegorz Konat

Hello,
I have a minor question concerning how sample size affects ADF unit root
test results in gretl and other econometric software.
Let me give you an example:
I have a series of T=51, for which ADF test results are all the same in
gretl, R (urca) and JMulTi. Yet when I use a subsample of T=20 (last
twenty observations), test statistics obtained with gretl are
significantly different from those of R and JMulTi (both the latter,
however, produce the same output). Of course, I use the same
deterministic term option and lag lenght for those comparisons.
Is there any particular reason for that situation? Or is it me doing
something wrong?
(I attach data file for those, who'd like to replicate my issue)
Best,
Greg
10 years, 8 months

Re: [Gretl-users] Problem with bootstrap result
by alexkakashi＠libero.it

The Allin method is perfect, I have only changed when there is the error
message.
In my application I have use the following commands to obtain the pseudo-data.
But the bootstrap results are strange. Is it right my script to generate the
pseudo-data?
r=154 ## number of observations
system method=sur
equation Y const Y(-1) Z(-1)
equation X const Y(-1) X(-1) Z(-1)
equation Z const Y(-1) Z(-1)
end system
genr residui=$uhat
genr M=$coeff
## Procedure to obtain the pseudo-data
ysim=Y
xsim=X
zsim=Z
genr A=resample(residui)
loop for i=2..154 --quiet
ysim[i]=M[1]+M[2]*ysim[i-1]+M[3]*zsim[i-1]+A[i-1,1]
xsim[i]=M[4]+M[5]*ysim[i-1]+M[6]*xsim[i-1]+M[7]*zsim[i-1]+A[i-1,2]
zsim[i]=M[8]+M[9]*ysim[i-1]+M[10]*zsim[i-1]+A[i-1,3]
endloop
10 years, 9 months

Re: [Gretl-users] Problem with bootstrap result
by alexkakashi＠libero.it

Thanks Ignacio. I know that the single equation can be estimated by OLS. In my
application I have no stationary time series and I work using variables in
levels. I'd like use bootstrap method based on residuals, which are
uncorrelated. I have considered only the equation
1. ols Y const Y(-1) Y(-2) X(-1) X(-2) Z(-1) Z(-2)
I am interested in testing Granger causality from X to Y, so I test this null
hypothesis. Under this hypothesis I estimate the model 1 and save the
coefficients and the residuals u(t). In this way I obtain the pseudo-data Y*
given by
Y*(t) = a + b Y*(t-1) + c Y*(t-1) + d Z(t-1) + e Z(t-2) + u*(t)
where u*(t) are the bootstrap residuals and Z is the original regressor. The
p-
value is small. If I replace every equation of the VAR the p-value is very
large. In my opinion, considering only the first equation, the results are
better than those which replace the VAR because the statistics tests is
large.
In yuor opinion can I work considering only one equation of the VAR in my
bootstrap method?
Best regards
Alessandro
>----Messaggio originale----
>Da: gretl-users-request(a)lists.wfu.edu
>Data: 23/02/2012 15.23
>A: <gretl-users(a)lists.wfu.edu>
>Ogg: Gretl-users Digest, Vol 61, Issue 18
>
>Send Gretl-users mailing list submissions to
> gretl-users(a)lists.wfu.edu
>
>To subscribe or unsubscribe via the World Wide Web, visit
> http://lists.wfu.edu/mailman/listinfo/gretl-users
>or, via email, send a message with subject or body 'help' to
> gretl-users-request(a)lists.wfu.edu
>
>You can reach the person managing the list at
> gretl-users-owner(a)lists.wfu.edu
>
>When replying, please edit your Subject line so it is more specific
>than "Re: Contents of Gretl-users digest..."
>
>
>Today's Topics:
>
> 1. Re: CARR model MLE ( Dan B?so? )
> 2. Re: Problem with bootstrap result (Ignacio Diaz-Emparanza)
> 3. Re: CARR model MLE ( Dan B?so? )
>
>
>----------------------------------------------------------------------
>
>Message: 1
>Date: Thu, 23 Feb 2012 12:11:05 +0100
>From: " Dan B?so? " <eubie(a)centrum.cz>
>Subject: Re: [Gretl-users] CARR model MLE
>To: <gretl-users(a)lists.wfu.edu>
>Message-ID: <20120223121105.924522A4(a)centrum.cz>
>Content-Type: text/plain; charset=UTF-8
>
>
>Thank you both a lot. I was out of my mind to overlook the +/- thing. Thank
you also for the exp() trick, so far I thought the only way to ensure
positiveness is to formulate a model for log(Rng).
>
>Best regards,
>Daniel
>
>______________________________________________________________
>> Od: gretl-users-request(a)lists.wfu.edu
>> Komu: <gretl-users(a)lists.wfu.edu>
>> Datum: 22.02.2012 13:48
>> P?edm?t: Gretl-users Digest, Vol 61, Issue 17
>>
>>Send Gretl-users mailing list submissions to
>> gretl-users(a)lists.wfu.edu
>>
>>To subscribe or unsubscribe via the World Wide Web, visit
>> http://lists.wfu.edu/mailman/listinfo/gretl-users
>>or, via email, send a message with subject or body 'help' to
>> gretl-users-request(a)lists.wfu.edu
>>
>>You can reach the person managing the list at
>> gretl-users-owner(a)lists.wfu.edu
>>
>>When replying, please edit your Subject line so it is more specific
>>than "Re: Contents of Gretl-users digest..."
>>
>>
>>Today's Topics:
>>
>> 1. CARR model MLE ( Dan B?so? )
>> 2. Re: CARR model MLE (Allin Cottrell)
>> 3. Re: CARR model MLE (Riccardo (Jack) Lucchetti)
>> 4. Re: Bootstrap VAR models (alexkakashi(a)libero.it)
>> 5. Problem with bootstrap result (alexkakashi(a)libero.it)
>>
>>
>>----------------------------------------------------------------------
>>
>>Message: 1
>>Date: Tue, 21 Feb 2012 21:15:02 +0100
>>From: " Dan B?so? " <eubie(a)centrum.cz>
>>Subject: [Gretl-users] CARR model MLE
>>To: <gretl-users(a)lists.wfu.edu>
>>Message-ID: <20120221211502.4991D432(a)centrum.cz>
>>Content-Type: text/plain; charset=UTF-8
>>
>>
>>Dear fellow users,
>>
>>I am trying to write a script for MLE estimation of a CARR model, similar to
GARCH. It is a MEM model in daily ranges of some instrument, i,e,
>>
>>Eq. 1: lRng = lambda * epsilon # epsilon is exponentially distributed
here, giving the shape of LL
>>Eq. 2: lambda = a + b*Rng(-1) + c*lambda(-1)
>>
>>I tried the following code but the algorithm never converges. What should I
improve?
>>Thanks in advance, Daniel
>>
>>
>>
>>scalar a = 0.1
>>scalar b = 0.4
>>scalar c = 0.4
>>
>>mle ll = -ln(lambda) + Rng/lambda
>>
>> series lambda = mean(Rng)
>> series lambda = a + b*Rng(-1) + c*lambda(-1)
>>
>> params a b c
>>end mle
>>
>>
>>
>>------------------------------
>>
>>Message: 2
>>Date: Tue, 21 Feb 2012 15:57:19 -0500 (EST)
>>From: Allin Cottrell <cottrell(a)wfu.edu>
>>Subject: Re: [Gretl-users] CARR model MLE
>>To: Gretl list <gretl-users(a)lists.wfu.edu>
>>Message-ID:
>> <alpine.LNX.2.01.1202211548120.22658(a)waverley.dhcp.wfu.edu>
>>Content-Type: text/plain; charset="iso-8859-2"
>>
>>On Tue, 21 Feb 2012, Dan B?so? wrote:
>>
>>> I am trying to write a script for MLE estimation of a CARR model, similar
to GARCH. It is a MEM model in daily ranges of some instrument, i,e,
>>>
>>> Eq. 1: lRng = lambda * epsilon # epsilon is exponentially distributed
here, giving the shape of LL
>>> Eq. 2: lambda = a + b*Rng(-1) + c*lambda(-1)
>>>
>>> I tried the following code but the algorithm never
>>> converges. What should I improve?
>>
>>> scalar a = 0.1
>>> scalar b = 0.4
>>> scalar c = 0.4
>>>
>>> mle ll = -ln(lambda) + Rng/lambda
>>
>>Improve here: use the correct loglikelihood!
>>
>> mle ll = -ln(lambda) - Rng/lambda
>>
>>> series lambda = mean(Rng)
>>> series lambda = a + b*Rng(-1) + c*lambda(-1)
>>>
>>> params a b c
>>> end mle
>>
>>You may also have to constrain all the parameter values to be
>>positive, if I'm reading the CARR literature correctly. In
>>which case you could, for example, express lambda as
>>exp(a) + exp(b)*Rng(-1) + exp(c)*lambda(-1).
>>
>>Allin Cottrell
>>
>>------------------------------
>>
>>Message: 3
>>Date: Tue, 21 Feb 2012 22:25:59 +0100 (CET)
>>From: "Riccardo (Jack) Lucchetti" <r.lucchetti(a)univpm.it>
>>Subject: Re: [Gretl-users] CARR model MLE
>>To: Gretl list <gretl-users(a)lists.wfu.edu>
>>Message-ID: <alpine.DEB.2.02.1202212216510.14044(a)ec-4.econ.univpm.it>
>>Content-Type: text/plain; charset="utf-8"
>>
>>On Tue, 21 Feb 2012, Allin Cottrell wrote:
>>
>>> On Tue, 21 Feb 2012, Dan B?so? wrote:
>>>
>>>> I am trying to write a script for MLE estimation of a CARR model,
similar
>>>> to GARCH. It is a MEM model in daily ranges of some instrument, i,e,
>>>>
>>>> Eq. 1: lRng = lambda * epsilon # epsilon is exponentially distributed
>>>> here, giving the shape of LL
>>>> Eq. 2: lambda = a + b*Rng(-1) + c*lambda(-1)
>>>>
>>>> I tried the following code but the algorithm never converges. What should
I
>>>> improve?
>>>
>>>> scalar a = 0.1
>>>> scalar b = 0.4
>>>> scalar c = 0.4
>>>>
>>>> mle ll = -ln(lambda) + Rng/lambda
>>>
>>> Improve here: use the correct loglikelihood!
>>>
>>> mle ll = -ln(lambda) - Rng/lambda
>>>
>>>> series lambda = mean(Rng)
>>>> series lambda = a + b*Rng(-1) + c*lambda(-1)
>>>>
>>>> params a b c
>>>> end mle
>>>
>>> You may also have to constrain all the parameter values to be positive,
if
>>> I'm reading the CARR literature correctly. In which case you could, for
>>> example, express lambda as
>>> exp(a) + exp(b)*Rng(-1) + exp(c)*lambda(-1).
>>
>>Alternatively, you can wrap everything up into a function so that checking
>>is done automatically inside the function, as in
>>
>><hansl>
>>function series CarrLoglik(series y, matrix theta)
>> if minc(theta)<0
>> series ret = NA
>> else
>> scalar a = theta[1]
>> scalar b = theta[2]
>> scalar c = theta[3]
>> series lambda = mean(y)
>> series lambda = a + b * y(-1) + c * lambda(-1)
>> series ret = -ln(lambda) - y/lambda
>> endif
>>
>> return ret
>>end function
>>
>>param = {0.1;0.4;0.4}
>>
>>mle ll = CarrLoglik(Rng, theta)
>> params theta
>>end mle
>></hansl>
>>
>>
>>Riccardo (Jack) Lucchetti
>>Dipartimento di Economia
>>Universit? Politecnica delle Marche
>>
>>r.lucchetti(a)univpm.it
>>http://www.econ.univpm.it/lucchetti
>>
>>------------------------------
>>
>>Message: 4
>>Date: Wed, 22 Feb 2012 11:37:33 +0100 (CET)
>>From: "alexkakashi(a)libero.it" <alexkakashi(a)libero.it>
>>Subject: Re: [Gretl-users] Bootstrap VAR models
>>To: <gretl-users(a)lists.wfu.edu>
>>Message-ID:
>> <9682170.1207401329907053657.JavaMail.defaultUser@defaultHost>
>>Content-Type: text/plain;charset="UTF-8"
>>
>>Thanks Stev.
>>
>>I have used this procedure to study Granger causality from X to Y in a
>>trivariate VAR:
>>
>>r=158 ## number of observation
>>
>>ysim=Y
>>
>>xsim=X
>>
>>Zsim=Z
>>
>>system method=sur
>>equation Y const Y(-1) Y(-2) Z(-1) Z(-2)
>>equation X const Y(-1) Y(-2) X(-1) X(-2) Z(-1) Z(-2)
>>equation Z const Y(-1) Y(-2) X(-1) X(-2) Z(-1) Z(-2)
>>end system
>>
>>genr residui=$uhat
>>
>>genr M=$coeff
>>
>>loop for i=3..r --quiet
>>
>>ysim[i]=M[1]+M[2]*ysim[i-1]+M[3]*ysim[i-2]+M[4]*zsim[i-1]+M[5]*zsim[i-2]
>>
>>xsim[i]=M[6]+M[7]*ysim[i-1]+M[8]*ysim[i-2]+M[9]*xsim[i-1]+M[10]*xsim[i-2]+M
[11]
>>*zsim[i-1]+M[12]*zsim[i-2]
>>
>>zsim[i]=M[13]+M[14]*ysim[i-1]+M[15]*ysim[i-2]+M[16]*xsim[i-1]+M[17]*xsim[i-2]
+M
>>[18]*zsim[i-1]+M[19]*zsim[i-2]
>>
>>loop replics --quiet ### BOOTSTRAP
>>
>>smpl full
>>
>>Ysim=ysim
>>
>>Xsim=xsim
>>
>>Zsim=zsim
>>
>>genr A=resample(residui)
>>
>>loop for i=3..r --quiet
>>
>>Ysim[i]=ysim[i]+A[i-2,1]
>>
>>Xsim[i]=ysim[i]+A[i-2,2]
>>
>>Zsim[i]=ysim[i]+A[i-2,3]
>>
>>endloop
>>
>>...................endloop
>>
>>There is a strange result when I apply the bootstrap procedure. In fact the
>>statistic test based on observed data is very large, but the bootstrap p-
value
>>is greater then 0.8 and I do not reject the null hypothesis of Granger non-
>>causality from X to Y. The results are different if I work considering only
the
>>equation
>>
>>equation Y const Y(-1) Y(-2) X(-1) X(-2) Z(-1) Z(-2)
>>
>>Under the null hypothesis I replace the series Y. In this case the bootstrap
p-
>>value is very small and I reject the null hypothesis of no-causality. I
don't
>>understant the different between these p-values.
>>
>>Best regards.
>>
>>Alessandro
>>
>>
>>
>>>----Messaggio originale----
>>>Da: gretl-users-request(a)lists.wfu.edu
>>>Data: 16/02/2012 18.00
>>>A: <gretl-users(a)lists.wfu.edu>
>>>Ogg: Gretl-users Digest, Vol 61, Issue 11
>>>
>>>Send Gretl-users mailing list submissions to
>>> gretl-users(a)lists.wfu.edu
>>>
>>>To subscribe or unsubscribe via the World Wide Web, visit
>>> http://lists.wfu.edu/mailman/listinfo/gretl-users
>>>or, via email, send a message with subject or body 'help' to
>>> gretl-users-request(a)lists.wfu.edu
>>>
>>>You can reach the person managing the list at
>>> gretl-users-owner(a)lists.wfu.edu
>>>
>>>When replying, please edit your Subject line so it is more specific
>>>than "Re: Contents of Gretl-users digest..."
>>>
>>>
>>>Today's Topics:
>>>
>>> 1. Bootstrap VAR models (alexkakashi(a)libero.it)
>>> 2. Re: Bootstrap VAR models (Sven Schreiber)
>>> 3. Gretl error/crash ((s) Simon Grenville-Wood)
>>> 4. Re: Gretl error/crash (Riccardo (Jack) Lucchetti)
>>> 5. Re: Gretl error/crash ((s) Simon Grenville-Wood)
>>> 6. Random-effects panel-data (Helgi Tomasson)
>>>
>>>
>>>----------------------------------------------------------------------
>>>
>>>Message: 1
>>>Date: Thu, 16 Feb 2012 09:34:37 +0100 (CET)
>>>From: "alexkakashi(a)libero.it" <alexkakashi(a)libero.it>
>>>Subject: [Gretl-users] Bootstrap VAR models
>>>To: gretl-users(a)lists.wfu.edu
>>>Message-ID: <25986877.1523161329381277575.JavaMail.root@wmail22>
>>>Content-Type: text/plain;charset="UTF-8"
>>>
>>>Hi,
>>>
>>>I have the following question. Let us consider a trivariate VAR model. The
>>>parameters of the model are estimated using:
>>>
>>>system method=sur
>>>equation Y const Y(-1) X(-1) Z(-1)
>>>equation X const Y(-1) X(-1) Z(-1)
>>>equation Z const Y(-1) X(-1) Z(-1)
>>>end system
>>>
>>>I'd like study Granger causality from X to Y and the critical values are
>>>calculated using bootstrap method based on residuals. Is this procedure
>>>implemented in gretl?
>>>
>>>Best regards.
>>>
>>>Alessandro
>>>
>>>
>>>------------------------------
>>>
>>>Message: 2
>>>Date: Thu, 16 Feb 2012 10:18:44 +0100
>>>From: Sven Schreiber <svetosch(a)gmx.net>
>>>Subject: Re: [Gretl-users] Bootstrap VAR models
>>>To: gretl-users(a)lists.wfu.edu
>>>Message-ID: <4F3CC9F4.4050602(a)gmx.net>
>>>Content-Type: text/plain; charset=ISO-8859-1
>>>
>>>On 02/16/2012 09:34 AM, alexkakashi(a)libero.it wrote:
>>>> Hi,
>>>>
>>>> I have the following question. Let us consider a trivariate VAR model.
The
>>>> parameters of the model are estimated using:
>>>>
>>>> system method=sur
>>>> equation Y const Y(-1) X(-1) Z(-1)
>>>> equation X const Y(-1) X(-1) Z(-1)
>>>> equation Z const Y(-1) X(-1) Z(-1)
>>>> end system
>>>>
>>>> I'd like study Granger causality from X to Y and the critical values are
>>>> calculated using bootstrap method based on residuals. Is this procedure
>>>> implemented in gretl?
>>>>
>>>
>>>
>>>Not that I know of, but have a look at the varsimul() and resample()
>>>functions, with those it's not too difficult to program it.
>>>
>>>hth,
>>>sven
>>>
>>>
>>>------------------------------
>>>
>>>Message: 3
>>>Date: Thu, 16 Feb 2012 14:50:11 +0000
>>>From: "(s) Simon Grenville-Wood"
>>> <simon.grenville-wood(a)students.plymouth.ac.uk>
>>>Subject: [Gretl-users] Gretl error/crash
>>>To: "gretl-users(a)lists.wfu.edu" <gretl-users(a)lists.wfu.edu>
>>>Message-ID:
>>> <A775801493FD6643B49F9B292B0376FB2F63D3CC(a)AMSPRD0302MB113.eurprd03.prod.
>>outlook.com>
>>>
>>>Content-Type: text/plain; charset="iso-8859-1"
>>>
>>>Hi,
>>>
>>>I'm currently attempting a multinomial logit model on a large sample of
panel
>>data.
>>>I'm having a problem where I need to be able to create dummies for each
>>individual in the sample to control for the individual fixed effects.
>>>
>>>In order to do so while using the logit model, I need to dummify the
person
>>ID (PID) in the sample.
>>>I've opened the gretl console and I enter the following commands:
>>>
>>>discrete PID <----transform the variable, 19,421 values, to be
discrete
>>>dummify PID <----create dummies for each individual to control for
fixed
>>effects
>>>
>>>The last command causes gretl to crash, giving a libcairo_32.dll error.
This
>>happens on whichever computer I am using. Occasionally, if I use the menus
>>instead of the console, it will give an 'out of memory' error. My PC is
>>definitely sufficiently powerful.
>>>
>>>Does anyone have any ideas as to how I can get around this issue?
>>>
>>>Thanks,
>>>
>>>Simon
>>>
10 years, 9 months

Re: [Gretl-users] CARR model MLE
by Dan Běsoň

I forgot - is there a way to extract the in-sample predictions of the CARR model?
Many thanks,
Daniel
______________________________________________________________
> Od: gretl-users-request(a)lists.wfu.edu
> Komu: <gretl-users(a)lists.wfu.edu>
> Datum: 22.02.2012 13:48
> Předmět: Gretl-users Digest, Vol 61, Issue 17
>
>Send Gretl-users mailing list submissions to
> gretl-users(a)lists.wfu.edu
>
>To subscribe or unsubscribe via the World Wide Web, visit
> http://lists.wfu.edu/mailman/listinfo/gretl-users
>or, via email, send a message with subject or body 'help' to
> gretl-users-request(a)lists.wfu.edu
>
>You can reach the person managing the list at
> gretl-users-owner(a)lists.wfu.edu
>
>When replying, please edit your Subject line so it is more specific
>than "Re: Contents of Gretl-users digest..."
>
>
>Today's Topics:
>
> 1. CARR model MLE ( Dan B?so? )
> 2. Re: CARR model MLE (Allin Cottrell)
> 3. Re: CARR model MLE (Riccardo (Jack) Lucchetti)
> 4. Re: Bootstrap VAR models (alexkakashi(a)libero.it)
> 5. Problem with bootstrap result (alexkakashi(a)libero.it)
>
>
>----------------------------------------------------------------------
>
>Message: 1
>Date: Tue, 21 Feb 2012 21:15:02 +0100
>From: " Dan B?so? " <eubie(a)centrum.cz>
>Subject: [Gretl-users] CARR model MLE
>To: <gretl-users(a)lists.wfu.edu>
>Message-ID: <20120221211502.4991D432(a)centrum.cz>
>Content-Type: text/plain; charset=UTF-8
>
>
>Dear fellow users,
>
>I am trying to write a script for MLE estimation of a CARR model, similar to GARCH. It is a MEM model in daily ranges of some instrument, i,e,
>
>Eq. 1: lRng = lambda * epsilon # epsilon is exponentially distributed here, giving the shape of LL
>Eq. 2: lambda = a + b*Rng(-1) + c*lambda(-1)
>
>I tried the following code but the algorithm never converges. What should I improve?
>Thanks in advance, Daniel
>
>
>
>scalar a = 0.1
>scalar b = 0.4
>scalar c = 0.4
>
>mle ll = -ln(lambda) + Rng/lambda
>
> series lambda = mean(Rng)
> series lambda = a + b*Rng(-1) + c*lambda(-1)
>
> params a b c
>end mle
>
>
>
>------------------------------
>
>Message: 2
>Date: Tue, 21 Feb 2012 15:57:19 -0500 (EST)
>From: Allin Cottrell <cottrell(a)wfu.edu>
>Subject: Re: [Gretl-users] CARR model MLE
>To: Gretl list <gretl-users(a)lists.wfu.edu>
>Message-ID:
> <alpine.LNX.2.01.1202211548120.22658(a)waverley.dhcp.wfu.edu>
>Content-Type: text/plain; charset="iso-8859-2"
>
>On Tue, 21 Feb 2012, Dan B?so? wrote:
>
>> I am trying to write a script for MLE estimation of a CARR model, similar to GARCH. It is a MEM model in daily ranges of some instrument, i,e,
>>
>> Eq. 1: lRng = lambda * epsilon # epsilon is exponentially distributed here, giving the shape of LL
>> Eq. 2: lambda = a + b*Rng(-1) + c*lambda(-1)
>>
>> I tried the following code but the algorithm never
>> converges. What should I improve?
>
>> scalar a = 0.1
>> scalar b = 0.4
>> scalar c = 0.4
>>
>> mle ll = -ln(lambda) + Rng/lambda
>
>Improve here: use the correct loglikelihood!
>
> mle ll = -ln(lambda) - Rng/lambda
>
>> series lambda = mean(Rng)
>> series lambda = a + b*Rng(-1) + c*lambda(-1)
>>
>> params a b c
>> end mle
>
>You may also have to constrain all the parameter values to be
>positive, if I'm reading the CARR literature correctly. In
>which case you could, for example, express lambda as
>exp(a) + exp(b)*Rng(-1) + exp(c)*lambda(-1).
>
>Allin Cottrell
>
>------------------------------
>
>Message: 3
>Date: Tue, 21 Feb 2012 22:25:59 +0100 (CET)
>From: "Riccardo (Jack) Lucchetti" <r.lucchetti(a)univpm.it>
>Subject: Re: [Gretl-users] CARR model MLE
>To: Gretl list <gretl-users(a)lists.wfu.edu>
>Message-ID: <alpine.DEB.2.02.1202212216510.14044(a)ec-4.econ.univpm.it>
>Content-Type: text/plain; charset="utf-8"
>
>On Tue, 21 Feb 2012, Allin Cottrell wrote:
>
>> On Tue, 21 Feb 2012, Dan B?so? wrote:
>>
>>> I am trying to write a script for MLE estimation of a CARR model, similar
>>> to GARCH. It is a MEM model in daily ranges of some instrument, i,e,
>>>
>>> Eq. 1: lRng = lambda * epsilon # epsilon is exponentially distributed
>>> here, giving the shape of LL
>>> Eq. 2: lambda = a + b*Rng(-1) + c*lambda(-1)
>>>
>>> I tried the following code but the algorithm never converges. What should I
>>> improve?
>>
>>> scalar a = 0.1
>>> scalar b = 0.4
>>> scalar c = 0.4
>>>
>>> mle ll = -ln(lambda) + Rng/lambda
>>
>> Improve here: use the correct loglikelihood!
>>
>> mle ll = -ln(lambda) - Rng/lambda
>>
>>> series lambda = mean(Rng)
>>> series lambda = a + b*Rng(-1) + c*lambda(-1)
>>>
>>> params a b c
>>> end mle
>>
>> You may also have to constrain all the parameter values to be positive, if
>> I'm reading the CARR literature correctly. In which case you could, for
>> example, express lambda as
>> exp(a) + exp(b)*Rng(-1) + exp(c)*lambda(-1).
>
>Alternatively, you can wrap everything up into a function so that checking
>is done automatically inside the function, as in
>
><hansl>
>function series CarrLoglik(series y, matrix theta)
> if minc(theta)<0
> series ret = NA
> else
> scalar a = theta[1]
> scalar b = theta[2]
> scalar c = theta[3]
> series lambda = mean(y)
> series lambda = a + b * y(-1) + c * lambda(-1)
> series ret = -ln(lambda) - y/lambda
> endif
>
> return ret
>end function
>
>param = {0.1;0.4;0.4}
>
>mle ll = CarrLoglik(Rng, theta)
> params theta
>end mle
></hansl>
>
>
>Riccardo (Jack) Lucchetti
>Dipartimento di Economia
>Universit? Politecnica delle Marche
>
>r.lucchetti(a)univpm.it
>http://www.econ.univpm.it/lucchetti
>
>------------------------------
>
>Message: 4
>Date: Wed, 22 Feb 2012 11:37:33 +0100 (CET)
>From: "alexkakashi(a)libero.it" <alexkakashi(a)libero.it>
>Subject: Re: [Gretl-users] Bootstrap VAR models
>To: <gretl-users(a)lists.wfu.edu>
>Message-ID:
> <9682170.1207401329907053657.JavaMail.defaultUser@defaultHost>
>Content-Type: text/plain;charset="UTF-8"
>
>Thanks Stev.
>
>I have used this procedure to study Granger causality from X to Y in a
>trivariate VAR:
>
>r=158 ## number of observation
>
>ysim=Y
>
>xsim=X
>
>Zsim=Z
>
>system method=sur
>equation Y const Y(-1) Y(-2) Z(-1) Z(-2)
>equation X const Y(-1) Y(-2) X(-1) X(-2) Z(-1) Z(-2)
>equation Z const Y(-1) Y(-2) X(-1) X(-2) Z(-1) Z(-2)
>end system
>
>genr residui=$uhat
>
>genr M=$coeff
>
>loop for i=3..r --quiet
>
>ysim[i]=M[1]+M[2]*ysim[i-1]+M[3]*ysim[i-2]+M[4]*zsim[i-1]+M[5]*zsim[i-2]
>
>xsim[i]=M[6]+M[7]*ysim[i-1]+M[8]*ysim[i-2]+M[9]*xsim[i-1]+M[10]*xsim[i-2]+M[11]
>*zsim[i-1]+M[12]*zsim[i-2]
>
>zsim[i]=M[13]+M[14]*ysim[i-1]+M[15]*ysim[i-2]+M[16]*xsim[i-1]+M[17]*xsim[i-2]+M
>[18]*zsim[i-1]+M[19]*zsim[i-2]
>
>loop replics --quiet ### BOOTSTRAP
>
>smpl full
>
>Ysim=ysim
>
>Xsim=xsim
>
>Zsim=zsim
>
>genr A=resample(residui)
>
>loop for i=3..r --quiet
>
>Ysim[i]=ysim[i]+A[i-2,1]
>
>Xsim[i]=ysim[i]+A[i-2,2]
>
>Zsim[i]=ysim[i]+A[i-2,3]
>
>endloop
>
>...................endloop
>
>There is a strange result when I apply the bootstrap procedure. In fact the
>statistic test based on observed data is very large, but the bootstrap p-value
>is greater then 0.8 and I do not reject the null hypothesis of Granger non-
>causality from X to Y. The results are different if I work considering only the
>equation
>
>equation Y const Y(-1) Y(-2) X(-1) X(-2) Z(-1) Z(-2)
>
>Under the null hypothesis I replace the series Y. In this case the bootstrap p-
>value is very small and I reject the null hypothesis of no-causality. I don't
>understant the different between these p-values.
>
>Best regards.
>
>Alessandro
>
>
>
>>----Messaggio originale----
>>Da: gretl-users-request(a)lists.wfu.edu
>>Data: 16/02/2012 18.00
>>A: <gretl-users(a)lists.wfu.edu>
>>Ogg: Gretl-users Digest, Vol 61, Issue 11
>>
>>Send Gretl-users mailing list submissions to
>> gretl-users(a)lists.wfu.edu
>>
>>To subscribe or unsubscribe via the World Wide Web, visit
>> http://lists.wfu.edu/mailman/listinfo/gretl-users
>>or, via email, send a message with subject or body 'help' to
>> gretl-users-request(a)lists.wfu.edu
>>
>>You can reach the person managing the list at
>> gretl-users-owner(a)lists.wfu.edu
>>
>>When replying, please edit your Subject line so it is more specific
>>than "Re: Contents of Gretl-users digest..."
>>
>>
>>Today's Topics:
>>
>> 1. Bootstrap VAR models (alexkakashi(a)libero.it)
>> 2. Re: Bootstrap VAR models (Sven Schreiber)
>> 3. Gretl error/crash ((s) Simon Grenville-Wood)
>> 4. Re: Gretl error/crash (Riccardo (Jack) Lucchetti)
>> 5. Re: Gretl error/crash ((s) Simon Grenville-Wood)
>> 6. Random-effects panel-data (Helgi Tomasson)
>>
>>
>>----------------------------------------------------------------------
>>
>>Message: 1
>>Date: Thu, 16 Feb 2012 09:34:37 +0100 (CET)
>>From: "alexkakashi(a)libero.it" <alexkakashi(a)libero.it>
>>Subject: [Gretl-users] Bootstrap VAR models
>>To: gretl-users(a)lists.wfu.edu
>>Message-ID: <25986877.1523161329381277575.JavaMail.root@wmail22>
>>Content-Type: text/plain;charset="UTF-8"
>>
>>Hi,
>>
>>I have the following question. Let us consider a trivariate VAR model. The
>>parameters of the model are estimated using:
>>
>>system method=sur
>>equation Y const Y(-1) X(-1) Z(-1)
>>equation X const Y(-1) X(-1) Z(-1)
>>equation Z const Y(-1) X(-1) Z(-1)
>>end system
>>
>>I'd like study Granger causality from X to Y and the critical values are
>>calculated using bootstrap method based on residuals. Is this procedure
>>implemented in gretl?
>>
>>Best regards.
>>
>>Alessandro
>>
>>
>>------------------------------
>>
>>Message: 2
>>Date: Thu, 16 Feb 2012 10:18:44 +0100
>>From: Sven Schreiber <svetosch(a)gmx.net>
>>Subject: Re: [Gretl-users] Bootstrap VAR models
>>To: gretl-users(a)lists.wfu.edu
>>Message-ID: <4F3CC9F4.4050602(a)gmx.net>
>>Content-Type: text/plain; charset=ISO-8859-1
>>
>>On 02/16/2012 09:34 AM, alexkakashi(a)libero.it wrote:
>>> Hi,
>>>
>>> I have the following question. Let us consider a trivariate VAR model. The
>>> parameters of the model are estimated using:
>>>
>>> system method=sur
>>> equation Y const Y(-1) X(-1) Z(-1)
>>> equation X const Y(-1) X(-1) Z(-1)
>>> equation Z const Y(-1) X(-1) Z(-1)
>>> end system
>>>
>>> I'd like study Granger causality from X to Y and the critical values are
>>> calculated using bootstrap method based on residuals. Is this procedure
>>> implemented in gretl?
>>>
>>
>>
>>Not that I know of, but have a look at the varsimul() and resample()
>>functions, with those it's not too difficult to program it.
>>
>>hth,
>>sven
>>
>>
>>------------------------------
>>
>>Message: 3
>>Date: Thu, 16 Feb 2012 14:50:11 +0000
>>From: "(s) Simon Grenville-Wood"
>> <simon.grenville-wood(a)students.plymouth.ac.uk>
>>Subject: [Gretl-users] Gretl error/crash
>>To: "gretl-users(a)lists.wfu.edu" <gretl-users(a)lists.wfu.edu>
>>Message-ID:
>> <A775801493FD6643B49F9B292B0376FB2F63D3CC(a)AMSPRD0302MB113.eurprd03.prod.
>outlook.com>
>>
>>Content-Type: text/plain; charset="iso-8859-1"
>>
>>Hi,
>>
>>I'm currently attempting a multinomial logit model on a large sample of panel
>data.
>>I'm having a problem where I need to be able to create dummies for each
>individual in the sample to control for the individual fixed effects.
>>
>>In order to do so while using the logit model, I need to dummify the person
>ID (PID) in the sample.
>>I've opened the gretl console and I enter the following commands:
>>
>>discrete PID <----transform the variable, 19,421 values, to be discrete
>>dummify PID <----create dummies for each individual to control for fixed
>effects
>>
>>The last command causes gretl to crash, giving a libcairo_32.dll error. This
>happens on whichever computer I am using. Occasionally, if I use the menus
>instead of the console, it will give an 'out of memory' error. My PC is
>definitely sufficiently powerful.
>>
>>Does anyone have any ideas as to how I can get around this issue?
>>
>>Thanks,
>>
>>Simon
>>
10 years, 9 months

Problem with bootstrap result
by alexkakashi＠libero.it

Dear community of gretl,
I prefer writing a new post about my problem. I'm interested in testing
Granger causality from X to Y in a trivariate VAR. The critical values are
found using bootstrap based on residuals. In the first stage I consider only
the equation
ols Y const Y(-1) Y(-2) X(-1) X(-2) Z(-1) Z(-2)
Under the null hypothesis I replace the series Y using the residuals of this
equation and the coefficient estimated under the null. The test statistics is
large and observing the p-value (small) I reject the null hypothesis of no-
causality.
I have also considered the VAR model and, in the bootstrap method, I have
replace every equation of the VAR. I have used this commands:
r=158 # number of observations
system method=sur
equation Y const Y(-1) Y(-2) X(-1) X(-2) Z(-1) Z(-2)
equation X const Y(-1) Y(-2) X(-1) X(-2) Z(-1) Z(-2)
equation Z const Y(-1) Y(-2) X(-1) X(-2) Z(-1) Z(-2)
end system
genr residui=$uhat
genr M=$coeff
loop for i=3..158 --quiet
ysim[i]=M[1]+M[2]*ysim[i-1]+M[3]*ysim[i-2]+M[4]*zsim[i-1]+M[5]*zsim[i-2]
xsim[i]=M[6]+M[7]*ysim[i-1]+M[8]*ysim[i-2]+M[9]*xsim[i-1]+M[10]*xsim[i-2]+M[11]
*zsim[i-1]+M[12]*zsim[i-2]
zsim[i]=M[13]+M[14]*ysim[i-1]+M[15]*ysim[i-2]+M[16]*xsim[i-1]+M[17]*xsim[i-2]+M
[18]*zsim[i-1]+M[19]*zsim[i-2]
endloop
loop replics --quiet ### BOOTSTRAP
Ysim=ysim
Xsim=xsim
Zsim=zsim
genr A=resample(residui)
loop for i=3..r --quiet
Ysim[i]=ysim[i]+A[i-2,1]
Xsim[i]=ysim[i]+A[i-2,2]
Zsim[i]=ysim[i]+A[i-2,3]
endloop
Calculate the bootstrap test statistics and p-values
......................endloop
There is a strange result when I apply this bootstrap procedure on the VAR. In
fact the statistic test based on observed data is very large, but the bootstrap
p-value
is greater then 0.8 and I do not reject the null hypothesis of Granger non-
causality from X to Y. This results is different from the previuos which use
only the first equation.
The residuals are incorrelated. I don't understant the different between
these p-values. Are there errors in my procedure?
Best regards.
Alessandro
10 years, 9 months

Re: [Gretl-users] CARR model MLE
by Dan Běsoň

Thank you both a lot. I was out of my mind to overlook the +/- thing. Thank you also for the exp() trick, so far I thought the only way to ensure positiveness is to formulate a model for log(Rng).
Best regards,
Daniel
______________________________________________________________
> Od: gretl-users-request(a)lists.wfu.edu
> Komu: <gretl-users(a)lists.wfu.edu>
> Datum: 22.02.2012 13:48
> Předmět: Gretl-users Digest, Vol 61, Issue 17
>
>Send Gretl-users mailing list submissions to
> gretl-users(a)lists.wfu.edu
>
>To subscribe or unsubscribe via the World Wide Web, visit
> http://lists.wfu.edu/mailman/listinfo/gretl-users
>or, via email, send a message with subject or body 'help' to
> gretl-users-request(a)lists.wfu.edu
>
>You can reach the person managing the list at
> gretl-users-owner(a)lists.wfu.edu
>
>When replying, please edit your Subject line so it is more specific
>than "Re: Contents of Gretl-users digest..."
>
>
>Today's Topics:
>
> 1. CARR model MLE ( Dan B?so? )
> 2. Re: CARR model MLE (Allin Cottrell)
> 3. Re: CARR model MLE (Riccardo (Jack) Lucchetti)
> 4. Re: Bootstrap VAR models (alexkakashi(a)libero.it)
> 5. Problem with bootstrap result (alexkakashi(a)libero.it)
>
>
>----------------------------------------------------------------------
>
>Message: 1
>Date: Tue, 21 Feb 2012 21:15:02 +0100
>From: " Dan B?so? " <eubie(a)centrum.cz>
>Subject: [Gretl-users] CARR model MLE
>To: <gretl-users(a)lists.wfu.edu>
>Message-ID: <20120221211502.4991D432(a)centrum.cz>
>Content-Type: text/plain; charset=UTF-8
>
>
>Dear fellow users,
>
>I am trying to write a script for MLE estimation of a CARR model, similar to GARCH. It is a MEM model in daily ranges of some instrument, i,e,
>
>Eq. 1: lRng = lambda * epsilon # epsilon is exponentially distributed here, giving the shape of LL
>Eq. 2: lambda = a + b*Rng(-1) + c*lambda(-1)
>
>I tried the following code but the algorithm never converges. What should I improve?
>Thanks in advance, Daniel
>
>
>
>scalar a = 0.1
>scalar b = 0.4
>scalar c = 0.4
>
>mle ll = -ln(lambda) + Rng/lambda
>
> series lambda = mean(Rng)
> series lambda = a + b*Rng(-1) + c*lambda(-1)
>
> params a b c
>end mle
>
>
>
>------------------------------
>
>Message: 2
>Date: Tue, 21 Feb 2012 15:57:19 -0500 (EST)
>From: Allin Cottrell <cottrell(a)wfu.edu>
>Subject: Re: [Gretl-users] CARR model MLE
>To: Gretl list <gretl-users(a)lists.wfu.edu>
>Message-ID:
> <alpine.LNX.2.01.1202211548120.22658(a)waverley.dhcp.wfu.edu>
>Content-Type: text/plain; charset="iso-8859-2"
>
>On Tue, 21 Feb 2012, Dan B?so? wrote:
>
>> I am trying to write a script for MLE estimation of a CARR model, similar to GARCH. It is a MEM model in daily ranges of some instrument, i,e,
>>
>> Eq. 1: lRng = lambda * epsilon # epsilon is exponentially distributed here, giving the shape of LL
>> Eq. 2: lambda = a + b*Rng(-1) + c*lambda(-1)
>>
>> I tried the following code but the algorithm never
>> converges. What should I improve?
>
>> scalar a = 0.1
>> scalar b = 0.4
>> scalar c = 0.4
>>
>> mle ll = -ln(lambda) + Rng/lambda
>
>Improve here: use the correct loglikelihood!
>
> mle ll = -ln(lambda) - Rng/lambda
>
>> series lambda = mean(Rng)
>> series lambda = a + b*Rng(-1) + c*lambda(-1)
>>
>> params a b c
>> end mle
>
>You may also have to constrain all the parameter values to be
>positive, if I'm reading the CARR literature correctly. In
>which case you could, for example, express lambda as
>exp(a) + exp(b)*Rng(-1) + exp(c)*lambda(-1).
>
>Allin Cottrell
>
>------------------------------
>
>Message: 3
>Date: Tue, 21 Feb 2012 22:25:59 +0100 (CET)
>From: "Riccardo (Jack) Lucchetti" <r.lucchetti(a)univpm.it>
>Subject: Re: [Gretl-users] CARR model MLE
>To: Gretl list <gretl-users(a)lists.wfu.edu>
>Message-ID: <alpine.DEB.2.02.1202212216510.14044(a)ec-4.econ.univpm.it>
>Content-Type: text/plain; charset="utf-8"
>
>On Tue, 21 Feb 2012, Allin Cottrell wrote:
>
>> On Tue, 21 Feb 2012, Dan B?so? wrote:
>>
>>> I am trying to write a script for MLE estimation of a CARR model, similar
>>> to GARCH. It is a MEM model in daily ranges of some instrument, i,e,
>>>
>>> Eq. 1: lRng = lambda * epsilon # epsilon is exponentially distributed
>>> here, giving the shape of LL
>>> Eq. 2: lambda = a + b*Rng(-1) + c*lambda(-1)
>>>
>>> I tried the following code but the algorithm never converges. What should I
>>> improve?
>>
>>> scalar a = 0.1
>>> scalar b = 0.4
>>> scalar c = 0.4
>>>
>>> mle ll = -ln(lambda) + Rng/lambda
>>
>> Improve here: use the correct loglikelihood!
>>
>> mle ll = -ln(lambda) - Rng/lambda
>>
>>> series lambda = mean(Rng)
>>> series lambda = a + b*Rng(-1) + c*lambda(-1)
>>>
>>> params a b c
>>> end mle
>>
>> You may also have to constrain all the parameter values to be positive, if
>> I'm reading the CARR literature correctly. In which case you could, for
>> example, express lambda as
>> exp(a) + exp(b)*Rng(-1) + exp(c)*lambda(-1).
>
>Alternatively, you can wrap everything up into a function so that checking
>is done automatically inside the function, as in
>
><hansl>
>function series CarrLoglik(series y, matrix theta)
> if minc(theta)<0
> series ret = NA
> else
> scalar a = theta[1]
> scalar b = theta[2]
> scalar c = theta[3]
> series lambda = mean(y)
> series lambda = a + b * y(-1) + c * lambda(-1)
> series ret = -ln(lambda) - y/lambda
> endif
>
> return ret
>end function
>
>param = {0.1;0.4;0.4}
>
>mle ll = CarrLoglik(Rng, theta)
> params theta
>end mle
></hansl>
>
>
>Riccardo (Jack) Lucchetti
>Dipartimento di Economia
>Universit? Politecnica delle Marche
>
>r.lucchetti(a)univpm.it
>http://www.econ.univpm.it/lucchetti
>
>------------------------------
>
>Message: 4
>Date: Wed, 22 Feb 2012 11:37:33 +0100 (CET)
>From: "alexkakashi(a)libero.it" <alexkakashi(a)libero.it>
>Subject: Re: [Gretl-users] Bootstrap VAR models
>To: <gretl-users(a)lists.wfu.edu>
>Message-ID:
> <9682170.1207401329907053657.JavaMail.defaultUser@defaultHost>
>Content-Type: text/plain;charset="UTF-8"
>
>Thanks Stev.
>
>I have used this procedure to study Granger causality from X to Y in a
>trivariate VAR:
>
>r=158 ## number of observation
>
>ysim=Y
>
>xsim=X
>
>Zsim=Z
>
>system method=sur
>equation Y const Y(-1) Y(-2) Z(-1) Z(-2)
>equation X const Y(-1) Y(-2) X(-1) X(-2) Z(-1) Z(-2)
>equation Z const Y(-1) Y(-2) X(-1) X(-2) Z(-1) Z(-2)
>end system
>
>genr residui=$uhat
>
>genr M=$coeff
>
>loop for i=3..r --quiet
>
>ysim[i]=M[1]+M[2]*ysim[i-1]+M[3]*ysim[i-2]+M[4]*zsim[i-1]+M[5]*zsim[i-2]
>
>xsim[i]=M[6]+M[7]*ysim[i-1]+M[8]*ysim[i-2]+M[9]*xsim[i-1]+M[10]*xsim[i-2]+M[11]
>*zsim[i-1]+M[12]*zsim[i-2]
>
>zsim[i]=M[13]+M[14]*ysim[i-1]+M[15]*ysim[i-2]+M[16]*xsim[i-1]+M[17]*xsim[i-2]+M
>[18]*zsim[i-1]+M[19]*zsim[i-2]
>
>loop replics --quiet ### BOOTSTRAP
>
>smpl full
>
>Ysim=ysim
>
>Xsim=xsim
>
>Zsim=zsim
>
>genr A=resample(residui)
>
>loop for i=3..r --quiet
>
>Ysim[i]=ysim[i]+A[i-2,1]
>
>Xsim[i]=ysim[i]+A[i-2,2]
>
>Zsim[i]=ysim[i]+A[i-2,3]
>
>endloop
>
>...................endloop
>
>There is a strange result when I apply the bootstrap procedure. In fact the
>statistic test based on observed data is very large, but the bootstrap p-value
>is greater then 0.8 and I do not reject the null hypothesis of Granger non-
>causality from X to Y. The results are different if I work considering only the
>equation
>
>equation Y const Y(-1) Y(-2) X(-1) X(-2) Z(-1) Z(-2)
>
>Under the null hypothesis I replace the series Y. In this case the bootstrap p-
>value is very small and I reject the null hypothesis of no-causality. I don't
>understant the different between these p-values.
>
>Best regards.
>
>Alessandro
>
>
>
>>----Messaggio originale----
>>Da: gretl-users-request(a)lists.wfu.edu
>>Data: 16/02/2012 18.00
>>A: <gretl-users(a)lists.wfu.edu>
>>Ogg: Gretl-users Digest, Vol 61, Issue 11
>>
>>Send Gretl-users mailing list submissions to
>> gretl-users(a)lists.wfu.edu
>>
>>To subscribe or unsubscribe via the World Wide Web, visit
>> http://lists.wfu.edu/mailman/listinfo/gretl-users
>>or, via email, send a message with subject or body 'help' to
>> gretl-users-request(a)lists.wfu.edu
>>
>>You can reach the person managing the list at
>> gretl-users-owner(a)lists.wfu.edu
>>
>>When replying, please edit your Subject line so it is more specific
>>than "Re: Contents of Gretl-users digest..."
>>
>>
>>Today's Topics:
>>
>> 1. Bootstrap VAR models (alexkakashi(a)libero.it)
>> 2. Re: Bootstrap VAR models (Sven Schreiber)
>> 3. Gretl error/crash ((s) Simon Grenville-Wood)
>> 4. Re: Gretl error/crash (Riccardo (Jack) Lucchetti)
>> 5. Re: Gretl error/crash ((s) Simon Grenville-Wood)
>> 6. Random-effects panel-data (Helgi Tomasson)
>>
>>
>>----------------------------------------------------------------------
>>
>>Message: 1
>>Date: Thu, 16 Feb 2012 09:34:37 +0100 (CET)
>>From: "alexkakashi(a)libero.it" <alexkakashi(a)libero.it>
>>Subject: [Gretl-users] Bootstrap VAR models
>>To: gretl-users(a)lists.wfu.edu
>>Message-ID: <25986877.1523161329381277575.JavaMail.root@wmail22>
>>Content-Type: text/plain;charset="UTF-8"
>>
>>Hi,
>>
>>I have the following question. Let us consider a trivariate VAR model. The
>>parameters of the model are estimated using:
>>
>>system method=sur
>>equation Y const Y(-1) X(-1) Z(-1)
>>equation X const Y(-1) X(-1) Z(-1)
>>equation Z const Y(-1) X(-1) Z(-1)
>>end system
>>
>>I'd like study Granger causality from X to Y and the critical values are
>>calculated using bootstrap method based on residuals. Is this procedure
>>implemented in gretl?
>>
>>Best regards.
>>
>>Alessandro
>>
>>
>>------------------------------
>>
>>Message: 2
>>Date: Thu, 16 Feb 2012 10:18:44 +0100
>>From: Sven Schreiber <svetosch(a)gmx.net>
>>Subject: Re: [Gretl-users] Bootstrap VAR models
>>To: gretl-users(a)lists.wfu.edu
>>Message-ID: <4F3CC9F4.4050602(a)gmx.net>
>>Content-Type: text/plain; charset=ISO-8859-1
>>
>>On 02/16/2012 09:34 AM, alexkakashi(a)libero.it wrote:
>>> Hi,
>>>
>>> I have the following question. Let us consider a trivariate VAR model. The
>>> parameters of the model are estimated using:
>>>
>>> system method=sur
>>> equation Y const Y(-1) X(-1) Z(-1)
>>> equation X const Y(-1) X(-1) Z(-1)
>>> equation Z const Y(-1) X(-1) Z(-1)
>>> end system
>>>
>>> I'd like study Granger causality from X to Y and the critical values are
>>> calculated using bootstrap method based on residuals. Is this procedure
>>> implemented in gretl?
>>>
>>
>>
>>Not that I know of, but have a look at the varsimul() and resample()
>>functions, with those it's not too difficult to program it.
>>
>>hth,
>>sven
>>
>>
>>------------------------------
>>
>>Message: 3
>>Date: Thu, 16 Feb 2012 14:50:11 +0000
>>From: "(s) Simon Grenville-Wood"
>> <simon.grenville-wood(a)students.plymouth.ac.uk>
>>Subject: [Gretl-users] Gretl error/crash
>>To: "gretl-users(a)lists.wfu.edu" <gretl-users(a)lists.wfu.edu>
>>Message-ID:
>> <A775801493FD6643B49F9B292B0376FB2F63D3CC(a)AMSPRD0302MB113.eurprd03.prod.
>outlook.com>
>>
>>Content-Type: text/plain; charset="iso-8859-1"
>>
>>Hi,
>>
>>I'm currently attempting a multinomial logit model on a large sample of panel
>data.
>>I'm having a problem where I need to be able to create dummies for each
>individual in the sample to control for the individual fixed effects.
>>
>>In order to do so while using the logit model, I need to dummify the person
>ID (PID) in the sample.
>>I've opened the gretl console and I enter the following commands:
>>
>>discrete PID <----transform the variable, 19,421 values, to be discrete
>>dummify PID <----create dummies for each individual to control for fixed
>effects
>>
>>The last command causes gretl to crash, giving a libcairo_32.dll error. This
>happens on whichever computer I am using. Occasionally, if I use the menus
>instead of the console, it will give an 'out of memory' error. My PC is
>definitely sufficiently powerful.
>>
>>Does anyone have any ideas as to how I can get around this issue?
>>
>>Thanks,
>>
>>Simon
>>
10 years, 9 months

Re: [Gretl-users] Bootstrap VAR models
by alexkakashi＠libero.it

Thanks Stev.
I have used this procedure to study Granger causality from X to Y in a
trivariate VAR:
r=158 ## number of observation
ysim=Y
xsim=X
Zsim=Z
system method=sur
equation Y const Y(-1) Y(-2) Z(-1) Z(-2)
equation X const Y(-1) Y(-2) X(-1) X(-2) Z(-1) Z(-2)
equation Z const Y(-1) Y(-2) X(-1) X(-2) Z(-1) Z(-2)
end system
genr residui=$uhat
genr M=$coeff
loop for i=3..r --quiet
ysim[i]=M[1]+M[2]*ysim[i-1]+M[3]*ysim[i-2]+M[4]*zsim[i-1]+M[5]*zsim[i-2]
xsim[i]=M[6]+M[7]*ysim[i-1]+M[8]*ysim[i-2]+M[9]*xsim[i-1]+M[10]*xsim[i-2]+M[11]
*zsim[i-1]+M[12]*zsim[i-2]
zsim[i]=M[13]+M[14]*ysim[i-1]+M[15]*ysim[i-2]+M[16]*xsim[i-1]+M[17]*xsim[i-2]+M
[18]*zsim[i-1]+M[19]*zsim[i-2]
loop replics --quiet ### BOOTSTRAP
smpl full
Ysim=ysim
Xsim=xsim
Zsim=zsim
genr A=resample(residui)
loop for i=3..r --quiet
Ysim[i]=ysim[i]+A[i-2,1]
Xsim[i]=ysim[i]+A[i-2,2]
Zsim[i]=ysim[i]+A[i-2,3]
endloop
...................endloop
There is a strange result when I apply the bootstrap procedure. In fact the
statistic test based on observed data is very large, but the bootstrap p-value
is greater then 0.8 and I do not reject the null hypothesis of Granger non-
causality from X to Y. The results are different if I work considering only the
equation
equation Y const Y(-1) Y(-2) X(-1) X(-2) Z(-1) Z(-2)
Under the null hypothesis I replace the series Y. In this case the bootstrap p-
value is very small and I reject the null hypothesis of no-causality. I don't
understant the different between these p-values.
Best regards.
Alessandro
>----Messaggio originale----
>Da: gretl-users-request(a)lists.wfu.edu
>Data: 16/02/2012 18.00
>A: <gretl-users(a)lists.wfu.edu>
>Ogg: Gretl-users Digest, Vol 61, Issue 11
>
>Send Gretl-users mailing list submissions to
> gretl-users(a)lists.wfu.edu
>
>To subscribe or unsubscribe via the World Wide Web, visit
> http://lists.wfu.edu/mailman/listinfo/gretl-users
>or, via email, send a message with subject or body 'help' to
> gretl-users-request(a)lists.wfu.edu
>
>You can reach the person managing the list at
> gretl-users-owner(a)lists.wfu.edu
>
>When replying, please edit your Subject line so it is more specific
>than "Re: Contents of Gretl-users digest..."
>
>
>Today's Topics:
>
> 1. Bootstrap VAR models (alexkakashi(a)libero.it)
> 2. Re: Bootstrap VAR models (Sven Schreiber)
> 3. Gretl error/crash ((s) Simon Grenville-Wood)
> 4. Re: Gretl error/crash (Riccardo (Jack) Lucchetti)
> 5. Re: Gretl error/crash ((s) Simon Grenville-Wood)
> 6. Random-effects panel-data (Helgi Tomasson)
>
>
>----------------------------------------------------------------------
>
>Message: 1
>Date: Thu, 16 Feb 2012 09:34:37 +0100 (CET)
>From: "alexkakashi(a)libero.it" <alexkakashi(a)libero.it>
>Subject: [Gretl-users] Bootstrap VAR models
>To: gretl-users(a)lists.wfu.edu
>Message-ID: <25986877.1523161329381277575.JavaMail.root@wmail22>
>Content-Type: text/plain;charset="UTF-8"
>
>Hi,
>
>I have the following question. Let us consider a trivariate VAR model. The
>parameters of the model are estimated using:
>
>system method=sur
>equation Y const Y(-1) X(-1) Z(-1)
>equation X const Y(-1) X(-1) Z(-1)
>equation Z const Y(-1) X(-1) Z(-1)
>end system
>
>I'd like study Granger causality from X to Y and the critical values are
>calculated using bootstrap method based on residuals. Is this procedure
>implemented in gretl?
>
>Best regards.
>
>Alessandro
>
>
>------------------------------
>
>Message: 2
>Date: Thu, 16 Feb 2012 10:18:44 +0100
>From: Sven Schreiber <svetosch(a)gmx.net>
>Subject: Re: [Gretl-users] Bootstrap VAR models
>To: gretl-users(a)lists.wfu.edu
>Message-ID: <4F3CC9F4.4050602(a)gmx.net>
>Content-Type: text/plain; charset=ISO-8859-1
>
>On 02/16/2012 09:34 AM, alexkakashi(a)libero.it wrote:
>> Hi,
>>
>> I have the following question. Let us consider a trivariate VAR model. The
>> parameters of the model are estimated using:
>>
>> system method=sur
>> equation Y const Y(-1) X(-1) Z(-1)
>> equation X const Y(-1) X(-1) Z(-1)
>> equation Z const Y(-1) X(-1) Z(-1)
>> end system
>>
>> I'd like study Granger causality from X to Y and the critical values are
>> calculated using bootstrap method based on residuals. Is this procedure
>> implemented in gretl?
>>
>
>
>Not that I know of, but have a look at the varsimul() and resample()
>functions, with those it's not too difficult to program it.
>
>hth,
>sven
>
>
>------------------------------
>
>Message: 3
>Date: Thu, 16 Feb 2012 14:50:11 +0000
>From: "(s) Simon Grenville-Wood"
> <simon.grenville-wood(a)students.plymouth.ac.uk>
>Subject: [Gretl-users] Gretl error/crash
>To: "gretl-users(a)lists.wfu.edu" <gretl-users(a)lists.wfu.edu>
>Message-ID:
> <A775801493FD6643B49F9B292B0376FB2F63D3CC(a)AMSPRD0302MB113.eurprd03.prod.
outlook.com>
>
>Content-Type: text/plain; charset="iso-8859-1"
>
>Hi,
>
>I'm currently attempting a multinomial logit model on a large sample of panel
data.
>I'm having a problem where I need to be able to create dummies for each
individual in the sample to control for the individual fixed effects.
>
>In order to do so while using the logit model, I need to dummify the person
ID (PID) in the sample.
>I've opened the gretl console and I enter the following commands:
>
>discrete PID <----transform the variable, 19,421 values, to be discrete
>dummify PID <----create dummies for each individual to control for fixed
effects
>
>The last command causes gretl to crash, giving a libcairo_32.dll error. This
happens on whichever computer I am using. Occasionally, if I use the menus
instead of the console, it will give an 'out of memory' error. My PC is
definitely sufficiently powerful.
>
>Does anyone have any ideas as to how I can get around this issue?
>
>Thanks,
>
>Simon
>
10 years, 9 months

CARR model MLE
by Dan Běsoň

Dear fellow users,
I am trying to write a script for MLE estimation of a CARR model, similar to GARCH. It is a MEM model in daily ranges of some instrument, i,e,
Eq. 1: lRng = lambda * epsilon # epsilon is exponentially distributed here, giving the shape of LL
Eq. 2: lambda = a + b*Rng(-1) + c*lambda(-1)
I tried the following code but the algorithm never converges. What should I improve?
Thanks in advance, Daniel
scalar a = 0.1
scalar b = 0.4
scalar c = 0.4
mle ll = -ln(lambda) + Rng/lambda
series lambda = mean(Rng)
series lambda = a + b*Rng(-1) + c*lambda(-1)
params a b c
end mle
10 years, 9 months