Announcement

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

  • interpretation of glm fam(gaussian) link(log)

    Dear stata team,
    I have been looking for a way to model my skewed data and I read that using glm family(gaussian) link(log) could be a reasonable approach. I am not sure however about the interpretation. if I add eform, will the interpretation be the geometric mean ratio? if not, then what be a code for modelling the geometric mean ratio?

    thank you very much

  • #2
    Originally posted by Umama Afr View Post
    using glm family(gaussian) link(log) . . .. if I add eform, will the interpretation be the geometric mean ratio? if not, then what be a code for modelling the geometric mean ratio?
    See below.

    .ÿ
    .ÿclearÿ*

    .ÿ
    .ÿsetÿseedÿ1416634

    .ÿquietlyÿsetÿobsÿ500

    .ÿ
    .ÿgenerateÿbyteÿxÿ=ÿmod(_n,ÿ2)

    .ÿgenerateÿdoubleÿyÿ=ÿruniform()

    .ÿ
    .ÿ*
    .ÿ*ÿAnswerÿtoÿfirstÿquestion
    .ÿ*
    .ÿquietlyÿameansÿyÿifÿ!x

    .ÿtempnameÿmean0

    .ÿscalarÿdefineÿ`mean0'ÿ=ÿr(mean_g)

    .ÿquietlyÿameansÿyÿifÿx

    .ÿdisplayÿinÿsmclÿasÿtextÿ"Geometricÿmeanÿratioÿ=ÿ"ÿasÿresultÿr(mean_g)ÿ/ÿ`mean0'
    Geometricÿmeanÿratioÿ=ÿ1.1562465

    .ÿ
    .ÿglmÿyÿi.x,ÿfamily(gaussian)ÿlink(log)ÿeformÿnolog

    GeneralizedÿlinearÿmodelsÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNo.ÿofÿobsÿÿÿÿÿÿ=ÿÿÿÿÿÿÿÿ500
    Optimizationÿÿÿÿÿ:ÿMLÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿResidualÿdfÿÿÿÿÿ=ÿÿÿÿÿÿÿÿ498
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿScaleÿparameterÿ=ÿÿÿ.0829651
    Devianceÿÿÿÿÿÿÿÿÿ=ÿÿ41.31661402ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ(1/df)ÿDevianceÿ=ÿÿÿ.0829651
    Pearsonÿÿÿÿÿÿÿÿÿÿ=ÿÿ41.31661402ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ(1/df)ÿPearsonÿÿ=ÿÿÿ.0829651

    Varianceÿfunction:ÿV(u)ÿ=ÿ1ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ[Gaussian]
    Linkÿfunctionÿÿÿÿ:ÿg(u)ÿ=ÿln(u)ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ[Log]

    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿAICÿÿÿÿÿÿÿÿÿÿÿÿÿ=ÿÿÿ.3525337
    Logÿlikelihoodÿÿÿ=ÿ-86.13341589ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿBICÿÿÿÿÿÿÿÿÿÿÿÿÿ=ÿÿ-3053.558

    ------------------------------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿOIM
    ÿÿÿÿÿÿÿÿÿÿÿyÿ|ÿÿÿÿÿexp(b)ÿÿÿStd.ÿErr.ÿÿÿÿÿÿzÿÿÿÿP>|z|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
    -------------+----------------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿ1.xÿ|ÿÿÿ1.094607ÿÿÿ.0570213ÿÿÿÿÿ1.74ÿÿÿ0.083ÿÿÿÿÿ.9883629ÿÿÿÿ1.212271
    ÿÿÿÿÿÿÿ_consÿ|ÿÿÿ.4736638ÿÿÿÿ.018217ÿÿÿ-19.43ÿÿÿ0.000ÿÿÿÿÿ.4392716ÿÿÿÿ.5107487
    ------------------------------------------------------------------------------

    .ÿ
    .ÿ*
    .ÿ*ÿAnswerÿtoÿsecondÿquestion
    .ÿ*
    .ÿgenerateÿdoubleÿln_yÿ=ÿln(y)

    .ÿquietlyÿregressÿln_yÿi.xÿ/*ÿotherÿpredictorsÿ*/

    .ÿnlcomÿGMR:ÿexp(_b[1.x])

    ÿÿÿÿÿÿÿÿÿGMR:ÿÿexp(_b[1.x])

    ------------------------------------------------------------------------------
    ÿÿÿÿÿÿÿÿln_yÿ|ÿÿÿÿÿÿCoef.ÿÿÿStd.ÿErr.ÿÿÿÿÿÿzÿÿÿÿP>|z|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
    -------------+----------------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿGMRÿ|ÿÿÿ1.156246ÿÿÿ.1069653ÿÿÿÿ10.81ÿÿÿ0.000ÿÿÿÿÿ.9465984ÿÿÿÿ1.365895
    ------------------------------------------------------------------------------

    .ÿ
    .ÿ//ÿYouÿcanÿdoÿsmearingÿifÿyouÿwant,ÿbutÿitÿwon'tÿmatterÿifÿyouÿcanÿassumeÿhomoscedasticity
    .ÿpredictÿdoubleÿmu,ÿxb

    .ÿpredictÿdoubleÿre,ÿresiduals

    .ÿgenerateÿdoubleÿereÿ=ÿexp(re)

    .ÿsummarizeÿere,ÿmeanonly

    .ÿgenerateÿdoubleÿmereÿ=ÿr(mean)

    .ÿgenerateÿdoubleÿsmearÿ=ÿexp(mu)ÿ/ÿmere

    .ÿsummarizeÿsmearÿifÿ!x,ÿmeanonly

    .ÿscalarÿdefineÿ`mean0'ÿ=ÿr(mean)

    .ÿsummarizeÿsmearÿifÿx,ÿmeanonly

    .ÿdisplayÿinÿsmclÿasÿtextÿ"Geometricÿmeanÿratioÿ=ÿ"ÿasÿresultÿr(mean)ÿ/ÿ`mean0'
    Geometricÿmeanÿratioÿ=ÿ1.1562465

    .ÿ
    .ÿexit

    endÿofÿdo-file


    .


    Question for you: why do you want a geometric mean ratio instead of the generalized linear model fit?

    Comment


    • #3
      Also, (quite) generally speaking, as a ‘way to model skewed data’, the gamma family or the use power is something to think about.
      Best regards,

      Marcos

      Comment


      • #4
        I agree with Marcos that you might consider a gamma family assumption. Since the model in levels is
        Code:
        y = exp(xb)*u
        gamma is actually a natural baseline GLM family assumption since it specifies the conditional variance as proportional to the square of the conditional mean. You would still probably want to do robust covariance estimation in case the assumption is incorrect, but that would be true in any event.

        Comment

        Working...
        X