Pingouinche
☆    

France,
2009-08-19 13:39
(6138 d 15:06 ago)

(edited on 2009-08-19 16:21)
Posting: # 4061
Views: 13,058
 

 2-sequence, 2-period, 2-trt crossover design (R, SAS) [Software]

Hello,

I'm new at BA/BE studies and I don't understand very well how to analyze a crossover experiment with R or SAS.

I'm trying to replicate the results I've read in a book (Design and analysis of bioavailability and bioequivalence studies): a complete example is proposed in section 3.6, data is p.73 and the classic ANOVA table I want to obtain is p.78.

I would like to know how I can obtain such an ANOVA table with R or SAS, with inter- and intra- source of variations separated.

I don't manage to write properly the model, in order to make SAS or R understand that each subject has two measures, and that some factors have to be tested between subject, and others within subjects.

Do you a have a document, or a code "ready to use" which could help me to replicate the results of the book ?

Thanks !


Edit: Subject line changed. [Helmut]
Pingouinche
☆    

France,
2009-08-19 18:21
(6138 d 10:25 ago)

@ Pingouinche
Posting: # 4064
Views: 10,387
 

 2-sequence, 2-period, 2-trt crossover design (R, SAS)

❝ Edit: Subject line changed. [Helmut]


Yes, sorry :-P

More precisely : with the (R) command
anova.table=lm(Result ~ Sequence + Subject:Sequence + Period + Drug, data=crossover)
I get this table :
Analysis of Variance Table

Response: Result
                 Df  Sum Sq Mean Sq F value    Pr(>F)   
Sequence          1   555.7   555.7  4.4106    0.0474 * 
Periode           1     0.9     0.9  0.0074    0.9324   
Drug              1     0.9     0.9  0.0074    0.9324   
Sequence:Subject 22 15553.4   707.0  5.6110 7.586e-05 ***
Residuals        22  2771.9   126.0                     
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

This new ANOVA table has approximately the same structure as the table in the book, but it is not the good syntax/answer...

Does someone have an idea? :confused:
Helmut
★★★
avatar
Homepage
Vienna, Austria,
2009-08-19 19:05
(6138 d 09:41 ago)

@ Pingouinche
Posting: # 4065
Views: 10,535
 

 R, SAS- codes

Dear Pingouinche,

sorry, but I'm short in time (sometimes I have to work). ;-)

You don’t have to reinvent the wheel!
Chow and Liu’s book gives SAS-code for a 2×2×2 design in the annex. Another one is given in Patterson's/Jones' book.
For S-Plus code see this post (Pikounis); needs some (a few) modifications for [image].
There’s the wonderful bioequivalence package bear for [image]; just have a look in the forum’s category R for BE/BA for a download link, a history of the development, and coding examples.

Dif-tor heh smusma 🖖🏼 Довге життя Україна! [image]
Helmut Schütz
[image]

The quality of responses received is directly proportional to the quality of the question asked. 🚮
Science Quotes
Pingouinche
☆    

France,
2009-08-20 00:20
(6138 d 04:25 ago)

@ Helmut
Posting: # 4067
Views: 10,360
 

 R, SAS- codes

❝ sorry, but I’m short in time (sometimes I have to work). ;-)


Yes, I can understand you have to work (just a little :-D) !

You don’t have to reinvent the wheel!

❝ Chow and Liu’s book gives SAS-code for a 2×2×2 design in the annex.


Indeed, there is probably the SAS-code on the book, but... Unfortunately, I don't have the book and the code is not included in the extracts available on Google Books...
Precisely, I'd like to know their code, because whatever I do, I don't manage to obtain the same ANOVA table as them !
Helmut
★★★
avatar
Homepage
Vienna, Austria,
2009-08-20 03:12
(6138 d 01:33 ago)

@ Pingouinche
Posting: # 4068
Views: 10,338
 

 R, SAS- codes

[image]Dear Pingouinche!

❝ Indeed, there is probably the SAS-code on the book,

                   ^^^^^^
The probability is close to 1 (unless you buy a misprint or somebody has ripped these pages out).

❝ Unfortunately, I don't have the book and the code is not included in the extracts available on Google Books...


No? Would you mind looking at page 560? OK, the interesting ones are 561-562. :-D

❝ Precisely, I'd like to know their code, because whatever I do, I don't manage to obtain the same ANOVA table as them !


In your first post you said you read the book. Fine. But f…g Google Books is not a source to gain knowlege from - at least nobody can ‘read a book’ there. The third edition was published this year. If you are with a company which can’t afford a book and give you enough time to study it, change the company. Quickly! If you are a poor fellow, maybe you can get the second edition cheaper or even a used copy. If you are a student, go to your library. Or get a copy of pages 559-576 (2nd ed, 691-714 3rd ed.) from a remote reference provider. It’s even possible to get their ANOVA-table up and running in M$-Excel (see the screenshot in this post). Or search this forum (codes for both SAS and [image] are available).
Sorry for the harsh reply, but please do you homework first. :cool:

See also this post for something you may check.

Dif-tor heh smusma 🖖🏼 Довге життя Україна! [image]
Helmut Schütz
[image]

The quality of responses received is directly proportional to the quality of the question asked. 🚮
Science Quotes
Pingouinche
☆    

France,
2009-08-20 11:19
(6137 d 17:26 ago)

@ Helmut
Posting: # 4073
Views: 10,281
 

 R, SAS- codes

❝ If you are a student, go to your library.


Indeed, I am. Mathematician. Doing a short work experience in PK/PD for the summer.
But the poor library of my little university: 1) is closed, 2) doesn't have any book an BA/BE anyway. :-P
I know Google Books is not the best way to learn BA/BE tests, but for me, it's simply the only way.

I'll find something... Thanks.
yjlee168
★★★
avatar
Homepage
Kaohsiung, Taiwan,
2009-08-19 20:42
(6138 d 08:03 ago)

@ Pingouinche
Posting: # 4066
Views: 10,369
 

 2-sequence, 2-period, 2-trt crossover design (R, SAS)

Dear Pingouinche,

❝ [..] Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

❝ This new ANOVA table has approximately the same structure as the table in the book, but it is not the good syntax/answer...

I'd like to help here, but I don't know which part is not the good syntax/answer. :ponder: The above ANOVA table is quite self-explained.

All the best,
-- Yung-jin Lee
bear v2.9.6:- created by Hsin-ya Lee & Yung-jin Lee
Kaohsiung, Taiwan https://www.pkpd168.com/bear
Download link (updated) -> here
Helmut
★★★
avatar
Homepage
Vienna, Austria,
2009-08-20 03:19
(6138 d 01:26 ago)

@ yjlee168
Posting: # 4069
Views: 10,603
 

 2-sequence, 2-period, 2-trt crossover design (R, SAS)

Hi Yung-jin!

❝ […] The above ANOVA table is quite self-explained.


Yes, but have you noticed that results for period and treatment are numerically identical? Maybe there’s a mistake in the coding of the dataset (levels?).

Dif-tor heh smusma 🖖🏼 Довге життя Україна! [image]
Helmut Schütz
[image]

The quality of responses received is directly proportional to the quality of the question asked. 🚮
Science Quotes
yjlee168
★★★
avatar
Homepage
Kaohsiung, Taiwan,
2009-08-20 14:02
(6137 d 14:44 ago)

@ Helmut
Posting: # 4075
Views: 10,334
 

 2-sequence, 2-period, 2-trt crossover design (R, SAS)

Dear Helmut,

❝ Yes, but have you noticed that results for period and treatment are numerically identical?


You're right! I really did NOT notice that part. A typical anova output obtained from bear is shown as follows.
  Dependent Variable: lnAUC0t                                               

Type I SS
Analysis of Variance Table

Response: lnAUC0t
          Df  Sum Sq Mean Sq F value Pr(>F)
seq        1 0.01876 0.01876  0.5138 0.4872
prd        1 0.00789 0.00789  0.2162 0.6503
drug       1 0.04216 0.04216  1.1546 0.3037
seq:subj  12 0.29718 0.02477  0.6782 0.7443
Residuals 12 0.43818 0.03652               

Type III SS
Single term deletions

Model:
lnAUC0t ~ seq + subj:seq + prd + drug
         Df Sum of Sq     RSS     AIC F value  Pr(F)
<none>                  0.438 -84.405               
prd       1     0.008   0.446 -85.905  0.2162 0.6503
drug      1     0.042   0.480 -83.833  1.1546 0.3037
seq:subj 12     0.297   0.735 -93.909  0.6782 0.7443

Tests of Hypothesis for SUBJECT(SEQUENCE) as an error term

Error: subj
          Df   Sum Sq  Mean Sq F value Pr(>F)
prd:drug   1 0.018762 0.018762  0.7576 0.4012
Residuals 12 0.297182 0.024765               

Error: Within
          Df  Sum Sq Mean Sq F value Pr(>F)
prd        1 0.00789 0.00789  0.2162 0.6503
drug       1 0.04216 0.04216  1.1546 0.3037
Residuals 12 0.43818 0.03652               

Intra_subj. CV = 100*sqrt(abs(exp(MSResidual)-1)) = 19.2847 %
Inter_subj. CV = 100*sqrt(abs(exp((MSSubject(seq)-MSResidual)/2)-1)) = 7.6536 %
    MSResidual = 0.03651522
MSSubject(seq) = 0.02476518


❝ Maybe there’s a mistake in the coding of the dataset (levels?).


The period and drug (treatment) could be coded incorrectly in the dataset.

All the best,
-- Yung-jin Lee
bear v2.9.6:- created by Hsin-ya Lee & Yung-jin Lee
Kaohsiung, Taiwan https://www.pkpd168.com/bear
Download link (updated) -> here
yjlee168
★★★
avatar
Homepage
Kaohsiung, Taiwan,
2009-08-20 14:17
(6137 d 14:29 ago)

@ Pingouinche
Posting: # 4076
Views: 10,332
 

 2-sequence, 2-period, 2-trt crossover design (R, SAS)

Dear Pingouinche,

Could you show us your dataset? Just part of it will be enough.

❝ Response: Result
❝                  Df  Sum Sq Mean Sq F value    Pr(>F) 
❝ Sequence          1   555.7   555.7  4.4106    0.0474 *
❝ Periode           1     0.9     0.9  0.0074    0.9324
❝ [...]

Periode? Did you edit the output when you're posting it or was it from the original output? Thanks.

All the best,
-- Yung-jin Lee
bear v2.9.6:- created by Hsin-ya Lee & Yung-jin Lee
Kaohsiung, Taiwan https://www.pkpd168.com/bear
Download link (updated) -> here
UA Flag
Activity
 Admin contact
23,653 posts in 4,991 threads, 1,570 registered users;
123 visitors (0 registered, 123 guests [including 19 identified bots]).
Forum time: 04:46 CEST (Europe/Vienna)

In theory, there is no difference between theory and practice.
But, in practice, there is.    Jan L.A. van de Snepscheut

The Bioequivalence and Bioavailability Forum is hosted by
BEBAC Ing. Helmut Schütz
HTML5