Search code examples
interactiondummy-variablegretl

gretl - dummy interactions


There does not seem to be an "easy" way (such as in R or python) to create interaction terms between dummy variables in gretl ? Do we really need to code those manually which will be difficult for many levels? Here is a minimal example of manual coding:

open credscore.gdt
SelfemplOwnRent=OwnRent*Selfempl
# model 1
ols Acc 0 OwnRent Selfempl SelfemplOwnRent

Now my manual interaction term will not work for factors with many levels and in fact does not even do the job for binary variables.

Thanks, ML


Solution

  • One way of doing this is to use lists. Use the dummify-command for generating dummies for each level and the ^-operator for creating the interactions. Example:

    open griliches.gdt
    
    discrete med
    
    list X = dummify(med)
    list D = dummify(mrt)
    list INT = X^D
    
    ols lw 0 X D INT
    

    The command discrete turns your variable into a discrete variable and allows to use dummify (this step is not necessary if your variable is already discrete). Now all interactions terms are stored in the list INT and you can easily assess them in the following ols-command.