Announcement

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

  • how to save individual-level slopes from panel regression?

    i have a panel dataset (hundreds of individuals, tens of measures per individual) arranged as xt data.
    in many analyses, i use xtreg or mixed-effects reregression to examine within-individual relationships and between-group differences.
    what is the most straightforward approach to retrieve and save individual-level slopes [ xvar parameters] after a command such as:
    xtreg y xvar1 xvar2 i.group
    or
    xtmixed y i.group || id: xvar1 xvar2

    i know i can do this with dummies for each individual, or by looping, but i thought there would be a more succinct methos using xtreg or mixed.
    i am using StataSE v 13 on windows.
    thank you for tolerating this basic query.
    sincerely, george hoffman

  • #2
    It isn't clear in what sense you want to "retrieve and save" the individual level coefficients. Assuming you want to create new variables which contain, in each observation, the coefficients of xvar1 and xvar2 for that observation's individual:

    Code:
    mixed y i.group xvar1 xvar2 || id: xvar1 xvar2
    predict coef*, reffects
    will give you those (and also the random intercepts, with each of the new variables labeled to tell you which is which).

    If you are looking to "retrieve and save" them in a matrix, or something like that, a different approach would be needed.

    A couple of notes: -xtmixed- is old Stata. Since you're running version 13, -mixed- is preferred (though they do the same thing). Also, the model

    Code:
    xtmixed y i.group || id: xvar1 xvar2
    including xvar1 and xvar2 in the random effects but not the fixed effects is problematic. It is the functional equivalent of constraining the mean coefficients of xvar1 and xvar2 to zero. If that makes sense scientifically in your situation, then fine, but that would be unusual in the application areas I work in. The model in the first code section of this reply includes them in the fixed effects, allowing for free estimation of the mean values of those coefficients--usually a better idea if there is no strong scientific reason to assume the means must be zero.

    Comment


    • #3
      George: after your regression, type matrix list e(b). Do the entries in that matrix contain the items that you seek? If so, you could extract the required elements using Stata's matrix operators, for example putting them into local or global macros and using them 'elsewhere'. But, like Clyde, I have to say that it's unclear precisely what you want the coefficients for. If you could say why, I think Forum members would be in a better position to advise you.

      Comment


      • #4
        thank you stephen and clyde.
        i am looking to examne the variation in how xvar1 and xvar2 predict y. in addtion to some known and some unknown random effects, there are likely to be individual-level effects on both intercept and slope. questions that i am concerns about: 1. the magnitude of individual-level variation as contribution to overall variation. 2. identification of 'outliers' based on extremes of slope or intercept 3. identification of covariation of individual slope with other possible predictors. 4. testing hypothesis that individual slope or intercept is related to individual-level outcomes (some time-invariant; some dynamic). specifically: does the slope of y vs xvar1 for an individual predict performance on a test. thus i need the individual slope (sum o fmean effect + individual effect) in a new variable.

        after a simple regression
        mixed y xvar1 || id:xvar1

        my e(b) matrix contains:

        e(b)[1,5]
        yvar: yvar: lns1_1_1: lns1_1_2: lnsig_e:
        xvar1 _cons _cons _cons _cons
        y1 .42695051 31.324132 -3.7294663 .83832451 1.6839488

        so no individual-level betas

        does this help?
        thanks again.
        Last edited by George Hoffman; 29 Jun 2014, 16:11.

        Comment


        • #5
          For #1, you don't need individual slopes, you need the variance components, which are part of the ordinary output of -mixed-.

          For #2-5 you will need individual slopes in variables, along the lines of my earlier reply.

          Also, bear in mind that the random intercepts will depend on how you center var1 and var2, so be sure you have done that in a way that is meaningful with respect to your research questions. (If you're not familiar with this issue, you might consider doing the online course on multilevel regression from Bristol University at http://www.bristol.ac.uk/cmm/learnin...rse/index.html.)

          Comment


          • #6
            i appreciate the guidance for additional learning. i've rad extensely but need more formal tutelage. thank you.

            Comment

            Working...
            X