Type: | Package |
Title: | Paired Data Analysis |
Version: | 1.1.1 |
Date: | 2018-06-02 |
Author: | Stephane Champely <champely@univ-lyon1.fr> |
Maintainer: | Stephane Champely <champely@univ-lyon1.fr> |
Description: | Many datasets and a set of graphics (based on ggplot2), statistics, effect sizes and hypothesis tests are provided for analysing paired data with S4 class. |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
Depends: | methods,graphics,MASS,gld,mvtnorm,lattice,ggplot2 |
Collate: | global1.R ClassP1.R |
Packaged: | 2018-06-02 14:53:04 UTC; STEPHANE.CHAMPELY |
NeedsCompilation: | no |
Repository: | CRAN |
Date/Publication: | 2018-06-02 22:57:15 UTC |
Paired Data Analysis
Description
Many datasets and a set of graphics (based on ggplot2), statistics, effect sizes and hypothesis tests are provided for analysing paired data with S4 class.
Details
The DESCRIPTION file:
Package: | PairedData |
Type: | Package |
Title: | Paired Data Analysis |
Version: | 1.1.1 |
Date: | 2018-06-02 |
Author: | Stephane Champely <champely@univ-lyon1.fr> |
Maintainer: | Stephane Champely <champely@univ-lyon1.fr> |
Description: | Many datasets and a set of graphics (based on ggplot2), statistics, effect sizes and hypothesis tests are provided for analysing paired data with S4 class. |
License: | GPL (>=2) |
Depends: | methods,graphics,MASS,gld,mvtnorm,lattice,ggplot2 |
Collate: | global1.R ClassP1.R |
Packaged: | 2017-12-18 15:31:56 UTC; champely |
Index of help topics:
Anorexia Anorexia data from Pruzek & Helmreich (2009) Barley Barley data from Preece (1982, Table 1) Blink Blink data from Preece (1982, Table 2) Blink2 Blink data (2nd example) from Preece (1982, Table 3) BloodLead Blood lead levels data from Pruzek & Helmreich (2009) ChickWeight Chick weight data from Preece (1982, Table 11) Corn Corn data (Darwin) Datalcoholic Datalcoholic: a dataset of paired datasets GDO Agreement study Grain Grain data from Preece (1982, Table 5) Grain2 Wheat grain data from Preece (1982, Table 12) GrapeFruit Grape Fruit data from Preece (1982, Table 6) HorseBeginners Actual and imaginary performances in equitation IceSkating Ice skating speed study Iron Iron data from Preece (1982, Table 10) Meat Meat data from Preece (1982, Table 4) PairedData-package Paired Data Analysis PrisonStress Stress in prison Rugby Agreement study in rugby expert ratings Sewage Chlorinating sewage data from Preece (1982, Table 9) Shoulder Shoulder flexibility in swimmers SkiExperts Actual and imaginary performances in ski Sleep Sleep hours data from Preece (1982, Table 16) Tobacco Tobacco data from Snedecor and Cochran (1967) Var.test Tests of variance(s) for normal distribution(s) anscombe2 Teaching the paired t test bonettseier.Var.test Bonett-Seier test of scale for paired samples effect.size Effect size computations for paired data grambsch.Var.test Grambsch test of scale for paired samples imam.Var.test Imam test of scale for paired samples lambda.table Parameters for Generalised Lambda Distributions levene.Var.test Levene test of scale for paired samples mcculloch.Var.test McCulloch test of scale for paired samples paired Paired paired-class Class '"paired"' paired.plotBA Bland-Altman plot paired.plotCor Paired correlation plot paired.plotMcNeil Parallel lines plot paired.plotProfiles Profile plot plot.paired ~~ Methods for Function 'plot' ~~ rpaired.contaminated Simulate paired samples rpaired.gld Simulate paired samples sandvikolsson.Var.test Sandvik-Olsson test of scale for paired samples slidingchart Sliding square plot summary Summary statistics for paired samples t.test Student's test test for paired data wilcox.test Wilcoxon's signed rank test for paired data winsor.cor.test Winsorized correlation test (for paired data) yuen.t.test Yuen's trimmed mean test
Author(s)
Stephane Champely <champely@univ-lyon1.fr>
Maintainer: Stephane Champely <champely@univ-lyon1.fr>
Anorexia data from Pruzek & Helmreich (2009)
Description
This dataset presents 17 paired data corresponding to the weights of girls before and after treatment for anorexia. A more complete version can be found in the package MASS. There is actually a cluster of four points in this dataset.
Usage
data(Anorexia)
Format
A dataframe with 17 rows and 2 numeric columns:
[,1] | Prior | numeric | weight (lbs) before therapy |
[,2] | Post | numeric | weight (lbs) after therapy |
Source
Hand, D.J., McConway, K., Lunn, D. & Ostrowki, editors (1993) A Handbook of Small Data Sets. Number 232, 285. Chapman & Hall: New-York.
References
Pruzek & Helmreich (2009) Enhancing dependent sample analysis with graphics. Journal of Statistics Education, 17 (1).
See Also
anorexia in MASS
Examples
data(Anorexia)
# Visualization of the cluster
with(Anorexia,plot(paired(Prior,Post),type="profile"))
# The effects of trimming or winsorizing
# with 4 outliers (n=17)
17*0.2
with(Anorexia,summary(paired(Prior,Post)))
17*0.25
with(Anorexia,summary(paired(Prior,Post),tr=0.25))
Barley data from Preece (1982, Table 1)
Description
This dataset presents 12 paired data corresponding to the yields of Glabron and Velvet Barley, grown on different farms. The values from farm 12 are quite different.
Usage
data(Barley)
Format
A dataframe with 17 rows and 3 columns:
[,1] | Farm | factor | |
[,2] | Glabron | numeric | yields (bushels per acre) |
[,3] | Velvet | numeric | yields |
Source
Leonard, W.H. & Clark, A.G. (1939) Field Plot Techniques. Burgess: Minneapolis.
References
Preece D.A. (1982) t is for trouble (and textbooks): a critique of some examples of the paired-samples t-test. The Statistician, 31 (2), 169-195.
Examples
data(Barley)
# Visualizing a clear outlier
with(Barley,plot(paired(Glabron,Velvet),type="BA"))
# Results form the paired t test and paired Yuen test are similar
with(Barley,t.test(paired(Glabron,Velvet)))
with(Barley,yuen.t.test(paired(Glabron,Velvet)))
# Nevertheless the outlier inflates the location (numerator) and
# scale (denominator) standard statictics for the difference
with(Barley,summary(paired(Glabron,Velvet)))
Blink data from Preece (1982, Table 2)
Description
This dataset presents paired data corresponding to average blink-rate per minute of 12 subjects in an experiment of a visual motor task. They had to steer a pencil along a moving track. Each subject was tested under two conditions : a straight track and an oscillating one. Note that the values from subjects 1 and 2 are somewhat different.
Usage
data(Blink)
Format
A dataframe with 12 rows and 3 columns:
[,1] | Subject | factor | |
[,2] | Straight | numeric | blink rate in first condition |
[,3] | Oscillating | numeric | blink rate in second condition |
Source
Wetherhill, G.B. (1972) Elementary Statistical Methods, 2nd ed Chapman and Hall: London.
References
Preece D.A. (1982) t is for trouble (and textbooks): a critique of some examples of the paired-samples t-test. The Statistician, 31 (2), 169-195.
Examples
data(Blink)
# Visualizing two "outliers"
with(Blink,plot(paired(Straight,Oscillating),type="profile"))
# Interestingly, the differences for the two outliers are quite "normal"
# so their influence on the t test is negligible
with(Blink,qqnorm(Straight-Oscillating))
with(Blink,qqline(Straight-Oscillating))
Blink data (2nd example) from Preece (1982, Table 3)
Description
This dataset presents paired data corresponding to average blink-rate per minute of 12 subjects in an experiment of a visual motor task. They had to steer a pencil along a moving track. Each subject was tested under two conditions : a straight track and an oscillating one. Data about blink-rate during a pre-experimental resting are also available. Subjects 1 and 2 then appear less extreme than in the dataset Blink.
Usage
data(Blink2)
Format
A dataframe with 12 rows and 4 columns:
[,1] | Subject | factor | |
[,2] | Resting | numeric | blink rate in pre-experimental condition |
[,3] | Straight | numeric | blink rate in first condition |
[,4] | Oscillating | numeric | blink rate in second condition |
Source
Drew, G.C. (1951) Variations in blink-rate during visual-motor tasks. Quarterly Journal of Experimental Psychology, 3, 73-88.
References
Preece D.A. (1982) t is for trouble (and textbooks): a critique of some examples of the paired-samples t-test. The Statistician, 31 (2), 169-195.
See Also
Blink
Blood lead levels data from Pruzek & Helmreich (2009)
Description
This dataset presents matched paired data corresponding to blood lead levels for 33 children of parents who had worked in a lead related factory and 33 control children from their neighborhood. The two samples have different dispersions and their correlation is small.
Usage
data(BloodLead)
Format
A dataframe with 33 rows and 3 columns:
[,1] | Pair | factor | matched pair of chidren |
[,2] | Exposed | numeric | blood lead levels (mg/dl) for exposed children |
[,3] | Control | numeric | blood lead levels for controls |
Source
Morton, D., Saah, A., Silberg, S., Owens, W., Roberts, M. & Saah, M. (1982) Lead absorption in children of employees in a lead related industry. American Journal of Epimediology, 115, 549-55.
References
Pruzek, R.M. & Helmreich, J.E. (2009) Enhancing dependent sample analysis with graphics. Journal of Statistics Education, 17 (1).
Examples
data(BloodLead)
# Control values are clealy less dispersed (and inferior)
# than exposed levels
with(BloodLead,plot(paired(Control,Exposed),type="McNeil"))
with(BloodLead,Var.test(paired(Control,Exposed)))
with(BloodLead,grambsch.Var.test(paired(Control,Exposed)))
with(BloodLead,bonettseier.Var.test(paired(Control,Exposed)))
# Correlation is small (bad matching)
with(BloodLead,cor.test(Control,Exposed))
with(BloodLead,winsor.cor.test(Control,Exposed))
Chick weight data from Preece (1982, Table 11)
Description
This dataset presents 10 paired data corresponding to the weights of chicks, two from ten families, reared in confinement or on open range.
Usage
data(ChickWeight)
Format
A dataframe with 10 rows and 3 columns:
[,1] | Chicks | factor | |
[,2] | Confinement | numeric | chick weight (ounces) |
[,3] | OpenRange | numeric | chick weight |
Source
Paterson, D.D. (1939) Statistical Techniques in Agricultural Research. McGrw-Hill: New-York.
References
Preece, D.A. (1982) t is for trouble (and textbooks): a critique of some examples of the paired-samples t-test. The Statistician, 31 (2), 169-195.
Examples
data(ChickWeight)
# Look at the interesting discussion in Preece (1982)
# about degree of precision and t test
with(ChickWeight,plot(paired(Confinement,OpenRange)))
with(ChickWeight,stem(Confinement-OpenRange,scale=2))
Corn data (Darwin)
Description
This dataset presents 15 paired data corresponding to the final height of corn data (Zea Mays), one produced by cross-fertilization and the other by self-fertilization. These data were used by Fisher (1936) and were published in Andrews and Herzberg (1985).
Usage
data(Corn)
Format
A dataframe with 15 rows and 4 columns:
[,1] | pair | numeric | |
[,2] | pot | numeric | |
[,3] | Crossed | numeric | plant height (inches) |
[,4] | Self | numeric | plant height |
Source
Darwin, C. (1876). The Effect of Cross- and Self-fertilization in the Vegetable Kingdom, 2nd Ed. London: John Murray.
References
Andrews, D. and Herzberg, A. (1985) Data: a collection of problems from many fields for the student and research worker. New York: Springer.
Fisher, R.A. (1936) The design of Experiments. Oliver & Boyd: London
Examples
data(Corn)
# Visualizing two outliers
with(Corn,slidingchart(paired(Crossed,Self)))
# Very bad matching in these data
with(Corn,cor.test(Crossed,Self))
with(Corn,winsor.cor.test(Crossed,Self))
# So the two-sample test is slightly
# more interesting than the paired test
with(Corn,t.test(Crossed,Self,var.equal=TRUE))
with(Corn,t.test(Crossed,Self,paired=TRUE))
# The Pitman-Morgan test is influenced by the two outliers
with(Corn,Var.test(paired(Crossed,Self)))
with(Corn,grambsch.Var.test(paired(Crossed,Self)))
with(Corn,bonettseier.Var.test(paired(Crossed,Self)))
# Lastly, is there a pot effect?
with(Corn,plot(paired(Crossed,Self)))
with(Corn,plot(paired(Crossed,Self),group=pot))
Datalcoholic: a dataset of paired datasets
Description
This dataset presents for teaching purposes 50 paired datasets available in different R packages.
Usage
data(Datalcoholic)
Format
A dataframe with 4 columns.
[,1] | Dataset | name of the dataset |
[,2] | Package | name of the package |
[,3] | Topic | corresponding discipline (marketing, medicine...) |
[,4] | NumberPairs | size of the (paired) sample |
Examples
data(Datalcoholic)
show(Datalcoholic)
Agreement study
Description
This dataset gives the same measurements of muscle activation (EMG) in 3 days corresponding to a reproductibility study for 18 tennis players.
Usage
data(GDO)
Format
A dataframe with 18 rows and 4 columns.
[,1] | Subject | factor | anonymous subjects |
[,2] | Day1 | numeric | measurement first day |
[,3] | Day2 | numeric | measurement second day |
[,4] | Day3 | numeric | measurement third day |
Source
Private communication. Samuel Rota, CRIS, Lyon 1 University, FRANCE
See Also
packages: agreement, irr and MethComp.
Examples
data(GDO)
# Building new vectors for performing
# a repeated measures ANOVA
# with a fixed Day effect
Activation<-c(GDO[,2],GDO[,3],GDO[,4])
Subject<-factor(rep(GDO[,1],3))
Day<-factor(rep(c("D1","D2","D3"),rep(18,3)))
aovGDO<-aov(Activation~Day+Error(Subject))
summary(aovGDO)
# Reliability measurement: SEM and ICC(3,1)
sqrt(12426)
72704/(72704+12426)
Grain data from Preece (1982, Table 5)
Description
This dataset presents 9 paired data corresponding to the grain yields of Great Northern and Big Four oats grown in "adjacent" plots.
Usage
data(Grain)
Format
A dataframe with 9 rows and 3 columns:
[,1] | Year | factor | |
[,2] | GreatNorthern | numeric | grain yield (bushels per acre) |
[,3] | BigFour | numeric | grain yield |
Source
LeClerg, E.L., Leonard, W.H. & Clark, A.G. (1962) Field Plot Technique. Burgess: Minneapolis.
References
Preece, D.A. (1982) t is for trouble (and textbooks): a critique of some examples of the paired-samples t-test. The Statistician, 31 (2), 169-195.
Examples
data(Grain)
# Usual visualization for paired data (2 clusters?)
with(Grain, plot(paired(GreatNorthern,BigFour)))
# Are they actually "adjacent" plots?
# Why this variable Year?
# Is there any time trend?
with(Grain, plot(Year,GreatNorthern,type="o"))
with(Grain, plot(Year,BigFour,type="o"))
Wheat grain data from Preece (1982, Table 12)
Description
This dataset presents 6 paired data corresponding to the grain yields of two wheat varieties grown on pairs of plots.
Usage
data(Grain2)
Format
A dataframe with 6 rows and 3 columns:
[,1] | Plot | factor | |
[,2] | Variety_1 | numeric | grain yield (bushels per acre) |
[,3] | Variety_2 | numeric | grain yield |
Source
Balaam, N.L. (1972) Fundamentals of Biometry. The Science of Biology Series (ed J.D. Carthy and J.F. Sutcliffe), No3, Allen and Unwin: London.
References
Preece, D.A. (1982) t is for trouble (and textbooks): a critique of some examples of the paired-samples t-test. The Statistician, 31 (2), 169-195.
Examples
data(Grain2)
# A very small data set
print(Grain2)
# The paired t test is the test of the differences
with(Grain2,t.test(Variety_1,Variety_2,paired=TRUE))
with(Grain2,t.test(Variety_1-Variety_2))
# The data are actually rounded to the nearest integer
# So they can be somewhere between +0.5 or -0.5
# and thus the differences between +1 or -1
# The possible t values can be simulated by:
simulating.t<-numeric(1000)
for(i in 1:1000){
simulating.t[i]<-with(Grain2,t.test(Variety_1-Variety_2+runif(6,-1,1)))$stat
}
hist(simulating.t)
abline(v=with(Grain2,t.test(Variety_1-Variety_2))$stat,lty=2)
Grape Fruit data from Preece (1982, Table 6)
Description
This dataset presents paired data corresponding to the percentage of solids recorded in the shaded and exposed halves of 25 grapefruits.
Usage
data(GrapeFruit)
Format
A dataframe with 25 rows and 3 columns:
[,1] | Fruit | numeric | |
[,2] | Shaded | numeric | percentage of solids in grapefruit |
[,3] | Exposed | numeric | percentage of solids |
Source
Croxton, F.E. & Coxden, D.J. (1955) Applied Genral Statistics, 2nd ed. Chapman and Hall, London.
References
Preece, D.A. (1982) t is for trouble (and textbooks): a critique of some examples of the paired-samples t-test. The Statistician, 31 (2), 169-195.
Examples
data(GrapeFruit)
# Visualizing a very strange paired distribution
with(GrapeFruit,plot(paired(Shaded,Exposed)))
with(GrapeFruit,plot(paired(Shaded,Exposed),type="BA"))
with(GrapeFruit,plot(paired(Shaded,Exposed),type="McNeil"))
with(GrapeFruit,plot(paired(Shaded,Exposed),type="profile"))
# As underlined by Preece (1982), have a look to
# the distribution of the final digits
show(GrapeFruit)
table(round((GrapeFruit$Shaded*10-floor(GrapeFruit$Shaded*10))*10))
table(round((GrapeFruit$Exposed*10-floor(GrapeFruit$Exposed*10))*10))
Actual and imaginary performances in equitation
Description
This dataset gives the actual and motor imaginary performances (time) in horse-riding for 8 beginners.
Usage
data(HorseBeginners)
Format
A dataframe with 8 rows and 3 columns.
[,1] | Subject | factor | Anonymous subjects |
[,2] | Actual | numeric | Actual performance (sec.) |
[,3] | Imaginary | numeric | Imaginary performance (sec.) |
Source
Private communication. Aymeric Guillot, CRIS, Lyon 1 University, FRANCE.
References
Louis, M. Collet, C. Champely, S. and Guillot, A. (2010) Differences in motor imagery time when predicting task duration. Research Quarterly for Exercise and Sport.
Examples
data(HorseBeginners)
# There is one outlier
with(HorseBeginners,plot(paired(Actual,Imaginary),type="profile"))
# This outlier has a great influence
# on the non robust Pitman-Morgan test of variances
with(HorseBeginners,Var.test(paired(Actual,Imaginary)))
with(HorseBeginners[-1,],Var.test(paired(Actual,Imaginary)))
with(HorseBeginners,grambsch.Var.test(paired(Actual,Imaginary)))
with(HorseBeginners,bonettseier.Var.test(paired(Actual,Imaginary)))
Ice skating speed study
Description
This dataset gives the speed measurement (m/sec) for seven iceskating dancers using the return leg in flexion or in extension.
Usage
data(IceSkating)
Format
A dataframe with 7 rows and 3 columns.
[,1] | Subject | factor | anonymous subjects |
[,2] | Extension | numeric | speed when return leg in extension (m/sec) |
[,3] | Flexion | numeric | speed when return leg in flexion (m/sec) |
Source
Private communication. Karine Monteil, CRIS, Lyon 1 University, FRANCE.
References
Haguenauer, M., Legreneur, P., Colloud, F. and Monteil, K.M. (2002) Characterisation of the Push-off in Ice Dancing: Influence of the Support Leg extension on Performance. Journal of Human Movement Studies, 43, 197-210.
Examples
data(IceSkating)
# Nothing particular in the paired plot
with(IceSkating,plot(paired(Extension,Flexion),type="McNeil"))
# The differences are normally distributed
with(IceSkating,qqnorm(Extension-Flexion))
with(IceSkating,qqline(Extension-Flexion))
# Usual t test
with(IceSkating,t.test(paired(Extension,Flexion)))
Iron data from Preece (1982, Table 10)
Description
This dataset presents 10 paired data corresponding to percentages of iron found in compounds with the help of two different methods (take a guess: A & B). It is quite intersting to study rounding effect on hypothesis test (have a look at the examples section).
Usage
data(Iron)
Format
A dataframe with 10 rows and 3 columns:
[,1] | Compound | factor | |
[,2] | Method_A | numeric | percentage of iron |
[,3] | Method_B | numeric | percentage of iron |
Source
Chatfield, C. (1978) Statistics for Technology: A Course in Applied Statistics, 2nd ed. Chapman and Hall: London.
References
Preece, D.A. (1982) t is for trouble (and textbooks): a critique of some examples of the paired-samples t-test. The Statistician, 31 (2), 169-195.
Examples
data(Iron)
# Visualizing, very nice correlation
# Is this an agreement problem or a comparison problem?
with(Iron,plot(paired(Method_A,MethodB)))
# Significant... p=0.045
with(Iron,t.test(paired(Method_A,MethodB)))
# Looking at data, rounded at 0.1 so they can be +0.05 or -0.05
show(Iron)
# Thus the differences can be +0.1 or -0.1
# Influence of rounding on the t-statistic
with(Iron,t.test(Method_A-MethodB+0.1))
with(Iron,t.test(Method_A-MethodB-0.1))
Meat data from Preece (1982, Table 4)
Description
This dataset presents 20 paired data corresponding to the percentage of fat in samples of meat using two different methods: AOAC and Babcock.
Usage
data(Meat)
Format
A dataframe with 20 rows and 3 columns:
[,1] | AOAC | numeric | percentage of fat |
[,2] | Babcock | numeric | percentage of fat |
[,3] | MeatType | factor | meat type |
Source
Tippett, L.H.C. (1952) Technological Applications of Statistics. Williams and Norgate: London.
References
Preece, D.A. (1982) t is for trouble (and textbooks): a critique of some examples of the paired-samples t-test. The Statistician, 31 (2), 169-195.
Examples
data(Meat)
# Presence of clusters or...
with(Meat,plot(paired(AOAC,Babcock)))
# group effect according to Meat type?
with(Meat,plot(paired(AOAC,Babcock),group=MeatType))
with(Meat,plot(paired(AOAC,Babcock),group=MeatType,facet=FALSE))
Internal PairedData objects
Description
Internal PairedData objects.
Details
These are not to be called by the user.
Stress in prison
Description
This dataset gives the PSS (stress measurement) for 26 people in prison at the entry and at the exit. Part of these people were physically trained during their imprisonment.
Usage
data(PrisonStress)
Format
A dataframe with 26 rows and 4 columns.
[,1] | Subject | factor | anonymous subjects |
[,2] | Group | factor | sport or control |
[,3] | PSSbefore | numeric | stress measurement before training |
[,4] | PSSafter | numeric | stress measurement after training |
Source
Private communication. Charlotte Verdot, CRIS, Lyon 1 University, FRANCE
References
Verdot, C., Champely, S., Massarelli, R. and Clement, M. (2008) Physical activities in prison as a tool to ameliorate detainees mood and well-being. International Review on Sport and Violence, 2.
Examples
data(PrisonStress)
# The two groups are not randomized!
# The control group is less stressed before the experiment
with(PrisonStress,boxplot(PSSbefore~Group,ylab="Stress at the eginning of the study"))
# But more stressed at the end!
with(PrisonStress,boxplot(PSSafter~Group,ylab="22 weeks later"))
# So the effects of physical training seems promising
with(PrisonStress,plot(paired(PSSbefore,PSSafter),groups=Group,type="BA",facet=FALSE))
# Testing using gain scores analysis
difference<-PrisonStress$PSSafter-PrisonStress$PSSbefore
t.test(difference~PrisonStress$Group,var.equal=TRUE)
# Testing using ANCOVA
lmJail<-lm(PSSafter~PSSbefore*Group,data=PrisonStress)
anova(lmJail)
# Testing using repeated measures ANOVA
PSS<-c(PrisonStress$PSSbefore,PrisonStress$PSSafter)
Time<-factor(rep(c("Before","After"),c(26,26)))
Subject<-rep(PrisonStress$Subject,2)
Condition<-rep(PrisonStress$Group,2)
aovJail<-aov(PSS~Condition*Time+Error(Subject))
summary(aovJail)
Agreement study in rugby expert ratings
Description
This dataset gives the ratings on a continuous ten-points scale of two experts about 93 actions during several rugby union matches.
Usage
data(Rugby)
Format
A dataframe with 93 rows and 3 columns.
[,1] | EXPERT.1 | numeric | First expert ratings |
[,2] | EXPERT.2 | numeric | Second expert ratings |
[,3] | Actions | factor | Subject label |
Source
Private communication. Mickael Campo, CRIS, Lyon 1 University, FRANCE.
Examples
data(Rugby)
with(Rugby,plot(paired(EXPERT.1,EXPERT.2)))
with(Rugby,plot(paired(EXPERT.1,EXPERT.2),type="BA"))
Chlorinating sewage data from Preece (1982, Table 9)
Description
This dataset presents 8 paired data corresponding to log coliform densities per ml for 2 sewage chlorination methods on each of 8 days.
Usage
data(Sewage)
Format
A dataframe with 8 rows and 3 columns:
[,1] | Day | numeric | |
[,2] | Method_A | numeric | log density |
[,3] | Method_B | numeric | log density |
Source
Wetherill, G.B. (1972) Elementary Statistical Methods, 2nd ed. Chapman and Hall: London.
References
Preece, D.A. (1982) t is for trouble (and textbooks): a critique of some examples of the paired-samples t-test. The Statistician, 31 (2), 169-195.
Examples
data(Sewage)
# Visualising
with(Sewage,plot(paired(Method_A,Method_B),type="profile"))
# Basic paired t-test
with(Sewage,t.test(paired(Method_A,Method_B)))
# Influence of the 0.1 rounding on the t-test
with(Sewage,t.test(Method_A-Method_B-0.1))
with(Sewage,t.test(Method_A-Method_B+0.1))
Shoulder flexibility in swimmers
Description
This dataset gives the flexibility for the right and left shoulders in 15 swimmers and 15 sedentary people.
Usage
data(Shoulder)
Format
A dataframe with 30 rows and 4 columns.
[,1] | Subject | factor | anonymous subjects |
[,2] | Group | factor | swimmer or control |
[,3] | Right | numeric | right shoulder flexibility (deg.) |
[,4] | Left | numeric | left shoulder flexibility (deg.) |
Source
Private communication. Karine Monteil, CRIS, Lyon 1 University, FRANCE.
References
Monteil, K., Taiar, R., Champely, S. and Martin, J. (2002) Competitive swimmers versus sedentary people: a predictive model based upon normal shoulders flexibility. Journal of Human Movement Studies, 43 , 17-34.
Examples
data(Shoulder)
# Is there some heteroscedasticity?
with(Shoulder,plot(paired(Left,Right)))
# Swimmers are indeed quite different
with(Shoulder,plot(paired(Right,Left),groups=Group))
# A first derived variable to compare the amplitude in flexibilty
with(Shoulder,boxplot(((Left+Right)/2)~Group,ylab="mean shoulder flexibility"))
# A second derived variable to study shoulder asymmetry
with(Shoulder,boxplot((abs(Left-Right))~Group,ylab="asymmetry in shoulder flexibility"))
Actual and imaginary performances in ski
Description
This dataset gives the actual and motor imaginary performances (time) in ski for 12 experts.
Usage
data(SkiExperts)
Format
A dataframe with 12 rows and 3 columns.
[,1] | Subject | factor | anonymous subjects |
[,2] | Actual | numeric | actual performance (sec.) |
[,3] | Imaginary | numeric | imaginary performance (sec.) |
Source
Private communication. Aymeric Guillot, CRIS, Lyon 1 University, FRANCE.
References
Louis, M., Collet, C., Champely, S. and Guillot, A. (2012) Differences in motor imagery time when predicting task duration in Alpine skiers and equestrian riders. Research Quarterly for Exercise and Sport, 83(1), 86-93.
Examples
data(SkiExperts)
# Visualising
with(SkiExperts,plot(paired(Actual,Imaginary),type="profile"))
# No underestimation of imaginary time for experts
with(SkiExperts,t.test(paired(Actual,Imaginary)))
# But a very interesting increase in dispersion in their
# predicted times
with(SkiExperts,Var.test(paired(Actual,Imaginary)))
Sleep hours data from Preece (1982, Table 16)
Description
This dataset presents paired data corresponding to the sleep hours gained by 10 patients (these are differences indeed) using two isomers (Dextro- and Laevo-). These data from Student were studied by Fischer (1925). Read the paper of Preece (1982, section 9) for a complete understanding of this quite complex situation.
Usage
data(Sleep)
Format
A dataframe with 10 rows and 2 columns:
[,1] | Dextro | numeric | sleep hour gain |
[,2] | Laevo | numeric | sleep hour gain |
Source
Fisher, R.A. (1925) Statistical Metods for Research Workers. Oliver and Boyd: Edinburgh.
References
Preece, D.A. (1982) t is for trouble (and textbooks): a critique of some examples of the paired-samples t-test. The Statistician, 31 (2), 169-195.
Tobacco data from Snedecor and Cochran (1967)
Description
This dataset presents 8 paired data corresponding to numbers of lesions caused by two virus preparations inoculated into the two halves of each tobacco leaves.
Usage
data(Tobacco)
Format
A dataframe with 8 rows and 3 columns:
[,1] | Plant | factor | |
[,2] | Preparation_1 | numeric | number of lesions |
[,3] | Preparation_2 | numeric | number of lesions |
Source
Snedecor, G.W. and Cochran, W.G. (1967) Statistical Methods, 6th ed. Iowa State University Press: Ames.
References
Pruzek, R.M. & Helmreich, J.E. (2009) Enhancing dependent sample analysis with graphics. Journal of Statistics Education, 17 (1).
Preece, D.A. (1982) t is for trouble (and textbooks): a critique of some examples of the paired-samples t-test. The Statistician, 31 (2), 169-195.
Examples
data(Tobacco)
# A clear outlier
with(Tobacco,plot(paired(Preparation_1,Preparation_2)))
# Comparison of normal and robust tests
with(Tobacco,t.test(paired(Preparation_1,Preparation_2)))
with(Tobacco,yuen.t.test(paired(Preparation_1,Preparation_2)))
with(Tobacco,Var.test(paired(Preparation_1,Preparation_2)))
with(Tobacco,grambsch.Var.test(paired(Preparation_1,Preparation_2)))
with(Tobacco,cor.test(Preparation_1,Preparation_2))
with(Tobacco,winsor.cor.test(Preparation_1,Preparation_2))
# Maybe a transformation
require(MASS)
with(Tobacco,eqscplot(log(Preparation_1),log(Preparation_2)))
abline(0,1,col="red")
Tests of variance(s) for normal distribution(s)
Description
Classical tests of variance for one-sample, two-independent samples or paired samples.
Usage
## Default S3 method:
Var.test(x, y = NULL, ratio = 1, alternative = c("two.sided",
"less", "greater"), paired = FALSE, conf.level = 0.95, ...)
## S3 method for class 'paired'
Var.test(x, ...)
## Default S3 method:
pitman.morgan.test(x, y = NULL, alternative = c("two.sided", "less", "greater"),
ratio = 1, conf.level = 0.95,...)
Arguments
x |
first sample or an object of class paired or an object of class lm. |
y |
second sample or an object of class lm. |
ratio |
a priori ratio of variances (two-samples) or variance (one-sample). |
alternative |
alternative hypothesis. |
paired |
independent (the default) or paired samples. |
conf.level |
confidence level. |
... |
further arguments to be passed to or from methods. |
Value
A list with class "htest" containing the following components:
statistic |
the value of the X-squared statistic (one-sample) or F-statistic (two-samples). |
parameter |
the degrees of freedom for the statistic. |
p.value |
the p-value for the test. |
conf.int |
a confidence interval for the parameter appropriate to the specified alternative hypothesis. |
estimate |
the estimated variance(s). |
null.value |
the specified hypothesized value of the parameter. |
alternative |
a character string describing the alternative hypothesis. |
method |
a character string indicating what type of test was performed. |
data.name |
a character string giving the name(s) of the data. |
Author(s)
Stephane CHAMPELY
References
Morgan, W.A. (1939) A test for the significance of the difference between two variances in a sample from a normal bivariate distribution. Biometrika, 31, 13-19.
Pitman, E.J.G. (1939) A note on normal correlation. Biometrika, 31, 9-12.
See Also
bonettseier.Var.test, grambsch.Var.test
Examples
data(HorseBeginners)
#one sample test
Var.test(HorseBeginners$Actual,ratio=15)
# two independent samples test
Var.test(HorseBeginners$Actual,HorseBeginners$Imaginary)
# two dependent samples test
Var.test(HorseBeginners$Actual,HorseBeginners$Imaginary,paired=TRUE)
p<-with(HorseBeginners,paired(Actual,Imaginary))
Var.test(p)
Teaching the paired t test
Description
This dataset presents four sets of paired samples (n=15), giving the same t statistic (t=2.11) and thus the same p-value whereas their situations are really diversified (differences in variances, clustering, heteroscedasticity). The importance of plotting data is thus stressed. The name is given from the famous Anscombe's dataset created to study simple linear regression.
Usage
data(anscombe2)
Format
A dataframe with 15 rows, 8 numeric columns of paired data: (X1,Y1) ; (X2,Y2) ; (X3,Y3) ; (X4,Y4), and 1 factor column: Subjects, giving a label for the subjects.
Source
S. Champely, CRIS, Lyon 1 University, FRANCE
References
F. Anscombe, Graphs in statistical analysis. The American Statistican, 27, 17-21.
Examples
data(anscombe2)
# p=0.05 for the paired t-test
with(anscombe2,plot(paired(X1,Y1),type="BA"))
with(anscombe2,t.test(paired(X1,Y1)))
# Same p but Var(X2)<Var(Y2) and
# correlation in the Bland-Altman plot
with(anscombe2,t.test(paired(X2,Y2)))
with(anscombe2,summary(paired(X2,Y2)))
with(anscombe2,plot(paired(X2,Y2),type="BA"))
# Same p but two clusters
with(anscombe2,plot(paired(X3,Y3),type="BA"))
# Same p but the difference is "linked" to the mean
with(anscombe2,plot(paired(X4,Y4),type="BA"))
Bonett-Seier test of scale for paired samples
Description
Robust test of scale for paired samples based on the mean absolute deviations.
Usage
bonettseier.Var.test(x, ...)
## Default S3 method:
bonettseier.Var.test(x, y = NULL, alternative = c("two.sided", "less", "greater"),
omega = 1, conf.level = 0.95,...)
## S3 method for class 'paired'
bonettseier.Var.test(x, ...)
Arguments
x |
first sample or object of class paired. |
y |
second sample. |
alternative |
alternative hypothesis. |
omega |
a priori ratio of means absolute deviations. |
conf.level |
confidence level. |
... |
further arguments to be passed to or from methods. |
Value
A list with class "htest" containing the following components:
statistic |
the value of the z-statistic. |
p.value |
the p-value for the test. |
conf.int |
a confidence interval for the ratio of means absolute deviations appropriate to the specified alternative hypothesis. |
estimate |
the estimated means absolute deviations. |
null.value |
the specified hypothesized value of the ratio of means absolute deviations. |
alternative |
a character string describing the alternative hypothesis. |
method |
a character string indicating what type of test was performed. |
data.name |
a character string giving the name(s) of the data. |
Author(s)
Stephane CHAMPELY
References
Bonett, D.G. and Seier E. (2003) Statistical inference for a ratio of dispersions using paired samples. Journal of Educational and Behavioral Statistics, 28, 21-30.
See Also
Var.test, grambsch.Var.test
Examples
z<-rnorm(20)
x<-rnorm(20)+z
y<-(rnorm(20)+z)*2
bonettseier.Var.test(x,y)
data(anscombe2)
p<-with(anscombe2,paired(X1,Y1))
bonettseier.Var.test(p)
Effect size computations for paired data
Description
Robust and classical effects sizes for paired samples of the form: (Mx-My)/S where Mx and My are location parameters for each sample and S is a scale parameter
Usage
## S4 method for signature 'paired'
effect.size(object,tr=0.2)
Arguments
object |
an object of class paired |
tr |
percentage of trimming |
Value
A table with two rows corresponding to classical (means) and robust (trimmed means, tr=0.2) delta-type effect sizes. The four columns correspond to:
Average |
Numerator is the difference in (trimmed) means, denominator is the average of the two (winsorised and rescaled to be consistent with the standard deviation when the distribution is normal) standard deviations |
Single (x) |
Denominator is the (winsorised and rescaled) standard deviation of the first sample |
Single (y) |
Denominator is the (winsorised and rescaled) standard deviation of the second sample |
Difference |
Numerator is the (trimmed) mean and denominator the (winsorised and rescaled) standard deviation of the differences (x-y) |
Author(s)
Stephane CHAMPELY
References
Algina, J., Keselman, H.J. and Penfield, R.D. (2005) Effects sizes and their intervals: the two-level repeated measures case. Educational and Psychological Measurement, 65, 241-258.
Examples
z<-rnorm(20)
x<-rnorm(20)+z
y<-rnorm(20)+z+1
p<-paired(x,y)
effect.size(p)
Grambsch test of scale for paired samples
Description
Robust test of scale for paired samples.
Usage
grambsch.Var.test(x, ...)
## Default S3 method:
grambsch.Var.test(x, y = NULL, alternative = c("two.sided", "less", "greater"),...)
## S3 method for class 'paired'
grambsch.Var.test(x, ...)
Arguments
x |
first sample or an object of class paired. |
y |
second sample. |
alternative |
alternative hypothesis. |
... |
further arguments to be passed to or from methods. |
Details
Denoting s=x+y and d=x-y, the test proposed by Grambsch (1994, and called by the author 'modified Pitman test') is based on the fact that var(x)-var(y)=cov(x+y,x-y)=cov(s,d). The values z=(s-mean(s))(d-mean(d)) can be tested for null expectation using a classical t test in order to compare the two variances. Note that the p value is computed using the normal distribution.
Value
A list with class "htest" containing the following components:
statistic |
the value of the F-statistic. |
p.value |
the p-value for the test. |
null.value |
the specified hypothesized value of the ratio of variances (=1!) |
alternative |
a character string describing the alternative hypothesis. |
method |
a character string indicating what type of test was performed. |
data.name |
a character string giving the name(s) of the data. |
Author(s)
Stephane CHAMPELY
References
Grambsch,P.M. (1994) Simple robust tests for scale differences in paired data. Biometrika, 81, 359-372.
See Also
Var.test, bonettseier.Var.test
Examples
z<-rnorm(20)
x<-rnorm(20)+z
y<-(rnorm(20)+z)*2
grambsch.Var.test(x,y)
p<-paired(x,y)
grambsch.Var.test(p)
Imam test of scale for paired samples
Description
Robust test of scale for paired samples based on absolute deviations from the trimmed means (or medians), called Imam test in Wilcox (1989).
Usage
imam.Var.test(x, ...)
## Default S3 method:
imam.Var.test(x, y = NULL,
alternative = c("two.sided", "less", "greater"),
mu = 0,conf.level = 0.95,location=c("trim","median"),
tr=0.1, ...)
## S3 method for class 'paired'
imam.Var.test(x, ...)
Arguments
x |
first sample or object of class paired. |
y |
second sample. |
alternative |
alternative hypothesis. |
mu |
the location parameter mu. |
conf.level |
confidence level. |
location |
location parameter for centering: trimmed mean or median. |
tr |
percentage of trimming. |
... |
further arguments to be passed to or from methods. |
Details
The data are transformed as deviations from the trimmed mean: X=abs(x-mean(x,tr=0.1)) and Y=(y-mean(y,tr=0.1)). A paired t test is then carried out on the (global) ranks of X and Y.
Value
A list with class "htest" containing the components of a paired t test.
Author(s)
Stephane CHAMPELY
References
Wilcox, R.R. (1989) Comparing the variances of dependent groups. Psychometrika, 54, 305-315.
Conover, W.J. and Iman, R.L. (1981) Rank transformations as a bridge between parametric and nonparametric statistics. The American Statistician, 35, 124-129.
See Also
Var.test, grambsch.Var.test
Examples
z<-rnorm(20)
x<-rnorm(20)+z
y<-(rnorm(20)+z)*2
imam.Var.test(x,y)
# some variations
imam.Var.test(x,y,tr=0.2)
imam.Var.test(x,y,location="median")
data(anscombe2)
p<-with(anscombe2,paired(X1,Y1))
imam.Var.test(p)
Parameters for Generalised Lambda Distributions
Description
This dataset gives the parameters for specific 8 Generalized Tukey-lambda distributions with zero mean and unit variance useful for simulation studies as given in Bonett and Seier (2003).
Usage
data(lambda.table)
Format
A dataframe with 8 rows (distributions) and 4 columns (parameters).
References
Bonett, D.G. and Seier, E. (2003) Statistical inference for a ratio of dispersions using paired samples. Journal of Educational and Behavioral Statistics, 28, 21-30.
Levene test of scale for paired samples
Description
Robust test of scale for paired samples based on absolute deviations from the trimmed means (or medians), called extended Brown-Forsythe test in Wilcox (1989).
Usage
levene.Var.test(x, ...)
## Default S3 method:
levene.Var.test(x, y = NULL,
alternative = c("two.sided", "less", "greater"),
mu = 0,conf.level = 0.95,location=c("trim","median"),
tr=0.1, ...)
## S3 method for class 'paired'
levene.Var.test(x, ...)
Arguments
x |
first sample or object of class paired. |
y |
second sample. |
alternative |
alternative hypothesis. |
mu |
the location parameter mu. |
conf.level |
confidence level. |
location |
location parameter for centering: trimmed mean or median. |
tr |
percentage of trimming. |
... |
further arguments to be passed to or from methods. |
Details
The data are transformed as deviations from the trimmed mean: X=abs(x-mean(x,tr=0.1)) and Y=(y-mean(y,tr=0.1)). A paired t test is then carried out on X and Y.
Value
A list with class "htest" containing the components of a paired t test.
Author(s)
Stephane CHAMPELY
References
Wilcox, R.R. (1989) Comparing the variances of dependent groups. Psychometrika, 54, 305-315.
See Also
Var.test, grambsch.Var.test
Examples
z<-rnorm(20)
x<-rnorm(20)+z
y<-(rnorm(20)+z)*2
levene.Var.test(x,y)
# Some variations
levene.Var.test(x,y,tr=0.2)
levene.Var.test(x,y,location="median")
data(anscombe2)
p<-with(anscombe2,paired(X2,Y2))
levene.Var.test(p)
McCulloch test of scale for paired samples
Description
Robust test of scale for paired samples based on spearman coefficient (the default, or kendall or pearson) of the transformed D=x-y and S=x+y.
Usage
mcculloch.Var.test(x, ...)
## Default S3 method:
mcculloch.Var.test(x, y = NULL,
alternative = c("two.sided", "less", "greater"),
method= c("spearman","pearson", "kendall"),
exact = NULL,conf.level = 0.95,continuity = FALSE, ...)
## S3 method for class 'paired'
mcculloch.Var.test(x, ...)
Arguments
x |
first sample or object of class paired. |
y |
second sample. |
alternative |
alternative hypothesis. |
method |
a character string indicating which correlation coefficient is to be used for the test. One of "spearman", "kendall", or "pearson", can be abbreviated. |
exact |
a logical indicating whether an exact p-value should be computed. |
conf.level |
confidence level. |
continuity |
logical: if true, a continuity correction is used for Spearman's rho when not computed exactly. |
... |
further arguments to be passed to or from methods. |
Value
A list with class "htest" containing the components of a (Spearman) correlation test.
Author(s)
Stephane CHAMPELY
References
McCulloch, C.E. (1987) Tests for equality of variances for paired data. Communications in Statistics - Theory and Methods, 16, 1377-1391.
See Also
Var.test, grambsch.Var.test
Examples
z<-rnorm(20)
x<-rnorm(20)+z
y<-(rnorm(20)+z)*2
mcculloch.Var.test(x,y)
p<-paired(x,y)
mcculloch.Var.test(p)
# A variation with kendall tau
mcculloch.Var.test(p,method="kendall")
# equivalence with the PitmanMorgan test
mcculloch.Var.test(p,method="pearson")
Var.test(p)
Paired
Description
This function creates objects of class paired
Usage
paired(x, y)
Arguments
x |
first vector. |
y |
second vector. |
Details
The two vectors must share the same class. Moreover, for vectors of class factor, they must have the same levels.
Value
An object of class paired.
Author(s)
Stephane Champely
Examples
x<-rnorm(15)
y<-rnorm(15)
p1<-paired(x,y)
show(p1)
data(IceSkating)
p2<-with(IceSkating,paired(Extension,Flexion))
show(p2)
Class "paired"
Description
An object of class paired is a dataframe with two columns sharing the same class (usually numeric).
Objects from the Class
Objects can be created by calls of the form new("paired", ...)
.
Slots
.Data
:Object of class
"list"
~~names
:Object of class
"character"
~~row.names
:Object of class
"data.frameRowLabels"
~~.S3Class
:Object of class
"character"
~~
Extends
Class "data.frame"
, directly.
Class "list"
, by class "data.frame", distance 2.
Class "oldClass"
, by class "data.frame", distance 2.
Class "vector"
, by class "data.frame", distance 3.
Methods
- effect.size
signature(object = "paired")
: ...- summary
signature(object = "paired")
: ...- plot
signature(object = "paired")
: ...
Author(s)
Stephane Champely
Examples
data(IceSkating)
p<-with(IceSkating,paired(Extension,Flexion))
show(p)
plot(p)
summary(p)
effect.size(p)
Bland-Altman plot
Description
Produce a Bland-Altman plot for paired data, including a confidence region for the mean of the differences.
Usage
paired.plotBA(df, condition1, condition2, groups = NULL,
facet = TRUE, ...)
Arguments
df |
a data.frame. |
condition1 |
name of the variable corresponding to the first sample. |
condition2 |
name of the variable corresponding to the first sample. |
groups |
name of the variable corresponding to the groups (optional). |
facet |
faceting or grouping strategy for plotting? |
... |
arguments to be passed to methods |
Value
a graphical object of class ggplot.
Author(s)
Stephane CHAMPELY
References
Bland, J.M. and Altman D.G. (1999) Measuring agreement in method comparison studies. Statistical Methods in Medical Research, 8, 135-160.
Meek, D.M. (2007) Two macros for producing graphs to assess agreement between two variables. In Proceedings of Midwest SAS Users Group Annual Meeting, October 2007.
See Also
tmd
Examples
data(PrisonStress)
paired.plotBA(PrisonStress,"PSSbefore","PSSafter")
# Extending the resulting ggplot object by faceting
paired.plotBA(PrisonStress,"PSSbefore","PSSafter")+facet_grid(~Group)
Paired correlation plot
Description
Produce a squared scatterplot for paired data (same units for both axes), including the first bisector line for reference.
Usage
paired.plotCor(df, condition1, condition2, groups = NULL,
facet = TRUE, ...)
Arguments
df |
a data.frame. |
condition1 |
name of the variable corresponding to the first sample. |
condition2 |
name of the variable corresponding to the first sample. |
groups |
name of the variable corresponding to the groups (optional). |
facet |
faceting or grouping strategy for plotting? |
... |
arguments to be passed to methods |
Value
a graphical object of class ggplot.
Author(s)
Stephane CHAMPELY
Examples
data(PrisonStress)
paired.plotCor(PrisonStress,"PSSbefore","PSSafter")
# Changing the theme of the ggplot object
paired.plotCor(PrisonStress,"PSSbefore","PSSafter")+theme_bw()
Parallel lines plot
Description
Produce a parallel lines plot for paired data.
Usage
paired.plotMcNeil(df, condition1, condition2, groups = NULL, subjects,facet = TRUE, ...)
Arguments
df |
a data frame. |
condition1 |
name of the variable corresponding to the second sample. |
condition2 |
name of the variable corresponding to the first sample. |
groups |
names of the variable corresponding to groups (optional). |
subjects |
names of the variable corresponding to subjects. |
facet |
faceting or grouping strategy for plotting? |
... |
further arguments to be passed to methods. |
Value
a graphical object of class ggplot.
Author(s)
Stephane CHAMPELY
References
McNeil, D.R. (1992) On graphing paired data. The American Statistician, 46 :307-310.
See Also
plotBA
Examples
data(PrisonStress)
paired.plotMcNeil(PrisonStress,"PSSbefore","PSSafter",subjects="Subject")
Profile plot
Description
Produce a profile plot or before-after plot or 1-1 plot for paired data.
Usage
paired.plotProfiles(df, condition1, condition2, groups = NULL,subjects,
facet = TRUE, ...)
Arguments
df |
a data frame. |
condition1 |
name of the variable corresponding to the second sample. |
condition2 |
name of the variable corresponding to the first sample. |
groups |
names of the variable corresponding to groups (optional). |
subjects |
names of the variable corresponding to subjects. |
facet |
faceting or grouping strategy for plotting? |
... |
further arguments to be passed to methods. |
Value
a graphical object of class ggplot.
Author(s)
Stephane CHAMPELY
References
Cox, N.J. (2004) Speaking data: graphing agreement and disagreement. The Stata Journal, 4, 329-349.
See Also
plotBA,plotMcNeil
Examples
data(PrisonStress)
paired.plotProfiles(PrisonStress,"PSSbefore","PSSafter",subjects="Subject",groups="Group")
# Changing the line colour
paired.plotProfiles(PrisonStress,"PSSbefore","PSSafter")+geom_line(colour="red")
~~ Methods for Function plot
~~
Description
Plot an object of class paired.
Usage
## S4 method for signature 'paired'
plot(x, groups=NULL,subjects=NULL,
facet=TRUE,type=c("correlation","BA","McNeil","profile"),...)
Arguments
x |
a paired object created by the
|
groups |
a factor (optional). |
subjects |
subjects name. |
facet |
faceting or grouping strategy for plotting? |
type |
type of the plot (correlation, Bland-Altman, McNeil or profile plot). |
... |
arguments to be passed to methods. |
Value
an graphical object of class ggplot.
Examples
data(HorseBeginners)
pd1<-with(HorseBeginners,paired(Actual,Imaginary))
plot(pd1)
plot(pd1,type="BA")
plot(pd1,type="McNeil")
plot(pd1,type="profile")
data(Shoulder)
with(Shoulder,plot(paired(Left,Right),groups=Group))
with(Shoulder,plot(paired(Left,Right),groups=Group,facet=FALSE))
with(Shoulder,plot(paired(Left,Right),
groups=Group,facet=FALSE,type="profile"))+theme_bw()
Simulate paired samples
Description
Simulate paired data with a given correlation (Kendall's tau=(2/pi)arcsine(r)) and marginals being contaminated normal distributions: (1-eps)*F(x)+eps*F(x/K) where F is the cumulative standard normal distribution, eps the percentage of contamination and K a scale parameter. Moreover, this marginal can be multiplied by another scale parameter sigma but usually sigma=1.
Usage
rpaired.contaminated(n, d1 = c(0.1, 10, 1), d2 = c(0.1, 10, 1), r = 0.5)
Arguments
n |
sample size. |
d1 |
vector of 3 parameters for the first contaminated normal distribution (eps,K,sigma). |
d2 |
vector of 3 parameters for the second contaminated normal distribution. |
r |
correlation. |
Value
An object of class paired.
Author(s)
Stephane CHAMPELY
References
Grambsch, P.M. (1994) Simple robust tests for scale differences in paired data. Biometrika, 81, 359-372.
See Also
rpaired.gld
Examples
rpaired.contaminated(n=30,r=0.25)
Simulate paired samples
Description
Simulate paired data with a given correlation (Kendall's tau=(2/pi)arcsine(r)) and marginals being Generalized Tukey-Lambda (G-TL) distributions.
Usage
rpaired.gld(n, d1=c(0.000,0.1974,0.1349,0.1349), d2=c(0.000,0.1974,0.1349,0.1349), r)
Arguments
n |
sample size. |
d1 |
vector of four parameters for the first G-TL distribution. |
d2 |
vector of four parameters for the second G-TL distribution. |
r |
correlation. |
Value
An object of class paired.
Author(s)
Stephane CHAMPELY
References
Grambsch, P.M. (1994) Simple robust tests for scale differences in paired data. Biometrika, 81, 359-372.
See Also
rpaired.contaminated
Examples
rpaired.gld(n=30,r=0.5)
data(lambda.table)
p<-rpaired.gld(n=30,d1=lambda.table[7,],d2=lambda.table[7,],r=0.5)
plot(p)
Sandvik-Olsson test of scale for paired samples
Description
Robust test of scale for paired samples based on the absolute deviations from the trimmed means (or medians).
Usage
sandvikolsson.Var.test(x, ...)
## Default S3 method:
sandvikolsson.Var.test(x, y = NULL,
alternative = c("two.sided", "less", "greater"),
mu = 0, exact = NULL, correct = TRUE,
conf.int = FALSE, conf.level = 0.95,location=c("trim","median"),tr=0.1, ...)
## S3 method for class 'paired'
sandvikolsson.Var.test(x, ...)
Arguments
x |
first sample or object of class paired. |
y |
second sample. |
alternative |
alternative hypothesis. |
mu |
the location parameter mu. |
exact |
a logical indicating whether an exact p-value should be computed. |
correct |
a logical indicating whether to apply continuity correction in the normal approximation for the p-value. |
conf.int |
a logical indicating whether a confidence interval should be computed. |
conf.level |
confidence level. |
location |
location parameter for centering: trimmed mean or median. |
tr |
percentage of trimming. |
... |
further arguments to be passed to or from methods. |
Details
The data are transformed as deviations from the trimmed mean: X=abs(x-mean(x,tr=0.1)) and Y=(y-mean(y,tr=0.1)). A wilcoxon signed-rank test is then carried out on X and Y.
Value
A list with class "htest" containing the components of a wilcoxon signed-rank test.
Author(s)
Stephane CHAMPELY
References
Sandvik, L. and Olsson, B. (1982) A nearly distribution-free test for comparing dispersion in paired samples. Biometrika, 69, 484-485.
See Also
Var.test, grambsch.Var.test
Examples
z<-rnorm(20)
x<-rnorm(20)+z
y<-(rnorm(20)+z)*2
sandvikolsson.Var.test(x,y)
p<-paired(x,y)
sandvikolsson.Var.test(p)
# some variations
sandvikolsson.Var.test(p,tr=0.2)
sandvikolsson.Var.test(p,location="median")
Sliding square plot
Description
Draw a sliding square plot for paired data which mixes the usual scatterplot with the tukey mean-difference plot.
Usage
## S4 method for signature 'paired'
slidingchart(object,...)
Arguments
object |
an object of class paired. |
... |
arguments to be passed to methods. |
Author(s)
Stephane CHAMPELY
References
Rosenbaum, P.R. (1989) Exploratory plot for paired data. American Statistician, 43, 108-110.
Pontius, J.S. and Schantz, R.M. (1994) Graphical analyses of a twoperiod crossover design. The American Statistician, 48, 249-253.
Pruzek, R.M. and Helmreich, J.E. (2009) Enhancing dependent sample analyses with graphics. Journal of Statistics Education, 17.
See Also
plot
Examples
data(PrisonStress)
with(PrisonStress,slidingchart(paired(PSSbefore,PSSafter)))
Summary statistics for paired samples
Description
Classical and robust statistics (location, scale and correlation) for paired samples.
Usage
## S4 method for signature 'paired'
summary(object,tr=0.2)
Arguments
object |
an object of class paired. |
tr |
percenatge of trimming. |
Value
A list with a first table corresponding to location and scale statistics and a second table to Pearson and winsorized correlation.
The first table contains four rows corresponding to calculations for x, y, x-y and (x+y)/2 variables. The location and scale statistics are given in columns.
n |
sample size. |
mean |
mean. |
median |
median. |
trim |
trimmed mean (tr=0.2) |
sd |
standard deviation. |
IQR |
interquartile range (standardised to be consistent with the sd in the normal case) |
median ad |
median of absolute deviations (standardised) |
mean ad |
mean of absolute deviations (standardised) |
sd(w) |
winsorised standard deviation (tr=0.2 and standardised) |
min |
minimum value. |
max |
maximum value. |
Author(s)
Stephane CHAMPELY
Examples
z<-rnorm(20)
x<-rnorm(20)+z
y<-rnorm(20)+z+1
p<-paired(x,y)
summary(p)
Student's test test for paired data
Description
A method designed for objects of class paired.
Usage
## S3 method for class 'paired'
t.test(x, ...)
Arguments
x |
An object of class paired. |
... |
further arguments to be passed to or from methods. |
Value
A list with class "htest" containing the following components:
statistic |
the value of the t-statistic. |
parameter |
the degrees of freedom for the t-statistic. |
p.value |
the p-value for the test. |
conf.int |
a confidence interval for the mean appropriate to the specified alternative hypothesis. |
estimate |
the estimated difference in mean. |
null.value |
the specified hypothesized value of mean difference. |
alternative |
a character string describing the alternative hypothesis. |
method |
a character string indicating what type of test was performed (always paired here) |
data.name |
a character string giving the name(s) of the data. |
Author(s)
Stephane Champely
See Also
yuen.t.test
Examples
data(PrisonStress)
with(PrisonStress,t.test(paired(PSSbefore,PSSafter)))
Wilcoxon's signed rank test for paired data
Description
A method designed for objects of class paired.
Usage
## S3 method for class 'paired'
wilcox.test(x, ...)
Arguments
x |
An object of class paired. |
... |
further arguments to be passed to or from methods. |
Value
A list with class "htest" containing the following components:
statistic |
the value of V statistic. |
parameter |
the parameter(s) for the exact distribution of the test statistic. |
p.value |
the p-value for the test. |
null.value |
the true location shift mu. |
alternative |
a character string describing the alternative hypothesis. |
method |
a character string indicating what type of test was performed (always paired here) |
data.name |
a character string giving the name(s) of the data. |
conf.int |
a confidence interval for the location parameter. (Only present if argument conf.int = TRUE.) |
estimate |
an estimate of the location parameter. (Only present if argument conf.int = TRUE.) |
Author(s)
Stephane Champely
See Also
yuen.test
Examples
data(PrisonStress)
with(PrisonStress,wilcox.test(PSSbefore,PSSafter))
with(PrisonStress,wilcox.test(PSSbefore,PSSafter,paired=TRUE))
with(PrisonStress,wilcox.test(paired(PSSbefore,PSSafter)))
Winsorized correlation test (for paired data)
Description
Test for association between paired samples, using winsorized correlation coefficient.
Usage
winsor.cor.test(x, ...)
## Default S3 method:
winsor.cor.test(x, y, tr=0.2,alternative = c("two.sided", "less", "greater"), ...)
## S3 method for class 'paired'
winsor.cor.test(x,tr=0.2,alternative = c("two.sided", "less", "greater"), ...)
Arguments
x |
an object of class paired or the first variable. |
y |
second variable. |
tr |
percentage of winsorizing. |
alternative |
a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less". You can specify just the initial letter. |
... |
further arguments to be passed to or from methods. |
Value
A list with class "htest" containing the following components:
statistic |
the value of the t-statistic. |
parameter |
the degrees of freedom for the t-statistic. |
p.value |
the p-value for the test. |
estimate |
the winsorized correlation. |
null.value |
the specified hypothesized value of the winsorized correlation (=0). |
alternative |
a character string describing the alternative hypothesis. |
data.name |
a character string giving the name(s) of the data. |
Author(s)
Stephane Champely
See Also
cor.test
Examples
data(PrisonStress)
with(PrisonStress,winsor.cor.test(PSSbefore,PSSafter))
with(PrisonStress,winsor.cor.test(paired(PSSbefore,PSSafter)))
Yuen's trimmed mean test
Description
Yuen's test for one, two or paired samples.
Usage
yuen.t.test(x, ...)
## Default S3 method:
yuen.t.test(x, y = NULL, tr = 0.2, alternative = c("two.sided", "less", "greater"),
mu = 0, paired = FALSE, conf.level = 0.95, ...)
## S3 method for class 'formula'
yuen.t.test(formula, data, subset, na.action, ...)
## S3 method for class 'paired'
yuen.t.test(x, ...)
Arguments
x |
first sample or object of class paired. |
y |
second sample. |
tr |
percentage of trimming. |
alternative |
alternative hypothesis. |
mu |
a number indicating the true value of the trimmed mean (or difference in trimmed means if you are performing a two sample test). |
paired |
a logical indicating whether you want a paired yuen's test. |
conf.level |
confidence level. |
formula |
a formula of the form y ~ f where y is a numeric variable giving the data values and f a factor with TWO levels giving the corresponding groups. |
data |
an optional matrix or data frame (or similar: see model.frame) containing the variables in the formula formula. By default the variables are taken from environment(formula). |
subset |
an optional vector specifying a subset of observations to be used. |
na.action |
a function which indicates what should happen when the data contain NAs. Defaults to getOption("na.action"). |
... |
further arguments to be passed to or from methods. |
Value
A list with class "htest" containing the following components:
statistic |
the value of the t-statistic. |
parameter |
the degrees of freedom for the t-statistic. |
p.value |
the p-value for the test. |
conf.int |
a confidence interval for the trimmed mean appropriate to the specified alternative hypothesis. |
estimate |
the estimated trimmed mean or difference in trimmed means depending on whether it was a one-sample test or a two-sample test. |
null.value |
the specified hypothesized value of the trimmed mean or trimmed mean difference depending on whether it was a one-sample test or a two-sample test. |
alternative |
a character string describing the alternative hypothesis. |
method |
a character string indicating what type of test was performed. |
data.name |
a character string giving the name(s) of the data. |
Author(s)
Stephane CHAMPELY, but some part are mere copy of the code of Wilcox (WRS)
References
Wilcox, R.R. (2005). Introduction to robust estimation and hypothesis testing. Academic Press.
Yuen, K.K. (1974) The two-sample trimmed t for unequal population variances. Biometrika, 61, 165-170.
See Also
t.test
Examples
z<-rnorm(20)
x<-rnorm(20)+z
y<-rnorm(20)+z+1
# two-sample test
yuen.t.test(x,y)
# one-sample test
yuen.t.test(y,mu=1,tr=0.25)
# paired-sample tests
yuen.t.test(x,y,paired=TRUE)
p<-paired(x,y)
yuen.t.test(p)