library(hadron)
We create some data and replace one column with NA
.
data <- matrix(rnorm(120), ncol = 10) data[, 3] <- NA print(data)
The covariance, with the implicit use = 'everything'
will give us a “cross” of NA
in the covariance matrix.
cov(data)
The jackknife covariance does the same thing.
jackknife_cov(data)
When we have some NA
values in a row, we have a conceptual problem with the jackknife as the width of the jackknife distribution is linked to the number of measurements.
data <- matrix(rnorm(120), ncol = 10) data[2, ] <- NA print(data)
Also here we get the same behavior by default:
cov(data)
jackknife_cov(data)
When we use complete
, we get the same thing as just dropping the NA
rows.
cov(data, use = 'complete')
all(cov(data, use = 'complete') == cov(data[complete.cases(data), ]))
With our jackknife function we get a failure, which should not happen!
jackknife_cov(data, na.rm = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.