# Compute the power-weighted identification function.
df <- data.frame(
y = rep(x = 2, times = 6),
x = c(1, 2, 3, 1, 2, 3),
a = rep(x = c(1, -2), each = 3)
)
df$powerweighted_if <- powerweighted_if(x = df$x, y = df$y, a = df$a)
print(df)
# The power-weighted identification function reduces to the mean identification
# function at a = 0.
set.seed(12345)
n <- 10
x <- runif(n = n, min = 0, max = 2)
y <- runif(n = n, min = 0, max = 2)
max(abs(powerweighted_if(x = x, y = y, a = 0) - mean_if(x = x, y = y)))
# values are slightly higher than 0 due to rounding error
Run the code above in your browser using DataLab