Announcement

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

  • Interactions and factor variables

    Dear Stata Users and Experts,

    To put it simply, I am trying to create interactions variables in Stata. I found the following way to do so:

    First and most importantly, is to mention that I am doing interaction between to explanatory variable not between the original method which is dummy variable X explanatory variable. Is this actually possible?

    Second of all I am creating factor variable by using "unary operator to treat as continuous". The reason to that is because when I am trying to do a simple " binary operator" I am getting the following message:
    "ownership_concentration: factor variables may not contain noninteger values".

    Basically, the command in Stata looks like this:

    official(regulation variable)#c.ownership_concentration(variable for governance). By using only one unary operator(only for ownership), I get strange result which I cannot interpret - Could you please advise?



    By using two unary operators (for both variables official and ownership) I get more logical result.




    However, I was not able to understand what is the difference between two of the approaches. Do you have any idea and most importantly is this a correct way to do the test? If this is a correct way, can we say the if we end with a significant value the official variable is interacting on the ownership variable?



    Thank you very much in advance for the help. It will be much appreciated.

  • #2
    If you use factor variables, then by default Stata asumes that the variables are categorical. For example, marital status which can be "married", "cohabitating", "divorced", "single", "widowed". For a a factor variable, these must be positive integers preferably, but not necessarily, with meaningful value labels. For example 1 = married, 2 = cohabitating, etc. So if you use factor variables to include an interaction, Stata will assume that those variables are categorical. If those variables contain negative values or non-integers, it will spit an error message out. Which is what happend to you.

    Even if your variable contains positive integers, and thus Stata "works", it may not be what you want. For example, you may have usual hours per week worked, which is almost always a set of positive integers, but you normally would want to treat that as a continuous variable. For those variables the factor variable notation includes the c. operator. If you use the factor variable notation to inlcude interactions and you want to treat the variable as continuous, then you have to use that operator before every single variable you want to treat as continuous.

    Which one is correct depends on what you want to do. Do you want to treat your variables as categorical or continuous.
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Thank you very much for the prompt answer.

      However, I still cannot find a solution of my problem.

      Perhaps is worth pointing out what is my main goal.

      I want to create interaction terms/variables

      I was told that I need to create this variable in STATA by multiplying the other two variables (e.g. Restrict * Ownership concentration -these variables are reflecting my scope of study, however, there are not dummy variables). I tried to do a research regarding this command in Stata and I came across the article for factor variables.

      Eventually, my goal is the following - If the estimated coefficient of the interaction term is positive that means the "Restrict" variable from above has stronger influence on the ownership concentration variable.

      Is there any other method which I can use in order to get the main idea/logic from above?

      Thank you very much in advance for the help. Really appreciate it.


      Comment


      • #4
        It could help if you showed your actual code and output. Use code tags. See point #12 in the FAQ on presenting questions effectively.
        -------------------------------------------
        Richard Williams, Notre Dame Dept of Sociology
        StataNow Version: 19.5 MP (2 processor)

        EMAIL: [email protected]
        WWW: https://www3.nd.edu/~rwilliam

        Comment


        • #5
          Dear Richard Williams,

          Dear all,

          Thank you for the note. I had a glance at the FAQ on "presenting questions effectively". Therefore, I will try to express my question more thoroughly.

          My scope of data is panel data. It has the following structure:
          Var1 Var2 etc.
          Banks Country Year

          Attached a .png example of my dataset. I am usung the following code to declare the data

          Code:
          xtset y banks
          In order to test my hypothesis I am using hausman test:

          Code:
          xtreg dependent variable(CIR) explanatory variables .....(restrict, ownership_concentration)
          Now my desire is to add additional explanatory variable to my model. My goal is that this variable should be an interaction variable.

          Lets pick up two of my explanatory variables

          - Restrict (regulation variable)

          - Ownership_concentration(governance variable).

          I want to multiply Restrict with Ownership_concentration.

          In stata it should be as follows

          Code:
          xtreg y x1 x2 x3 x4*x5(in my case Restric*Ownership_Concentration)
          Eventually, my idea/logic is to prove that - If the estimated coefficient of the interaction term is positive that means the "Restrict" (x4) variable has stronger influence on the (x5) ownership concentration variable.

          Perhaps there is another way to make interaction between variables. Therefore, I am seeking for your help if you can advise another option/command.

          Thanks in advance and apologies if I have misunderstood any of the FAQ rules.

          Attached Files

          Comment

          Working...
          X