Announcement

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

  • Wald test for trends

    Hi! I'm new to STATA. I came across a paper that reported a Wald-test for trends p-value along with their logistic regression output (pasted below). Is it possible to do this test on STATA and if so how? Is this different from a Chi squared test for trends?

    Thank you so much!


    Click image for larger version

Name:	Screen Shot 2021-04-22 at 3.47.30 PM.png
Views:	1
Size:	134.1 KB
ID:	1605062


  • #2
    You could write to the authors to ask them how they did it, but one approach would be to examine the linear component of a set of orthogonal polynomial contrasts of the ordered categorical predictor after fitting the logistic regression model. It would be something along the lines of the following.
    Code:
    logit pos i.(age sex edu)
    contrast p.age, noeffects // examine the first (linear) component
    contrast p.edu, noeffects // ditto

    Comment


    • #3
      Joseph Coveney Thank you so much for your response, I will look into this. Do you know if this is different from doing a "testparm" post-estimation command after fitting the model? According to the STATA manual this is a Wald test of a linear hypothesis which sounds the most like "wald test for trend".
      Code:
      xi: logit HBsAg ///
       ib(first).univariate_age ///
       ib(last).urban_status ///
       ib(last).ses_grp ///
       ib(last).education_level ///
       ib(last).HivFinalResult /// 
       ib2.church_denomination ///
       ib(first).employment_sector /// 
       ib(last).literacy ///
       ib(first).non_regular_sex, or vce(robust)
      
      testparm i.non_regular_sex
      
      testparm i.literacy

      Comment


      • #4
        Originally posted by Adya Rao View Post
        Do you know if this is different from doing a "testparm" post-estimation command after fitting the model?
        Yes, a test of the linear component of the set of orthogonal polynomial contrasts is different from what -testparm- does. See below.

        Compare the test of the "(linear)" component after -contrast- with you you see after -testparm-. The latter is the same as the "Joint" test, that is, of the entire set, and not just of the (linear) trend.

        .ÿ
        .ÿversionÿ17.0

        .ÿ
        .ÿclearÿ*

        .ÿ
        .ÿsetÿseedÿ`=strreverse("1605335")'

        .ÿ
        .ÿquietlyÿsetÿobsÿ250

        .ÿ
        .ÿ#ÿdelimitÿ;
        delimiterÿnowÿ;
        .ÿforeachÿvarÿofÿnewlistÿ
        >ÿÿÿÿÿÿÿÿÿHBsAg
        >ÿÿÿÿÿÿÿÿÿurban_status
        >ÿÿÿÿÿÿÿÿÿHivFinalResultÿ{;
        ÿÿ2.ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿgenerateÿbyteÿ`var'ÿ=ÿrnormal()ÿ<ÿ0.5;
        ÿÿ3.ÿ};

        .ÿforeachÿvarÿofÿnewlist
        >ÿÿÿÿÿÿÿÿÿunivariate_age
        >ÿÿÿÿÿÿÿÿÿeducation_level
        >ÿÿÿÿÿÿÿÿÿses_grp
        >ÿÿÿÿÿÿÿÿÿchurch_denomination
        >ÿÿÿÿÿÿÿÿÿemployment_sector
        >ÿÿÿÿÿÿÿÿÿliteracy
        >ÿÿÿÿÿÿÿÿÿnon_regular_sexÿ{;
        ÿÿ2.ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿgenerateÿbyteÿ`var'ÿ=ÿruniformint(1,ÿ4);
        ÿÿ3.ÿ};

        .ÿquietlyÿlogitÿHBsAg
        >ÿÿÿÿÿÿÿÿÿib(first).univariate_age
        >ÿÿÿÿÿÿÿÿÿib(last).urban_status
        >ÿÿÿÿÿÿÿÿÿib(last).ses_grp
        >ÿÿÿÿÿÿÿÿÿib(last).education_level
        >ÿÿÿÿÿÿÿÿÿib(last).HivFinalResultÿ
        >ÿÿÿÿÿÿÿÿÿib2.church_denomination
        >ÿÿÿÿÿÿÿÿÿib(first).employment_sectorÿ
        >ÿÿÿÿÿÿÿÿÿib(last).literacy
        >ÿÿÿÿÿÿÿÿÿib(first).non_regular_sex;

        .ÿ#ÿdelimitÿcr
        delimiterÿnowÿcr
        .ÿ
        .ÿtestparmÿi.non_regular_sex

        ÿ(ÿ1)ÿÿ[HBsAg]2.non_regular_sexÿ=ÿ0
        ÿ(ÿ2)ÿÿ[HBsAg]3.non_regular_sexÿ=ÿ0
        ÿ(ÿ3)ÿÿ[HBsAg]4.non_regular_sexÿ=ÿ0

        ÿÿÿÿÿÿÿÿÿÿÿchi2(ÿÿ3)ÿ=ÿÿÿÿ0.51
        ÿÿÿÿÿÿÿÿÿProbÿ>ÿchi2ÿ=ÿÿÿÿ0.9171

        .ÿcontrastÿp.non_regular_sex,ÿnoeffects

        Contrastsÿofÿmarginalÿlinearÿpredictions

        Margins:ÿasbalanced

        ---------------------------------------------------
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿÿÿÿdfÿÿÿÿÿÿÿÿchi2ÿÿÿÿÿP>chi2
        ----------------+----------------------------------
        non_regular_sexÿ|
        ÿÿÿÿÿÿ(linear)ÿÿ|ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿÿÿÿÿÿ0.15ÿÿÿÿÿ0.6998
        ÿÿÿ(quadratic)ÿÿ|ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿÿÿÿÿÿ0.04ÿÿÿÿÿ0.8390
        ÿÿÿÿÿÿÿ(cubic)ÿÿ|ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿÿÿÿÿÿ0.25ÿÿÿÿÿ0.6181
        ÿÿÿÿÿÿÿÿÿJointÿÿ|ÿÿÿÿÿÿÿÿÿÿ3ÿÿÿÿÿÿÿÿ0.51ÿÿÿÿÿ0.9171
        ---------------------------------------------------

        .ÿ
        .ÿtestparmÿi.literacy

        ÿ(ÿ1)ÿÿ[HBsAg]1.literacyÿ=ÿ0
        ÿ(ÿ2)ÿÿ[HBsAg]2.literacyÿ=ÿ0
        ÿ(ÿ3)ÿÿ[HBsAg]3.literacyÿ=ÿ0

        ÿÿÿÿÿÿÿÿÿÿÿchi2(ÿÿ3)ÿ=ÿÿÿÿ5.16
        ÿÿÿÿÿÿÿÿÿProbÿ>ÿchi2ÿ=ÿÿÿÿ0.1601

        .ÿcontrastÿp.literacy,ÿnoeffects

        Contrastsÿofÿmarginalÿlinearÿpredictions

        Margins:ÿasbalanced

        ------------------------------------------------
        ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿÿÿÿdfÿÿÿÿÿÿÿÿchi2ÿÿÿÿÿP>chi2
        -------------+----------------------------------
        ÿÿÿÿliteracyÿ|
        ÿÿÿ(linear)ÿÿ|ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿÿÿÿÿÿ4.08ÿÿÿÿÿ0.0434
        (quadratic)ÿÿ|ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿÿÿÿÿÿ0.18ÿÿÿÿÿ0.6730
        ÿÿÿÿ(cubic)ÿÿ|ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿÿÿÿÿÿ0.80ÿÿÿÿÿ0.3701
        ÿÿÿÿÿÿJointÿÿ|ÿÿÿÿÿÿÿÿÿÿ3ÿÿÿÿÿÿÿÿ5.16ÿÿÿÿÿ0.1601
        ------------------------------------------------

        .ÿ
        .ÿexit

        endÿofÿdo-file


        .

        Comment

        Working...
        X