以下の検定ではP<0.05を有意な値として検定を行う。

パッケージの読み込み

データの読み込み

ds1 <- read_excel("サンプルデータ.xlsx", na='.', 1) 

1.TCの比較に対する母平均の差の検定

まずはデータの可視化

ggplot(ds1, aes(x=factor(治療法), y=TC)) + 
    geom_violin() +
    geom_boxplot(width=0.1)

2群はある程度左右対称でありt検定を用いる。

t.test(TC~治療法, data=ds1, var.equal=T)
## 
##  Two Sample t-test
## 
## data:  TC by 治療法
## t = 0.74948, df = 236, p-value = 0.4543
## alternative hypothesis: true difference in means between group 1 and group 2 is not equal to 0
## 95 percent confidence interval:
##  -5.814518 12.955049
## sample estimates:
## mean in group 1 mean in group 2 
##        193.7099        190.1397

上記結果から2群に有意差は認めなかった。

2.TGの比較に対する母平均の差の検定

まずはデータの可視化

ggplot(ds1, aes(x=factor(治療法), y=TG)) + 
    geom_violin() +
    geom_boxplot(width=0.1)

明らかに左右非対称で、右に裾を引く分布となる。 このため、Wilcoxon検定を用いる。

wilcox_test(TG~as.factor(治療法), data=ds1, distribution="exact", conf.int=TRUE)
## 
##  Exact Wilcoxon-Mann-Whitney Test
## 
## data:  TG by as.factor(治療法) (1, 2)
## Z = 0.14902, p-value = 0.8821
## alternative hypothesis: true mu is not equal to 0
## 95 percent confidence interval:
##  -6.865141  8.233999
## sample estimates:
## difference in location 
##              0.1404705

上記結果より2群に有意差は認めなかった。

3.TC5年後変化量の正負(変化量が正なら1,変化量が負なら0と定義)の比較に対する独立性の検定

TC5年後変化量の正負のデータを作成する。

ds2 <-ds1 %>%  mutate(five_year_con=5年後のTC-TC) 
ds3 <-ds2 %>%  mutate(five_year_cate= if_else(five_year_con>=0,1,0))
ds3
## # A tibble: 238 × 21
##    症例番号  性別  年齢 重症度 治療法 有効性  施設  身長  体重   sBP   dBP    TC
##       <dbl> <dbl> <dbl>  <dbl>  <dbl>  <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
##  1        1     2  33.7      4      1      1     1  171.  62.7  147.  76.4  197.
##  2        2     1  40.3      3      2      1     1  161.  52.2  151.  67.9  181.
##  3        3     2  41.9      4      2      0     1  184.  86.3  140.  79.1  190.
##  4        4     1  36.6      3      1      1     1  176.  52.2  136.  67.8  130.
##  5        5     2  42.8      3      2      1     1  186.  72.6  161.  90.3  172.
##  6        6     2  39.1      1      1      0     1  172.  68.1  125.  70.4  233.
##  7        7     2  36.5      2      2      1     1  186.  69.9  154.  77.2  193.
##  8        8     2  34.8      4      1      1     1  182.  84.0  143.  72.7  154.
##  9        9     2  38.8      3      2      1     1  187.  80.8  145.  80.6  233.
## 10       10     2  40.5      4      2      0     1  184.  71.7  159.  87.7  200.
## # … with 228 more rows, and 9 more variables: TG <dbl>, HbA1c <dbl>,
## #   5年後のTC <dbl>, 5年後のTG <dbl>, イベントの有無 <dbl>,
## #   観察打ち切りの理由 <chr>, 生存時間 <dbl>, five_year_con <dbl>,
## #   five_year_cate <dbl>

正・負データでの問題はなさそであることは確認できた。

CreateTableOne(vars="five_year_cate",strata = "治療法",factorVars = "five_year_cate",data = ds3,test = F)
##                         Stratified by 治療法
##                          1           2          
##   n                      126         112        
##   five_year_cate = 1 (%)  20 (15.9)   23 (20.5)

症例数としては20例と症例数も確保され、独立性の検定にカイ二乗検定を用いても問題なさそうである。

一応可視化も行う。

ggplot(data=ds3, mapping=aes(x=five_year_cate)) + 
    geom_bar()+
  facet_wrap(~治療法)

両群に近しい所見であり、予想としては差はない可能性が高いと思われる。

カイ二乗検定

chisq.test(table(ds3 [,c("治療法", "five_year_cate")]))
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  table(ds3[, c("治療法", "five_year_cate")])
## X-squared = 0.58434, df = 1, p-value = 0.4446

以上より両群に有意差は認めない。

4.共変量を治療法とした有効性(1:有効,0:無効)に関するロジスティック回帰

ひとまず可視化を行う 連続量データがないためgeom_pointではなく、棒グラフとして比較してみる。

ggplot(data=ds1, mapping=aes(x=有効性)) + 
    geom_bar()+
  facet_wrap(~治療法)

視覚情報からは治療法1.2によって有効性に差を認める結果になりそうである。

res <- glm(有効性~治療法, data=ds1, family=binomial(link="logit"))
summary(res)
## 
## Call:
## glm(formula = 有効性 ~ 治療法, family = binomial(link = "logit"), 
##     data = ds1)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.2858  -0.9925  -0.9925   1.0727   1.3744  
## 
## Coefficients:
##             Estimate Std. Error z value Pr(>|z|)   
## (Intercept)  -1.1553     0.4121  -2.803  0.00506 **
## 治療法        0.7033     0.2640   2.664  0.00771 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 329.11  on 237  degrees of freedom
## Residual deviance: 321.91  on 236  degrees of freedom
## AIC: 325.91
## 
## Number of Fisher Scoring iterations: 4
exp(res[[1]])
## (Intercept)      治療法 
##   0.3149679   2.0204082
 exp(confint(res))
## Waiting for profiling to be done...
##                 2.5 %   97.5 %
## (Intercept) 0.1390812 0.701775
## 治療法      1.2080452 3.404837

以上より、治療法2は治療法1に対し、オッズ比2.02(1.21-3.40)と有意に有効性を認める結果である。