Interaction of variables
by Pindar
Hi,
I'd be thankful for 'a cheat' in order to improve my code on interaction
between the factor steps.
I hereby also want to make the proposal of adding a new function to
GRETL called 'interaction'
that could be used like 'dummify'. I'm thinking of something like
interaction(series or list [discrete variables], optional series or list).
If only one argument is given this would be the case of the example
below, if two arguments are given the case of the user guide is tackled.
Up until now I generated interaction series according to the example on
p.121 in the guide.
Now with factor step combinations it's getting really tricky:
1) make the list of factors -> ok
2) make dummies for all steps of each factor -> ok
3) interact the dummies BUT without replications -> here I have a
problem
What if there are more than two factors? My 'if condition' is not that good.
I'm using the 'loop foreach' construction.
<hansl>
dummify factors
loop foreach i factors-q
sprintf ni "%d",i
list Dum_$i=null
string str="D$i*"
list Dum_$i=@str
endloop
loop foreach i factors-q
loop foreach j factors-q
count++
if count<2 || count>nfactors
break
else
sprintf ni "%d",i
sprintf nj "%d",j
smpl D$i_@ni>0 --restrict --replace
smpl D$j_@ni>0 --restrict --replace
smpl D$j_@nj>0 --restrict --replace
smpl D$i_@nj>0 --restrict --replace
endif
enloop
<hansl>
Cheers
Leon
12 years
SVAR some questions
by Pindar
Hi there,
the SVAR analysis is a powerful tool and Jack's SVAR package already in
it's present state is magnificent!
At the moment I'm working through it step by step. My ultimate goal is
to perform a 'Structural vector autoregressions with
nonnormal residuals' by Lütkepohl (see attached file). Unfortunately his
examples are SVECMs which makes the stuff even more complicated.
However, while learning from the 'SVAR code' and with Lütkepohl's book
'New Introduction to Multiple Time Series Analysis' I came across the
following questions:
a) In his book on page 367 (section 9.1.3) the Rd matrix (following the
notation of Jack) seems to me wrong.
b) Is it in order to use 'abs(nullspace(R))~R'invpd(R*R')*d' instead of
the things done in imp2exp (and btw. exp stands for expansion, or, and
imp for ?)
<hansl>
nulldata 10
include SVAR.gfn
#example
matrix
R_Luedkepohl={1,0,0,0,0,0,0,0,0;0,0,1,0,0,0,0,0,0;0,0,0,0,1,0,0,0,0;0,0,0,0,0,1,0,0,0;0,1,0,0,0,0,1,0,0;0,0,0,0,0,0,0,0,1}
eval R_Luedkepohl
matrix
R={1,0,0,0,0,0,0,0,0;0,0,1,0,0,0,0,0,0;0,0,0,0,1,0,0,0,0;0,0,0,0,0,1,0,0,0;0,0,0,0,0,0,1,0,0;0,0,0,0,0,0,0,0,1}
eval R
matrix R_orth={0,0,0;1,0,0;0,0,0;0,1,0;0,0,0;0,0,0;0,0,0;0,0,1;0,0,0}
eval R_orth
eval R*R_orth
matrix d ={1;0;1;0;0;1}
matrix Rd=R~d
eval imp2exp(Rd)
matrix s = R'invpd(R*R')*d
eval abs(nullspace(R))~s
<hansl>
Cheers
Leon
12 years
functions mshape with variable elements and isscalar
by Pindar
Hi,
I have a question concerning the mshape and isscalar functions:
The second and third argument are scalars but when I tried to use
different inputs for these arguments stored in a matrix
GRETL flags an error. This is not the case with similar functions like
'zeros'.
The function 'isscalar' seems to be broken (and is only named on p. 148
in the Command Reference).
<hansl>
nulldata 24
matrix FaktorA={1;1;1;1;1;1;2;2;2;2;2;2;3;3;3;3;3;3;4;4;4;4;4;4}
matrix k={3;4}
eval mshape(FaktorA,3,4)
eval mshape(FaktorA,k[1],k[2]) #error caused by matrix k[]
eval zeros(k[1],k[2]) #here is works fine
scalar test=10
eval isscalar("10") #=0
eval isscalar(10) #error
eval isscalar(test) #error
<hansl>
Best
Leon
12 years
Out-of-sample forecasting
by Marta Szymańska
Hello,
I'm writing a master thesis about volatility forecasting using GARCH and
GJR models (with Normal, stud-t and GED distributions). I need to
prepare out-of-sample forecasting for that models. Thus, I've tried to
prepare scripts using gig package.
I've got the following script for GARCH (1,1) with GED distribution:
include gig.gfn
open file.gdt
model = gig_setup(RETURN,1,const)
gig_set_dist(&model, 2)
gig_estimate(&model)
#gig_plot(&emodel)
#gig_dplot(&emodel)
series e = $uhat
series h = $h
dataset addobs 1
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 165 ;
print e h hfc --byobs
However, the commands series e = $uhat and series h = $h don't work. The
information is that: "The statistic you requested is not available"
I'll be really grateful if you can write me how to get 'uhat' and 'h'
series in that case. Or maybe it is some another way for preparing
out-of-sample forecasting for GARCH and GJR models.
Best regards,
Marta
12 years
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
12 years
GARCH, GJR forecasting
by Tomasz Bielawski
Hello,
I am working now with time series and I found your script for garch
forecasting which was very useful for me:
<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>
I have question if it is possible in gretl to prepare similar prediction
with one regressant in variance equation for normal,t and GED
distributions for garch model. Moreover I would like to ask if the same
procedure is possible for GJR model. I tried with GIG procedures: I
estimated model but than I have problem how to get residuals and
conditional variance because language from the script above doesn't
work. I would like to add that I am quite new user of Gretl. I will be
very gratefull for any suggestion from you.
Best regards,
Tomasz Bielawski
12 years
Problem with comment lines
by Henrique Andrade
Dear Gretl Team,
I think I found a small error in Hansl when someone insert commas in
the end of the comment line. Please take a look at the following code
to check this.
<hansl>
open australia.gdt
list vars = dataset
lags 2 ; vars
list list1 = null # If I terminate this comment line WITH a comma,
list list2 = null # I get an error (in the following loop) saying
# list2_ati does not exist.
loop i=1..2 --quiet
list list1 = list1 || PAU_$i
loop j=1..2 --quiet
list list2 = list2 || PUS_$j
endloop
endloop
list list1 = null # If I terminate this comment line WITHOUT a comma
list list2 = null # I do not get the error saying list2 does not exist.
loop i=1..2 --quiet
list list1 = list1 || PAU_$i
loop j=1..2 --quiet
list list2 = list2 || PUS_$j
endloop
endloop
list list1 print
list list2 print
</hansl>
Also I would like to make a suggestion: In my humble opinion, the
syntax to print list elements is not so intuitive and it looks like
very different from the other uses of the "print" command. My
suggestion is use something like this:
print list1 --names
or
print list1 --varnames
Best regards,
Henrique Andrade
12 years
Quantile Regression with for autocorrelated process
by Daniel Bencik
Dear guys,
I have a time series of hourly deviations of the electricity market saturation from zero, in other words I have data on whether the total electric system in my country was in black or red quantitites for each hour of the last months. The intention is to predict the likelihood that in two hours this deviation will be above zero. The data favor an AR(2) model with some GARCH component, but that's good only for the point forecast. To obtain the likelihood, I was going to use quantile regressions - by finding the specification for tau, which predicts a 2-step ahead forecast of 0 deviation, I would find my probability. So I wanted to ask whether QR in gretl is OK with autocorrelated series of 'y'. I know there are no assumptions on the error term distribution, but I found some extensions to QR to handle autocorrelated observations (but they were pretty scarce).
Many thanks,
Daniel
12 years
Bug in msortby
by Pindar
Hi,
when working on my multivariate statistic package I found the following
bug in function msortby:
If one wants to sort an already sorted matrix the matrix elements get
though rearranged.
In the 2-factor Anova with interaction this results in wrong calculations.
<hansl>
nulldata 24
#two factor orthogonal Anova
matrix FaktorA={1;1;1;1;1;1;2;2;2;2;2;2;3;3;3;3;3;3;4;4;4;4;4;4}
matrix FaktorB={1;1;2;2;3;3;1;1;2;2;3;3;1;1;2;2;3;3;1;1;2;2;3;3}
matrix
OutputM={69;77;61;67;65;69;79;83;62;64;72;78;80;78;74;76;80;74;75;67;70;62;70;76}
eval OutputM~FaktorA
eval msortby(OutputM~FaktorA,2)
<hansl>
Cheers
Leon
12 years
Update to gretl 1.9.10 with "Check for updates?"
by Logan Kelly
Hello,
Should I be able to update to 1.9.10 by selecting "Check for updates" in the Help menu? I am running gretl 1.9.9 on Win7 64bit.
Sorry if this posted in the wrong mail list,
Logan Kelly
12 years