#formula: A formula of the structure ‘response ~ treatment’ for #numerical variables, and of structure ‘cbind(success, # failure)’ ‘~ treatment’ for binomial variables # Param.diff: Difference of two means # Median.diff # help(pairwiseCI) –> 예시
Packages <- c("moonBook","pairwiseCI")
lapply(Packages, library, character.only = TRUE)
## Warning: package 'pairwiseCI' was built under R version 4.0.2
## Loading required package: MCPAN
## Warning: package 'MCPAN' was built under R version 4.0.2
## Loading required package: coin
## Warning: package 'coin' was built under R version 4.0.2
## Loading required package: survival
## [[1]]
## [1] "moonBook" "stats" "graphics" "grDevices" "utils" "datasets"
## [7] "methods" "base"
##
## [[2]]
## [1] "pairwiseCI" "coin" "survival" "MCPAN" "moonBook"
## [6] "stats" "graphics" "grDevices" "utils" "datasets"
## [11] "methods" "base"
ccb<- read.csv("/Users/koho0/Desktop/ccb.csv")
ccb$delta_ins_dt<-as.numeric(ccb$pre_ins_dt-ccb$post_ins_dt)
ccb$delta_exp_dt<-as.numeric(ccb$pre_exp_dt-ccb$post_exp_dt)
mytable(group~ delta_ins_dt + delta_exp_dt,ccb,method=3,catMethod=0)
##
## Descriptive Statistics by 'group'
## _____________________________________________________
## C S p
## (N=35) (N=40)
## -----------------------------------------------------
## delta_ins_dt 0.4 [ 0.0; 1.0] 1.4 [ 0.4; 1.9] 0.012
## delta_exp_dt 0.0 [-0.2; 0.2] 0.0 [-0.2; 0.2] 0.757
## -----------------------------------------------------
ccb<-ccb[,c("pre_ins_dt","post_ins_dt","pre_exp_dt","post_exp_dt","delta_ins_dt","delta_exp_dt","group")]
mytable(group~ .,ccb,method=3,catMethod=0)
##
## Descriptive Statistics by 'group'
## _____________________________________________________
## C S p
## (N=35) (N=40)
## -----------------------------------------------------
## pre_ins_dt 3.6 [ 2.9; 4.2] 4.0 [ 3.2; 4.8] 0.435
## post_ins_dt 3.1 [ 2.7; 3.7] 2.5 [ 2.0; 3.2] 0.009
## pre_exp_dt 1.8 [ 1.6; 2.4] 2.1 [ 1.7; 2.5] 0.555
## post_exp_dt 1.9 [ 1.6; 2.4] 2.0 [ 1.6; 2.2] 0.898
## delta_ins_dt 0.4 [ 0.0; 1.0] 1.4 [ 0.4; 1.9] 0.012
## delta_exp_dt 0.0 [-0.2; 0.2] 0.0 [-0.2; 0.2] 0.757
## -----------------------------------------------------
colnames(ccb) <- c("a","b","c","d","e","f", "group")
variable <-data.frame(variable = c("a","b","c","d","e","f"))
a<- pairwiseCI(a ~ group, ccb, by = NULL,
alternative = "two.sided", conf.level = 0.95,
method = "Median.diff", control = NULL)
a<- data.frame(a)
b<- pairwiseCI(b~ group, ccb, by = NULL,
alternative = "two.sided", conf.level = 0.95,
method = "Median.diff", control = NULL)
b<- data.frame(b)
c<- pairwiseCI(c ~ group, ccb, by = NULL,
alternative = "two.sided", conf.level = 0.95,
method = "Median.diff", control = NULL)
c<- data.frame(c)
d<- pairwiseCI(d ~ group, ccb, by = NULL,
alternative = "two.sided", conf.level = 0.95,
method = "Median.diff", control = NULL)
d<- data.frame(d)
e<- pairwiseCI(e ~ group, ccb, by = NULL,
alternative = "two.sided", conf.level = 0.95,
method = "Median.diff", control = NULL)
e<- data.frame(e)
f<- pairwiseCI(f ~ group, ccb, by = NULL,
alternative = "two.sided", conf.level = 0.95,
method = "Median.diff", control = NULL)
f<- data.frame(f)
all <-rbind(a,b,c,d,e,f)
cbind (variable,all)
## variable estimate lower upper comparison
## 1 a 0.35 -0.3 1.0 S-C
## 2 b -0.60 -1.1 -0.1 S-C
## 3 c 0.30 -0.2 0.5 S-C
## 4 d 0.10 -0.2 0.3 S-C
## 5 e 1.00 0.2 1.3 S-C
## 6 f 0.00 -0.1 0.2 S-C
a[[1, "estimate"]]
## [1] 0.35