SlideShare ist ein Scribd-Unternehmen logo
1 von 18
Clinical data Analysis using R 
A case study
Dataset 
• Diastolic blood pressure (DBP) was measured (mm HG) in the 
supine position at baseline (i.e., DBP1) before randomization 
and monthly thereafter up to 4 months as indicated by 
DBP2,DBP3,DBP4 and DBP5. 
• Patients age and sex were recorded at baseline and represent 
potential covariates. 
• primary objective is to test whether treatment A (new drug) 
may be effective in lowering DBP as compared to B (placebo) 
and to describe changes in DBP across the times at which it 
was measured.
Dataset
Statistical Models for Treatment 
Comparisons 
A) Student's t-tests :test the null hypothesis that the means of the two 
treatment groups are the same 
H0 : μ1= μ2 
The test statistic is constructed as: 
• yi are the treatment group means of the observed data, and s is the pooled 
standard error . Under the null hypothesis, this t -statistic has a Student's t – 
distribution with n1 + n2 - 2 degrees of freedom. 
confidence interval (CI)
Parameter Violations 
• Unequal variances: Welch test in R (t.test) 
v degrees of freedom calculated as 
• Non-normal data: 
Mann Whitney Wilcoxon (MWW) U-test (also called Wilcoxon rank-sum test, or 
Wilcoxon{Mann{Whitney test). In R (wilcox.test) . 
• Bootstrap resampling: 
Iteratively resampling the data with replacement, calculating the value of the statistic 
for each sample obtained, and generating the resampling distribution. In R Use 
library(bootstrap)
One-Way Analysis of Variance 
(ANOVA) 
• For comparisons involving more than two treatment groups, 
F -tests deriving ANOVA is used. 
Note : If the null hypothesis fails to be rejected, the analysis ends and it is concluded that there is 
insufficient evidence to conclude that the treatment group means differ. However, if the null 
hypothesis is rejected, the next logical step is to investigate which levels differ by using so-called 
multiple comparisons. We use Tukey's honest significant difference (HSD). 
• The ANOVA procedure is implemented in the R system as aov() and 
Tukey’s HSD procedure as TukeyHSD() .
Data Analysis of Diastolic Pressure data in R 
>dat = read.csv("dbpdata.csv",header=TRUE) 
# create the difference 
>dat$diff = dat$DBP5-dat$DBP1 
>boxplot(diff~TRT, dat, xlab="Treatment", ylab="DBP Changes")
Perform t.test 
> t.test(diff~TRT, dat, var.equal=T) 
Two Sample t-test 
data: diff by TRT 
t = -12.1504, df = 38, p-value = 1.169e-14 
alternative hypothesis: true difference in means is not equal to 0 
95 percent confidence interval: 
-12.132758 -8.667242 
sample estimates: 
mean in group A mean in group B 
-15.2 -4.8 
> t.test(diff~TRT, dat, var.equal=F) 
Welch Two Sample t-test 
data: diff by TRT 
t = -12.1504, df = 36.522, p-value = 2.149e-14 
alternative hypothesis: true difference in means is not equal to 0 
95 percent confidence interval: 
-12.135063 -8.664937 
sample estimates: 
mean in group A mean in group B 
-15.2 -4.8
More tests 
> var.test(diff~TRT, dat) 
F test to compare two variances 
data: diff by TRT 
F = 1.5036, num df = 19, denom df = 19, p-value = 0.3819 
alternative hypothesis: true ratio of variances is not equal to 1 
95 percent confidence interval: 
0.595142 3.798764 
sample estimates: 
ratio of variances 
1.503597 
> wilcox.test(diff~TRT, dat) 
Wilcoxon rank sum test with continuity correction 
data: diff by TRT 
W = 0, p-value = 6.286e-08 
alternative hypothesis: true location shift is not equal to 0
One-sided t-test 
> diff.A = dat[dat$TRT=="A",]$diff 
# data from treatment B 
> diff.B = dat[dat$TRT=="B",]$diff 
# call t.test for one-sided test 
> t.test(diff.A, diff.B,alternative="less") 
Welch Two Sample t-test 
data: diff.A and diff.B 
t = -12.1504, df = 36.522, p-value = 1.074e-14 
alternative hypothesis: true difference in means is less than 0 
95 percent confidence interval: 
-Inf -8.955466 
sample estimates: 
mean of x mean of y 
-15.2 -4.8 
A and B are statistically significantly different; i.e., there is evidence that A is more effective.
Bootstrapping 
> library(bootstrap) 
> mean.diff = function(bn,dat) 
+ diff(tapply(dat[bn,]$diff, dat[bn,]$TRT,mean)) 
> nboot = 1000 
> boot.mean = bootstrap(1:dim(dat)[1], nboot, mean.diff,dat) 
> x = boot.mean$thetastar 
> x.quantile = quantile(x, c(0.025,0.5, 0.975)) 
> print(x.quantile) 
2.5% 50% 97.5% 
8.79144 10.38121 12.06272 
> hist(boot.mean$thetastar, 
xlab="Mean Differences", main="") 
> abline(v=x.quantile,lwd=2, lty=c(4,1,4))
One-Way ANOVA for Time Changes 
• The treatment period in the DBP trial was 
four months with DBP measured at months 1, 
2, 3, and 4 post baseline. 
> aggregate(dat[,3:7], list(TRT=dat$TRT), mean) 
TRT DBP1 DBP2 DBP3 DBP4 DBP5 
1 A 116.55 113.5 110.70 106.25 101.35 
2 B 116.75 115.2 114.05 112.45 111.95
DBP Changes are Different One – Way 
Anova to see change over time. 
H0 : μ1= μ2 = μ3 = μ4 = μ5 
Ha : Not all means are equal 
> Dat = reshape(dat, direction="long", 
+ varying=c("DBP1","DBP2","DBP3","DBP4","DBP5"), 
+ idvar = c("Subject","TRT","Age","Sex","diff"),sep="") 
> colnames(Dat) = 
c("Subject","TRT","Age","Sex","diff","Time","DBP") 
> Dat$Time = as.factor(Dat$Time) 
> head(Dat) 
Subject TRT Age Sex diff Time DBP 
1.A.43.F.-9.1 1 A 43 F -9 1 114 
2.A.51.M.-15.1 2 A 51 M -15 1 116 
3.A.48.F.-21.1 3 A 48 F -21 1 119 
4.A.42.F.-14.1 4 A 42 F -14 1 115 
5.A.49.M.-11.1 5 A 49 M -11 1 116 
6.A.47.M.-15.1 6 A 47 M -15 1 117
One Way ANOVA 
> # one-way ANOVA to test the null hypotheses that the means of DBP at all five 
times of measurement are equal 
> # test treatment "A" 
> datA = Dat[Dat$TRT=="A",] 
> test.A = aov(DBP~Time, datA) 
> summary(test.A) 
Df Sum Sq Mean Sq F value Pr(>F) 
Time 4 2879.7 719.9 127 <2e-16 *** 
Residuals 95 538.5 5.7 
--- 
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 
> # test treatment "B" 
> datB = Dat[Dat$TRT=="B",] 
> test.B = aov(DBP~Time, datB) 
> summary(test.B) 
Df Sum Sq Mean Sq F value Pr(>F) 
Time 4 311.6 77.89 17.63 7.5e-11 *** 
Residuals 95 419.8 4.42 
--- 
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
TukeyHBD test 
> TukeyHSD(test.A) 
Tukey multiple comparisons of means 
95% family-wise confidence level 
Fit: aov(formula = DBP ~ Time, data = datA) 
$Time 
diff lwr upr p adj 
2-1 -3.05 -5.143586 -0.9564144 0.0009687 
3-1 -5.85 -7.943586 -3.7564144 0.0000000 
4-1 -10.30 -12.393586 -8.2064144 0.0000000 
5-1 -15.20 -17.293586 -13.1064144 0.0000000 
3-2 -2.80 -4.893586 -0.7064144 0.0030529 
4-2 -7.25 -9.343586 -5.1564144 0.0000000 
5-2 -12.15 -14.243586 -10.0564144 0.0000000 
4-3 -4.45 -6.543586 -2.3564144 0.0000005 
5-3 -9.35 -11.443586 -7.2564144 0.0000000 
5-4 -4.90 -6.993586 -2.8064144 0.0000000 
> TukeyHSD(test.B) 
Tukey multiple comparisons of means 
95% family-wise confidence level 
Fit: aov(formula = DBP ~ Time, data = datB) 
$Time 
diff lwr upr p adj 
2-1 -1.55 -3.398584 0.2985843 0.1440046 
3-1 -2.70 -4.548584 -0.8514157 0.0009333 
4-1 -4.30 -6.148584 -2.4514157 0.0000000 
5-1 -4.80 -6.648584 -2.9514157 0.0000000 
3-2 -1.15 -2.998584 0.6985843 0.4207789 
4-2 -2.75 -4.598584 -0.9014157 0.0007122 
5-2 -3.25 -5.098584 -1.4014157 0.0000400 
4-3 -1.60 -3.448584 0.2485843 0.1223788 
5-3 -2.10 -3.948584 -0.2514157 0.0176793 
5-4 -0.50 -2.348584 1.3485843 0.9433857
Two-Way ANOVA for Interaction 
mod2 = aov(DBP~ TRT*Time, Dat) 
summary(mod2) 
Df Sum Sq Mean Sq F value Pr(>F) 
TRT 1 972.4 972.4 192.81 <2e-16 *** 
Time 4 2514.1 628.5 124.62 <2e-16 *** 
TRT:Time 4 677.1 169.3 33.56 <2e-16 *** 
Residuals 190 958.2 5.0 
par(mfrow=c(2,1),mar=c(5,3,1,1)) 
with(Dat,interaction.plot(Time,TRT,DBP,las=1,legend=T)) 
with(Dat,interaction.plot(TRT,Time,DBP,las=1,legend=T)) 
At the end of trial, mean DBP for new drug 
treatment A decreased from 116.55 to 101.35 mm 
HG whereas mean DBP decreased from 116.75 to 
111.95 mm for placebo.
Multiple comparisons 
>TukeyHSD(aov(DBP ~ TRT*Time,Dat)) 
• Treatment A at Time 1 (i.e., A1), the Placebo at 
Time points 1 and 2 (i.e., B1, B2) 
• For Treatment A at Time 3 (i.e., A3), the Placebo 
at Time points 4 and 5 (i.e., B4 and B5) 
• For Placebo B at Time 2 (i.e., B2), the Placebo at 
Time point 3 (i.e.,B3) 
find out how many are not significant ....
References 
• Multivariate Data Analysis (7th Edition) 
by Joseph F. Hair Jr, William C. Black , Barry J. Babin, Rolph E. Anderson 
• An Introduction to Applied Multivariate Analysis with R (Use R!) 
by Brian Everitt, Torsten Hothorn 
• Clinical Trial Data Analysis Using R (Chapman & Hall/CRC Biostatistics Series) 
by Din Chen, Karl E. Peace

Weitere ähnliche Inhalte

Andere mochten auch

Data handling in r
Data handling in rData handling in r
Data handling in rAbhik Seal
 
Introduction to Adverse Drug Reactions
Introduction to Adverse Drug ReactionsIntroduction to Adverse Drug Reactions
Introduction to Adverse Drug ReactionsAbhik Seal
 
Adverse Drug Reactions - Identifying, Causality & Reporting
Adverse Drug Reactions - Identifying, Causality & ReportingAdverse Drug Reactions - Identifying, Causality & Reporting
Adverse Drug Reactions - Identifying, Causality & ReportingRuella D'Costa Fernandes
 
Adverse drug reactions
Adverse drug  reactionsAdverse drug  reactions
Adverse drug reactionssuniu
 
Adverse drug reactions
Adverse drug reactionsAdverse drug reactions
Adverse drug reactionsDr.Vijay Talla
 
Master's thesis : "Shifting advertising strategies and designs : Consequences...
Master's thesis : "Shifting advertising strategies and designs : Consequences...Master's thesis : "Shifting advertising strategies and designs : Consequences...
Master's thesis : "Shifting advertising strategies and designs : Consequences...Michaël Perez
 
Metabolomic Data Analysis Case Studies
Metabolomic Data Analysis Case StudiesMetabolomic Data Analysis Case Studies
Metabolomic Data Analysis Case StudiesDmitry Grapov
 
Social networking site research study
Social networking site research studySocial networking site research study
Social networking site research studyprathimap
 
ANOVA in Marketing Research
ANOVA  in Marketing ResearchANOVA  in Marketing Research
ANOVA in Marketing Researchvivek_goyal87
 
Parametric tests
Parametric testsParametric tests
Parametric testsheena45
 
Intranet trends in Finland 2014
Intranet trends in Finland 2014Intranet trends in Finland 2014
Intranet trends in Finland 2014Hanna P. Korhonen
 
Web 2 0/Social Media Presentation V2
Web 2 0/Social Media Presentation V2Web 2 0/Social Media Presentation V2
Web 2 0/Social Media Presentation V2Bernie Borges
 
Chronic pain australia disrupting the culture around people living with chr...
Chronic pain australia   disrupting the culture around people living with chr...Chronic pain australia   disrupting the culture around people living with chr...
Chronic pain australia disrupting the culture around people living with chr...Anne-Marie Elias
 
Primer parcial ea
Primer parcial eaPrimer parcial ea
Primer parcial eaAdalberto
 

Andere mochten auch (20)

Data handling in r
Data handling in rData handling in r
Data handling in r
 
Chemical data
Chemical dataChemical data
Chemical data
 
Introduction to Adverse Drug Reactions
Introduction to Adverse Drug ReactionsIntroduction to Adverse Drug Reactions
Introduction to Adverse Drug Reactions
 
Adverse Drug Reactions - Identifying, Causality & Reporting
Adverse Drug Reactions - Identifying, Causality & ReportingAdverse Drug Reactions - Identifying, Causality & Reporting
Adverse Drug Reactions - Identifying, Causality & Reporting
 
Adverse drug reactions
Adverse drug  reactionsAdverse drug  reactions
Adverse drug reactions
 
Adverse drug reactions
Adverse drug reactionsAdverse drug reactions
Adverse drug reactions
 
Adverse drug reactions ppt
Adverse drug reactions pptAdverse drug reactions ppt
Adverse drug reactions ppt
 
Adverse drug reactions
Adverse drug reactionsAdverse drug reactions
Adverse drug reactions
 
Who ever said traditional media had to be traditional?
Who ever said traditional media had to be traditional?Who ever said traditional media had to be traditional?
Who ever said traditional media had to be traditional?
 
Eigen value & annova
Eigen value & annovaEigen value & annova
Eigen value & annova
 
Master's thesis : "Shifting advertising strategies and designs : Consequences...
Master's thesis : "Shifting advertising strategies and designs : Consequences...Master's thesis : "Shifting advertising strategies and designs : Consequences...
Master's thesis : "Shifting advertising strategies and designs : Consequences...
 
Metabolomic Data Analysis Case Studies
Metabolomic Data Analysis Case StudiesMetabolomic Data Analysis Case Studies
Metabolomic Data Analysis Case Studies
 
Social networking site research study
Social networking site research studySocial networking site research study
Social networking site research study
 
ANOVA in Marketing Research
ANOVA  in Marketing ResearchANOVA  in Marketing Research
ANOVA in Marketing Research
 
Parametric tests
Parametric testsParametric tests
Parametric tests
 
Ecolabel affiche generique-a4
Ecolabel affiche generique-a4Ecolabel affiche generique-a4
Ecolabel affiche generique-a4
 
Intranet trends in Finland 2014
Intranet trends in Finland 2014Intranet trends in Finland 2014
Intranet trends in Finland 2014
 
Web 2 0/Social Media Presentation V2
Web 2 0/Social Media Presentation V2Web 2 0/Social Media Presentation V2
Web 2 0/Social Media Presentation V2
 
Chronic pain australia disrupting the culture around people living with chr...
Chronic pain australia   disrupting the culture around people living with chr...Chronic pain australia   disrupting the culture around people living with chr...
Chronic pain australia disrupting the culture around people living with chr...
 
Primer parcial ea
Primer parcial eaPrimer parcial ea
Primer parcial ea
 

Ähnlich wie Clinical Data Analysis Using R

2.0.statistical methods and determination of sample size
2.0.statistical methods and determination of sample size2.0.statistical methods and determination of sample size
2.0.statistical methods and determination of sample sizesalummkata1
 
Treatment comparisons in clinical trials with Covariates analysis of diastoli...
Treatment comparisons in clinical trials with Covariates analysis of diastoli...Treatment comparisons in clinical trials with Covariates analysis of diastoli...
Treatment comparisons in clinical trials with Covariates analysis of diastoli...Dr.Govind Nidigattu
 
Test of significance (t-test, proportion test, chi-square test)
Test of significance (t-test, proportion test, chi-square test)Test of significance (t-test, proportion test, chi-square test)
Test of significance (t-test, proportion test, chi-square test)Ramnath Takiar
 
One-way ANOVA research paper
One-way ANOVA research paperOne-way ANOVA research paper
One-way ANOVA research paperJose Dela Cruz
 
Chapter 7 : Inference for Distributions(The t Distributions, One-Sample t Con...
Chapter 7 : Inference for Distributions(The t Distributions, One-Sample t Con...Chapter 7 : Inference for Distributions(The t Distributions, One-Sample t Con...
Chapter 7 : Inference for Distributions(The t Distributions, One-Sample t Con...nszakir
 
Anova by Hazilah Mohd Amin
Anova by Hazilah Mohd AminAnova by Hazilah Mohd Amin
Anova by Hazilah Mohd AminHazilahMohd
 
ANOVAs01.ppt KHLUGYIFTFYLYUGUH;OUYYUHJLNOI
ANOVAs01.ppt KHLUGYIFTFYLYUGUH;OUYYUHJLNOIANOVAs01.ppt KHLUGYIFTFYLYUGUH;OUYYUHJLNOI
ANOVAs01.ppt KHLUGYIFTFYLYUGUH;OUYYUHJLNOIprasad439227
 
test_using_one-way_analysis_of_varianceANOVA_063847.pptx
test_using_one-way_analysis_of_varianceANOVA_063847.pptxtest_using_one-way_analysis_of_varianceANOVA_063847.pptx
test_using_one-way_analysis_of_varianceANOVA_063847.pptxRaquelMaacap
 
Chapter 5 experimental design for sbh
Chapter 5 experimental design for sbhChapter 5 experimental design for sbh
Chapter 5 experimental design for sbhRione Drevale
 

Ähnlich wie Clinical Data Analysis Using R (20)

2.0.statistical methods and determination of sample size
2.0.statistical methods and determination of sample size2.0.statistical methods and determination of sample size
2.0.statistical methods and determination of sample size
 
Treatment comparisons in clinical trials with Covariates analysis of diastoli...
Treatment comparisons in clinical trials with Covariates analysis of diastoli...Treatment comparisons in clinical trials with Covariates analysis of diastoli...
Treatment comparisons in clinical trials with Covariates analysis of diastoli...
 
Test of significance (t-test, proportion test, chi-square test)
Test of significance (t-test, proportion test, chi-square test)Test of significance (t-test, proportion test, chi-square test)
Test of significance (t-test, proportion test, chi-square test)
 
f and t test
f and t testf and t test
f and t test
 
One-way ANOVA research paper
One-way ANOVA research paperOne-way ANOVA research paper
One-way ANOVA research paper
 
Unit-5.-t-test.ppt
Unit-5.-t-test.pptUnit-5.-t-test.ppt
Unit-5.-t-test.ppt
 
Chapter 7 : Inference for Distributions(The t Distributions, One-Sample t Con...
Chapter 7 : Inference for Distributions(The t Distributions, One-Sample t Con...Chapter 7 : Inference for Distributions(The t Distributions, One-Sample t Con...
Chapter 7 : Inference for Distributions(The t Distributions, One-Sample t Con...
 
Anova by Hazilah Mohd Amin
Anova by Hazilah Mohd AminAnova by Hazilah Mohd Amin
Anova by Hazilah Mohd Amin
 
Posthoc
PosthocPosthoc
Posthoc
 
ANOVAs01.ppt
ANOVAs01.pptANOVAs01.ppt
ANOVAs01.ppt
 
ANOVAs01.ppt
ANOVAs01.pptANOVAs01.ppt
ANOVAs01.ppt
 
ANOVAs01.ppt KHLUGYIFTFYLYUGUH;OUYYUHJLNOI
ANOVAs01.ppt KHLUGYIFTFYLYUGUH;OUYYUHJLNOIANOVAs01.ppt KHLUGYIFTFYLYUGUH;OUYYUHJLNOI
ANOVAs01.ppt KHLUGYIFTFYLYUGUH;OUYYUHJLNOI
 
ANOVAs01.ppt
ANOVAs01.pptANOVAs01.ppt
ANOVAs01.ppt
 
ANOVAs01.ppt
ANOVAs01.pptANOVAs01.ppt
ANOVAs01.ppt
 
ANOVAs01.ppt
ANOVAs01.pptANOVAs01.ppt
ANOVAs01.ppt
 
test_using_one-way_analysis_of_varianceANOVA_063847.pptx
test_using_one-way_analysis_of_varianceANOVA_063847.pptxtest_using_one-way_analysis_of_varianceANOVA_063847.pptx
test_using_one-way_analysis_of_varianceANOVA_063847.pptx
 
Chapter 5 experimental design for sbh
Chapter 5 experimental design for sbhChapter 5 experimental design for sbh
Chapter 5 experimental design for sbh
 
Stata
StataStata
Stata
 
The t test
The t testThe t test
The t test
 
Stat2013
Stat2013Stat2013
Stat2013
 

Mehr von Abhik Seal

Virtual Screening in Drug Discovery
Virtual Screening in Drug DiscoveryVirtual Screening in Drug Discovery
Virtual Screening in Drug DiscoveryAbhik Seal
 
Data manipulation on r
Data manipulation on rData manipulation on r
Data manipulation on rAbhik Seal
 
Modeling Chemical Datasets
Modeling Chemical DatasetsModeling Chemical Datasets
Modeling Chemical DatasetsAbhik Seal
 
Mapping protein to function
Mapping protein to functionMapping protein to function
Mapping protein to functionAbhik Seal
 
Sequencedatabases
SequencedatabasesSequencedatabases
SequencedatabasesAbhik Seal
 
Chemical File Formats for storing chemical data
Chemical File Formats for storing chemical dataChemical File Formats for storing chemical data
Chemical File Formats for storing chemical dataAbhik Seal
 
Understanding Smiles
Understanding Smiles Understanding Smiles
Understanding Smiles Abhik Seal
 
Learning chemistry with google
Learning chemistry with googleLearning chemistry with google
Learning chemistry with googleAbhik Seal
 
3 d virtual screening of pknb inhibitors using data
3 d virtual screening of pknb inhibitors using data3 d virtual screening of pknb inhibitors using data
3 d virtual screening of pknb inhibitors using dataAbhik Seal
 
R scatter plots
R scatter plotsR scatter plots
R scatter plotsAbhik Seal
 
Q plot tutorial
Q plot tutorialQ plot tutorial
Q plot tutorialAbhik Seal
 
Pharmacohoreppt
PharmacohorepptPharmacohoreppt
PharmacohorepptAbhik Seal
 
Qsar and drug design ppt
Qsar and drug design pptQsar and drug design ppt
Qsar and drug design pptAbhik Seal
 

Mehr von Abhik Seal (18)

Virtual Screening in Drug Discovery
Virtual Screening in Drug DiscoveryVirtual Screening in Drug Discovery
Virtual Screening in Drug Discovery
 
Data manipulation on r
Data manipulation on rData manipulation on r
Data manipulation on r
 
Networks
NetworksNetworks
Networks
 
Modeling Chemical Datasets
Modeling Chemical DatasetsModeling Chemical Datasets
Modeling Chemical Datasets
 
Mapping protein to function
Mapping protein to functionMapping protein to function
Mapping protein to function
 
Sequencedatabases
SequencedatabasesSequencedatabases
Sequencedatabases
 
Chemical File Formats for storing chemical data
Chemical File Formats for storing chemical dataChemical File Formats for storing chemical data
Chemical File Formats for storing chemical data
 
Understanding Smiles
Understanding Smiles Understanding Smiles
Understanding Smiles
 
Learning chemistry with google
Learning chemistry with googleLearning chemistry with google
Learning chemistry with google
 
3 d virtual screening of pknb inhibitors using data
3 d virtual screening of pknb inhibitors using data3 d virtual screening of pknb inhibitors using data
3 d virtual screening of pknb inhibitors using data
 
Poster
PosterPoster
Poster
 
R scatter plots
R scatter plotsR scatter plots
R scatter plots
 
Indo us 2012
Indo us 2012Indo us 2012
Indo us 2012
 
Q plot tutorial
Q plot tutorialQ plot tutorial
Q plot tutorial
 
Weka guide
Weka guideWeka guide
Weka guide
 
Pharmacohoreppt
PharmacohorepptPharmacohoreppt
Pharmacohoreppt
 
Document1
Document1Document1
Document1
 
Qsar and drug design ppt
Qsar and drug design pptQsar and drug design ppt
Qsar and drug design ppt
 

Kürzlich hochgeladen

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 

Kürzlich hochgeladen (20)

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 

Clinical Data Analysis Using R

  • 1. Clinical data Analysis using R A case study
  • 2. Dataset • Diastolic blood pressure (DBP) was measured (mm HG) in the supine position at baseline (i.e., DBP1) before randomization and monthly thereafter up to 4 months as indicated by DBP2,DBP3,DBP4 and DBP5. • Patients age and sex were recorded at baseline and represent potential covariates. • primary objective is to test whether treatment A (new drug) may be effective in lowering DBP as compared to B (placebo) and to describe changes in DBP across the times at which it was measured.
  • 4. Statistical Models for Treatment Comparisons A) Student's t-tests :test the null hypothesis that the means of the two treatment groups are the same H0 : μ1= μ2 The test statistic is constructed as: • yi are the treatment group means of the observed data, and s is the pooled standard error . Under the null hypothesis, this t -statistic has a Student's t – distribution with n1 + n2 - 2 degrees of freedom. confidence interval (CI)
  • 5. Parameter Violations • Unequal variances: Welch test in R (t.test) v degrees of freedom calculated as • Non-normal data: Mann Whitney Wilcoxon (MWW) U-test (also called Wilcoxon rank-sum test, or Wilcoxon{Mann{Whitney test). In R (wilcox.test) . • Bootstrap resampling: Iteratively resampling the data with replacement, calculating the value of the statistic for each sample obtained, and generating the resampling distribution. In R Use library(bootstrap)
  • 6. One-Way Analysis of Variance (ANOVA) • For comparisons involving more than two treatment groups, F -tests deriving ANOVA is used. Note : If the null hypothesis fails to be rejected, the analysis ends and it is concluded that there is insufficient evidence to conclude that the treatment group means differ. However, if the null hypothesis is rejected, the next logical step is to investigate which levels differ by using so-called multiple comparisons. We use Tukey's honest significant difference (HSD). • The ANOVA procedure is implemented in the R system as aov() and Tukey’s HSD procedure as TukeyHSD() .
  • 7. Data Analysis of Diastolic Pressure data in R >dat = read.csv("dbpdata.csv",header=TRUE) # create the difference >dat$diff = dat$DBP5-dat$DBP1 >boxplot(diff~TRT, dat, xlab="Treatment", ylab="DBP Changes")
  • 8. Perform t.test > t.test(diff~TRT, dat, var.equal=T) Two Sample t-test data: diff by TRT t = -12.1504, df = 38, p-value = 1.169e-14 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -12.132758 -8.667242 sample estimates: mean in group A mean in group B -15.2 -4.8 > t.test(diff~TRT, dat, var.equal=F) Welch Two Sample t-test data: diff by TRT t = -12.1504, df = 36.522, p-value = 2.149e-14 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -12.135063 -8.664937 sample estimates: mean in group A mean in group B -15.2 -4.8
  • 9. More tests > var.test(diff~TRT, dat) F test to compare two variances data: diff by TRT F = 1.5036, num df = 19, denom df = 19, p-value = 0.3819 alternative hypothesis: true ratio of variances is not equal to 1 95 percent confidence interval: 0.595142 3.798764 sample estimates: ratio of variances 1.503597 > wilcox.test(diff~TRT, dat) Wilcoxon rank sum test with continuity correction data: diff by TRT W = 0, p-value = 6.286e-08 alternative hypothesis: true location shift is not equal to 0
  • 10. One-sided t-test > diff.A = dat[dat$TRT=="A",]$diff # data from treatment B > diff.B = dat[dat$TRT=="B",]$diff # call t.test for one-sided test > t.test(diff.A, diff.B,alternative="less") Welch Two Sample t-test data: diff.A and diff.B t = -12.1504, df = 36.522, p-value = 1.074e-14 alternative hypothesis: true difference in means is less than 0 95 percent confidence interval: -Inf -8.955466 sample estimates: mean of x mean of y -15.2 -4.8 A and B are statistically significantly different; i.e., there is evidence that A is more effective.
  • 11. Bootstrapping > library(bootstrap) > mean.diff = function(bn,dat) + diff(tapply(dat[bn,]$diff, dat[bn,]$TRT,mean)) > nboot = 1000 > boot.mean = bootstrap(1:dim(dat)[1], nboot, mean.diff,dat) > x = boot.mean$thetastar > x.quantile = quantile(x, c(0.025,0.5, 0.975)) > print(x.quantile) 2.5% 50% 97.5% 8.79144 10.38121 12.06272 > hist(boot.mean$thetastar, xlab="Mean Differences", main="") > abline(v=x.quantile,lwd=2, lty=c(4,1,4))
  • 12. One-Way ANOVA for Time Changes • The treatment period in the DBP trial was four months with DBP measured at months 1, 2, 3, and 4 post baseline. > aggregate(dat[,3:7], list(TRT=dat$TRT), mean) TRT DBP1 DBP2 DBP3 DBP4 DBP5 1 A 116.55 113.5 110.70 106.25 101.35 2 B 116.75 115.2 114.05 112.45 111.95
  • 13. DBP Changes are Different One – Way Anova to see change over time. H0 : μ1= μ2 = μ3 = μ4 = μ5 Ha : Not all means are equal > Dat = reshape(dat, direction="long", + varying=c("DBP1","DBP2","DBP3","DBP4","DBP5"), + idvar = c("Subject","TRT","Age","Sex","diff"),sep="") > colnames(Dat) = c("Subject","TRT","Age","Sex","diff","Time","DBP") > Dat$Time = as.factor(Dat$Time) > head(Dat) Subject TRT Age Sex diff Time DBP 1.A.43.F.-9.1 1 A 43 F -9 1 114 2.A.51.M.-15.1 2 A 51 M -15 1 116 3.A.48.F.-21.1 3 A 48 F -21 1 119 4.A.42.F.-14.1 4 A 42 F -14 1 115 5.A.49.M.-11.1 5 A 49 M -11 1 116 6.A.47.M.-15.1 6 A 47 M -15 1 117
  • 14. One Way ANOVA > # one-way ANOVA to test the null hypotheses that the means of DBP at all five times of measurement are equal > # test treatment "A" > datA = Dat[Dat$TRT=="A",] > test.A = aov(DBP~Time, datA) > summary(test.A) Df Sum Sq Mean Sq F value Pr(>F) Time 4 2879.7 719.9 127 <2e-16 *** Residuals 95 538.5 5.7 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 > # test treatment "B" > datB = Dat[Dat$TRT=="B",] > test.B = aov(DBP~Time, datB) > summary(test.B) Df Sum Sq Mean Sq F value Pr(>F) Time 4 311.6 77.89 17.63 7.5e-11 *** Residuals 95 419.8 4.42 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
  • 15. TukeyHBD test > TukeyHSD(test.A) Tukey multiple comparisons of means 95% family-wise confidence level Fit: aov(formula = DBP ~ Time, data = datA) $Time diff lwr upr p adj 2-1 -3.05 -5.143586 -0.9564144 0.0009687 3-1 -5.85 -7.943586 -3.7564144 0.0000000 4-1 -10.30 -12.393586 -8.2064144 0.0000000 5-1 -15.20 -17.293586 -13.1064144 0.0000000 3-2 -2.80 -4.893586 -0.7064144 0.0030529 4-2 -7.25 -9.343586 -5.1564144 0.0000000 5-2 -12.15 -14.243586 -10.0564144 0.0000000 4-3 -4.45 -6.543586 -2.3564144 0.0000005 5-3 -9.35 -11.443586 -7.2564144 0.0000000 5-4 -4.90 -6.993586 -2.8064144 0.0000000 > TukeyHSD(test.B) Tukey multiple comparisons of means 95% family-wise confidence level Fit: aov(formula = DBP ~ Time, data = datB) $Time diff lwr upr p adj 2-1 -1.55 -3.398584 0.2985843 0.1440046 3-1 -2.70 -4.548584 -0.8514157 0.0009333 4-1 -4.30 -6.148584 -2.4514157 0.0000000 5-1 -4.80 -6.648584 -2.9514157 0.0000000 3-2 -1.15 -2.998584 0.6985843 0.4207789 4-2 -2.75 -4.598584 -0.9014157 0.0007122 5-2 -3.25 -5.098584 -1.4014157 0.0000400 4-3 -1.60 -3.448584 0.2485843 0.1223788 5-3 -2.10 -3.948584 -0.2514157 0.0176793 5-4 -0.50 -2.348584 1.3485843 0.9433857
  • 16. Two-Way ANOVA for Interaction mod2 = aov(DBP~ TRT*Time, Dat) summary(mod2) Df Sum Sq Mean Sq F value Pr(>F) TRT 1 972.4 972.4 192.81 <2e-16 *** Time 4 2514.1 628.5 124.62 <2e-16 *** TRT:Time 4 677.1 169.3 33.56 <2e-16 *** Residuals 190 958.2 5.0 par(mfrow=c(2,1),mar=c(5,3,1,1)) with(Dat,interaction.plot(Time,TRT,DBP,las=1,legend=T)) with(Dat,interaction.plot(TRT,Time,DBP,las=1,legend=T)) At the end of trial, mean DBP for new drug treatment A decreased from 116.55 to 101.35 mm HG whereas mean DBP decreased from 116.75 to 111.95 mm for placebo.
  • 17. Multiple comparisons >TukeyHSD(aov(DBP ~ TRT*Time,Dat)) • Treatment A at Time 1 (i.e., A1), the Placebo at Time points 1 and 2 (i.e., B1, B2) • For Treatment A at Time 3 (i.e., A3), the Placebo at Time points 4 and 5 (i.e., B4 and B5) • For Placebo B at Time 2 (i.e., B2), the Placebo at Time point 3 (i.e.,B3) find out how many are not significant ....
  • 18. References • Multivariate Data Analysis (7th Edition) by Joseph F. Hair Jr, William C. Black , Barry J. Babin, Rolph E. Anderson • An Introduction to Applied Multivariate Analysis with R (Use R!) by Brian Everitt, Torsten Hothorn • Clinical Trial Data Analysis Using R (Chapman & Hall/CRC Biostatistics Series) by Din Chen, Karl E. Peace