04.- T-TEST

Maybe you need to read before the first steps in R or how to read files.

Copy, Paste and Adapts

ttest.between.fnc(dat, dv='rt', iv='group')

ttest.between.fnc(dat, dv='rt', iv='group', identification=T)

ttest.within.fnc(dat, pair=c('v1','v2') )

ttest.within.fnc(dat, pair=c('v1','v2'), delete.outliers=T)

Objetive

Performs contrast t of two independent groups or two repeated measures.

TTest between group

dat = OBrienKaiser; head(dat)

Whith semicolon (;) you can add two command in the same line.

ttest.between.fnc(dat, dv='pre.1', iv='gender')

We have requested a t contrast with the data base dat. We will use pre.1 as dependent variable and gender as independent. See the output of this request in the lower graph.

Arbitrarily we will add now an extreme case in the dependent variable

pre.1 (case 4, column 3)

dat[4,3]=11

ttest.between.fnc(dat,, dv='pre.1', iv='gender',

identification=T)

With identification=T (TRUE) we will indicate to R we want a boxplot that allows us to identify the cases that we could consider extreme.

Output:

boxplot without identification

boxplot with identification

We can repeat the analysis by eliminating the subject with extreme value on the dependent variable.

ttest.between.fnc(dat,[-4,], dv='pre.1', iv='gender')

If there had been several extreme cases remove then on this way :ttest.between.fnc(dat,[-c(4,8,10),], dv='pre.1', iv='gender')

Don't omit the character comma to the right side of parenthesis.

TTest within

ttest.within.fnc(OBrienKaiser, pair=c('pre.1','pre.2'))

We just have to indicate the pair of variables on which we perform repeated measures contrast. The user can define the pair by the name or by the number of column.

ttest.within.fnc(OBrienKaiser, pair=3:4)

If the columns were not consecutive use c( ):

ttest.within.fnc(OBrienKaiser, pair=c(4,6))

If there is any pair whose difference is contrary to most observations, the output will detect the subject concerned and reflected in the line chart with red. We can repeat the analysis including the argument delete.outliers =T.

ttest.within.fnc(OBrienKaiser, par=c('pre.1','pre.2'),

delete.outliers=T)

The new output will give you the t contrast with and without the subjects removed.

Up ->