Announcement

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

  • Weights for ordered logistic regression model

    Hello folks, I am trying to run a multilevel ordered logistic regression because the outcome is an ordinal variable. However, I have sampling weights which I need to plug in the model as well. According to the manual for meologit which could be found here: https://www.stata.com/manuals/memeologit.pdf on page 5, it says that I need two types of sampling weight: one for level 1 and one for level 2. However, the data I am working on only had sampling weights for level 1 (the lower level). How should I deal with this? below is the syntax I am trying to use. I put question mark on the sampling weight option for level 2, which is not provided in the data. Since students were tested repetitively, so level 1 is individual student assessment scores and level 2 is student.

    Code:
    meologit selfconcept c.age##c.age i.group [pw = wt_sa1] || StudentID:, pweight(??) mle cluster(Cluster)

  • #2
    Man,

    I booted up the Stata example dataset for -meologit- called tvsfpors.dta. I then simulated sampling weights using a RNG for a uniform(0,1) distribution. I then calculated inverse-probability weights and arbitrarily truncated them at 5 for any weight beyond 5. I then fit a -meologit- model and it worked no problem and did not ask for higher-level weights. Here is the code:
    Code:
    use http://www.stata-press.com/data/r14/tvsfpors.dta
    describe
    generate pr = runiform(0,1)
    generate wt = 1/pr
    replace wt = 5 if wt >5
    meologit thk prethk cc##tv [pweight=wt] || school:
    Are you sure you NEED higher level weights, or just that Stata provides the option to specify higher level weights, if available?

    Comment


    • #3
      Hi Matt, thanks a lot for your reply. It seems from your example, higher level weights is not required. However, if following your example, below is my syntax

      Code:
      meologit academic_selfconcept c.age##c.age i.group [pweight = wt_sa1] || StudentID:, mle cluster(Cluster)
      Stata spit out error message: weights not allowed.

      Please note wt_sa1 is the weight provided by the data and it is for level 1. Can you tell me where it could go wrong?

      Comment


      • #4
        Man,

        A quick scan of the Stata help manual for -meologit- seems to suggest that the -mle- and -cluster- sub-options are not acceptable arguments. Try removing those and re-running the model. If you want clustered SEs you must use the following code...
        Code:
        vce(cluster clustervar)
        Where clustervar is the name of a variable in your data set that indicates the clusters.

        In your case it would look like...
        Code:
        meologit academic_selfconcept c.age##c.age i.group [pweight = wt_sa1] || StudentID:,  vce(cluster Cluster)

        Comment


        • #5
          Hi Matt, thanks for the reply and I removed the options. But unfortunately... the syntax still doesn't work

          Comment


          • #6
            Point of clarification here. Man's data appear to be measurements nested within students. Matt's example data here were for students nested within schools.

            Man, do you have one sampling weight for each student, then a number of different measurements? Or is it one sampling weight for each student in each year (or whatever the interval between tests was)? If the latter, I am guessing that you don't need level 2 weights. If you have sampling weight for each student, then it sounds like you need a level 2 but not a level 1 weight. I can't see in the manual where it says that weights are required at all levels, merely that they are optional.
            Be aware that it can be very hard to answer a question without sample data. You can use the dataex command for this. Type help dataex at the command line.

            When presenting code or results, please use the code delimiters format them. Use the # button on the formatting toolbar, between the " (double quote) and <> buttons.

            Comment


            • #7
              Good observation, Weiwen. I did not pick up on this distinction. If the weight is for the Student, and not whatever is measured within each student, then you are probably correct -- level 2 weights are needed, and not for level 1.

              Man --> Your new code would look as follows:
              Code:
              meologit academic_selfconcept c.age##c.age i.group || StudentID: , pw(wt_sa1)

              Comment


              • #8
                Hi Matt and Weiwen, thanks for your replies.
                Weiwen, I only have level 1 sampling weight in the data.
                Matt, I tried your syntax in #7, but Stata still spits out error says option pw() not allowed. Any clues?

                Comment


                • #9
                  Without knowing more about the structure of your data, and the sampling that went into generating the data it is hard to offer advice. If you can provide more explanation on how the data were sampled, this would be helpful. If you can, download the Stata package -dataex- using the following code:
                  Code:
                  ssc install dataex
                  You can use the -dataex- command to prepare a snippet of your data to post on this forum for us to look at. It is your responsibility to determine whether this is allowed based on the confidential nature of the data.

                  The following code will provide a lot of insight:
                  Code:
                  dataex academic_selfconcept age group StudentID wt_sa1 in 1/10

                  Comment


                  • #10
                    Hi Matt, thanks for your advice. Below is the data output after running the code.

                    Code:
                    ----------------------- copy starting from the next line -----------------------
                    
                    
                    Code:
                    * Example generated by -dataex-. To install: ssc install dataex
                    clear
                    input double academic_selfconcept float agec byte group double(StudentID wt_sa1)
                    14 -3.22 0 10023  55.17
                    15  -.22 0 10023  55.17
                    .a -2.22 . 10023  55.17
                    12  3.78 1 10028  23.54
                    11  1.78 1 10028  23.54
                    11   .78 0 10029  18.68
                    15  4.78 0 10029  18.68
                    15 -4.22 1 10031 215.88
                    12 -1.22 1 10031 215.88
                    11 -2.22 1 10031 215.88
                    end
                    label values academic_selfconcept sa3AcademicSelfConcept
                    label values group _treated
                    label def _treated 0 "Untreated", modify
                    label def _treated 1 "Treated", modify
                    ------------------ copy up to and including the previous line ------------------

                    Comment


                    • #11
                      Man,

                      I used your sample of data and ran the following code, it executed properly. Please review and let me know if you notice any differences:
                      Code:
                      clear input double academic_selfconcept float agec byte group double(StudentID wt_sa1)
                      14 -3.22 0 10023 55.17
                      15 -.22 0 10023 55.17
                      .a -2.22 . 10023 55.17
                      12 3.78 1 10028 23.54
                      11 1.78 1 10028 23.54
                      11 .78 0 10029 18.68
                      15 4.78 0 10029 18.68
                      15 -4.22 1 10031 215.88
                      12 -1.22 1 10031 215.88
                      11 -2.22 1 10031 215.88
                      end
                      Code:
                      meologit academic_selfconcept c.agec##c.agec i.group || StudentID:, pw(wt_sa1)
                      Click image for larger version

Name:	Man.png
Views:	1
Size:	27.6 KB
ID:	1426330

                      Comment


                      • #12
                        Hi Matt, thanks for your response. It's getting really odd since you run it properly. I double checked my syntax and it is completely the same with yours. Do you think missing values in any of these variables matter? I tried dropping all the missing cases in the weights but still Stata shows option pw not allowed. How about the version of Stata (I am using version 13)? Does it matter?

                        To add: I even tried keeping only the first 10 observations (same as the data you were using) and then copy and paste your syntax in Stata, it still spit out error messages of pw not allowed...
                        Last edited by Man Yang; 18 Jan 2018, 12:24.

                        Comment


                        • #13
                          Yes, this is the issue. I was running this all on Stata 14.2. I just booted up my version of Stata 13 and consulted the help manual and weights were not supported for this version of -meologit-. In order to do weighed meologit it seems like you need to update to Stata 14 or newer. I don't think there is a workaround for this.

                          Comment


                          • #14
                            Thanks so much! At least we figured it out

                            Comment


                            • #15
                              Hi Mat, can I ask you a follow-up question please? Since I am using -meologit-, meaning my model is a multilevel ordered logistic regression model and in my model, I also have a linear and quadratic term of time. The model and the output is as follows (sorry for some reason, I cannot copy and paste the stata code directly). As you can see, both the linear and quadratic age are not significant. What does this tell me then? Does the insignificance impact my postestimation using margins?

                              Click image for larger version

Name:	Picture1.png
Views:	1
Size:	147.0 KB
ID:	1427336


                              Comment

                              Working...
                              X