-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #90 from sfcheung/devel
Update to 0.1.9.7
- Loading branch information
Showing
18 changed files
with
556 additions
and
16 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#' @title Asymmetric Bootstrap p-Value | ||
#' | ||
#' @description Compute the asymmetric | ||
#' bootstrap *p*-value from a vector of | ||
#' bootstrap estimates. | ||
#' | ||
#' @details It computes the *p*-value | ||
#' based on the method presented in | ||
#' Asparouhov and Muthén (2021). | ||
#' | ||
#' @return | ||
#' Numeric. The *p*-value. `NA` if | ||
#' it cannot be computed. | ||
#' | ||
#' @param x A numeric vector. The | ||
#' bootstrap estimates. | ||
#' | ||
#' @param h0 The value for the null | ||
#' hypothesis. Default is zero. | ||
#' | ||
#' @param min_size Integer. The | ||
#' bootstrap *p*-value will be computed | ||
#' only if `x` has at least `min_size` | ||
#' valid values. | ||
#' | ||
#' @references | ||
#' Asparouhov, A., & Muthén, B. (2021). Bootstrap p-value computation. | ||
#' Retrieved from https://www.statmodel.com/download/FAQ-Bootstrap%20-%20Pvalue.pdf | ||
#' | ||
#' @examples | ||
#' x1 <- rnorm(n, 2, 4) | ||
#' est2p(x1) | ||
#' | ||
#' @noRd | ||
|
||
est2p <- function(x, | ||
h0 = 0, | ||
min_size = 100, | ||
warn = FALSE) { | ||
# Based on the method in | ||
# https://www.statmodel.com/download/FAQ-Bootstrap%20-%20Pvalue.pdf | ||
x <- x[!is.na(x)] | ||
if (length(x) == 0) return(NA) | ||
if (length(x) < min_size) { | ||
if (warn) { | ||
warning(paste("Bootstrap p-value not computed. Less than ", | ||
min_size, | ||
"bootstrap estimates.")) | ||
} | ||
return(NA) | ||
} | ||
b <- length(x) | ||
m0 <- sum((x < h0)) | ||
out <- 2 * min(m0 / b, 1 - m0 / b) | ||
out | ||
} |
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
Oops, something went wrong.