-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NAs in sign.test, plus Nsigntest. Close #326
- Loading branch information
Showing
6 changed files
with
56 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,49 @@ | ||
|
||
paired.t <- function(x, y, ...) { | ||
paired.t <- function(x, y, ..., na.rm = TRUE) { | ||
if(is.Date(x) && is.Date(y)) | ||
{ | ||
x <- as.integer(x) | ||
y <- as.integer(y) | ||
} | ||
if(na.rm) { | ||
idx <- is.na(x) | is.na(y) | ||
x <- x[!idx] | ||
y <- y[!idx] | ||
} | ||
stats::t.test(x, y, paired = TRUE) | ||
} | ||
|
||
mcnemar <- function(x, y, mcnemar.correct = TRUE, ...) | ||
mcnemar <- function(x, y, mcnemar.correct = TRUE, ..., na.rm = TRUE) | ||
{ | ||
if(na.rm) { | ||
idx <- is.na(x) | is.na(y) | ||
x <- x[!idx] | ||
y <- y[!idx] | ||
} | ||
stats::mcnemar.test(x, y, correct = mcnemar.correct) | ||
} | ||
|
||
signed.rank <- function(x, y, signed.rank.exact = NULL, signed.rank.correct = TRUE, ...) | ||
signed.rank <- function(x, y, signed.rank.exact = NULL, signed.rank.correct = TRUE, ..., na.rm = TRUE) | ||
{ | ||
if(is.ordered(x) && is.ordered(y)) | ||
{ | ||
x <- as.integer(x) | ||
y <- as.integer(y) | ||
} | ||
if(na.rm) { | ||
idx <- is.na(x) | is.na(y) | ||
x <- x[!idx] | ||
y <- y[!idx] | ||
} | ||
stats::wilcox.test(x, y, paired = TRUE, exact = signed.rank.exact, correct = signed.rank.correct) | ||
} | ||
|
||
sign.test <- function(x, y, ...) | ||
sign.test <- function(x, y, ..., na.rm = TRUE) | ||
{ | ||
if(na.rm) { | ||
idx <- is.na(x) | is.na(y) | ||
x <- x[!idx] | ||
y <- y[!idx] | ||
} | ||
stats::binom.test(c(sum(x > y), sum(x < y))) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1f853e8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello again,
Thank you for your prompt reply and for modifying the package to account for
NA
s. Thesign.test
is working correctly.The bug now is:
-the "N" option displays always the number of subjects in the group originally present, instead of how many where actually used for the calculation of the summary statistic. Same bug with Nmiss. I went back to the previous code for "N" and "Nmiss" and the problem was solved.
What I mean is that previously the table would show:
and now it shows:
Which is clearly wrong, since there are patients missing.
Also for
Nsigntest
, I believe that the most informative position would be next to the p-value instead of a separate line as in the following table (possibly with a footnote?)Finally, for the difference column, especially when the summary statistic displayed is "medianmad", it would be very informative to show how many differences were negative, how many were 0 and how many were positive in order to have a better idea of the underlying observations (the string could be something like N/Z/P or -/0+ with or without the percentages of the observations depending on how crowded the lines are; or the percentages could be on a separate line):
Thank you again for a great package.
Alex
1f853e8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Dunno what I was thinking there. Chalk it up to a Friday afternoon, I guess? Sorry about that.
I'll track the other two requests in separate issues (#328 and #329)
1f853e8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's exactly what I thought! :)
Thanx again for taking care of it fast.