knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) set.seed(2353454)
library("varDecomp") library("data.table") library("microbenchmark") data(wage) wage <- wage[wage$wage > 5000, ] setDT(wage) f <- log(wage) ~ racer + educr
wage2 <- copy(wage) microbenchmark::microbenchmark({ varDecomp(wage, wage2, f, silent = TRUE, precision = .001) }, times = 10) microbenchmark::microbenchmark({ varDecomp(wage, wage2, f, silent = TRUE, precision = 1e-11) }, times = 10)
wage[, wt := 1] wage2 <- copy(wage) wage2[educr == "4-year college+", wt := 2] microbenchmark::microbenchmark({ varDecomp(wage, wage2, f, weight = "wt", silent = TRUE, precision = .001) }, times = 10) microbenchmark::microbenchmark({ varDecomp(wage, wage2, f, weight = "wt", silent = TRUE, precision = 1e-11) }, times = 10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.