Exact power and sample size, Part II [🇷 for BE/BA]
Dear All!
Here comes part II of the story:
Continuation follows.
Again: Use it on your own risk! The author does not take any responsibility for
damage of your computer, your career or of the world
.
Here comes part II of the story:
# a bunch of functions to get the design characteristics
known.designs<-function()
{
# Note: the df for the replicate designs are those without carry-over
# n is the total number in case of cross-over design,
# n is number per group in case of parallel group design
# df2 = degrees of freedom for robust analysis (aka Senn's basic estimator)
# bk is the so-called design constant
des <- ("no design df df2 steps bk
0 parallel 2*(n-1) 2*(n-1) 1 2
1 2x2 n-2 n-2 2 2
2 3x3 2*n-3 n-3 3 2
3 4x4 3*n-5 n-4 4 2
4 2x2x3 2*n-3 n-2 2 1.5
5 2x2x4 3*n-4 n-2 2 1
6 2x4x4 3*n-4 n-4 4 1")
# eventually it would be better to have steps=6 in case of 3x3 (6 seq. design)
# the df2 have to be checked! Not used so far. TODO !
des2 <- textConnection(des)
designs <- read.table(des2, header=TRUE, sep="", strip.white=TRUE, as.is=TRUE)
close(des2) # without this close() warnings are generated
# names for nicer output of design
designs$name[designs$no==0] <- "2 parallel groups"
designs$name[designs$no %in% c(1,2,3)] <-
paste(designs$design[designs$no %in% c(1,2,3)],"crossover")
designs$name[designs$no %in% c(4,5,6)] <-
paste(designs$design[designs$no %in% c(4,5,6)],"replicate crossover")
return(designs)
}
#--- return no of design ---
# design: a character string describing the design
.design.no<-function(design)
{
#take the first word if more then one
desi <- unlist(strsplit(tolower(design)," "))[1]
des <- known.designs()
i <- match(desi, des$design)
if (!is.na(i)) return(des$no[i]) else return(NA)
}
#--- return design constant ---
.design.bk<-function(design.no)
{
des <- known.designs()
return(des$bk[des$no==design.no])
}
#--- return design degrees of freedom ---
# as expression
.design.df<-function(design.no, nvar="n")
{
des <- known.designs()
df <- (des$df[des$no==design.no])
#replace with calling variable name
df <- gsub('n',nvar,df)
e <- parse(text=df, srcfile=NULL)
return(as.expression(e))
}
#--- return step for sample size search ---
.design.step<-function(design.no)
{
des <- known.designs()
return (des$steps[des$no==design.no])
}
#--- return step for sample size search ---
.design.name<-function(design.no)
{
des <- known.designs()
return (des$name[des$no==design.no])
}
Continuation follows.
Again: Use it on your own risk! The author does not take any responsibility for
damage of your computer, your career or of the world
.—
Regards,
Detlew
Regards,
Detlew
Complete thread:
- Exact power and sample size, Part I d_labes 2009-11-23 14:32
- Exact power and sample size, Part IId_labes 2009-11-23 14:38
- Exact power and sample size, Part III d_labes 2009-11-23 14:50
- Exact power and sample size, Part IV d_labes 2009-11-23 14:57
- Backslashes in R-code Helmut 2009-11-23 15:13
- Backslashes eater d_labes 2009-11-23 15:19
- Backslashes eater Helmut 2009-11-23 15:28
- Backslashes eater d_labes 2009-11-23 15:19
- Backslashes in R-code Helmut 2009-11-23 15:13
- Exact power and sample size, Part IV d_labes 2009-11-23 14:57
- Exact power and sample size, Part III d_labes 2009-11-23 14:50
- Exact power and sample size, Part IId_labes 2009-11-23 14:38
