On 21/11/2023 19:36, Artur T. wrote:
Hi,

Many years ago Jack and I (the clever part came from Jack) came up with this for an ARDL model:

https://github.com/atecon/ardl_bruteforce_lagselection

The main code is in the script: brute_force.inp
You have to call that script via the "include" command as shown in the sample script: sample_script.inp

What Artur posted is quite sophisticated: if you want something that cuts the logic to its bare bones and makes it easier (well, it's a matter of taste) to follow what's going on, you may want to study the script below:

<hansl>
set verbose off
open denmark.gdt --quiet

scalar maxlag = 4
list ALL = LRM LRY IBO IDE # dep. var. must come first

s = seq(0, maxlag)'
matrix c = s
loop i = 2 .. nelem(ALL)
    n = rows(c)
    c = (c ** ones(maxlag+1,1)) ~ (ones(n,1) ** s)
endloop

smpl +maxlag ;
matrix mX = ALL
mincrit = $huge
loop i = 1 .. rows(c)
    list Z = deflist()
    loop j = 1 .. nelem(ALL)
        l = c[i,j]
        first = -(j==1)
        if !first || (l > 0)
            list H = mX[j]
            list Z += H(first to -l)
        endif
    endloop
    ols LRM const Z --quiet
    if $bic < mincrit
        best = Z
        mincrit = $bic
    endif
endloop

print mincrit
depvar = ALL[1]

ols depvar const best

</hansl>

-------------------------------------------------------
  Riccardo (Jack) Lucchetti
  Dipartimento di Scienze Economiche e Sociali (DiSES)

  Università Politecnica delle Marche
  (formerly known as Università di Ancona)

  r.lucche...@univpm.it
  http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------
_______________________________________________
Gretl-users mailing list -- gretl-users@gretlml.univpm.it
To unsubscribe send an email to gretl-users-le...@gretlml.univpm.it
Website: 
https://gretlml.univpm.it/postorius/lists/gretl-users.gretlml.univpm.it/

Reply via email to