d.contr: Cohen's d for contrasts

Description Usage Arguments Details Value Author(s) Examples

View source: R/functions.R

Description

Compute Cohen's d for contrasts with different scaling functions

Usage

1
2
d.contr(cont, means = NULL, sd = NULL, y = NULL, x = NULL,
  scale = "g")

Arguments

cont

contrast codes as a numeric vector

means

pattern of means as numeric vector of the same length of cont

sd

pooled standard deviation

y

dependent variable

x

independent variable with k-groups, with k being length(cont)

scale

scaling method of the d index

Details

data to compute the d index can be either actual data or a vector of means and a standard deviation actual data are specified with the y and x parameters, means and standard deviation with the means , and sd parameters. The parameter means and sd are prevalent, thus if means,y and x are provided, but not sd, y and x are used to computed the pooled standard deviation. If means and sd are provided, y and x are ignored.

The parameter scale controls the method used to scale the effect size d.

  1. scale="g" assumes scaling by dividing 2*d by the sum of absolute coefficients

  2. scale="z" assumes scaling by dividing d by the square-root of the sum of squares of the contrast weigths

  3. numeric any constant that multiplies the unscaled d to obtain the scaled d

Value

t-test for the contrast.

Author(s)

Marcello Gallucci, mcfanda@gmail.com

Examples

1
2
3
4
5
6
7
8
9
cont<-c(-3,-1,1,3)
means<-c(10,12,10,12)
d.contr(cont,means = means,sd=2,scale = "g")
### different scaling
d.contr(cont,means = means,sd=2,scale = "z")
### raw data
y<-rep(means,1000)+rnorm(4000,0,2)
x<-factor(rep(1:4,1000))
d.contr(cont,y = y,x = x)

mcfanda/cpower documentation built on May 28, 2019, 1 p.m.