Announcement

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

  • Fixed effects

    Dear All,

    Thank you for helping me.

    I am reading the do-file of one article. It uses the fixed effect to deal with the panal data. Before the regression and creation of dummy variables, the author use the dropvars command to drop some variables. I assume the purpose of doing so is to confirm there is no variable that shares the same variable name before we creat the dummy variables. I do not know whether my guess is right or not. I follow the same logic, but it shows the following.


    dropvars yr* fix*

    tab id, gen(fix)
    drop fix1

    tab year, gen(yr)
    drop yr1

    global y "consume"
    global x "gdpper real_i rategap ss depend bank_w"

    reg $y $x
    est store c1

    reg $y $x fix*
    est store c2
    lrtest c1 c2
    estadd scalar FeChi2=r(chi2)
    estadd scalar FeChi2p=r(p)
    ereturn list

    reg $y $x fix* yr*
    est store c3
    lrtest c2 c3
    estadd scalar YrChi2=r(chi2)
    estadd scalar Yrchi2p=r(p)

    When running the program, stata shows that:

    dropvars yr* fix*
    unrecognized command: dropvars
    r(199);

    end of do-file


    r(199);

    So I try to alter the syntax as such:
    drop yr*
    drop fix*


    but this time, stata shows that

    drop yr*
    variable yr* not found
    r(111);


    end of do-file

    r(111);

    I do not know what is wrong with this. I also want to know the purpose of author use dropvars yr* fix* before the regression.

    Thank you indeed,

    Best





  • #2
    To start, - dropvars - may well be a command from a user-written program. Being this so, it won't work, unless the program is installed.

    Second, you don't need this command to drop variables: just use - drop - or - keep - accordingly.

    Third, the commands of - tab - with - gen - were done in order to create binary (dummy) variables. After that, the first dummy was deleted.

    I wonder whether you are using an old version of Stata, for you don't need to: a)create dummies; b) drop the first one.

    In short, you may just follow the examples from the Stata Manual for the regression analysis, using factor notation. For example: i.year, as in the command below:

    Code:
    reg $y $x i.year
    Hopefully that helps.

    P.S.: 1) With regards to creating binary variables concerning the id, or using id as a categorical variable, I fail to envisage the reason under the OLS regression. 2) I also fail to understand the relationship of your query with the fixed effects models in panel data regression, hence the title seemed to me somewhat uninformative.3) Please use the CODE delimiters or - dataex - to share command/data/output. Thanks.
    Last edited by Marcos Almeida; 01 Jun 2018, 05:28.
    Best regards,

    Marcos

    Comment


    • #3
      Thank you Macros. My stata version is 13.1, a little bit old.

      Comment


      • #4
        Not that much. All the recommendations in #2 apply for this version as well.

        With regards to the user-written - dropvars, there is some text in the Web. from 1999 and, as far as I could infer, it is from the Stata 6 era. All that being said, I recommend to drop or keep the variables with - drop - and - keep - commands, respectively. Anyway, by reading #1, I believe you won't need to drop whatsoever variable, since you may just use the factor notation to reach the goal.
        Best regards,

        Marcos

        Comment


        • #5
          Thank you sincerely, Marcos.

          Comment

          Working...
          X