Announcement

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

  • P value for trend

    I would be very grateful if someone could help me with the code for this - I'm reporting the incidence of stroke in patients with diabetes versus no diabetes in 5 year bands, and would like to calculate the P value for trend over time if possible. I've tried the ptrend command but I'm confused about the other syntax. My data looks something like this:

    Year Strokes in non-diabetics Strokes in diabetics
    2002-2007 238/72243 343/4030
    2007-2012 336/74945 282/4375
    2012-2017 431/76741 169/4809

    Thanks much in advance!

  • #2
    The intervals are ambiguous. Can you get annual data?

    Comment


    • #3
      Originally posted by Dearbhla Kelly View Post
      I . . . would like to calculate the P value for trend over time if possible.
      Take a look at the linear component of the orthogonal polynomial contrasts below.


      .ÿ
      .ÿversionÿ16.0

      .ÿ
      .ÿclearÿ*

      .ÿ
      .ÿinputÿstr9ÿepochÿlong(count01ÿcount0tÿcount11ÿcount1t)

      ÿÿÿÿÿÿÿÿÿepochÿÿÿÿÿÿÿcount01ÿÿÿÿÿÿÿcount0tÿÿÿÿÿÿÿcount11ÿÿÿÿÿÿÿcount1t
      ÿÿ1.ÿ"2002-2007"ÿ238ÿ72243ÿ343ÿ4030
      ÿÿ2.ÿ"2007-2012"ÿ336ÿ74945ÿ282ÿ4375
      ÿÿ3.ÿ"2012-2017"ÿ431ÿ76741ÿ169ÿ4809
      ÿÿ4.ÿend

      .ÿ
      .ÿencodeÿepoch,ÿgenerate(epo)ÿlabel(Epochs)

      .ÿforvaluesÿiÿ=ÿ0/1ÿ{
      ÿÿ2.ÿÿÿÿÿÿÿÿÿgenerateÿlongÿcount`i'0ÿ=ÿcount`i'tÿ-ÿcount`i'1
      ÿÿ3.ÿÿÿÿÿÿÿÿÿdropÿcount`i't
      ÿÿ4.ÿ}

      .ÿ
      .ÿquietlyÿreshapeÿlongÿcount0ÿcount1,ÿi(epo)ÿj(stk)

      .ÿquietlyÿreshapeÿlongÿcount,ÿi(epoÿstk)ÿj(dbs)

      .ÿ
      .ÿlogitÿstkÿi.epo##i.dbsÿ[fweight=count],ÿnolog

      LogisticÿregressionÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿ237,143
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿLRÿchi2(5)ÿÿÿÿÿÿÿÿ=ÿÿÿÿ2419.51
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿProbÿ>ÿchi2ÿÿÿÿÿÿÿ=ÿÿÿÿÿ0.0000
      Logÿlikelihoodÿ=ÿ-9364.0993ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿPseudoÿR2ÿÿÿÿÿÿÿÿÿ=ÿÿÿÿÿ0.1144

      ------------------------------------------------------------------------------
      ÿÿÿÿÿÿÿÿÿstkÿ|ÿÿÿÿÿÿCoef.ÿÿÿStd.ÿErr.ÿÿÿÿÿÿzÿÿÿÿP>|z|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
      -------------+----------------------------------------------------------------
      ÿÿÿÿÿÿÿÿÿepoÿ|
      ÿÿ2007-2012ÿÿ|ÿÿÿ.3093149ÿÿÿ.0848832ÿÿÿÿÿ3.64ÿÿÿ0.000ÿÿÿÿÿ.1429468ÿÿÿÿÿ.475683
      ÿÿ2012-2017ÿÿ|ÿÿÿÿ.535769ÿÿÿÿ.080925ÿÿÿÿÿ6.62ÿÿÿ0.000ÿÿÿÿÿ.3771589ÿÿÿÿ.6943791
      ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
      ÿÿÿÿÿÿÿ1.dbsÿ|ÿÿÿ3.337382ÿÿÿ.0860363ÿÿÿÿ38.79ÿÿÿ0.000ÿÿÿÿÿ3.168754ÿÿÿÿÿ3.50601
      ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
      ÿÿÿÿÿepo#dbsÿ|
      2007-2012#1ÿÿ|ÿÿ-.6096034ÿÿÿ.1190893ÿÿÿÿ-5.12ÿÿÿ0.000ÿÿÿÿ-.8430141ÿÿÿ-.3761927
      2012-2017#1ÿÿ|ÿÿ-1.473502ÿÿÿ.1259691ÿÿÿ-11.70ÿÿÿ0.000ÿÿÿÿ-1.720397ÿÿÿ-1.226607
      ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
      ÿÿÿÿÿÿÿ_consÿ|ÿÿÿ-5.71222ÿÿÿ.0649274ÿÿÿ-87.98ÿÿÿ0.000ÿÿÿÿ-5.839476ÿÿÿ-5.584965
      ------------------------------------------------------------------------------

      .ÿ
      .ÿ//ÿInÿtheÿoriginalÿestimationÿmetric
      .ÿcontrastÿp.epo#dbs

      Contrastsÿofÿmarginalÿlinearÿpredictions

      Marginsÿÿÿÿÿÿ:ÿasbalanced

      --------------------------------------------------------
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿÿÿÿdfÿÿÿÿÿÿÿÿchi2ÿÿÿÿÿP>chi2
      ---------------------+----------------------------------
      ÿÿÿÿÿÿÿÿÿÿÿÿÿepo#dbsÿ|
      ÿÿÿ(linear)ÿ(joint)ÿÿ|ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿÿÿÿ136.83ÿÿÿÿÿ0.0000
      (quadratic)ÿ(joint)ÿÿ|ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿÿÿÿÿÿ1.50ÿÿÿÿÿ0.2200
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿJointÿÿ|ÿÿÿÿÿÿÿÿÿÿ2ÿÿÿÿÿÿ137.39ÿÿÿÿÿ0.0000
      --------------------------------------------------------

      .ÿ
      .ÿ//ÿInÿtermsÿofÿproportions
      .ÿquietlyÿmarginsÿepo#dbs,ÿpost

      .ÿcontrastÿp.epo#dbs

      ContrastsÿofÿadjustedÿpredictionsÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿ237,143
      ModelÿVCEÿÿÿÿ:ÿOIM

      Expressionÿÿÿ:ÿPr(stk),ÿpredict()

      --------------------------------------------------------
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿÿÿÿdfÿÿÿÿÿÿÿÿchi2ÿÿÿÿÿP>chi2
      ---------------------+----------------------------------
      ÿÿÿÿÿÿÿÿÿÿÿÿÿepo#dbsÿ|
      ÿÿÿ(linear)ÿ(joint)ÿÿ|ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿÿÿÿ103.22ÿÿÿÿÿ0.0000
      (quadratic)ÿ(joint)ÿÿ|ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿÿÿÿÿÿ0.90ÿÿÿÿÿ0.3416
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿJointÿÿ|ÿÿÿÿÿÿÿÿÿÿ2ÿÿÿÿÿÿ117.31ÿÿÿÿÿ0.0000
      --------------------------------------------------------

      .ÿ
      .ÿexit

      endÿofÿdo-file


      .


      Nick is doubly right, by the way: not only do your intervals overlap, but it's not clear how the data came about (complex survey?) or whether a logistic model (e.g., binomial likelihood) is even appropriate.

      Comment

      Working...
      X