Skip to content

Commit c15e41d

Browse files
authored
Merge pull request #23 from mthulin/master
Fix bootstrap residuals and add permutation residuals
2 parents 91c02cf + 2f13ee0 commit c15e41d

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

R/method-model.r

+14-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
#'
77
#' @param f model specification formula, as defined by \code{\link{lm}}
88
#' @param method method for generating null residuals. Built in methods
9-
#' 'rotate', 'pboot' and 'boot' are defined by \code{\link{resid_rotate}},
10-
#' \code{\link{resid_pboot}} and \code{\link{resid_boot}} respectively
9+
#' 'rotate', 'perm', 'pboot' and 'boot' are defined by \code{\link{resid_rotate}},
10+
#' \code{\link{resid_perm}}, \code{\link{resid_pboot}} and \code{\link{resid_boot}}
11+
#' respectively
1112
#' @param ... other arguments passedd onto \code{method}.
1213
#' @return a function that given \code{data} generates a null data set.
1314
#' For use with \code{\link{lineup}} or \code{\link{rorschach}}
@@ -93,5 +94,16 @@ resid_sigma <- function(model, data, sigma = 1) {
9394
#' @importFrom stats resid
9495
#' @export
9596
resid_boot <- function(model, data) {
97+
sample(stats::resid(model), replace = TRUE)
98+
}
99+
100+
#' Permutation residuals.
101+
#'
102+
#' For use with \code{\link{null_lm}}
103+
#'
104+
#' @param model to extract residuals from
105+
#' @importFrom stats resid
106+
#' @export
107+
resid_perm <- function(model, data) {
96108
sample(stats::resid(model))
97109
}

0 commit comments

Comments
 (0)