Announcement

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

  • Keeping variables in xtdata

    The xtdata command centers variables within panels. It also drops all the variables that you don't ask it to center, which isn't always desirable. Respondent's name is a simple example of a variable you might want to keep but couldn't center.

    Is there a way to keep selected variables without centering them? Thanks.

  • #2
    Also: I am finding that xtdata drops a small fraction of rows. Under what circumstances will xtdata drop rows?

    Comment


    • #3
      I don't know an answer to the first question but for #2, note that the manual specifically says that any observation with a missing value will be dropped; so, do you have any missing data?

      Comment


      • #4
        Originally posted by paulvonhippel View Post
        Is there a way to keep selected variables without centering them? Thanks.
        Code:
        help keep
        help merge

        Comment


        • #5
          Thanks, rows were indeed being dropped because of missing values.

          Andrew Musau : Are you suggesting I merge the centered data back to the original data? I'm trying that. Makes me a little nervous since the row ID is one of the variables that xtdata drops. So I'm assuming that the rows are in the same order after xtdata as before. Which looks to be the case, but isn't stated in the documentation.

          Any other options?

          Comment


          • #6
            In a panel dataset, the combination of the panel identifier and time variable uniquely identify observations. Not to mention that "rows" is not standard terminology in Stata. As far as I know, xtdata does not drop the identifiers.

            Comment


            • #7
              In our data, each row (ok, observation) is a child. The panel is the school that the child attends, and since there are multiple children per school, the school ID and year do not uniquely identify the child.

              Comment


              • #8
                As long as the transformation of the observation number variable is monotonic within panel, you can recover the observation order. There is no reason to believe that it isn't. Note that listwise deletion is applied by xtdata, so make sure that you do not have missing values prior to running xtdata.

                Code:
                sort panelid
                by panelid: gen long obsno=_n
                xtset panelid
                xtdata ...
                Last edited by Andrew Musau; 11 Jun 2024, 11:29.

                Comment


                • #9
                  given that -xtdata- is for specification searches and not for final models; is your N so large that the difference in speed between -regress- and -xtreg- is worth all this work?

                  Comment

                  Working...
                  X