Skip to content

Commit 5f2e566

Browse files
committed
change postive use chisq.test
1 parent ea88d0c commit 5f2e566

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

hospital.Rmd

+19-8
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ summary(AC_lm)
402402

403403
R方为0.0769,模型效果比全部数据建模效果更不明显
404404

405-
## 同组中各指标间阳性率T检验
405+
## 同组中各指标间阳性率卡方检验
406406

407407
```{r, echo=FALSE, warning=FALSE, include=FALSE}
408408
@@ -418,10 +418,21 @@ TTTT.test <- function(DaTa, group1, Col1, Col2){
418418
Group2 <- DaTa %>% filter(Y_CLASS == group1) %>%
419419
as.data.frame(.) %>% .[, Col2]
420420
421+
Group1_sum <- sum(Group1)
422+
Group1_0 <- length(Group1) - Group1_sum
423+
424+
Group2_sum <- sum(Group2)
425+
Group2_0 <- length(Group2) - Group2_sum
426+
427+
Matrix10 <- matrix(c(Group1_sum,
428+
Group2_sum,
429+
Group1_0,
430+
Group2_0), nrow = 2, ncol = 2)
431+
421432
data.frame(class = group1,
422433
Col1 = Col1,
423434
Col2 = Col2,
424-
pvalue = t.test(Group1, Group2)$p.value,
435+
pvalue = chisq.test(Matrix10)$p.value,
425436
row.names = NULL)
426437
427438
}
@@ -461,7 +472,7 @@ Normaldata_p <- newdata111 %>%
461472
pvalue = as.character(pvalue)) %>%
462473
select(-class) %>%
463474
spread(Col2, pvalue)
464-
kable(Normaldata_p, caption = '正常白蛋白尿组各指标间T检验')
475+
kable(Normaldata_p, caption = '正常白蛋白尿组各指标间卡方检验')
465476
```
466477

467478
```{r, echo=FALSE}
@@ -473,7 +484,7 @@ Normaldata_p <- newdata111 %>%
473484
pvalue = as.character(pvalue)) %>%
474485
select(-class) %>%
475486
spread(Col2, pvalue)
476-
kable(Normaldata_p, caption = '微量白蛋白尿组各指标间T检验')
487+
kable(Normaldata_p, caption = '微量白蛋白尿组各指标间卡方检验')
477488
```
478489

479490
```{r, echo=FALSE}
@@ -485,11 +496,11 @@ Bigdata_p <- newdata111 %>%
485496
pvalue = as.character(pvalue)) %>%
486497
select(-class) %>%
487498
spread(Col2, pvalue)
488-
kable(Bigdata_p, caption = '大量白蛋白尿组各指标间T检验')
499+
kable(Bigdata_p, caption = '大量白蛋白尿组各指标间卡方检验')
489500
```
490501

491502

492-
## 同组中各指标间阳性率T检验(合并正常与微量)
503+
## 同组中各指标间阳性率卡方检验(合并大量与微量)
493504

494505

495506
```{r, echo=FALSE}
@@ -549,7 +560,7 @@ Normaldata_p_com <- newdata1111 %>%
549560
pvalue = as.character(pvalue)) %>%
550561
select(-class) %>%
551562
spread(Col2, pvalue)
552-
kable(Normaldata_p_com, caption = '正常白蛋白尿组各指标间T检验(合并)')
563+
kable(Normaldata_p_com, caption = '正常白蛋白尿组各指标间卡方检验(合并)')
553564
```
554565

555566
```{r, echo=FALSE}
@@ -561,5 +572,5 @@ Bigdata_p_com <- newdata1111 %>%
561572
pvalue = as.character(pvalue)) %>%
562573
select(-class) %>%
563574
spread(Col2, pvalue)
564-
kable(Bigdata_p_com, caption = '大量白蛋白尿组各指标间T检验(合并)')
575+
kable(Bigdata_p_com, caption = '大量白蛋白尿组各指标间卡方检验(合并)')
565576
```

0 commit comments

Comments
 (0)