tests/testthat/test-distance.R

set.seed(123)
## Standard scenario
n = 200
x = rnorm(n)
y = x + rnorm(n)
plot(x, y)
abline(a = 0, b = 1, col = "red")
CPOP::identity_dist(x, y)

## Bias scenario
z = y - 1
plot(x, z)
abline(a = 0, b = 1, col = "red")
CPOP::identity_dist(x, z)

mse = function(x, y){
  ## Assuming x is the truth
  var(y) + mean(y - x)^2
}
mse(x, y)
mse(x, z)
kevinwang09/top documentation built on April 20, 2022, 3:01 a.m.