Announcement

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

  • error reshaping wide xtdpdml

    Hi everyone,
    I am working with a longitudinal data set (four waves) that looks like this:


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input long fallnum byte(alter isced) float(sum_helpfromchildren srh) byte female long welle
    1000007 59 3  0 5 1 1
    1000007 62 3  0 4 1 2
    1000007 65 3  0 4 1 3
    1000007  . .  . . 1 4
    1000020 59 2  0 4 1 1
    1000020  . .  . . 1 2
    1000020 65 2  0 4 1 3
    1000020 68 2  0 4 1 4
    1000024 68 2  0 3 1 1
    1000024 71 2  0 4 1 2
    1000024 74 2  1 4 1 3
    1000024 77 2  0 4 1 4
    1000076 83 2  0 4 0 1
    1000076 86 2  0 3 0 2
    1000076 89 2  0 2 0 3
    1000076  . .  . . 0 4
    1000090 74 2  0 4 0 1
    1000090 77 2  0 3 0 2
    1000090  . .  . . 0 3
    1000090  . .  . . 0 4
    1000150 74 3  0 3 0 1
    1000150 77 3  0 3 0 2
    1000150 80 3  0 3 0 3
    1000150  . .  . . 0 4
    1000181 89 3  0 2 0 1
    1000181 92 3  0 1 0 2
    1000181  . .  . . 0 3
    1000181  . .  . . 0 4
    1000195 88 1  0 2 0 1
    1000195 91 1  0 2 0 2
    1000195  . .  . . 0 3
    1000195  . .  . . 0 4
    1000219 84 3  1 2 1 1
    1000219 87 3  1 3 1 2
    1000219 90 3  1 3 1 3
    1000219 93 3  1 3 1 4
    1000258 85 1  1 2 0 1
    1000258 88 1  0 3 0 2
    1000258 91 1  1 1 0 3
    1000258  . .  . . 0 4
    1000263 82 3  0 4 0 1
    1000263 85 3  0 3 0 2
    1000263 88 3  0 3 0 3
    1000263  . .  . . 0 4
    1000338 84 2  0 3 1 1
    1000338 87 2  0 3 1 2
    1000338 90 2  0 3 1 3
    1000338 93 2  0 3 1 4
    1000341 83 3  0 4 0 1
    1000341 86 3  0 3 0 2
    1000341  . .  . . 0 3
    1000341  . .  . . 0 4
    1000351 70 2  0 3 0 1
    1000351 73 2  0 4 0 2
    1000351 76 2  1 4 0 3
    1000351  . .  . . 0 4
    1000410 84 2  0 4 1 1
    1000410 87 2  0 3 1 2
    1000410 90 2  0 3 1 3
    1000410  . .  . . 1 4
    1000447 87 2  0 3 1 1
    1000447 90 2  1 4 1 2
    1000447 93 2  1 4 1 3
    1000447  . .  . . 1 4
    1000454 79 1  0 2 1 1
    1000454 82 1  0 2 1 2
    1000454  . .  . . 1 3
    1000454  . .  . . 1 4
    1000464 76 1  0 4 1 1
    1000464 79 1  0 3 1 2
    1000464 82 1  1 3 1 3
    1000464  . .  . . 1 4
    1000525 93 2  1 3 0 1
    1000525 95 2  1 3 0 2
    1000525  . .  . . 0 3
    1000525  . .  . . 0 4
    1000571 67 2  1 4 1 1
    1000571 70 2  0 4 1 2
    1000571 73 2  0 3 1 3
    1000571 76 2  0 4 1 4
    1000596 77 3  0 3 1 1
    1000596 80 3  1 4 1 2
    1000596 83 3 .a 3 1 3
    1000596 86 3  1 2 1 4
    1000616 78 2  0 3 0 1
    1000616 81 2  0 3 0 2
    1000616 84 2  0 2 0 3
    1000616  . .  . . 0 4
    1000620 88 2  0 3 0 1
    1000620 91 2  0 1 0 2
    1000620  . .  . . 0 3
    1000620  . .  . . 0 4
    1000628 79 2  0 4 0 1
    1000628 82 2  1 4 0 2
    1000628  . .  . . 0 3
    1000628  . .  . . 0 4
    1000629 70 2  0 4 1 1
    1000629  . .  . . 1 2
    1000629 76 2  0 4 1 3
    1000629 79 2  0 4 1 4
    end
    label values fallnum misslab
    label values alter ALTER_17
    label values isced ISCED_17
    label def ISCED_17 1 "1. niedrig (ISCED 0-2)", modify
    label def ISCED_17 2 "2. mittel (ISCED 3-4)", modify
    label def ISCED_17 3 "3. hoch (ISCED 5-6)", modify
    label values welle welle
    label def welle 1 "_08", modify
    label def welle 2 "_11", modify
    label def welle 3 "_14", modify
    label def welle 4 "_17", modify
    I'm using the command "xtdpdml" for a cross-lagged panel model with fixed-effects. My code is the following:



    xtset fallnum welle

    xtdpdml sum_helpfromchildren alter, pre(L.srh) inv(female isced) errorinv fiml details



    However, the reshaping from long to wide format does not work properly within the command. The error code is the following:

    "variable isced not constant within fallnum
    Your data are currently long. You are performing a reshape wide. You typed something like

    . reshape wide a b, i(fallnum) j(welle)

    There are variables other than a, b, fallnum, welle in your data. They must be constant within fallnum because
    that is the only way they can fit into wide data without loss of information.

    The variable or variables listed above are not constant within fallnum. Perhaps the values are in error. Type
    reshape error for a list of the problem observations.

    Either that, or the values vary because they should vary, in which case you must either add the variables to
    the list of xij variables to be reshaped, or drop them."

    When I try to reshape the data before the xtdpdml command, it works perfectly. As soon as I set the panel and time variable, it does not work anymore.
    I would be greatful for any tips!

    Kind Regards,
    Lisa

  • #2
    isced isn't time invariant, because (unlike female) its value is often missing within a panel. To fill in those missing values, do something like

    Code:
    bysort fallnum (welle): egen iscedx = min(isced)
    and then use iscedx instead of isced. (Or, clean up isced some other way).

    In your example, xtdpdml still won't run -- it complains about initial values not feasible. Maybe you will fair better with the full dataset though.

    In the example you present though, the data aren't really "balanced." Having records that only have missing values is the same as not having the record at all. The fiml option is good when, say, a record has data on x1, x2, and x3, but is missing on x4. If it is missing data on everything though, fiml can't save it. Unlike some other xt methods, xtdpdml has problems with unbalanced or de facto unbalanced panels.

    Anyway, clean up your data set a bit. If a variable really is time-invariant, it should not be missing on any of a panel's records (unless it is missing for all of them). Try to minimize MD in your data as much as you can.
    -------------------------------------------
    Richard Williams, Notre Dame Dept of Sociology
    StataNow Version: 18.5 MP (2 processor)

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

    Comment


    • #3
      Thank you very much!
      I ran the analyses again and it worked. Thank you also for the other tips. I am just starting the analyses and will still have figure some things out.
      Kind Regards,
      Lisa

      Comment

      Working...
      X