Announcement

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

  • factor-variable and time-series operators not allowed

    Hi,

    I'm trying to use the "xtserial" command to test for autocorrelation but I get the error message, "factor-variable and time-series operators not allowed r(101);". Why is this please? I did "tsset id year" and "xtserial ideology i.partisanship gini i.partisanship#c.gini i.agegroup i.sex i.Black i.Asian i.Hispanic i.AmericanIndian i.region education i.employment i.union income i.religion2"

  • #2
    The message means exactly what it says. xtserial (from the Stata Journal, as you are asked to explain) is from 2003 and written for Stata 8. Therefore, it does not support factor variable notation, which was introduced later in Stata 11. I guess your options are to clone and rewrite the command or to create the needed indicator and interaction variables yourself beforehand.

    Comment


    • #3
      How do I do that please? I tried using "xi:" but I'm not sure I'm using it correctly

      Comment


      • #4
        No one but you can see what you tried with xi: but it might work. You should show what you tried and what happened.

        Comment


        • #5
          I did: "xi: ideology i.partisanship gini i.partisanship*gini i.agegroup i.sex i.Black i.Asian i.Hispanic i.AmericanIndian i.region education i.employment i.union income i.religion2" and it said "invalid syntax"

          Comment


          • #6
            I also tried to use the "xttest1" command for the Breusch-Pagan LM test and it said "factor-variable and time-series operators not allowed". The regression I did before using the xttset1 command was "xtreg ideology i.partisanship gini i.partisanship#c.gini i.agegroup i.sex i.Black i.Asian i.Hispanic i.AmericanIndian i.region education i.employment i.union income i.religion2 i.year, re"

            Comment


            • #7
              I rarely use these commands but thinkthe idea should be that you issue the xtserial command (in this case) under the aegis of xi:

              Code:
              xi: xtserial ideology i.partisanship gini i.partisanship*gini i.agegroup i.sex i.Black i.Asian i.Hispanic i.AmericanIndian i.region education i.employment i.union income i.religion2


              Please do use CODE delimiters as requested. It makes your code easier to read.

              Comment


              • #8
                I tried that and it's still not working. What exactly did you mean by "I guess your options are to clone and rewrite the command or to create the needed indicator and interaction variables yourself beforehand." How do I do that?

                Comment


                • #9
                  Sorry, but I have no further ideas. "still not working" means nothing that I can decode.

                  You can generate indicator variables using xi: or tabulate.

                  Comment


                  • #10
                    Can someone else respond to my question please? My friend used the code and everything was fine, I don't know why I can't use it

                    Comment


                    • #11
                      Show the code and output you got when you tried Nick’s command and we might be able to help. I don’t see any obvious issues with what he suggested but without seeing the output I can’t evaluate what the problem is.

                      if it works for your friend but not for you, then directly compare what you friend is typing and what you are typing.
                      -------------------------------------------
                      Richard Williams, Notre Dame Dept of Sociology
                      StataNow Version: 19.5 MP (2 processor)

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

                      Comment


                      • #12
                        I first used the command
                        Code:
                        tsset id year
                        Then I used the command
                        Code:
                        xi xtserial ideology i.partisanship gini i.partisanship*gini i.agegroup i.sex i.Black i.Asian i.Hispanic i.AmericanIndian i.region education i.employment i.union income i.religion2
                        And what I got was
                        i.partisanship _Ipartisans_0-6 (naturally coded; _Ipartisans_0 omitted)
                        i.partis~p*gini _IparXgini_# (coded as above)
                        i.agegroup _Iagegroup_0-6 (naturally coded; _Iagegroup_0 omitted)
                        i.sex _Isex_0-1 (naturally coded; _Isex_0 omitted)
                        i.Black _IBlack_0-1 (naturally coded; _IBlack_0 omitted)
                        i.Asian _IAsian_0-1 (naturally coded; _IAsian_0 omitted)
                        i.Hispanic _IHispanic_0-1 (naturally coded; _IHispanic_0 omitted)
                        i.AmericanInd~n _IAmericanI_0-1 (naturally coded; _IAmericanI_0 omitted)
                        i.region _Iregion_1-4 (naturally coded; _Iregion_1 omitted)
                        i.employment _Iemploymen_1-9 (naturally coded; _Iemploymen_1 omitted)
                        i.union _Iunion_0-1 (naturally coded; _Iunion_0 omitted)
                        i.religion2 _Ireligion2_1-9 (naturally coded; _Ireligion2_1 omitted)

                        I can't really compare exactly with my friend because she's using a different dataset. But she used the command "xtserial" without having to use "xi" and it worked for her. Even with "xi" for me, I don't understand what's going on

                        Comment


                        • #13
                          Sarah:
                          - as per Nick's suggestion #7, -xi- should have been -xi:- (perhaps it is just a copy and paste mishap);
                          - as expected -xtserial- is sheltering your code from the so called dummy trap (https://en.wikipedia.org/wiki/Dummy_...le_(statistics)).
                          Hence, what's the reason of your concern/complaint with Stata output (that you did not show us)?
                          Kind regards,
                          Carlo
                          (Stata 19.0)

                          Comment


                          • #14
                            When I use -xi:- this is what I get:

                            i.partisanship _Ipartisans_0-6 (naturally coded; _Ipartisans_0 omitted)
                            i.partis~p*gini _IparXgini_# (coded as above)
                            i.agegroup _Iagegroup_0-6 (naturally coded; _Iagegroup_0 omitted)
                            i.sex _Isex_0-1 (naturally coded; _Isex_0 omitted)
                            i.Black _IBlack_0-1 (naturally coded; _IBlack_0 omitted)
                            i.Asian _IAsian_0-1 (naturally coded; _IAsian_0 omitted)
                            i.Hispanic _IHispanic_0-1 (naturally coded; _IHispanic_0 omitted)
                            i.AmericanInd~n _IAmericanI_0-1 (naturally coded; _IAmericanI_0 omitted)
                            i.region _Iregion_1-4 (naturally coded; _Iregion_1 omitted)
                            i.employment _Iemploymen_1-9 (naturally coded; _Iemploymen_1 omitted)
                            i.union _Iunion_0-1 (naturally coded; _Iunion_0 omitted)
                            i.religion2 _Ireligion2_1-9 (naturally coded; _Ireligion2_1 omitted)
                            no observations
                            r(2000);

                            I don't understand what you mean by I didn't show the Stata output, I did. That is all that was shown. There was no autocorrelation test done and I don't know how to fix it

                            Comment


                            • #15
                              Sarah:
                              in your previous post you forgot to paste the last two lines of what Stata gave you back
                              Code:
                              no observations
                              r(2000);
                              That omission made me think that Stata report was left unreported.

                              Perhaps you may want to post an excerpt/example of your dataset via -dataex-.
                              Kind regards,
                              Carlo
                              (Stata 19.0)

                              Comment

                              Working...
                              X