# \donttest{
set.seed(123)
n <- 300
S2 <- cbind(2*runif(n) - 1, 2*runif(n) - 1)
Z2 <- 4 * S2[, 1] + S2[, 2]
E2 <- 0.2 * runif(n) - 0.1
T2 <- cos(pi * Z2^3) + Z2 / 4 + E2
Y2 <- T2^2 + T2 + 10 * Z2 + rnorm(n, mean = 0, sd = 1)
X2 <- cbind(T2, S2)
t_qry2 = seq(min(T2) + 0.01, max(T2) - 0.01, length.out = 100)
chk <- Sys.getenv("_R_CHECK_LIMIT_CORES_", "")
if (nzchar(chk) && chk == "TRUE") {
# use 2 cores in CRAN/Travis/AppVeyor
num_workers <- 2L
} else {
# use all cores in devtools::test()
num_workers <- parallel::detectCores()
}
m_est2 = IntegEst(Y2, X2, t_eval = t_qry2, h_bar = NULL, kernT_bar = "gaussian",
h = NULL, b = NULL, C_h = 7, C_b = 3, print_bw = FALSE,
degree = 2, deriv_ord = 1, kernT = "epanechnikov",
kernS = "epanechnikov", parallel = FALSE, cores = num_workers)
plot(t_qry2, m_est2, type="l", col = "blue", xlab = "t", lwd=5,
ylab="(Estimated) dose-response curves")
lines(t_qry2, t_qry2^2 + t_qry2, col = "red", lwd=3)
legend(-2, 6, legend=c("Estimated curve", "True curve"), fill = c("blue","red"))
# }
Run the code above in your browser using DataLab