Wednesday, November 2, 2016

Specification Tests for Logit Models Using Gretl

In various earlier posts I've commented on the need for conducting specification tests when working with Logit and Probit models. (For instance, see herehere, and here.) 

One of the seminal references on this topic is Davidson and MacKinnon (1984). On my primary website, you can find a comprehensive list of other related references, together with EViews files that will enable you to conduct various specification tests with LDV  models.

The link for that material is here.

Today I had an email from Artur Tarassow at the University of Hamburg. He wrote:
I know that you're already aware of the open-source econometric software called "Gretl". 
I would like to let you know that I updated my package "LOGIT_HETERO.gfn". This package runs both the tests of homoskedasticity and correct functional form based on your nice program "Logit_hetero.prg" written for EViews.
If you want to have a look at it, simply run:
    set echo off
    set messages off
    install LOGIT_HETERO.gfn
    include LOGIT_HETERO.gfn
    logit Y 0 X1 X2
    matrix M = LOGIT_HETERO(Y,$xlist,$coeff,1)
    print M
Thanks for this, Artur - I'm sure it will be very helpful to many readers of this blog.

Footnote: See Artur's comment below, and the more recent post here. In particular, note Artur's comment: As a note to your blog readers: The two Logit model related packages “logit_burr.gfn” and “LOGIT_HETERO.gfn” are not available any more, as BMST includes both of them.


Davidson, R. & J. G. MacKinnon, 1984. Convenient specification tests for logit and probit models. Journal of Econometrics, 25, 241 262.

© 2016, David E. Giles


  1. In fact, Artur's script is slightly incomplete: the line

    install LOGIT_HETERO.gfn

    fetches the packages from the gretl server, but in order to actually have the corresponding function available, one should also insert the line

    include LOGIT_HETERO.gfn

    It's the same difference you get, eg in R between the install.package() and the library() functions.

    1. Jack - thanks very much! I've added the extra line in the code above.

  2. Dear Dave, I've decided to write the "Binary Model Specification Tests" (BMST) package for Gretl. This single package comprises various tests for binary Probit and Logit models which you have coded for Eviews.

    For LOGIT models:
    1) LM test of the null that the distribution is Logistic against the alternative that it is Burr Type 2
    2) LM test for homoskedasticity
    3) LM test for correct functional form

    For PROBIT models:
    1) LM test for homoskedasticity
    2) LM test for correct functional form

    Here is an example on how to use BMST with Gretl:

    # Name of Gretl's scripting language

    # Example 1
    set echo off
    set messages off
    open greene19_1.gdt
    #install BMST.gfn # Download the package if not done so, yet
    include BMST.gfn

    # Logit example
    type = 1
    logit GRADE 0 GPA TUCE PSI
    # setupBMST() must always be called 1st:
    bundle b = setupBMST(GRADE, $xlist, $yhat, $coeff, type, 1)
    Logit_burr(&b) # Next, call the test of interest
    print b # Print information stored in the bundle
    scalar burr_pval = b.Log_burr_pval # Store p-value of Logistic Against Burr Type II test
    print burr_pval
    # Call other tests

    # Probit example
    type = 2
    probit GRADE 0 GPA TUCE PSI
    bundle c = setupBMST(GRADE, $xlist, $yhat, $coeff, type, 1)

    /* Activate if needed
    # Example 2: Replicate Dave Gile's PROBIT_HETERO program
    open --quiet
    include BMST.gfn
    type = 2
    probit Y 0 X1 X2
    bundle b = setupBMST(Y, $xlist, $yhat, $coeff, type, 1)

    # Replicate Dave Gile's LOGIT_HETERO and
    # LOGIT_BURR programs
    type = 1
    logit Y const X1 X2
    bundle b = setupBMST(Y,$xlist, $yhat, $coeff,type, 1)


    Hope that will be helpful for many of your blog readers and also attract more people to try and use Gretl!



Note: Only a member of this blog may post a comment.