Estimate smoothed exposure-response function (ERF) for pseudo population
Source:R/estimate_npmetric_erf.R
estimate_npmetric_erf.Rd
Estimate smoothed exposure-response function (ERF) for matched and weighted data set using non-parametric models.
Usage
estimate_npmetric_erf(
m_Y,
m_w,
counter_weight,
bw_seq,
w_vals,
nthread,
kernel_appr = "locpol"
)
Arguments
- m_Y
A vector of outcome variable in the matched set.
- m_w
A vector of continuous exposure variable in the matched set.
- counter_weight
A vector of counter or weight variable in the matched set.
- bw_seq
A vector of bandwidth values.
- w_vals
A vector of values that you want to calculate the values of the ERF at.
- nthread
The number of available cores.
- kernel_appr
Internal kernel approach. Available options are
locpol
andkernsmooth
.
Value
The function returns a gpsm_erf object. The object includes the following attributes:
params
m_Y
m_w
bw_seq
w_vals
erf
fcall
Examples
# \donttest{
set.seed(697)
m_d <- generate_syn_data(sample_size = 200)
pseudo_pop <- generate_pseudo_pop(m_d[, c("id", "w")],
m_d[, c("id", "cf1","cf2","cf3",
"cf4","cf5","cf6")],
ci_appr = "matching",
pred_model = "sl",
sl_lib = c("m_xgboost"),
params = list(xgb_nrounds=c(10,20,30),
xgb_eta=c(0.1,0.2,0.3)),
nthread = 1,
covar_bl_method = "absolute",
covar_bl_trs = 0.1,
covar_bl_trs_type="mean",
max_attempt = 1,
dist_measure = "l1",
delta_n = 1,
scale = 0.5)
#> mean absolute correlation: 0.233156732082237| Covariate balance threshold: 0.1
#> mean absolute correlation: 0.189312229205105| Covariate balance threshold: 0.1
#> Covariate balance condition has not been met.
#> Best mean absolute correlation: 0.189312229205105| Covariate balance threshold: 0.1
data <- merge(m_d[, c("id", "Y")], pseudo_pop$pseudo_pop, by = "id")
erf_obj <- estimate_npmetric_erf(data$Y,
data$w,
data$counter_weight,
bw_seq=seq(0.2,2,0.2),
w_vals = seq(2,20,0.5),
nthread = 1)
#> Error in checkForRemoteErrors(val): one node produced an error: could not find function "smooth_erf_locpol"
# }