All the tests were done on an Arch Linux x86_64 machine with an Intel(R) Core(TM) i7 CPU (1.90GHz).
We show the performance of computing empirical likelihood with
el_mean(). We test the computation speed with simulated
data sets in two different settings: 1) the number of observations
increases with the number of parameters fixed, and 2) the number of
parameters increases with the number of observations fixed.
We fix the number of parameters at \(p =
10\), and simulate the parameter value and \(n \times p\) matrices using
rnorm(). In order to ensure convergence with a large \(n\), we set a large threshold value using
el_control().
library(ggplot2)
library(microbenchmark)
set.seed(3175775)
p <- 10
par <- rnorm(p, sd = 0.1)
ctrl <- el_control(th = 1e+10)
result <- microbenchmark(
n1e2 = el_mean(matrix(rnorm(100 * p), ncol = p), par = par, control = ctrl),
n1e3 = el_mean(matrix(rnorm(1000 * p), ncol = p), par = par, control = ctrl),
n1e4 = el_mean(matrix(rnorm(10000 * p), ncol = p), par = par, control = ctrl),
n1e5 = el_mean(matrix(rnorm(100000 * p), ncol = p), par = par, control = ctrl)
)Below are the results:
result
#> Unit: microseconds
#> expr min lq mean median uq max
#> n1e2 459.948 517.440 568.6729 536.8755 595.1395 2274.450
#> n1e3 1231.867 1430.787 1590.3326 1515.2300 1652.3800 4313.711
#> n1e4 10629.384 12292.655 15267.3551 15054.6975 15992.3555 94108.977
#> n1e5 160227.706 180903.198 208634.1411 199963.5875 243355.6930 291492.193
#> neval cld
#> 100 a
#> 100 a
#> 100 b
#> 100 c
autoplot(result)
#> Warning: `aes_string()` was deprecated in ggplot2 3.0.0.
#> ℹ Please use tidy evaluation idioms with `aes()`.
#> ℹ See also `vignette("ggplot2-in-packages")` for more information.
#> ℹ The deprecated feature was likely used in the microbenchmark package.
#> Please report the issue at
#> <https://github.com/joshuaulrich/microbenchmark/issues/>.
#> This warning is displayed once per session.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.This time we fix the number of observations at \(n = 1000\), and evaluate empirical likelihood at zero vectors of different sizes.
n <- 1000
result2 <- microbenchmark(
p5 = el_mean(matrix(rnorm(n * 5), ncol = 5),
par = rep(0, 5),
control = ctrl
),
p25 = el_mean(matrix(rnorm(n * 25), ncol = 25),
par = rep(0, 25),
control = ctrl
),
p100 = el_mean(matrix(rnorm(n * 100), ncol = 100),
par = rep(0, 100),
control = ctrl
),
p400 = el_mean(matrix(rnorm(n * 400), ncol = 400),
par = rep(0, 400),
control = ctrl
)
)result2
#> Unit: microseconds
#> expr min lq mean median uq max neval
#> p5 724.48 748.7305 840.7127 780.3805 799.641 3924.827 100
#> p25 2762.70 2800.0945 2900.4594 2820.1515 2866.583 5980.037 100
#> p100 21365.25 23895.9440 25859.0226 24063.6715 28950.421 44246.820 100
#> p400 237932.66 261374.5520 295688.7497 283215.1095 319643.595 421861.572 100
#> cld
#> a
#> a
#> b
#> c
autoplot(result2)On average, evaluating empirical likelihood with a 100000×10 or 1000×400 matrix at a parameter value satisfying the convex hull constraint takes less than a second.