Shape Mean: Overall

取 2~17 秒

dta <- read.csv("Forinter.csv")
dta <- dta[1:20,]
#str(dta)
dtalong <- melt(dta,id=c("Subjects","Negative","ZY7"))
dtalong$Channel <-substr(dtalong$variable,1,3)
dtalong$Condition <-substr(dtalong$variable,5,6)
dtalong$Condition <- as.factor(dtalong$Condition)
dtalong$Channel <- as.factor(dtalong$Channel)

Shape Mean: Overall Test

fit <- aov(value~Condition+Error(Subjects/Condition),
           data=subset(dtalong,
                       dtalong$Channel == "Ch1"))
summary(fit)

Error: Subjects
          Df Sum Sq Mean Sq F value Pr(>F)
Residuals  1   12.7    12.7               

Error: Subjects:Condition
          Df Sum Sq Mean Sq
Condition  2    127   63.52

Error: Within
          Df Sum Sq Mean Sq F value Pr(>F)
Condition  2   68.7   34.34   0.635  0.534
Residuals 54 2921.0   54.09               
fit <- aov(value~Condition+Error(Subjects/Condition),
           data=subset(dtalong,
                       dtalong$Channel == "Ch2"))
summary(fit)

Error: Subjects
          Df Sum Sq Mean Sq F value Pr(>F)
Residuals  1  22.31   22.31               

Error: Subjects:Condition
          Df Sum Sq Mean Sq
Condition  2  12.96    6.48

Error: Within
          Df Sum Sq Mean Sq F value Pr(>F)
Condition  2     27   13.32   0.221  0.803
Residuals 54   3258   60.34               
fit <- aov(value~Condition+Error(Subjects/Condition),
           data=subset(dtalong,
                       dtalong$Channel == "Ch3"))
summary(fit)

Error: Subjects
          Df Sum Sq Mean Sq F value Pr(>F)
Residuals  1  26.92   26.92               

Error: Subjects:Condition
          Df Sum Sq Mean Sq
Condition  2  34.14   17.07

Error: Within
          Df Sum Sq Mean Sq F value Pr(>F)
Condition  2    9.9    4.96   0.094  0.911
Residuals 54 2855.1   52.87               
fit <- aov(value~Condition+Error(Subjects/Condition),
           data=subset(dtalong,
                       dtalong$Channel == "Ch4"))
summary(fit)

Error: Subjects
          Df Sum Sq Mean Sq F value Pr(>F)
Residuals  1  18.12   18.12               

Error: Subjects:Condition
          Df Sum Sq Mean Sq
Condition  2  600.8   300.4

Error: Within
          Df Sum Sq Mean Sq F value Pr(>F)
Condition  2     69   34.69     0.3  0.742
Residuals 48   5552  115.67               

Boot Ci Plot

dta <- readRDS("ZY_NIRS.Rdata")
dta <- na.omit(dta)
dtacondsum <- data_summarize(dta,1:33,4:36,1,3,c(2,37),c(1,3,37))
dtacondsum$Channel <- factor(dtacondsum$Channel,levels = c("CH1_HBO","CH2_HBO","CH3_HBO","CH4_HBO"),
                             labels = c("Ch1","Ch2","Ch3","Ch4"))
dtacondsum$Cond <- factor(dtacondsum$Cond,levels = c("ZY","nZY","Control"),labels=c("ZY","non-ZY","Control"))
ciplot(dtacondsum,seq(2,16,by=0.5),datacol = 8:36,
       subjcol = 1,chancol = 2,othvarcol = c(3:7),cpvarcol = 3,
       ci.alpha = 0.2,type = "boot", bootnum = 2000)+
        theme_bw()+
        labs(list(title = "Curve with Bootstrapping Interval of Four Channels",x = "Time Points",y="Signal"))

Interaction

dta_inter <- subset(dtalong,dtalong$Condition %in% c("ZY","nZ"))
dta_inter$Condition <- as.factor(dta_inter$Condition) 
dta_ZY7_H <- subset(dta_inter,dta_inter$ZY7 >=  mean(dta_inter$ZY7)) 
dta_ZY7_L <- subset(dta_inter,dta_inter$ZY7 < mean(dta_inter$ZY7)) 
dta_Neg_H <- subset(dta_inter,dta_inter$Negative >= mean(dta_inter$Negative)) 
dta_Neg_L <- subset(dta_inter,dta_inter$Negative < mean(dta_inter$Negative)) 
# dta_ZY7_H
t.test(value~Condition,paired = T,
           data=subset(dta_ZY7_H,
                       dta_ZY7_H$Channel == "Ch1"))

    Paired t-test

data:  value by Condition
t = -1.4585, df = 10, p-value = 0.1754
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -8.408629  1.755512
sample estimates:
mean of the differences 
              -3.326558 
t.test(value~Condition,paired=T,
           data=subset(dta_ZY7_H,
                       dta_ZY7_H$Channel == "Ch2"))

    Paired t-test

data:  value by Condition
t = -1.0941, df = 10, p-value = 0.2996
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -5.276285  1.801087
sample estimates:
mean of the differences 
              -1.737599 
t.test(value~Condition,paired=T,
           data=subset(dta_ZY7_H,
                       dta_ZY7_H$Channel == "Ch3"))

    Paired t-test

data:  value by Condition
t = -0.72366, df = 10, p-value = 0.4859
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -4.292213  2.187675
sample estimates:
mean of the differences 
              -1.052269 
t.test(value~Condition,paired=T,
           data=subset(dta_ZY7_H,
                       dta_ZY7_H$Channel == "Ch4"))

    Paired t-test

data:  value by Condition
t = 0.37846, df = 9, p-value = 0.7139
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -3.501021  4.907832
sample estimates:
mean of the differences 
              0.7034052 
# dta_ZY7_L
t.test(value~Condition,paired=T,
           data=subset(dta_ZY7_L,
                       dta_ZY7_L$Channel == "Ch1"))

    Paired t-test

data:  value by Condition
t = -1.551, df = 8, p-value = 0.1595
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -3.7455292  0.7331806
sample estimates:
mean of the differences 
              -1.506174 
t.test(value~Condition,paired=T,
           data=subset(dta_ZY7_L,
                       dta_ZY7_L$Channel == "Ch2"))

    Paired t-test

data:  value by Condition
t = -0.53079, df = 8, p-value = 0.61
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -2.331368  1.458921
sample estimates:
mean of the differences 
             -0.4362235 
t.test(value~Condition,paired=T,
           data=subset(dta_ZY7_L,
                       dta_ZY7_L$Channel == "Ch3"))

    Paired t-test

data:  value by Condition
t = 0.055566, df = 8, p-value = 0.9571
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -2.431774  2.551861
sample estimates:
mean of the differences 
             0.06004345 
t.test(value~Condition,paired=T,
           data=subset(dta_ZY7_L,
                       dta_ZY7_L$Channel == "Ch4"))

    Paired t-test

data:  value by Condition
t = -2.4361, df = 7, p-value = 0.04502
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -5.39808263 -0.08036339
sample estimates:
mean of the differences 
              -2.739223 
#dta_Neg_H
t.test(value~Condition,paired=T,
           data=subset(dta_Neg_H,
                       dta_Neg_H$Channel == "Ch1"))

    Paired t-test

data:  value by Condition
t = -2.1752, df = 8, p-value = 0.06132
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -10.7116982   0.3126604
sample estimates:
mean of the differences 
              -5.199519 
t.test(value~Condition,paired=T,
           data=subset(dta_Neg_H,
                       dta_Neg_H$Channel == "Ch2"))

    Paired t-test

data:  value by Condition
t = -2.671, df = 8, p-value = 0.02832
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -7.0360105 -0.5159602
sample estimates:
mean of the differences 
              -3.775985 
t.test(value~Condition,paired=T,
           data=subset(dta_Neg_H,
                       dta_Neg_H$Channel == "Ch3"))

    Paired t-test

data:  value by Condition
t = -2.0632, df = 8, p-value = 0.073
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -4.7962622  0.2665823
sample estimates:
mean of the differences 
               -2.26484 
t.test(value~Condition,paired=T,
           data=subset(dta_Neg_H,
                       dta_Neg_H$Channel == "Ch4"))

    Paired t-test

data:  value by Condition
t = -2.0869, df = 6, p-value = 0.08195
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -8.7220719  0.6926218
sample estimates:
mean of the differences 
              -4.014725 
#dta_Neg_L
t.test(value~Condition,paired=T,
           data=subset(dta_Neg_L,
                       dta_Neg_L$Channel == "Ch1"))

    Paired t-test

data:  value by Condition
t = -0.28409, df = 10, p-value = 0.7821
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -2.694755  2.085293
sample estimates:
mean of the differences 
             -0.3047309 
t.test(value~Condition,paired=T,
           data=subset(dta_Neg_L,
                       dta_Neg_L$Channel == "Ch2"))

    Paired t-test

data:  value by Condition
t = 1.1823, df = 10, p-value = 0.2644
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -0.880113  2.869980
sample estimates:
mean of the differences 
              0.9949334 
t.test(value~Condition,paired=T,
           data=subset(dta_Neg_L,
                       dta_Neg_L$Channel == "Ch3"))

    Paired t-test

data:  value by Condition
t = 0.65013, df = 10, p-value = 0.5303
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -2.062935  3.762751
sample estimates:
mean of the differences 
               0.849908 
t.test(value~Condition,paired=T,
           data=subset(dta_Neg_L,
                       dta_Neg_L$Channel == "Ch4"))

    Paired t-test

data:  value by Condition
t = 0.98903, df = 10, p-value = 0.346
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -1.506091  3.910336
sample estimates:
mean of the differences 
               1.202122 
dta_inter$Neg <- ifelse(dta_inter$Negative >= mean(dta_inter$Negative),"H","L") 
dtaplot <- summarySE(dta_inter,measurevar = "value",
                     groupvars=c("variable","Channel","Condition","Neg"),na.rm=T)
dtaplot$Condition <- factor(dtaplot$Condition,levels=c("ZY","nZ")) 
ggplot(dtaplot, aes(x=Neg, y=value,fill=Condition)) + 
    geom_bar(position=position_dodge(), stat="identity",width=.3) +
    geom_errorbar(aes(ymin= value-se, ymax= value+se),
                  width=.1,                    # Width of the error bars
                  position=position_dodge(.3))+
        #theme(axis.title.y = element_text(size = rel(2), angle = 90),
        #      axis.title.x = element_blank(),
        #      axis.text = element_text(size = rel(2)),
        #      legend.text = element_text(size = rel(2)),
        #      legend.title = element_text(size = rel(2)))+
        facet_wrap(~Channel)+
        theme_bw()+
        labs(list(x="Negative Feeling",y = "Signal"))+
        scale_fill_manual(values = c("grey30","grey"),labels=c("non-ZY","ZY"))

Others