Announcement

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

  • how to catch individual fixed effect

    I have a biennial panel by using:
    xtset hhidpn Year, delta(2)

    hhidpn denotes the individuals in the survey, through command --xtdescribe-- I get the following result for hhidpn:

    hhidpn: 3010, 3020, ..., 9.584e+08 n = 13329
    Year: 1998, 2000, ..., 2012 T = 8
    Delta(Year) = 2 units
    Span(Year) = 8 periods
    (hhidpn*Year uniquely identifies each observation)

    Distribution of T_i: min 5% 25% 50% 75% 95% max
    1 1 1 2 3 5 8

    Freq. Percent Cum. | Pattern
    ---------------------------+----------
    2638 19.79 19.79 | ......11
    1125 8.44 28.23 | 1.......
    980 7.35 35.58 | .....1..
    914 6.86 42.44 | 11......
    835 6.26 48.71 | ...11.11
    758 5.69 54.39 | ......1.
    643 4.82 59.22 | .......1
    563 4.22 63.44 | 111.....
    513 3.85 67.29 | 11111...
    4360 32.71 100.00 | (other patterns)
    ---------------------------+----------
    13329 100.00 | XXXXXXXX

    .It shows this is a cross-sectional data set, and I want to evaluate whether high job insecurity (HS) has an impact on
    the health, which is H in the model. HS is endogeneous and I want to use the IV for the panel dataset.

    the number of hhidpn is larger, can I use the following commands to estimate the individual fixed effects?
    I understand that we may use county, area or other variables' fixed effects, but here assume that
    individual fixed effects are recommended.

    local Var_A hhidpn i.Year ,,,,
    ivregress 2sls H (HS=IV) `Var_A' ,first

    If I assign ---- ivregress 2sls, fe -----, stata reports an error.
    Another question is that if I do not transfer the data to panel by -----xtset hhidpn Year, delta(2)----,
    just do a normal OLS regression and want to catch the individual fixed effect, can I use the following?

    local Var_A hhidpn i.Year ,,,,
    regress H HS `Var_A'

    If I assign i.hhidpn in the above, stata will return an error.
    I understand that by setting it to a panel like below, we can catch the individual fixed effect,
    but here we do not change it to panel, just a normal OLS.
    xtset hhidpn Year, delta(2)
    local Var_A i.Year ,,,,
    xtreg H HS `Var_A' , fe


    Thanks for your comments.
    Last edited by sladmin; 04 Jun 2018, 10:35. Reason: fix title typo

  • #2
    You'll increase your chances of a useful answer by following the FAQ on asking questions - provide Stata code in code delimiters, readable Stata output, and sample data using dataex. Also, simplify your code - there is no reason to have local macros if you're just explaining a two variable regression. Also, "will return an error" is not terribly helpful - what error specifically?

    If you have multiple observations per person, I would think you have a panel dataset. If you're estimating fixed effects, why not use xtreg or xtivreg? You have an error since ivreg is not a panel estimator so fixed effects make no sense in ivreg. Look at the documentation and you'll see fe is not an allowed option for ivreg.

    You can do the equivalent of fixed effects with ols and i.panel as a control. However, it is slower. regress H HS i.hhidpgn i.year is allowable code But, it could still give you an error depending on what you've got in the variables. You may want to use "set trace on" to make sure Stata is interpreting your macro the way you intend.

    Comment


    • #3
      Hi Dr. Phil, thank you for your comment. The control here is long and omit some others. I will try to
      learn
      dataex in the coming time.
      Yes, you are correct. I have an unbalanced panel data.
      -------------------------------------------
      local Var_A i.Year i.rcendivnew Age ib(first).Gender ib(first).Race ib(first).Education ....

      If I use "xtivreg2 SH (GenderxHS HS= FNER FNERxGender) `Var_A' ,fe first cluster(hhid)
      stata reports an error "factor-variable operators not allowed".
      -------------------------------------------

      Should I remove the factor in the local Macro?
      However, I do want to see the relative value that is compared with the reference group.
      Another thing is that the fixed effects for year and region (
      i.rcendivnew
      ) also have a factor operation.

      Comment

      Working...
      X