Function to get the powerset
by Henrique Andrade
Dear Gretl Community,
I really stuck trying to define a function that gives a power set of a
set. Suppose I have a set S:
S = {"A", "B", "C"}
The associated power set, P(S), is:
P(S) = {{ }, {"A"}, {"B"}, {"C"}, {"A", "B"}, {"A", "C"}, {"B", "C"},
{"A", "B", "C"}}
All that I can think by now (shame on me!) is this:
strings S = defarray("A", "B", "C")
scalar P_S_len = 2^nelem(S) # the size of the power set
strings P_S = array(P_S_len) # an array with 8 spaces.
Does anyone have any ideas?
Best,
Henrique Andrade
5 years, 11 months
libsvm installation issue
by Artur T.
Dear Allin,
first of all thanks for implementing the libsvm program into gretl!
I just tried to test it on my xubuntu 17.04 linux machine. I used the
shell script build.sh to install the libsvm libraries. It ran through
without any issues. The following directories and files were set up:
/usr/local/include/libsvm/svm.h
/usr/local/lib/libsvm.so
/usr/local/lib/libsvm.so.2
/usr/local/lib/gretl-gtk2/svm.la
/usr/local/lib/gretl-gtk2/svm.so
/usr/local/bin/svm-predict
/usr/local/bin/svm-train
/usr/local/bin/svm-scale
After running the shell script, I recompiled gretl using the
--with-libsvm option. However, I obtain the following error message when
running your first example script "Listing 1"
<output>
Failed to load plugin: /usr/local/lib/gretl-gtk2/svm.so
Couldn't load plugin function
Error executing script: halting
> series svmpred = svm(L, parms)
</output>
even though the smv.so file is in the directory.
Best,
Artur
7 years, 1 month
Using ARIMA to determine the relationship of Venezuela's GDP Growth and oil variables.
by Nook Thanpisit
Dear Gretl-Users Community,
I am a political science student, who is working on a Master Thesis in
'What factors hinder economic growth of oil-producing countries?' through
the case of Venezuela from 2001 to 2015. I have to admit that I have poor
background in statistics but comfortable with using computer software,
hence I am writing to seek for guidance in model correction and
interpretation of dataset. I would like to determine the positive/negative
correlations between Venezuela's GDP Growth and varying factors such as Oil
Production, OPEC Spare Capacity, Economic Freedom etc. from 2001 to 2015
(annual basis). Could you guys please comment on my model, whether it fits
for the aim of determining relationship and correlations between varying
factors? Thank you
Using the time series ARIMA model, the Dependent var. = Venezuela's GDP
Growth Rate
Here's the ADF Test of GDP Growth with lag of 2 from 14 data (annual).
*Augmented Dickey-Fuller test for GDP_Growth*
including 0 lags of (1-L)GDP_Growth
(max was 2, criterion AIC)
sample size 14
unit-root null hypothesis: a = 1
test with constant
model: (1-L)y = b0 + (a-1)*y(-1) + e
estimated value of (a - 1): -0.657506
test statistic: tau_c(1) = -2.29321
p-value 0.1868
1st-order autocorrelation coeff. for e: 0.131
with constant and trend
model: (1-L)y = b0 + b1*t + (a-1)*y(-1) + ... + e
estimated value of (a - 1): -0.935225
test statistic: tau_ct(1) = -3.03246
asymptotic p-value 0.1232
1st-order autocorrelation coeff. for e: -0.517
*ARIMA Model (0,0,0)*Model 2: ARMAX, using observations 2001-2015 (T = 15)
Estimated using least squares (= MLE)
Dependent variable: GDP_Growth
coefficient std.
error z p-value
----------------------------------------------------------------
const −26.9659 24.2697
−1.111 0.2665
ProvenCrude_Rese~ −0.0559316 0.0214914 −2.603
0.0093 ***
CrudeOil_Product~ 23.8026 8.44659
2.818 0.0048 ***
BalanceofTrade_U~ 0.000221970 0.000111334 1.994
0.0462 **
OPEC_SpareCapaci~ −3.80518 1.11847 −3.402
0.0007 ***
Economic_Freedom −0.570406 0.314276 −1.815
0.0695 *
Mean dependent var 2.371052 S.D. dependent var 7.682116
Mean of innovations 1.05e-14 S.D. of innovations 4.646369
Log-likelihood −40.49418 Akaike criterion 92.98835
Schwarz criterion 97.23665 Hannan-Quinn 92.94310
7 years, 1 month
Re: [Gretl-users] Principal Components Analysis: "pca" command versus "eigengen" function
by Ioannis Venetis
Hello all again,
I stick to real symmetric matrices. I think the eigengen and eigensym use
different algorithms to compute eigenvectors that's why there might be
differences in sign for some eigenvectors.
I do not know the intrinsics of the algorithms so i cannot tell why
patricular eigenvecs have the same and some have different sign.
However, due to sign being non-identified "it does not matter". You must
have extra information to identify depending on your purposes.
The pca does not know what sign to assign. I think (correct me if i am
wrong)
pca uses princomp which uses eigensym and not eigengen.
For example,
<hansl>
matrix A = (1~0.8~-0.5)|(0.8~1~0.2)|(-0.5~0.2~1)
print A
matrix U0 = {}
eval eigengen(A,&U0)
print U0
matrix U1 = {}
eval eigensym(A,&U1)
print U1
</hansl>
or
<hansl>
matrix A = (1~0.8~0.25)|(0.8~1~0.4)|(0.25~0.4~1)
print A
matrix U0 = {}
eval eigengen(A,&U0)
print U0
matrix U1 = {}
eval eigensym(A,&U1)
print U1
</hansl>
Best,
Yiannis
7 years, 1 month
Principal Components Analysis: "pca" command versus "eigengen" function
by Henrique Andrade
Dear Gretl Community,
I would like to replicate the "pca" command using "eigengen" function
but I can't replicate the "signs behavior" of the component loadings.
Sorry if this is a very newbie/dummy question, but I really don't
understand the signal inversion in PC1 PC6 and PC7. Please take a look
at my code:
<hansl>
set echo off
set messages off
open AWM.gdt --quiet
list L = CAN COMPR EEN FDD HICP ITN KSR
printf "\n########## Gretl's native PCA ##########\n\n"
pca L
printf "\n########## Alternative PCA (using 'eigengen' function) ##########\n\n"
matrix X = {L}
matrix C = mcorr(X)
matrix Eigenvector = {}
matrix Eigenvalue = eigengen(C, &Eigenvector)
matrix Proportion = zeros(rows(Eigenvalue), 1)
matrix Cumulative = zeros(rows(Eigenvalue), 1)
loop i = 1..rows(Eigenvalue) --quiet
Proportion[i, 1] = Eigenvalue[i, 1]/sumc(Eigenvalue)
Cumulative[i, 1] = sumc(Proportion[1:i])
endloop
matrix Eigenvalue = Eigenvalue ~ Proportion ~ Cumulative
rownames(Eigenvalue, "1 2 3 4 5 6 7")
colnames(Eigenvalue, "Eigenvalue Proportion Cumulative")
rownames(Eigenvector, "CAN COMPR EEN FDD HICP ITN KSR")
colnames(Eigenvector, "PC1 PC2 PC3 PC4 PC5 PC6 PC7")
printf "Principal Components Analysis\nn = %d\n\n", rows(X)
printf "Eigenanalysis of the Correlation Matrix\n\n"
printf "%15.4f\n", Eigenvalue
printf "Eigenvectors (component loadings)\n\n"
printf "%10.3f\n", Eigenvector
</hansl>
Best regards,
Henrique Andrade
7 years, 1 month
Re: [Gretl-users] pca command versus eigengen function (Henrique Andrade)
by Ioannis Venetis
Dear Henrique,
Replace one line in your code by
matrix Eigenvalue = mreverse( eigensym(C, &Eigenvector) )
and add the following line
Eigenvector = mreverse( Eigenvector ' ) '
and you get the same results as pca. Unlike ''eigengen'', with ''eigensym''
eigenvalues are returned in ascending order. So you need to reverse the
ordering (and the columns of the corresponding eigenvectors).
Now, that does not immediately answer your question on signs. This is more
tricky (goes beyond my technical capabilitites) but it has to do with
probably different libraries (and methodologies?) used to compute
eigenvalues and eigenvectors plus the fact that eigenvector signs are
non-identified anyway.
In typical econometric factor models you may want the first factor that
explains much of the data variability and enters the real gdp growth to be
say the business cycle component through which you will built a coincident
indicator or do some other "job". However, it turns to be negatively
correlated with real gdp (looks upside-down). It's ok. You multiply all
produced factors by (-1) and all loadings by (-1) as well (Λ*(-1)*(-1)*F).
Nothing changes statistically.
Yiannis
7 years, 1 month
help on VECM (was "pca" vs "eigengen)
by Summers, Peter
Dear Jan,
First of all, you should start a new thread (use a relevant subject line) for questions like this, rather than replying to a message unrelated to your question.
To your question, chapters 29 and 30 of the Gretl User’s Guide would be a good place for you to start.
I hope this helps,
Peter
[High Point University logo]
Dr. Peter M. Summers |
One University Parkway, High Point, NC 27268
Office: 336-841-9650 | Economics
Choose to be extraordinary!®
[Facebook logo]<https://www.facebook.com/HighPointU>[Twitter logo]<https://twitter.com/HighPointU>[Instagram logo]<http://instagram.com/highpointu>[LinkedIn logo]<https://www.linkedin.com/school/28206>
From: gretl-users-bounces(a)lists.wfu.edu [mailto:gretl-users-bounces@lists.wfu.edu] On Behalf Of Cernohorsky Jan
Sent: Wednesday, August 23, 2017 4:59 PM
To: Gretl list
Subject: Re: [Gretl-users] Principal Components Analysis: "pca" command versus "eigengen" function
Dear Gretl users,
please could anybody help me how to do VECM /Errot correction model/.
I dont know what should I fill and then how can I distinguish between short-term and long-term relationships...
Or please if there is any manual how to do it.
Thank you for your answer
Jan Cernohorsky
Sent from my Windows Phone
________________________________
From: Henrique Andrade<mailto:henrique.coelho@gmail.com>
Sent: 23/08/2017 22:21
To: Gretl Discussion List (users)<mailto:gretl-users@lists.wfu.edu>
Subject: [Gretl-users] Principal Components Analysis: "pca" command versus "eigengen" function
Dear Gretl Community,
I would like to replicate the "pca" command using "eigengen" function
but I can't replicate the "signs behavior" of the component loadings.
Sorry if this is a very newbie/dummy question, but I really don't
understand the signal inversion in PC1 PC6 and PC7. Please take a look
at my code:
<hansl>
set echo off
set messages off
open AWM.gdt --quiet
list L = CAN COMPR EEN FDD HICP ITN KSR
printf "\n########## Gretl's native PCA ##########\n\n"
pca L
printf "\n########## Alternative PCA (using 'eigengen' function) ##########\n\n"
matrix X = {L}
matrix C = mcorr(X)
matrix Eigenvector = {}
matrix Eigenvalue = eigengen(C, &Eigenvector)
matrix Proportion = zeros(rows(Eigenvalue), 1)
matrix Cumulative = zeros(rows(Eigenvalue), 1)
loop i = 1..rows(Eigenvalue) --quiet
Proportion[i, 1] = Eigenvalue[i, 1]/sumc(Eigenvalue)
Cumulative[i, 1] = sumc(Proportion[1:i])
endloop
matrix Eigenvalue = Eigenvalue ~ Proportion ~ Cumulative
rownames(Eigenvalue, "1 2 3 4 5 6 7")
colnames(Eigenvalue, "Eigenvalue Proportion Cumulative")
rownames(Eigenvector, "CAN COMPR EEN FDD HICP ITN KSR")
colnames(Eigenvector, "PC1 PC2 PC3 PC4 PC5 PC6 PC7")
printf "Principal Components Analysis\nn = %d\n\n", rows(X)
printf "Eigenanalysis of the Correlation Matrix\n\n"
printf "%15.4f\n", Eigenvalue
printf "Eigenvectors (component loadings)\n\n"
printf "%10.3f\n", Eigenvector
</hansl>
Best regards,
Henrique Andrade
_______________________________________________
Gretl-users mailing list
Gretl-users(a)lists.wfu.edu<mailto:Gretl-users@lists.wfu.edu>
http://lists.wfu.edu/mailman/listinfo/gretl-users<https://linkprotect.cudasvc.com/url?a=http://lists.wfu.edu/mailman/listin...>
7 years, 1 month
the scriptopt-option
by Artur Tarassow
Dear all,
I tried to run a script using the bash with the --scripopt option
(latest git using ubuntu 17.04). The example script looks like:
<hansl>
clear # needs to be deactivated to work
set verbose off
scalar p = scriptopt
print p
</hansl>
When the clear command is inserted, gretl stops saying
<output>
> p = scriptopt
The symbol 'scriptopt' is undefined
gretlcli: error executing script: halting
> scalar p = scriptopt
</output>
Is this intended, or a bug?
Best,
Artur
7 years, 1 month
Some questions on gretl2017c MS Windows (x86_64)
by Ioannis A. Venetis
Deal all,
Some questions for our summer vacations
==============================
using abdata.gdt
PANEL PLOT
_Multiple plot in grid (N<=16)_ turns functional when N<=6. It should be
_Multiple plot in grid (N<=6)_
PANEL PLOT
_boxplots by group (N<=150)_ produces a very nice plot!!! imhop. RIGHT
CLICK on the produced plot you get options.
The option "Font" (does not work, it does nothing?)
The option "Numerical summary" crashes gretl (gretl.exe has stopped
working)
==============================
==============================
ROLLING K-STEP AHEAD FORECASTS (notice that is returns output with
explanation Recursive #-step ahead forecasts)
I think it should be RECURSIVE K-STEP AHEAD FORECASTS (since rolling
gives the feeling of a constant pro-forecast sample length during the
forecast execise (moving window))
also can we change the --rolling switch to --recursive ?
==============================
==============================
MODELTAB command (either in script or adding models to the model table
in icon view by draging) does not work when estimation in script or
console has been performed with --quiet.
It only adds one model and then does nothing
==============================
==============================
COINT command saves an empty icon if the switch --silent is applied to a
script
say
EGAIC <- coint 4 xlist --test-down=AIC --skip-df --silent
saves EGAIC icon but it is empty. Of course it is not empty with either
--verbose or no switch
==============================
Thanks,
Yiannis
7 years, 1 month