Reputation: 378
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
Upvotes: 0
Views: 944
Reputation: 31
@Markus Loecher on your second question:
You can always use the rename
command to rename a series. So you would have to loop over all elements in list INT to do so. However, I would rather suggest to rename both input series, in the above example mrt
and med
respectively, before computing the interaction terms if you want shorter series names.
Upvotes: 0
Reputation: 51
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.
Upvotes: 1