Re: [Gretl-users] Nonlinear switching regression vs Loop constructs
by Allin Cottrell
On Fri, 4 Feb 2011, Riccardo (Jack) Lucchetti wrote:
> On Fri, 4 Feb 2011, GREg Ory wrote:
>
> > After searching in the manual and the list it seems that only the
> > model (i.e. Model 1,2,3,4) can be saved in the LaTex format and what
> > shows on the output screen cannot.
> >
> > How is it possible to add the estimates of mu and sigma to the model
> > that is calculated?
> >
> > In other words what do we need to add to the script to get what is
> > written in the output window in the red circle to the model in the
> > green sircle if it's possible of course. (please see the attached
> > screenshot)
>
> Maybe it's not exactly what you're looking for, but the modprint command
> has a --tex option (which is, I now realise, undocumented - sorry!).
Yes, you can find the modprint command in the script and modify it
thus:
outfile nls.tex --write
modprint cfse vnam --tex
outfile --close
The output, nls.tex, is not a complete LaTeX file, it will have to
be included in a holder, as in
\documentclass{article}
\begin{document}
\input nls.tex
\end{document}
Allin Cottrell
13 years, 8 months
Re: [Gretl-users] Nonlinear switching regression vs Loop constructs
by Allin Cottrell
On Thu, 3 Feb 2011, GREg Ory wrote:
> Thank you for your reply Allin. The question about the dependent
> variable is now cleared.
>
> Minor adjustments were made to the script to save the models seperately.
>
> However the problem with $unit in the script still persists despite
> the dataset structure set as panel. Please see the attached screenshot
> and the script file.
Ah, this seems to be a bug that has been fixed since the gretl
1.9.3 release. Please try the current snapshot for Windows at
http://gretl.sourceforge.net/win32/
> My question about the NLS procedure is more theoretical - imho the
> manual doesn't provide enough theoretical background for the way the
> Gauss-Newton regression is used
Try Davidson and MacKinnon, "Econometric Theory and Methods".
Allin Cottrell
13 years, 8 months
Re: [Gretl-users] Nonlinear switching regression vs Loop constructs
by Allin Cottrell
On Tue, 1 Feb 2011, GREg Ory wrote:
> First of all I would like to express most sincere thanks to everybody
> who answered on the matter. All gretl users must have seen this very
> fine result of scripting and it�s rare to receive fast and quality
> help and get exactly what you were looking for when dealing with
> econometric packages. Allin and Jack � I may become your fan.
[...]
> A question: why estimate �y � GDV� and not �y� as a dependent
> variable. I understand that it�s equivalent in the linear regression
> just want to know the reason for this.
The coefficient on the variable constructed by Jack's GDV()
function is constrained to be 1.0 in the model you're estimating.
So the obvious way of implementing this is to subtract it from the
"real" dependent variable.
> The problem with the script is - NLS isn't estimated if FE = 1
> because series u = $unit doesn't work with the current
> periodicity. Some pointers on how to solve this would be nice.
Apparently your dataset is not recognized as a panel. See the
"setobs" command, or the menu item /Data/Dataset structure in the
GUI.
> Another problem I encountered is my little knowledge of the NLS
> estimation process � I can�t figure out how Jack uses linear
> combinations, nelem function and covarince matrix to get the NLS
> results.
The lincomb() (linear combination) function is just a way of doing
the matrix mutiplication X*b, in the case where X is not actually
a matrix but a list of series.
The nelem() function just returns the number of members in a list
of series.
In gretl's nls you need to construct a formula for the dependent
variable -- in terms of various parameters and right-hand-side
variables -- then tell gretl what are the parameters you want to
adjust to minimize the sum of squared residuals.
The model you wanted to estimate is basically linear (hence the
"lincomb" part), with an element of nonlinearity introduced by the
logistic term (hence the need for nls).
Allin Cottrell
13 years, 8 months
Re: [Gretl-users] import data via odbc
by Allin Cottrell
On Mon, 31 Jan 2011, Leon Unger wrote:
> In terms of importing data via ODBC I've got another general question
> myself:
> obs-format combinded with string (%s) does not work, or to be
> precise, GRETL
> crashes immediately! Could someone provide an example for such
> string indices?
The conversion "%s" in an obs-format string requires that the
corresponding variable from the database is of string type. For
example:
string Q = "SELECT country,year,y FROM FooBase"
data y obs-format="%s:%d" query=Q --odbc
This should work if the "country" variable contains string
country-codes such as "FRA", "GER", etc., and the year variable
contains years as integers:
GER:1990 123.5
GER:1991 127.6
This assumes that the pre-existing gretl dataset has observation
strings on the pattern shown above.
Allin Cottrell
13 years, 8 months
Re: [Gretl-users] Copying the stocks data fulfilling certain criteria to a new data file
by Allin Cottrell
On Wed, 2 Feb 2011, Allin Cottrell wrote:
> loop j=1973..2006
> smpl $j:1 $j:12+1
> list OKstocks = null
> loop foreach i r_AEX_INDE..r_ZEELAND_
> n = sum(ok($i))
> if n == 13
> OKstocks = OKstocks $i
> endif
> if nelem(OKstocks) > 0
> store "/Documents/data/stocks_valid_$j.gdt" OKstocks
> endif
> endloop
> endloop
Sorry, I messed that up, it should be
loop j=1973..2006
smpl $j:1 $j:12+1
list OKstocks = null
loop foreach i r_AEX_INDE..r_ZEELAND_
n = sum(ok($i))
if n == 13
OKstocks = OKstocks $i
endif
endloop
if nelem(OKstocks) > 0
store "/Documents/data/stocks_valid_$j.gdt" OKstocks
endif
endloop
Allin Cottrell
13 years, 8 months
Re: [Gretl-users] Copying the stocks data fulfilling certain criteria to a new data file
by Allin Cottrell
On Wed, 2 Feb 2011, Sergey N wrote:
> Most probably due to very limited experience in programming and in working
> with gretl I'm
> currently stuck with the following issue:
>
> I have a data file with time series of monthly returns of AEX stocks from
> 1973 to 2007. By using
> a script (attached and probably not the most elegant) I'm trying to
> accomplish 2 things:
>
> 1. Count the number of "valid" stocks, that is stocks which have 12
> months of returns data prior to t=0.
> 2. Only the stocks which fulfil the above mentioned criteria should be
> copied to a new data file (appended).
>
> Can anyone please explain to me how to accomplish #2 because just with
> "store" instruction the data gets
> overwritten.
I'm not sure if you want a separate data file for each 13-month
period. But if so (and if I've understood the rest of your
intentions), then something like this would do it:
loop j=1973..2006
smpl $j:1 $j:12+1
list OKstocks = null
loop foreach i r_AEX_INDE..r_ZEELAND_
n = sum(ok($i))
if n == 13
OKstocks = OKstocks $i
endif
if nelem(OKstocks) > 0
store "/Documents/data/stocks_valid_$j.gdt" OKstocks
endif
endloop
endloop
(Your outer loop cannot go to 2007 if you don't have a 2008:01
observation.)
Allin Cottrell
13 years, 8 months
Re: [Gretl-users] ADF test inside a loop
by Allin Cottrell
On Mon, 31 Jan 2011, Henrique Andrade wrote:
> I'm trying to perform several ADF tests and save the results (statistic +
> p-value) inside a matrix. Please take a look at my script:
>
> <script>
> open australia.gdt
> list Variables = lpus iau2 lpau
> scalar T = nelem(Variables)
>
> scalar lag = int(12*($nobs/100)^(1/4))
>
> matrix ADF = zeros(nelem(Variables),2)
> colnames(ADF, "estatistica p-valor")
> rownames(ADF, "lpus iau2 lpau")
>
> loop foreach i Variables
> loop j=1..T
> adf lag $i --c --test-down
> matrix ADF[$j,] = $test ~ $pvalue
> endloop
> endloop
Why are you using two loops? Conceptually, there's only one:
loop foreach i Variables -q
adf lag $i --c --test-down
ADF[i,] = $test ~ $pvalue
endloop
You should use "$i" (and the like) _only_ when you need string
substitution (as in the adf command): otherwise use plain "i"
(as in matrix indexation) to get the numerical value.
Allin Cottrell
13 years, 8 months
Copying the stocks data fulfilling certain criteria to a new data file
by Sergey N
Dear all,
Most probably due to very limited experience in programming and in working
with gretl I'm
currently stuck with the following issue:
I have a data file with time series of monthly returns of AEX stocks from
1973 to 2007. By using
a script (attached and probably not the most elegant) I'm trying to
accomplish 2 things:
1. Count the number of "valid" stocks, that is stocks which have 12
months of returns data prior to t=0.
2. Only the stocks which fulfil the above mentioned criteria should be
copied to a new data file (appended).
Can anyone please explain to me how to accomplish #2 because just with
"store" instruction the data gets
overwritten.
--
---------------------------------------
Sergey
13 years, 8 months
Re: [Gretl-users] import data via odbc
by RENIER Mélanie
Dear All,
I found that in fact if GRETL says it connect to the data source inf1 in Oracle, it does not stay connected to it!
Does somebody already encounter this problem?
Thanks in advance,
Kind Regards,
Mélanie Renier
Attaché
Etudes Financières et Actuarielles
Tél. 02 529 33 34
melanie.renier(a)onprvp.fgov.be
Office national des Pensions
Tour du Midi ~ 13e étage
1060 Bruxelles
[cid:image001.gif@01CBC2B4.CBCE2E20]
_______________________________________________
Pensez à l'environnement avant d'imprimer ce message!
De : gretl-users-bounces(a)lists.wfu.edu [mailto:gretl-users-bounces@lists.wfu.edu] De la part de Leon Unger
Envoyé : lundi 31 janvier 2011 17:04
À : Gretl list
Objet : Re: [Gretl-users] import data via odbc
Am 31.01.2011 15:55, schrieb RENIER Mélanie:
Dear All,
I have one problem when trying to import data via odbc.
It connect to the server but does not achieve to load the data.
I have the following message error:
? open dsn=inf1 --odbc
Connected to ODBC data source 'inf1'
? data x y query="select code,denomination from usig.co_etciv" --odbc
Error executing script: halting
> data x y query="select code,denomination from usig.co_etciv" -odbc
Do you maybe know where does the problem come from or where I can have more details?
Thanks in advance,
Kind Regards,
Mélanie Renier
Hi Mélanie,
sounds for me like an error resulting from a misspecified SQL statement.
Is it an Access Database? Or perhaps the stucture of your workfile does not fit.
By the way, I personally prefer performing ODBC operations with scripts, because it much easier to alter the code and to reuse it.
In terms of importing data via ODBC I've got another general question myself:
obs-format combinded with string (%s) does not work, or to be precise, GRETL
crashes immediately! Could someone provide an example for such string indices?
E.g. I want to load for 4 Countries GER, UK, JP, CN the CPI and WPI series in the
following order: GER CPI
GER WPI
UK CPI
.....
I succeeded in using numbers instead of Names (1:1; 1:2; 2:1...). But if it's possible to
use the strings with %s it would be even nicer.
Thanks in advance
Pindar
13 years, 8 months
Re: [Gretl-users] Nonlinear switching regression vs Loop constructs
by Allin Cottrell
On Fri, 28 Jan 2011, GREg Ory wrote:
> I need some tips on estimating panel data using nonlinear switching
> regression technique. AFAIK there are two ways of solving it.
I've had one more go at this problem, because it seems like quite
a nice showcase for what one can now do with gretl scripting. I'm
attaching a script which combines the grid-search approach with
NLS estimation. That is, I first do the grid-search, over what
you stated were acceptable values for mu and sigma, then I
initialize NLS using the best values from the grid. The script
includes a "switch" to turn fixed-effects on or off.
What I'm getting from this (with fixed effects on) is:
grid-search
(mu,sigma) = (0.40, 0.20); SSR = 25.6531, R^2 = 0.803620
NLS (unconstrained)
(mu,sigma) = (0.18, 0.03); SSR = 25.4212, R^2 = 0.806201
That is, NLS finds a slightly better fit with an "out of bounds"
mu value. NLS also shows that the sigma estimate is statistically
indistinguishable from zero, which suggests that the logistic term
may not be appropriate.
Allin Cottrell
13 years, 8 months