Announcement

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

  • Accounting for baseline data with pkshape and pkcross

    I am preparing to analyze a cross-over trial of flavored vs. unflavored cigars on heaviness of cigar smoking. In Week 1, participants used their own brand of cigars as normal. Then they were randomized to receive either flavored or unflavored cigars, which they used during Week 2. Then, they crossed over and received the other cigar type. I am attempting to use pkshape in order to use pkcross. I put my data into wide format:

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input byte pid float randomization long cigartype1 float(tlfb_cig_heavy1 tlfb_cigar_heavy1 sex flavoredcigar) long cigartype2 float(tlfb_cig_heavy2 tlfb_cigar_heavy2) long cigartype3 float(tlfb_cig_heavy3 tlfb_cigar_heavy3)
     1 0 0   135    17 0 1 1  31    4 2  24   4
     5 1 0   135    54 0 0 2  27   11 1  21   8
     7 0 0   562    49 1 1 1  85 10.5 2  70 5.5
     8 0 0   360    41 0 0 1  80   11 2  80  13
     9 0 0   900    74 0 1 1 220   20 2 225  17
    10 1 0   110    55 0 1 2  16   11 1  16  15
    11 1 0   600    20 0 1 2 140    6 1 140   6
    12 1 0    11   8.5 0 1 2   0    5 1   0   5
    13 0 0   610 115.5 0 1 1   0   24 2   0  24
    16 1 0   311    13 0 0 2  72    5 1  70   7
    17 0 0  1155   118 0 1 1 270   16 2 140  17
    18 1 0   102    12 1 1 2  29    6 1  26   6
    19 0 0   520    24 0 1 1 160    7 2 120  11
    20 0 0   300   300 1 1 1  21   28 2  46  28
    21 0 0   3.5   8.5 0 1 1   1    2 2   1   2
    22 1 0 159.5   362 0 1 2   2 67.5 1   0  81
    24 1 0    15    28 0 1 2   2    5 1   1   6
    25 1 0   160   160 1 1 2  11   28 1   7  29
    26 1 0    15   300 0 1 2   6   60 1   0  76
    27 1 0   600     8 0 1 2 140  4.5 1   7   0
    end
    label values randomization rand1
    label def rand1 0 "Flavored First", modify
    label def rand1 1 "Unflavored First", modify
    label values cigartype1 type1
    label values cigartype2 type1
    label values cigartype3 type1
    label def type1 0 "Own brand", modify
    label def type1 1 "Flavored", modify
    label def type1 2 "Unflavored", modify
    label values sex sex1
    label def sex1 0 "Male", modify
    label def sex1 1 "Female", modify
    label values flavoredcigar noyes
    label def noyes 0 "No", modify
    label def noyes 1 "Yes", modify
    randomization is their assigned sequence: flavored first then unflavored cigar, or unflavored first then flavored cigar.
    cigartype is the type of cigar they were assigned to. cigartype1 is the cigar they were assigned to in Week 1 (own brand by default), cigartype2 is the assigned cigar in Week 2, cigartype 3 is the assigned cigar in Week 3
    sex is their sex at baseline
    flavoredcigar is whether or not they reported preferring a flavored cigar (as opposed to unflavored) at baseline
    tlfb_cig_heavy is the heaviness of their cigarette smoking (# days smoked cigarette X mean cigarettes smoked on smoking days). tlfb_cig_heavy1 is the heaviness of their cigarette smoking in Week 1, etc.
    tlfb_cig_heavy is the heaviness of their cigar smoking, same as above.

    When I ran pkshape, I received an error message:

    Code:
    . pkshape pid randomization cigartype1 tlfb_cig_heavy1 tlfb_cigar_heavy1 sex flavoredcigar cigartype2 tlfb_cig_he
    > avy2 tlfb_cigar_heavy2 cigartype3 tlfb_cig_heavy3 tlfb_cigar_heavy3, order(FlUn UnFl)
    note: ignoring value labels for numeric sequence variable randomization and using treatment codes specified in
          option order()
    the number of periods in the data and in option order() does not agree
    r(198);
    I also ran the command and included baseline in order:

    Code:
    . pkshape pid randomization cigartype1 tlfb_cig_heavy1 tlfb_cigar_heavy1 sex flavoredcigar cigartype2 tlfb_cig_he
    > avy2 tlfb_cigar_heavy2 cigartype3 tlfb_cig_heavy3 tlfb_cigar_heavy3, order(OB FlUn UnFl)
    note: ignoring value labels for numeric sequence variable randomization and using treatment codes specified in
          option order()
    the number of sequences in input sequence variable randomization and in option order() does not agree
    r(198);
    I believe the problem is that I am telling Stata baseline (own brand) is a third treatment, but that is not the case. I don't want to drop week 1 data (baseline). Is there a way to account for it in the pk commands?

    Thank you for your assistance.
    Last edited by Erin Mead-Morse; 11 Jul 2023, 15:09.

  • #2
    UPDATE: I dropped the baseline visit, and included only one outcome variable. And now the command pkshape runs well

    Code:
    . pkshape pid randomization tlfb_cigar_heavy1 tlfb_cigar_heavy2, order(FU UF)
    note: ignoring value labels for numeric sequence variable randomization and using treatment codes specified in
          option order()
    I supposed that means that only one outcome variable can be included? I do not see that written explicitly in the help file for the command. So if I need to investigate the carryover or sequence effects, I need to create a data set for each outcome separately? Thank you.

    Comment


    • #3
      Originally posted by Erin Mead-Morse View Post
      I supposed that means that only one outcome variable can be included? I do not see that written explicitly in the help file for the command.
      I'm guessing that that's true, and it's implied in the option outcome(newvar) that allows for only a new variable and not a stub for a new variable list. Also, the expected follow-on estimation command is ANOVA-based, which is for only a single outcome variable.

      So if I need to investigate the carryover or sequence effects, I need to create a data set for each outcome separately?
      Not really. pkshape is basically a convenience command for reshape and a conditional generate for the carryover variable. You can do that manually in two lines of code if you've set up your dataset in a manner that's compatible.

      Comment

      Working...
      X