Announcement

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

  • error with GLM modeling costs and obtaining predicted means.

    Hello . I am modeling costs and have balanced covariates using ebalance. The glm runs but when I call for adjusted predicted means I get an error.

    GLM:
    glm total_cost_2015 pcp_vs_er_index spine_surgery mental sex_rc age neck chronic_pain smoking obesity i.lumbar_surgery_history i.cervical_surgery_history i.sud ///
    median_incom elixhauser_score i.married_rc i.latino i.urban i.hsvscoll ///
    i.high_dp_rc i.muscle_relaxants i.nsaids i.opioid i.oral_steroid m_total_visit [pweight=_webal] if insur == 0 & education < 5 & high_dp_rc <2 ///
    & married_rc <2 & latino < 2 & urban < 2, link(log) family(gamma)

    Pred means:
    adjust, by(pcp_vs_er_index) exp ci

    ERROR: 0b: operator invalid

    When I don't include the covariates and run the glm with the weights, I get the predicted costs just fine but not when I run the glm with the covariates. Below are partial variables limited by the number of accepted variables by dataex.

    I am looking for help on the ERROR on getting the predicted mean costs. Thanks for your help. Please let me know if more information is needed. I consulted Stata help but am still stymied.

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(total_cost_2015 pcp_vs_er_index spine_surgery mental sex_rc age neck chronic_pain smoking obesity lumbar_surgery_history cervical_surgery_history sud) long median_income float elixhauser_score
     1759.808 1 0 1 0 63 0 0 1 0 0 0 1  52517 5
      2053.89 1 0 0 1 29 0 0 0 0 0 0 0  63910 0
        76.44 0 0 0 0 49 1 0 0 0 0 0 0  67037 0
            0 1 0 0 1 41 0 0 0 0 0 0 0  53324 0
     447.5552 0 0 1 0 44 0 1 0 0 0 0 0  60172 1
            0 1 0 0 1 64 0 0 0 0 0 0 0  45605 1
     1438.041 1 0 0 1 63 0 0 0 0 0 0 0  63155 0
            0 0 0 0 0 55 1 0 0 0 0 0 0  41336 2
    2090.4058 0 0 0 0 50 0 0 0 0 0 0 0  56883 1
     5298.303 1 0 0 0 53 1 0 0 0 0 0 0  96005 0
            0 1 0 0 0 41 1 0 0 0 0 0 0  59393 0
    3474.8455 1 0 0 1 30 0 0 0 0 0 0 0  79000 0
            0 1 0 0 0 50 0 0 1 0 0 0 1  35859 2
     6101.723 1 1 0 1 58 0 0 0 0 0 0 0  58915 0
    220.09624 1 0 0 0 50 0 0 0 0 0 0 0  34350 1
        42.63 1 0 0 1 47 0 0 0 0 0 0 0  61393 0
     856.7705 0 0 0 0 23 0 0 0 0 0 0 0  44668 0
            0 1 0 0 1 46 0 0 0 0 0 0 0  70294 0
     12.09991 1 0 1 0 33 0 0 0 0 0 0 0  39460 1
    160.26825 1 0 0 0 21 0 0 0 0 0 0 0  28837 1
            0 0 0 1 1 18 0 0 1 0 0 0 1  58594 0
            0 1 0 0 0 54 1 0 0 0 0 0 0  74133 1
    173.51897 1 0 0 1 62 0 1 0 0 0 0 0  66019 1
     647.1835 1 0 1 0 52 0 0 1 0 0 0 1  66941 1
            0 1 0 0 1 37 0 0 0 0 0 0 0  69194 0
            0 1 0 1 1 37 0 0 0 0 0 0 0  91660 0
     3.636033 1 0 0 1 61 0 0 0 0 0 0 0  48348 0
            0 1 0 0 0 61 0 0 1 0 0 0 1  44536 1
            0 1 0 1 0 47 0 0 0 0 0 0 0  60671 0
            0 1 0 1 0 50 0 0 0 0 0 0 0  26305 3
            0 1 0 0 0 30 0 0 0 0 0 0 0  67564 0
            0 1 0 1 1 44 0 0 0 0 0 0 0  45909 1
            0 0 0 1 0 51 0 1 1 0 0 0 1  23618 6
       727.45 1 0 0 0 29 0 0 0 0 0 0 0  46624 0
     53.26788 1 0 0 0 21 0 0 0 0 0 0 0  64293 0
            0 1 0 1 0 47 0 0 0 0 0 0 0  38779 2
            0 1 0 1 1 38 0 0 0 0 0 0 0  32444 2
    280.10883 1 0 1 0 59 1 1 0 0 0 0 0  46624 4
            0 1 0 0 1 46 0 0 0 0 0 0 0  61324 0
            0 1 0 1 0 22 0 0 0 0 0 0 0  49493 0
    1661.5273 1 0 1 0 59 0 0 0 0 0 0 0  76442 2
    304.65915 1 0 0 0 23 0 0 0 0 0 0 0  64828 0
     82.95205 1 0 1 0 33 0 0 0 1 0 0 0  71736 3
     410.8057 1 0 1 0 38 0 0 0 0 0 0 1  66941 2
        242.9 0 0 0 0 26 0 0 1 0 0 0 1  43635 0
     3020.458 1 0 0 0 55 1 0 0 0 1 1 0  63077 0
            0 1 0 1 0 47 1 0 0 0 0 0 0  42981 1
            0 0 0 0 0 39 0 0 0 0 0 0 0  71048 0
     691.6946 0 0 0 1 38 0 1 0 0 0 0 0  35966 0
     15.10061 1 0 1 0 44 1 0 0 0 0 0 0  40040 0
            0 0 0 0 0 31 1 0 0 0 0 0 0  58482 0
            0 0 0 1 0 30 0 0 0 0 0 0 0  59390 1
    105.47048 0 0 0 1 59 0 1 0 0 0 0 0  49479 2
            0 1 0 0 0 41 0 0 0 0 0 0 0  67564 1
            0 1 0 1 1 35 0 1 0 1 0 0 1  64583 5
            0 1 0 0 0 54 0 0 1 0 0 0 1  43241 3
     92.43604 1 0 0 1 43 0 0 0 0 0 0 0  43024 0
    180.71083 1 0 1 0 38 1 0 0 0 0 0 0  70240 1
            0 1 0 0 0 55 0 0 0 0 0 0 0  45679 1
            0 1 0 0 1 32 1 0 0 0 0 0 0  53524 0
            0 0 0 0 1 63 0 1 0 0 0 0 1  44797 5
      2275.39 1 1 1 0 43 0 0 0 0 0 0 0  63345 1
            0 1 0 0 1 18 0 0 0 0 0 0 0  91071 0
            0 1 0 0 0 57 0 0 0 0 0 0 0  64069 1
            0 1 0 0 0 33 0 0 0 0 0 0 0  51364 0
            0 1 0 0 1 36 0 0 0 0 0 0 0  81103 0
       110.09 1 0 0 0 24 0 0 1 0 0 0 0  31667 1
     832.7615 1 0 1 0 58 0 0 0 0 0 0 0  64792 1
    3780.7544 0 0 0 0 47 0 0 0 0 0 0 0  62768 0
     508.4539 1 0 0 0 56 1 0 0 0 0 0 0 108294 0
       128.44 1 0 0 1 44 0 0 0 0 0 0 0  41087 0
            0 0 0 1 1 58 0 0 0 0 0 0 0  74178 1
     86.07298 1 0 0 0 23 0 0 0 0 0 0 0  48821 0
            0 1 0 0 1 63 1 0 0 0 0 0 0  97500 1
     278.7536 1 0 1 1 27 0 0 0 0 0 0 0  53478 1
     944.8231 1 0 0 1 24 0 0 0 0 0 0 0  46017 0
    258.98654 1 0 0 0 62 0 0 0 0 0 0 0  53324 2
            0 1 0 1 0 57 0 0 0 0 0 0 0  68257 3
            0 0 0 1 1 38 1 0 1 0 0 0 1  33782 2
            0 1 0 0 1 47 0 0 0 0 0 0 0  83260 1
    128.13986 1 0 0 1 50 1 0 0 0 0 0 0  59393 0
            0 1 0 0 1 48 1 0 0 0 0 0 0  48455 0
    128.72566 1 0 0 1 41 1 0 0 0 0 0 0  55652 0
     240.3777 1 0 0 0 41 0 1 0 0 0 0 0  80795 0
            0 1 0 0 0 26 0 0 0 0 0 0 0  90341 0
            0 0 0 0 0 42 0 0 0 0 0 0 0  71402 0
            0 1 0 0 0 49 0 0 0 0 0 0 0  42891 0
            0 1 0 1 0 47 0 0 0 0 0 0 0  54368 1
            0 1 0 0 1 18 0 0 0 0 0 0 0  90208 0
      153.784 1 0 0 0 58 0 0 0 0 0 0 0  53524 5
            0 1 0 0 0 61 0 0 0 0 0 0 0  51682 2
            0 1 0 0 0 58 1 0 0 1 0 0 0  42981 7
     1432.617 1 0 0 1 40 1 0 0 0 0 0 0  43175 0
      2452.15 1 0 1 0 29 0 0 0 0 0 0 0  71048 1
            0 1 0 0 1 19 0 0 0 0 0 0 0  95106 0
     3409.565 1 0 0 0 58 0 0 0 1 0 0 0  50327 2
     4386.179 1 0 0 1 32 1 0 0 0 0 0 0  63910 0
            0 0 0 0 1 24 0 0 1 0 0 0 1  57400 0
    33.596954 1 0 0 0 57 1 0 0 0 0 0 0  80795 0
       376.05 1 0 0 1 55 0 0 1 0 0 0 1  32353 0
    end
    label values sex_rc sexlab
    label def sexlab 0 "Female", modify
    label def sexlab 1 "Male", modify

  • #2
    Read -help adjust-, where you will find near the top:
    [quote]
    adjust has been superseded by margins. Except for adjust's generate() and stdf options, the margins command can do everything that adjust did and more. margins
    syntax differs from adjust; see margins. adjust continues to work but does not support factor variables and will often fail if you do not run your estimation
    command under version control, with the version set to less than 11. This help file remains to assist those who encounter an adjust command in old do-files and
    programs
    [/code]

    Comment

    Working...
    X