FAQ/dunR - CBU statistics Wiki

Upload page content

You can upload content for the page named below. If you change the page name, you can also upload content for another page. If the page name is empty, we derive the page name from the file name.

File to load page content from
Page name
Comment
Type the missing letters from: He's no ded, he's jus resing hs eys

location: FAQ / dunR

R code for working our critical t statistics, td for Dunnett's test

This agrees with Howell's td appendix e.g.

install.packages("MCPMod")
library(MCPMod)
critVal(CM,n=4,alpha=0.025)

gives 2.6860 which is the td value in Howell for an alpha of 0.05, 4 treatment means (including the control) and an error df = 12 (=Nk - k = 4 x 4 - 4 = 12) for N people per group and k groups which corresponds to the error degrees of freedom for a between subjects ANOVA. The error df for a repeated measures ANOVA can be used by judicious choice of the group sizes so that Nk-k or the sum of the group sizes - k = the error df from the repeated measures ANOVA or, equivalently, the sum of the group sizes = error df + k.

Examples

# Calculation of critical value for Dunnett test

# Set up contrast matrix (3 active doses)

CM <- rbind(-1,diag(3))

# 30 patients per group, one-sided alpha 0.05

critVal(CM, n=30, alpha = 0.05)

# Example from R News 1(2) p. 28, 29

CM <- c(1, 1, 1, 0, 0, -1, 0, 0, 1, 0, 0, -1, 0, 0,
       1, 0, 0, 0, -1, -1, 0, 0, -1, 0, 0)
CM <- t(matrix(CM, ncol = 5))
critVal(CM, n=c(26, 24, 20, 33, 32), alpha = 0.05, 
    twoSide = TRUE)


Results

R version 2.11.1 (2010-05-31)

Copyright (C) 2010 The R Foundation for Statistical Computing

ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.

You are welcome to redistribute it under certain conditions.

Type 'license()' or 'licence()' for distribution details.

  • Natural language support but running in an English locale

R is a collaborative project with many contributors.

Type 'contributors()' for more information and

'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or

'help.start()' for an HTML browser interface to help.

Type 'q()' to quit R.

> library(MCPMod)
> png(filename="critVal_%03d_med.png", width=480, height=480)
> ### Name: critVal
> ### Title: Calculate critical value for multiple contrast test
> ### Aliases: critVal
> ### Keywords: htest design
> 
> ### ** Examples
> 
> # Calculation of critical value for Dunnett test
> # Set up contrast matrix (3 active doses)
> CM <- rbind(-1,diag(3))
> # 30 patients per group, one-sided alpha 0.05
> critVal(CM, n=30, alpha = 0.05)

[1] 2.084034

> # Example from R News 1(2) p. 28, 29
> CM <- c(1, 1, 1, 0, 0, -1, 0, 0, 1, 0, 0, -1, 0, 0,
+        1, 0, 0, 0, -1, -1, 0, 0, -1, 0, 0)
> CM <- t(matrix(CM, ncol = 5))
> critVal(CM, n=c(26, 24, 20, 33, 32), alpha = 0.05, 
+     twoSide = TRUE)

[1] 2.560253

  • dev.off()

null device

  • 1