Announcement

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

  • Running a weighted OLS regression

    Hello I would like to run a logistic regression:
    outcome: Ordinal variable of three levels, lets call this ASA
    intervention: Anaesthethic type (Categorical variable 2 levels)
    other covariates: Age, Gender

    I tried:
    Code:
    regress asa anaesthetic_type gender age [pw=attweight]
    however stata is unable to run a factor variable regression

    i then tried
    Code:
    logit i.asa anaestethic_type gender age [pw=attweight]
    it then said logit can not use weights

    my question is, what is the alternative ?


  • #2
    It'd be great if in future you can post the actual error with the code and preferably some sample data. I was not able to replicate the errors mentioned.

    If you meant that asa being a 3-level factor variable and so not suitable as a dependent variable for linear regression, that I'd agree.

    But the second error does not make sense:
    1. Logit can definitely use pweight. Try help logit and click on "weight" in the syntax example at the top and it'd show what weights it accepts.
    2. However, logit does not require any "i." prefix for the dependent variable. Your second code wouldn't even run and I am not sure how the "logit can not use weights" was concluded. As long as the variable is coded in 1 and 0, logit should run fine.
    3. Your variable is 3-level, so logit is not the best choice because it's for binary variable (aka 2-level only). For multiple levels, look into help ologit for ordered logistic if your asa is ordinal in nature, and help mlogit for multinomial logistic if your asa is categorical in nature. Both of them accept pweight.

    Comment


    • #3
      I don't think you are accurately reporting what happened. Can you please show the exact results you got from Stata, by copy/pasting from your Results window or log file?

      I say that because your -logit- command is syntactically illegal, but, for reasons having nothing to do with weights. It's because you can't have i. in front of the dependent variable. Here's an example:
      Code:
      . sysuse auto, clear
      (1978 automobile data)
      
      .
      . set seed 1000
      
      .
      . gen pwt = runiformint(1, 30)
      
      .
      . logit foreign i.rep78 mpg [pw = pwt] // CORRECT
      
      note: 1.rep78 != 0 predicts failure perfectly;
            1.rep78 omitted and 2 obs not used.
      
      note: 2.rep78 != 0 predicts failure perfectly;
            2.rep78 omitted and 8 obs not used.
      
      note: 5.rep78 omitted because of collinearity.
      Iteration 0:  Log pseudolikelihood = -574.80495  
      Iteration 1:  Log pseudolikelihood = -293.32505  
      Iteration 2:  Log pseudolikelihood = -276.89391  
      Iteration 3:  Log pseudolikelihood = -276.47268  
      Iteration 4:  Log pseudolikelihood = -276.47209  
      Iteration 5:  Log pseudolikelihood = -276.47209  
      
      Logistic regression                                     Number of obs =     59
                                                              Wald chi2(3)  =  11.26
                                                              Prob > chi2   = 0.0104
      Log pseudolikelihood = -276.47209                       Pseudo R2     = 0.5190
      
      ------------------------------------------------------------------------------
                   |               Robust
           foreign | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
      -------------+----------------------------------------------------------------
             rep78 |
                1  |          0  (empty)
                2  |          0  (empty)
                3  |  -5.127848   1.656673    -3.10   0.002    -8.374866   -1.880829
                4  |  -2.912035   1.595664    -1.82   0.068    -6.039478    .2154077
                5  |          0  (omitted)
                   |
               mpg |   .2174643   .1041816     2.09   0.037     .0132721    .4216564
             _cons |  -1.764023   1.445039    -1.22   0.222    -4.596248    1.068202
      ------------------------------------------------------------------------------
      
      .
      . logit i.foreign i.rep78 mpg [pw = pwt] // INCORRECT
      depvar may not be a factor variable
      r(198);
      And my next question is, why are you using -logit- here? If your dependent variable is three levels, and ordinal, -logit- cannot properly represent that. -logit- is only usable with dichotomous outcomes. -ologit- or -mlogit- would seem more appropriate.

      Added: Crossed with #2 which raises the same major points.

      Comment

      Working...
      X