Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Creating interaction terms of country and period fixed effects

    Dear all,

    I had a general question regarding the construction of interaction terms using country and period fixed effects. To illustrate, my data looks as follows (I generated a random variable fin with value 100):
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str3 countrycode int year float(fin dec1950 dec1960 dec1970 dec1980 dec1990 dec2000 decrecent)
    "BEL" 1950 100 1 0 0 0 0 0 0
    "BEL" 1951 100 1 0 0 0 0 0 0
    "BEL" 1952 100 1 0 0 0 0 0 0
    "BEL" 1953 100 1 0 0 0 0 0 0
    "BEL" 1954 100 1 0 0 0 0 0 0
    "BEL" 1955 100 1 0 0 0 0 0 0
    "BEL" 1956 100 1 0 0 0 0 0 0
    "BEL" 1957 100 1 0 0 0 0 0 0
    "BEL" 1958 100 1 0 0 0 0 0 0
    "BEL" 1959 100 1 0 0 0 0 0 0
    "BEL" 1960 100 0 1 0 0 0 0 0
    "BEL" 1961 100 0 1 0 0 0 0 0
    "BEL" 1962 100 0 1 0 0 0 0 0
    "BEL" 1963 100 0 1 0 0 0 0 0
    "BEL" 1964 100 0 1 0 0 0 0 0
    "BEL" 1965 100 0 1 0 0 0 0 0
    "BEL" 1966 100 0 1 0 0 0 0 0
    "BEL" 1967 100 0 1 0 0 0 0 0
    "BEL" 1968 100 0 1 0 0 0 0 0
    "BEL" 1969 100 0 1 0 0 0 0 0
    "BEL" 1970 100 0 0 1 0 0 0 0
    "BEL" 1971 100 0 0 1 0 0 0 0
    "BEL" 1972 100 0 0 1 0 0 0 0
    "BEL" 1973 100 0 0 1 0 0 0 0
    "BEL" 1974 100 0 0 1 0 0 0 0
    "BEL" 1975 100 0 0 1 0 0 0 0
    "BEL" 1976 100 0 0 1 0 0 0 0
    "BEL" 1977 100 0 0 1 0 0 0 0
    "BEL" 1978 100 0 0 1 0 0 0 0
    "BEL" 1979 100 0 0 1 0 0 0 0
    "BEL" 1980 100 0 0 0 1 0 0 0
    "BEL" 1981 100 0 0 0 1 0 0 0
    "BEL" 1982 100 0 0 0 1 0 0 0
    "BEL" 1983 100 0 0 0 1 0 0 0
    "BEL" 1984 100 0 0 0 1 0 0 0
    "BEL" 1985 100 0 0 0 1 0 0 0
    "BEL" 1986 100 0 0 0 1 0 0 0
    "BEL" 1987 100 0 0 0 1 0 0 0
    "BEL" 1988 100 0 0 0 1 0 0 0
    "BEL" 1989 100 0 0 0 1 0 0 0
    "BEL" 1990 100 0 0 0 0 1 0 0
    "BEL" 1991 100 0 0 0 0 1 0 0
    "BEL" 1992 100 0 0 0 0 1 0 0
    "BEL" 1993 100 0 0 0 0 1 0 0
    "BEL" 1994 100 0 0 0 0 1 0 0
    "BEL" 1995 100 0 0 0 0 1 0 0
    "BEL" 1996 100 0 0 0 0 1 0 0
    "BEL" 1997 100 0 0 0 0 1 0 0
    "BEL" 1998 100 0 0 0 0 1 0 0
    "BEL" 1999 100 0 0 0 0 1 0 0
    "BEL" 2000 100 0 0 0 0 0 1 0
    "BEL" 2001 100 0 0 0 0 0 1 0
    "BEL" 2002 100 0 0 0 0 0 1 0
    "BEL" 2003 100 0 0 0 0 0 1 0
    "BEL" 2004 100 0 0 0 0 0 1 0
    "BEL" 2005 100 0 0 0 0 0 1 0
    "BEL" 2006 100 0 0 0 0 0 1 0
    "BEL" 2007 100 0 0 0 0 0 1 0
    "BEL" 2008 100 0 0 0 0 0 1 0
    "BEL" 2009 100 0 0 0 0 0 1 0
    "BEL" 2010 100 0 0 0 0 0 0 1
    "BEL" 2011 100 0 0 0 0 0 0 1
    "BEL" 2012 100 0 0 0 0 0 0 1
    "BEL" 2013 100 0 0 0 0 0 0 1
    "BEL" 2014 100 0 0 0 0 0 0 1
    "BEL" 2015 100 0 0 0 0 0 0 1
    "BEL" 2016 100 0 0 0 0 0 0 1
    "BEL" 2017 100 0 0 0 0 0 0 1
    "BRA" 1950 100 1 0 0 0 0 0 0
    "BRA" 1951 100 1 0 0 0 0 0 0
    "BRA" 1952 100 1 0 0 0 0 0 0
    "BRA" 1953 100 1 0 0 0 0 0 0
    "BRA" 1954 100 1 0 0 0 0 0 0
    "BRA" 1955 100 1 0 0 0 0 0 0
    "BRA" 1956 100 1 0 0 0 0 0 0
    "BRA" 1957 100 1 0 0 0 0 0 0
    "BRA" 1958 100 1 0 0 0 0 0 0
    "BRA" 1959 100 1 0 0 0 0 0 0
    "BRA" 1960 100 0 1 0 0 0 0 0
    "BRA" 1961 100 0 1 0 0 0 0 0
    "BRA" 1962 100 0 1 0 0 0 0 0
    "BRA" 1963 100 0 1 0 0 0 0 0
    "BRA" 1964 100 0 1 0 0 0 0 0
    "BRA" 1965 100 0 1 0 0 0 0 0
    "BRA" 1966 100 0 1 0 0 0 0 0
    "BRA" 1967 100 0 1 0 0 0 0 0
    "BRA" 1968 100 0 1 0 0 0 0 0
    "BRA" 1969 100 0 1 0 0 0 0 0
    "BRA" 1970 100 0 0 1 0 0 0 0
    "BRA" 1971 100 0 0 1 0 0 0 0
    "BRA" 1972 100 0 0 1 0 0 0 0
    "BRA" 1973 100 0 0 1 0 0 0 0
    "BRA" 1974 100 0 0 1 0 0 0 0
    "BRA" 1975 100 0 0 1 0 0 0 0
    "BRA" 1976 100 0 0 1 0 0 0 0
    "BRA" 1977 100 0 0 1 0 0 0 0
    "BRA" 1978 100 0 0 1 0 0 0 0
    "BRA" 1979 100 0 0 1 0 0 0 0
    "BRA" 1980 100 0 0 0 1 0 0 0
    "BRA" 1981 100 0 0 0 1 0 0 0
    end
    I would like to run a regression which features interaction terms of country and period fixed effects. Thus, I would like to have the interaction term Country*Period fixed effects as an explanatory variable in the regression. The period fixed effects in my panel dataset are decade fixed effects and I have modelled this with dummy variables. For example the dummy variable dec1960 =1 if year>1959 and <1970, and 0 otherwise.I am aware on how to construct interaction terms, but I am only able to do this with year fixed effects, i.e. i.Country*i.Year. I am not sure how this is done in the case of decade fixed effects using dummy variables. If anyone has a suggestion on how I can do this, I would greatly appreciate it.

    Best,

    Satya

  • #2
    Originally posted by satya otil View Post
    I would like to have the interaction term Country*Period fixed effects as an explanatory variable in the regression. . . . I am not sure how this is done in the case of decade fixed effects using dummy variables.
    Code:
    generate byte decade = 0 * dec1950 + 1 * dec1960 + 2 * dec1970 + 3 * dec1980 + 4 * dec1990 + 5 * dec2000 + 6 * decrecent
    encode countrycode, generate(cid) label(Countries)
    regress <whatever> i.cid##i.decade
    Replace <whatever> with your outcome variable.

    Comment


    • #3
      Dear mr. Coveney,

      The code worked perfectly, thank you very much.

      Best,
      Satya

      Comment


      • #4
        You're welcome. And thanks for closing out the thread with your feedback.

        Comment

        Working...
        X