Announcement

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

  • GLM binomial logit model gof - Deviance

    Good day,

    I'm using Stata 16 and trying to do gof for a glm logit model but the results show a lot of missing data. My commands are as follows:

    Code:
    glm obese $X [aw=wt], family(binomial) link(logit)
    predict mu_logit
    predict dr_logit, deviance
    qui glm obese $X [aw=wt], family(binomial) link(cloglog)
    predict mu_cl
    predict dr_cl, d
    format mu_logit dr_logit mu_cl dr_cl %9.5f
    list mu_logit dr_logit mu_cl dr_cl, sep(4)
    The results show a lot of missing data

    6616. | . . . . |
    |------------------------------------------|
    216617. | . . . . |
    216618. | . . . . |
    216619. | . . . . |
    216620. | . . . . |
    |------------------------------------------|
    216621. | . . . . |
    216622. | . . . . |
    216623. | . . . . |
    216624. | . . . . |
    |------------------------------------------|
    216625. | . . . . |
    216626. | . . . . |
    216627. | . . . . |
    216628. | . . . . |
    |------------------------------------------|
    216629. | . . . . |
    216630. | . . . . |
    216631. | . . . . |
    216632. | . . . . |
    |------------------------------------------|
    216633. | . . . . |
    216634. | . . . . |
    216635. | . . . . |
    216636. | . . . . |
    |------------------------------------------|
    216637. | . . . . |
    216638. | . . . . |
    216639. | . . . . |
    216640. | . . . . |
    |------------------------------------------|
    216641. | . . . . |
    216642. | . . . . |
    216643. | . . . . |
    216644. | . . . . |
    |------------------------------------------|
    216645. | . . . . |
    216646. | . . . . |
    216647. | . . . . |
    216648. | . . . . |
    |-----------------------------------------

    My dataex

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float obese byte(wquintile fprogram_1 fprogram_2 gender_1 gender_2 race_1 race_2 race_3 race_4 geo_1 geo_2 mbmi_1 mbmi_2 gradem_1 gradem_2 employed_1 employed_2)
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . 1 0 1 0 1 0
    0 1 1 0 0 1 0 1 0 0 1 0 1 0 1 0 1 0
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . 1 0 1 0 1 0
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . 1 0 1 0 0 1
    . . . . . . . . . . . . 1 0 1 0 0 1
    . . . . . . . . . . . . 1 0 1 0 0 1
    . . . . . . . . . . . . . . . . . .
    0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 0 1
    . . . . . . . . . . . . 1 0 1 0 0 1
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . . . . . . .
    0 1 1 0 0 1 0 1 0 0 1 0 . . . . . .
    0 1 1 0 1 0 0 1 0 0 1 0 . . . . . .
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . . . . . . .
    . 1 1 0 0 1 0 1 0 0 1 0 . . . . . .
    . . . . . . . . . . . . 0 1 1 0 1 0
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . . . . . . .
    0 1 1 0 1 0 0 1 0 0 1 0 1 0 1 0 0 1
    0 1 1 0 0 1 0 1 0 0 1 0 1 0 1 0 0 1
    . . . . . . . . . . . . 1 0 1 0 0 1
    . . . . . . . . . . . . 1 0 1 0 0 1
    0 1 1 0 1 0 0 1 0 0 1 0 . . . . . .
    0 1 1 0 1 0 0 1 0 0 1 0 . . . . . .
    . 1 . . 1 0 0 1 0 0 1 0 . . . . . .
    0 1 1 0 1 0 0 1 0 0 1 0 . . . . . .
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . . . . . . .
    0 1 . . 0 1 0 1 0 0 1 0 . . . . . .
    0 1 1 0 0 1 0 1 0 0 1 0 0 1 1 0 1 0
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . . . . . . .
    0 1 1 0 1 0 0 1 0 0 1 0 0 1 1 0 1 0
    0 1 1 0 0 1 0 1 0 0 1 0 1 0 1 0 1 0
    0 1 1 0 0 1 0 1 0 0 1 0 0 1 1 0 1 0
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . . . . . . .
    0 1 1 0 0 1 0 1 0 0 1 0 . . . . . .
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . . . . . . .
    0 1 1 0 0 1 0 1 0 0 1 0 . . . . . .
    . 1 1 0 1 0 0 1 0 0 1 0 . . . . . .
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . 1 0 1 0 1 0
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . 1 0 1 0 1 0
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . 1 0 1 0 1 0
    0 1 1 0 0 1 0 1 0 0 1 0 1 0 1 0 1 0
    . . . . . . . . . . . . 1 0 1 0 1 0
    0 1 . . 1 0 0 1 0 0 1 0 1 0 1 0 1 0
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . . . . . . .
    0 1 1 0 1 0 0 1 0 0 1 0 0 1 1 0 0 1
    0 1 0 1 0 1 0 1 0 0 1 0 0 1 1 0 0 1
    . 1 . . 0 1 0 1 0 0 1 0 0 1 1 0 0 1
    . . . . . . . . . . . . . . . . . .
    1 1 1 0 0 1 0 1 0 0 1 0 0 1 1 0 0 1
    . . . . . . . . . . . . 1 0 0 1 1 0
    0 1 1 0 0 1 0 1 0 0 1 0 0 1 1 0 0 1
    . . . . . . . . . . . . 0 1 1 0 1 0
    . . . . . . . . . . . . 0 1 1 0 1 0
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . 1 0 1 0 1 0
    . . . . . . . . . . . . 1 0 1 0 1 0
    . . . . . . . . . . . . 0 1 1 0 1 0
    . . . . . . . . . . . . 0 1 1 0 1 0
    . . . . . . . . . . . . 0 1 1 0 1 0
    . . . . . . . . . . . . . . . . . .
    0 1 0 1 0 1 0 1 0 0 1 0 0 1 1 0 1 0
    . . . . . . . . . . . . . . . . . .
    . . . . . . . . . . . . 1 0 1 0 1 0
    . . . . . . . . . . . . 1 0 1 0 1 0
    0 1 1 0 1 0 0 1 0 0 1 0 0 1 1 0 1 0
    1 1 1 0 0 1 0 1 0 0 1 0 0 1 1 0 1 0
    . . . . . . . . . . . . 0 1 1 0 1 0
    . . . . . . . . . . . . 0 1 1 0 1 0
    . . . . . . . . . . . . . . . . . .
    . 1 0 1 1 0 0 1 0 0 1 0 1 0 1 0 1 0
    end
    label values obese obese5
    label def obese5 0 "0. Not_Obese", modify
    label def obese5 1 "1. Obese", modify
    ------------------ copy up to and including the previous line ------------------

    Please assist.

    Regards
    Nthato




  • #2
    Nthato:
    no wonder that you got disappointing results:
    Code:
    . egen wanted=rowmiss( obese- employed_2)
    
    . tab wanted
    
         wanted |      Freq.     Percent        Cum.
    ------------+-----------------------------------
              0 |         16       16.00       16.00
              1 |          1        1.00       17.00
              2 |          1        1.00       18.00
              3 |          1        1.00       19.00
              6 |          7        7.00       26.00
              7 |          2        2.00       28.00
              8 |          1        1.00       29.00
              9 |          1        1.00       30.00
             12 |         25       25.00       55.00
             18 |         45       45.00      100.00
    ------------+-----------------------------------
          Total |        100      100.00
    
    .
    You have a severe missing value problem that you have to deal with (if feasible) before any inferential procedure.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Hi Carlo

      *Thank you for the prompt response. How do I deal with missing data? Somebody please assist...

      Regards
      Nthato

      Comment


      • #4
        Nthato:
        the most trivial adcide is to collect them from the original source, if feasible.
        Otherwise, you shoud first diagnose whether their missingness is informative or not and then act on accordibky to deal with this issue.
        Unfortunately, if your example reflects the severity of the missing value problem in your dataset, I'm afraid that you are going to have hard times with fixing this issue.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Carlo I'm using secondary data. I copied the data to Xcel and realize that mother pid is not connecting to children pid correctly. That is where most of the data is missing.

          My variables are obese (adolescent obestiy), equivalized_inc, fprogram_1 fprogram_2 gender_1 gender_2 race_1 race_2 race_3 race_4 geo_1 geo_2 gradem_1 gradem_2 employed_1 employed_2 mbmi_1 mbmi_2

          fprogram - school feeding program
          geo - geopgraphy
          gradem - maternal education (tertiary or lower)
          employed - whether mother is employed
          mbmi - whether mother is obese or not

          Code:
          global X wquintile fprogram_1 fprogram_2 gender_1 gender_2 race_1 race_2 race_3 race_4  geo_1 geo_2 gradem_1 gradem_2 employed_1 employed_2 mbmi_1 mbmi_2
          I used the following loop to connect mother to adolescent\

          Code:
          by hhid (pid), sort: gen pid1=_n
          gen empl_f=.
          gen empl_m=.
          gen educ_f=.
          gen educ_m=.
          gen wgt_f=.
          gen wgt_m=.
          sum pid1, meanonly
          forval i =  1/`r(max)' { 
          
          by hhid: replace empl_f=employ[`i'] if fthpid==pid[`i'] & !missing(fthpid)
          by hhid: replace empl_m=employ[`i'] if mthpid==pid[`i'] & !missing(mthpid)
          
          by hhid: replace educ_ff=aedu[`i'] if fthpid==pid[`i'] & !missing(fthpid)
          by hhid: replace educ_mm=aedu[`i'] if mthpid==pid[`i'] & !missing(mthpid)
          
          by hhid: replace wgt_f=adult_bmi[`i'] if fthpid==pid[`i'] & !missing(fthpid)
          by hhid: replace wgt_m=adult_bmi[`i'] if mthpid==pid[`i'] & !missing(mthpid)
          }

          I can't even show results because it goes on showing numbers until it gets to zeros for a long time, then I switch the computer, saving of course, and restart Stata.

          Please advise on a better way to connect mother and children.

          Thanks Carlo



          Comment

          Working...
          X