Partover.test: The partially overlapping samples t-test

Description Usage Arguments Details Value Examples

View source: R/Partiallyoverlapping.R

Description

Performs a comparison of means using the partially overlapping t-test, for two samples each with paired and unpaired observations. This functions calculates the test statistic, the degrees of freedom, and the p-value. Additionally calculates a confidence interval for the difference in means when requested.

By default, four vectors are to be specified: unpaired observations in Sample 1, unpaired observations in Sample 2, paired observations in Sample 1, paired observations in Sample 2. If the structure of your data is of two vectors, one for each sample, then the option stacked = TRUE can be specified.

Usage

1
2
3
Partover.test(x1 = NULL, x2 = NULL, x3 = NULL, x4 = NULL,
  var.equal = FALSE, mu = 0, alternative = "two.sided",
  conf.level = NULL, stacked = FALSE)

Arguments

x1

a vector of unpaired observations in Sample 1 (or all observations in Sample 1 if stacked = "TRUE")

x2

a vector of unpaired observations in Sample 2 (or all observations in Sample 2 if stacked = "TRUE")

x3

a vector of paired observations in Sample 1 (not applicable if stacked = "TRUE")

x4

a vector of paired observations in Sample 2 (not applicable if stacked = "TRUE")

var.equal

a logical variable indicating whether to treat the two variances as being equal. If "TRUE" then the pooled variance is used to estimate the variance, otherwise the Welch approximation to the degrees of freedom is used.

mu

difference in population means under the null hypothesis

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less".

conf.level

confidence level of the interval.

stacked

indicator of whether paired and unpaired observations are stacked within one vector ("TRUE"), or if specified as four separate vectors (default)

Details

The formula is only applicable for the 2 sample partially overlapping samples t-test. The number of unpaired observations may be zero for up to one of the two samples. The number of paired observations must be of equal length of two or greater. Error messages are generated when these conditions are not true

If your observations are from a data frame of two paired samples with missing observations, use the option "stacked=TRUE". Corresponding pairs should be given on the same row when this option is applied.

Value

A list which contains the following components of the test:

statistic ~~ The value of the t-statistic

parameter ~~ The degrees of freedom for the test statistic

p.value ~~ The p-value for the test

estimate ~~ The estimated difference in the means

conf.int ~~ A confidence interval for the mean difference appropriate to the specified alternative hypothesis

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Example taken from Derrick, Toher and White (2017)
# How to compare the means of two samples that include
# paired observations and independent observations:
# A companion to Derrick, Russ, Toher and White (2017).
# The Quantitative Methods in Psychology, 13(2). pp.120-126.

#The sample means for two groups, "a" and "b" are compared
#for a two sided test assuming equal variances.

#Approach 1:
#For each sample, unpaired observations and paired observations defined as separate vectors:
a.unpaired<-c(20,21,16,18,14,12,14,17)
a.paired<-c(14,15,18,20,11,19,14,15)
b.unpaired<-c(10,16,18,16,15,14,13,10)
b.paired<-c(15,10,15,17,13,19,12,13)
Partover.test(a.unpaired,b.unpaired,a.paired,b.paired,var.equal=TRUE) 
#p.value = 0.026, the samples from group "a" and group "b" have significantly different means

#Equivalently, Approach 2:
#Independent observations and the paired samples stacked for each sample:
a<-c(20,21,16,18,14,12,14,17,NA,NA,NA,NA,NA,NA,NA,NA,14,15,18,20,11,19,14,15)
b<-c(NA,NA,NA,NA,NA,NA,NA,NA,10,16,18,16,15,14,13,10,15,10,15,17,13,19,12,13)
Partover.test(a,b,var.equal=TRUE,stacked=TRUE) 
#p.value = 0.026, the samples from group "a" and group "b" have significantly different means

Partiallyoverlapping documentation built on Dec. 13, 2018, 5:04 p.m.