Henrique Andrade | 25 Mar 17:15 2015
Picon

"If-Else" syntax help

Dear Gretl community,

I'm not a good "if-else" user so I need a little help. What's wrong with the following code?

<hansl>

open australia.gdt

series E_hp = E - hpfilt(E, 1600)

if E > E_hp
    series E_reg1 = E
    series PAUreg1 = PAU
    series PUSreg1 = PUS
else
    series E_reg1 = NA
    series PAUreg1 = NA
    series PUSreg1 = NA
endif

<hansl>

When I execute it I get the messages: "error evaluating 'if'" "Error executing script: halting".

Best regards,
Henrique Andrade
<div><div dir="ltr">Dear Gretl community,<div><br></div>
<div>I'm not a good "if-else" user so I need a little help. What's wrong with the following code?</div>
<div><br></div>
<div>&lt;hansl&gt;</div>
<div><br></div>
<div>
<div>open australia.gdt</div>
<div><br></div>
<div>series E_hp = E - hpfilt(E, 1600)</div>
<div><br></div>
<div>if E &gt; E_hp</div>
<div>&nbsp; &nbsp; series E_reg1 = E</div>
<div>&nbsp; &nbsp; series PAUreg1 = PAU</div>
<div>&nbsp; &nbsp; series PUSreg1 = PUS</div>
<div>else</div>
<div>&nbsp; &nbsp; series E_reg1 = NA</div>
<div>&nbsp; &nbsp; series PAUreg1 = NA</div>
<div>&nbsp; &nbsp; series PUSreg1 = NA</div>
<div>endif</div>
<div><br></div>
<div>&lt;hansl&gt;</div>
<div><br></div>
<div>When I execute it I get the messages: "error evaluating 'if'" "Error executing script: halting".</div>
<div><br></div>
<div>Best regards,</div>
<div class="gmail_signature">Henrique Andrade<br>
</div>
</div>
</div></div>
Artur T. | 25 Mar 11:05 2015

ARDL lag lenght selection using all possible combinations

Dear all,

I want to find the optimal lag length of an ARDL model allowing for variable-specific lag lengths.

For instance, I've got K variables and want to select the optimal lag structure by searching across the (pmax-1)^K ARDL models, spanned by p=0,1,..., pmax and p_k=0,1,..., pmax, k=1,.., K using some criteria (e.g. AIC).

I am looking for a clever trick to estimate all of these possible models but only have a complicated "loop-in-loop-in-loop" structure in mind. Does anybody have a clever idea how to realize this task efficiently?

Btw, it seems that the latest Eviews 9 version has this feature included:
http://www.eviews.com/EViews9/ev9ecest_n.html#ardl

Best,
Artur
<div><div dir="ltr">
<div>
<div>
<div>
<div>
<div>
<div>Dear all,<br><br>
</div>I want to find the optimal lag length of an ARDL model allowing for variable-specific lag lengths.<br>
</div>
<br>For instance, I've got K variables and want to select the optimal lag structure by searching across the (pmax-1)^K ARDL models, spanned by p=0,1,..., pmax and p_k=0,1,..., pmax, k=1,.., K using some criteria (e.g. AIC). <br><br>I am looking for a clever trick to estimate all of these possible models but only have a complicated "loop-in-loop-in-loop" structure in mind. Does anybody have a clever idea how to realize this task efficiently?<br>
</div>
<br>
</div>Btw, it seems that the latest Eviews 9 version has this feature included:<br><a href="http://www.eviews.com/EViews9/ev9ecest_n.html#ardl">http://www.eviews.com/EViews9/ev9ecest_n.html#ardl</a><br><br>
</div>Best,<br>
</div>Artur<br>
</div></div>
Qi Shi | 21 Mar 12:50 2015

Could gretl do numerical integration?

<!-- .hmmessage P { margin:0px; padding:0px } body.hmmessage { font-size: 12pt; font-family:Calibri } -->
hi,

Could gretl do numerical integration? just as R's "integrate".

thanks

shi,qi
<div><div dir="ltr">

&lt;!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--&gt;<div dir="ltr">hi,<div><br></div>
<div>Could gretl do numerical integration? just as R's "integrate".</div>
<div><br></div>
<div>thanks<br><br>shi,qi</div>
</div>
 		 	   		  </div></div>
Qi Shi | 18 Mar 04:10 2015

how to write syntax to plot a graph by observation number?

dear everyone,

For a cross-section data, how to write syntax to plot a graph by observation number?

thanks

shi,qi
<div><div dir="ltr">dear everyone,<div><br></div>
<div>For a cross-section data, how to write syntax to plot a graph by observation number?</div>
<div><br></div>
<div>thanks<br><br>shi,qi</div> 		 	   		  </div></div>
oleg_komashko | 18 Mar 00:21 2015
Picon

a possible bug in coint2 via GUI

Dear all!
To reproduce,

open denmark.gdt
series un = randgen(u,0,1)
coint2 2 LRM LRY IBO IDE ;null; un --seasonals --rc

works OK.

When I try do to this via GUI with LRM LRY IBO IDE in "Variables to test"; un R in "Exogenous variables"
lag order 2; checked "Include seasonal dummies"; and "Restricted constant" I get "Syntax error"

Looks as if the GUI calls 

coint2 2 LRM LRY IBO IDE ;; un --seasonals --rc

I use 1.10 on debian (outdated by a month or so)
!
<div>
<span class="xfm_88347733">Dear all!<div>To reproduce,</div>
<div><br></div>
<div>
<div>open denmark.gdt</div>
<div>series un = randgen(u,0,1)</div>
<div>coint2 2 LRM LRY IBO IDE ;null; un --seasonals --rc</div>
</div>
<div><br></div>
<div>works OK.</div>
<div><br></div>
<div>When I try do to this via GUI with LRM LRY IBO IDE in "Variables to test"; un R in "Exogenous variables"</div>
<div>lag order 2; checked "Include seasonal dummies"; and "Restricted constant" I get "Syntax error"</div>
<div><br></div>
<div>Looks as if the GUI calls&nbsp;</div>
<div><br></div>
<div>coint2 2 LRM LRY IBO IDE ;; un --seasonals --rc</div>
<div><br></div>
<div>I use 1.10 on debian (outdated by a month or so)<br>
</div></span>                                                                        !
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 </div>
Thomas Schneider | 17 Mar 07:34 2015
Picon

Impulse responses in VECM

I have two questions related to the impulse response functions of VEC models.

(1) How many draws are conducted when bootstrapping the confidence intervals and how can their value be modified?

(2) I want to calculate the percentage responses to a 1 percent change in a specific shock variable (which comes first in the Cholesky ordering). Since all variables enter the model in natural logs, I divided the default impulse responses by one standard error (SE) of the logged shock variable to achieve this. Looking at the summary statistics and calculating one SE as <one standard deviation> / <square root of no. of observations> gives me something different from the value of the logged shock variable in period 1, however. Since I presume this is the contemporaneous/instantaneous impact (corresponding to period 0 in the graphs), I would expect both values to be the same, since the variable should respond by exactly one SE when itself is shocked by one SE. What am I doing wrong?

Thank you for your help.
Thomas
<div><div dir="ltr">
<div>I have two questions related to the impulse response functions of VEC models.</div>
<div><br></div>
<div>(1) How many draws are conducted when bootstrapping the confidence intervals and how can their value be modified?</div>
<div><br></div>
<div>(2) I want to calculate the percentage responses to a 1 percent change in a specific shock variable (which comes first in the Cholesky ordering). Since all variables enter the model in natural logs, I divided the default impulse responses by one standard error (SE) of the logged shock variable to achieve this. Looking at the summary statistics and calculating one SE as &lt;one standard deviation&gt; / &lt;square root of no. of observations&gt; gives me something different from the value of the logged shock variable in period 1, however. Since I presume this is the contemporaneous/instantaneous impact (corresponding to period 0 in the graphs), I would expect both values to be the same, since the variable should respond by exactly one SE when itself is shocked by one SE. What am I doing wrong?</div>
<div><br></div>
<div>Thank you for your help.</div>
<div>Thomas</div>
</div></div>
Qi Shi | 17 Mar 03:44 2015

why the error?

dear everyone,

when i write in gretl the scripts

"
open greene22_2
discrete Z5
list X=dummify(Z5) --drop-first
"

then I run the program and get the results,

"
gretl version 1.9.92
Current session: 2015-03-14 16:31

? open greene22_2

Read datafile C:\Program Files\gretl\data\greene\greene22_2.gdt
periodicity: 1, maxobs: 601
observations range: 1 to 601

Listing 10 variables:
  0) const    1) Y        2) Z1       3) Z2       4) Z3     
  5) Z4       6) Z5       7) Z6       8) Z7       9) Z8     

? discrete Z5
? list X=dummify(Z5) --drop-first
> list X=dummify(Z5) --drop-
The symbol 'drop' is undefined

Error executing script: halting
> list X=dummify(Z5) --drop-first
"

why did i encounter the error?

best,

shi,qi
<div><div dir="ltr">
<div class="gmail_default">dear everyone,</div>
<div class="gmail_default"><br></div>
<div class="gmail_default">when i write in gretl the scripts</div>
<div class="gmail_default"><br></div>
<div class="gmail_default">"</div>
<div class="gmail_default">
<div class="gmail_default">open greene22_2</div>
<div class="gmail_default">discrete Z5</div>
<div class="gmail_default">list X=dummify(Z5) --drop-first</div>
<div class="gmail_default">"</div>
<div class="gmail_default"><br></div>
<div class="gmail_default">then I run the program and get the results,</div>
<div class="gmail_default"><br></div>
<div class="gmail_default">"</div>
<div class="gmail_default">
<div class="gmail_default">gretl version 1.9.92</div>
<div class="gmail_default">Current session: 2015-03-14 16:31</div>
<div class="gmail_default"><br></div>
<div class="gmail_default">? open greene22_2</div>
<div class="gmail_default"><br></div>
<div class="gmail_default">Read datafile C:\Program Files\gretl\data\greene\greene22_2.gdt</div>
<div class="gmail_default">periodicity: 1, maxobs: 601</div>
<div class="gmail_default">observations range: 1 to 601</div>
<div class="gmail_default"><br></div>
<div class="gmail_default">Listing 10 variables:</div>
<div class="gmail_default">&nbsp; 0) const &nbsp; &nbsp;1) Y &nbsp; &nbsp; &nbsp; &nbsp;2) Z1 &nbsp; &nbsp; &nbsp; 3) Z2 &nbsp; &nbsp; &nbsp; 4) Z3 &nbsp; &nbsp;&nbsp;</div>
<div class="gmail_default">&nbsp; 5) Z4 &nbsp; &nbsp; &nbsp; 6) Z5 &nbsp; &nbsp; &nbsp; 7) Z6 &nbsp; &nbsp; &nbsp; 8) Z7 &nbsp; &nbsp; &nbsp; 9) Z8 &nbsp; &nbsp;&nbsp;</div>
<div class="gmail_default"><br></div>
<div class="gmail_default">? discrete Z5</div>
<div class="gmail_default">? list X=dummify(Z5) --drop-first</div>
<div class="gmail_default">&gt; list X=dummify(Z5) --drop-≤/div>
<div class="gmail_default">The symbol 'drop' is undefined</div>
<div class="gmail_default"><br></div>
<div class="gmail_default">Error executing script: halting</div>
<div class="gmail_default">&gt; list X=dummify(Z5) --drop-first</div>
<div class="gmail_default">"</div>
<div class="gmail_default"><br></div>
<div class="gmail_default">why did i encounter the error?</div>
<div class="gmail_default"><br></div>
<div class="gmail_default">best,</div>
</div>
</div>
<br>shi,qi 		 	   		  </div></div>
zsófia farkas | 14 Mar 19:21 2015
Picon

calculating abnormal returns with Gretl

Dear Gretl users,

I would like to use gretl in my thesis for calculating short term abnormal return after a occuring a stock split and check its significance.
I use a model, where Abnormal return(ARi)=Ri (actual return)- alpha+(beta*Rm).
In the function alpha and beta is caculated from the data before the split (from the calculate window) and Rm is the actual market return (from the event window). I already have run an OLS on the data before the split, so I get the alpha and the beta of the stocks before the event. I have some problem how to run an other regression with the given alpha and beta (calculated from the past) and the market return, but now using the actual market return and not that of from the past? Could you please help me how to do it? And how to check the significance of the abnormal return?

Thank you very much for your help in advance!

Sophi
<div><div dir="ltr">
<div>
<div>
<div>Dear Gretl users,<br><br>
</div>I would like to use 
gretl in my thesis for calculating short term abnormal return after a 
occuring a stock split and check its significance.<br>I use a model, where Abnormal return(ARi)=Ri (actual return)- alpha+(beta*Rm).<br>In
 the function alpha and beta is caculated from the data before the split
 (from the calculate window) and Rm is the actual market return (from 
the event window). I already have run an OLS on the data before the 
split, so I get the alpha and the beta of the stocks before the event. I
 have some problem how to run an other regression with the given alpha 
and beta (calculated from the past) and the market return, but now using
 the actual market return and not that of from the past? Could you 
please help me how to do it? And how to check the significance of the 
abnormal return?<br><br>
</div>Thank you very much for your help in advance!<br><br>
</div>Sophi<br>
</div></div>
Allin Cottrell | 14 Mar 17:31 2015
Picon

longitudinal data

This is a follow-up to
http://lists.wfu.edu/pipermail/gretl-users/2015-March/010772.html

It strikes me that the issue raised -- namely, how to wrangle 
"difficult" data into gretl panel format -- may be of interest to 
others so I've thought about it a bit more.

First a disclaimer: the method outlined below cannot be applied 
mechanically to the ICPSR data mentioned by Christian. One would 
have to go through the codebook very carefully to see which 
variables actually "line up" across the waves of the study.

All the same, here's a toy example that might be helpful as a 
template. It's in the form of two scripts: the first creates an 
artificial dataset that mimics the general structure of the ICPSR 
"Children of the Immigrants" data, and the second shows how the data 
can be turned into a gretl panel.

1. Make the artificial data:

<hansl>
# let's suppose we have data on 50 individuals
# over 3 "waves", with the respective per-wave
# observations recorded as distinct variables
# (columns), here 10 columns per wave
nulldata 50
# unique ID for the individuals
series casenum = 10000 + index
# create a bunch of artificial data (30 series)
loop i=1..30 --quiet
   series v$i = index * i
   if i > 20
     v$i += 20
   elif i > 10
     v$i += 10
   endif
endloop
# write to CSV file
store rawdata.csv
</hansl>

2. Process the data into a panel

<hansl>
open rawdata.csv --quiet
# the number of longitudinal waves
scalar nwaves = 3
# the total number of panel observations
scalar NT = $nobs * nwaves
# create lists of series per wave
list L1 = v1..v10
list L2 = v11..v20
list L3 = v21..v30
# make a vector repeating the case numbers
matrix C = mshape({casenum}, NT, 1)
# matrix consisting of three vertically stacked
# components, each of which holds a wave number
# followed by the observations for that wave
matrix X = ({1}~{L1}) | ({2}~{L2}) | ({3}~{L3})
# note that X has an extra column for the wave
scalar nx = cols(X) - 1

# create empty dataset for panel
nulldata NT --preserve
# trash the automatic "index" variable
delete index
# add the casenum series from vector
series casenum = C
# add the wave number series from the first
# column of matrix X
series wave = X[,1]
# add the actual data
loop i=1..nx --quiet
   series pan$i = X[,i+1]
endloop

# let's take a look...
print --byobs

# now turn into gretl panel format
setobs casenum wave --panel-vars
# and take a look again...
print --byobs
</hansl>

Allin Cottrell
Qi Shi | 14 Mar 09:36 2015
Picon

why the error

dear everyone,

when i write in gretl the scripts

"
open greene22_2
discrete Z5
list X=dummify(Z5) --drop-first
"

then I run the program and get the results,

"
gretl version 1.9.92
Current session: 2015-03-14 16:31

? open greene22_2

Read datafile C:\Program Files\gretl\data\greene\greene22_2.gdt
periodicity: 1, maxobs: 601
observations range: 1 to 601

Listing 10 variables:
  0) const    1) Y        2) Z1       3) Z2       4) Z3     
  5) Z4       6) Z5       7) Z6       8) Z7       9) Z8     

? discrete Z5
? list X=dummify(Z5) --drop-first
> list X=dummify(Z5) --drop-
The symbol 'drop' is undefined

Error executing script: halting
> list X=dummify(Z5) --drop-first
"

why did i encounter the error?

best,

shi,qi
<div><div dir="ltr">
<div class="gmail_default">dear everyone,</div>
<div class="gmail_default"><br></div>
<div class="gmail_default">when i write in gretl the scripts</div>
<div class="gmail_default"><br></div>
<div class="gmail_default">"</div>
<div class="gmail_default">
<div class="gmail_default">open greene22_2</div>
<div class="gmail_default">discrete Z5</div>
<div class="gmail_default">list X=dummify(Z5) --drop-first</div>
<div class="gmail_default">"</div>
<div class="gmail_default"><br></div>
<div class="gmail_default">then I run the program and get the results,</div>
<div class="gmail_default"><br></div>
<div class="gmail_default">"</div>
<div class="gmail_default">
<div class="gmail_default">gretl version 1.9.92</div>
<div class="gmail_default">Current session: 2015-03-14 16:31</div>
<div class="gmail_default"><br></div>
<div class="gmail_default">? open greene22_2</div>
<div class="gmail_default"><br></div>
<div class="gmail_default">Read datafile C:\Program Files\gretl\data\greene\greene22_2.gdt</div>
<div class="gmail_default">periodicity: 1, maxobs: 601</div>
<div class="gmail_default">observations range: 1 to 601</div>
<div class="gmail_default"><br></div>
<div class="gmail_default">Listing 10 variables:</div>
<div class="gmail_default">&nbsp; 0) const &nbsp; &nbsp;1) Y &nbsp; &nbsp; &nbsp; &nbsp;2) Z1 &nbsp; &nbsp; &nbsp; 3) Z2 &nbsp; &nbsp; &nbsp; 4) Z3 &nbsp; &nbsp;&nbsp;</div>
<div class="gmail_default">&nbsp; 5) Z4 &nbsp; &nbsp; &nbsp; 6) Z5 &nbsp; &nbsp; &nbsp; 7) Z6 &nbsp; &nbsp; &nbsp; 8) Z7 &nbsp; &nbsp; &nbsp; 9) Z8 &nbsp; &nbsp;&nbsp;</div>
<div class="gmail_default"><br></div>
<div class="gmail_default">? discrete Z5</div>
<div class="gmail_default">? list X=dummify(Z5) --drop-first</div>
<div class="gmail_default">&gt; list X=dummify(Z5) --drop-≤/div>
<div class="gmail_default">The symbol 'drop' is undefined</div>
<div class="gmail_default"><br></div>
<div class="gmail_default">Error executing script: halting</div>
<div class="gmail_default">&gt; list X=dummify(Z5) --drop-first</div>
<div class="gmail_default">"</div>
<div class="gmail_default"><br></div>
<div class="gmail_default">why did i encounter the error?</div>
<div class="gmail_default"><br></div>
<div class="gmail_default">best,</div>
<div><br></div>
</div>
</div>
<div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div>shi,qi</div></div></div></div></div></div></div></div></div>
</div></div>
Allin Cottrell | 13 Mar 16:31 2015
Picon

Re: Question regarding the econometrics program gretl

Please post this sort of question to the gretl-users mailing list
[ http://lists.wfu.edu/mailman/listinfo/gretl-users ]
I'm forwarding it to the list; my comments follow the question.

On Fri, 13 Mar 2015, Christian Mücher wrote:

> I am an economics student at the university of constance. During the 
> last semester I leaned the use of the econometrics program gretl. 
> Right now I am writing my Bachelor Thesis with this program and 
> encountered a problem.
>
> I am using the Children of the Immigrants Longitudinal Study Dataset 
> http://doi.org/10.3886/ICPSR20520.v2
>
> When importing the Dataset in gretl the panel structure of the 
> dataset is lost. When trying to impose a panel structure on the 
> dataset the problem ist, that there is no variable measuring the 
> period. Further, the Dataset is coded such that each observation is 
> in one row and all variables are in columns. The problem is, that v1 
> to v148 are measured in period 1, v203 to p144 are measured in 
> period 2 and v400 to v450 are measured in period 3. But I fail to 
> define this periodicity such that a panel structure can be defined. 
> I tried pretty much everything I could think of, and my supervising 
> professor does not now gretl. The tutor who taught us gretl also has 
> no solution for my problem. The last thing I can think of ist to 
> export the Dataset as .csv file and include a timevariable manually. 
> I hope that you can help me out with an easier way, as this method 
> would be very time consuming.

From what I can tell, the ICPSR20520 dataset is not actually a panel, 
although it is longitudinal. According to the codebook, the three 
waves differ in regard to the information recorded, although there is 
some overlap between the waves. You'll have to think carefully about 
how you want to analyse these data.

That said, if you need to rearrange blocks of data to get a semblance 
of a panel, then gretl's matrix methods are likely to be useful. Just 
to illustrate, here's a hansl script to make a matrix out of variables
v1 to v148:

<hansl>
set echo off
set csv_delim tab
open 20520-0001-Data.tsv
list L1 = v1..v148
matrix X1 = {L1}
</hansl>

Having created blocks of this sort you can then create a new dataset 
of an appropriate size and extract series from the blocks in the 
"right places", wherever that may be:

<hansl>
scalar N = <you figure it out>
nulldata N --preserve
# pull stuff from matrices into series
# use "smpl" to set the range for writing from matrix to series
</hansl>

Allin Cottrell
Please post this sort of question to the gretl-users mailing list
[ http://lists.wfu.edu/mailman/listinfo/gretl-users ]
I'm forwarding it to the list; my comments follow the question.

On Fri, 13 Mar 2015, Christian Mücher wrote:

> I am an economics student at the university of constance. During the 
> last semester I leaned the use of the econometrics program gretl. 
> Right now I am writing my Bachelor Thesis with this program and 
> encountered a problem.
>
> I am using the Children of the Immigrants Longitudinal Study Dataset 
> http://doi.org/10.3886/ICPSR20520.v2
>
> When importing the Dataset in gretl the panel structure of the 
> dataset is lost. When trying to impose a panel structure on the 
> dataset the problem ist, that there is no variable measuring the 
> period. Further, the Dataset is coded such that each observation is 
> in one row and all variables are in columns. The problem is, that v1 
> to v148 are measured in period 1, v203 to p144 are measured in 
> period 2 and v400 to v450 are measured in period 3. But I fail to 
> define this periodicity such that a panel structure can be defined. 
> I tried pretty much everything I could think of, and my supervising 
> professor does not now gretl. The tutor who taught us gretl also has 
> no solution for my problem. The last thing I can think of ist to 
> export the Dataset as .csv file and include a timevariable manually. 
> I hope that you can help me out with an easier way, as this method 
> would be very time consuming.

From what I can tell, the ICPSR20520 dataset is not actually a panel, 
although it is longitudinal. According to the codebook, the three 
waves differ in regard to the information recorded, although there is 
some overlap between the waves. You'll have to think carefully about 
how you want to analyse these data.

That said, if you need to rearrange blocks of data to get a semblance 
of a panel, then gretl's matrix methods are likely to be useful. Just 
to illustrate, here's a hansl script to make a matrix out of variables
v1 to v148:

<hansl>
set echo off
set csv_delim tab
open 20520-0001-Data.tsv
list L1 = v1..v148
matrix X1 = {L1}
</hansl>

Having created blocks of this sort you can then create a new dataset 
of an appropriate size and extract series from the blocks in the 
"right places", wherever that may be:

<hansl>
scalar N = <you figure it out>
nulldata N --preserve
# pull stuff from matrices into series
# use "smpl" to set the range for writing from matrix to series
</hansl>

Allin Cottrell

Gmane