binless | R Documentation |
Use this function in place of traditional binning methods to derive VPC. For continuous
VPC, this is obtained using additive quantile regression (quantreg::rqss()
) and LOESS for pcVPC. While for categorical
VPC, this is obtained using a generalized additive model (gam(family = "binomial")
).
binless(o, ...)
## S3 method for class 'tidyvpcobj'
binless(
o,
optimize = TRUE,
optimization.interval = c(0, 7),
loess.ypc = NULL,
lambda = NULL,
span = NULL,
sp = NULL,
...
)
o |
A |
... |
Other arguments to include will be ignored. |
optimize |
Logical indicating whether smoothing parameters should be optimized using AIC. |
optimization.interval |
Numeric vector of length 2 specifying the min/max range of smoothing parameter for optimization. Only applicable if |
loess.ypc |
(Deprecated) Argument is ignored. For a LOESS pcVPC using the 'binless' method, usage of |
lambda |
Numeric vector of length 3 specifying lambda values for each quantile. If stratified, specify a |
span |
Numeric between 0,1 specifying smoothing parameter for LOESS prediction correction. Only applicable for continuous VPC with |
sp |
List of smoothing parameters applied to |
For continuous VPC, updates tidyvpcobj
with additive quantile regression fits for observed and simulated data for quantiles specified in the qpred
argument of vpcstats()
.
If the optimize = TRUE
argument is specified, the resulting tidyvpcobj
will contain optimized lambda values according to AIC. For prediction
corrected VPC (pcVPC), specifying loess.ypc = TRUE
will return optimized span value for LOESS smoothing. For categorical VPC,
updates tidyvpcobj
with fits obtained by gam(family="binomial")
for observed and simulated data for each category of DV (in each stratum if stratify
defined).
If optimize = TRUE
argument is specified, the resulting tidyvpcobj
wil contain optimized sp
values according to AIC.
observed
simulated
censoring
predcorrect
stratify
binning
vpcstats
require(magrittr)
require(data.table)
obs_data <- obs_data[MDV == 0]
sim_data <- sim_data[MDV == 0]
vpc <- observed(obs_data, y = DV, x = TIME) %>%
simulated(sim_data, y = DV) %>%
binless() %>%
vpcstats()
# Binless example with LOESS prediction correction
obs_data$PRED <- sim_data[REP == 1, PRED]
vpc <- observed(obs_data, y = DV, x = TIME) %>%
simulated(sim_data, y = DV) %>%
binless(optimize = TRUE) %>%
predcorrect(pred = PRED) %>%
vpcstats()
# Binless example with user specified lambda values stratified on
# "GENDER" with 2 levels ("M", "F"), 10%, 50%, 90% quantiles.
lambda_strat <- data.table(
GENDER_M = c(3,5,2),
GENDER_F = c(1,3,4)
)
vpc <- observed(obs_data, y = DV, x = TIME) %>%
simulated(sim_data, y = DV) %>%
stratify(~ GENDER) %>%
binless(optimize = FALSE, lambda = lambda_strat) %>%
vpcstats(qpred = c(0.1, 0.5, 0.9))
# Binless example for categorical DV with optimized smoothing
vpc <- observed(obs_cat_data, x = agemonths, yobs = zlencat) %>%
simulated(sim_cat_data, ysim = DV) %>%
stratify(~ Country_ID_code) %>%
binless() %>%
vpcstats(vpc.type = "cat", quantile.type = 6)
# Binless example for categorical DV with user specified sp values
user_sp <- list(
Country1_prob0 = 100,
Country1_prob1 = 3,
Country1_prob2 = 4,
Country2_prob0 = 90,
Country2_prob1 = 3,
Country2_prob2 = 4,
Country3_prob0 = 55,
Country3_prob1 = 3,
Country3_prob2 = 200)
vpc <- observed(obs_cat_data, x = agemonths, yobs = zlencat) %>%
simulated(sim_cat_data, ysim = DV) %>%
stratify(~ Country_ID_code) %>%
binless(optimize = FALSE, sp = user_sp) %>%
vpcstats(vpc.type = "categorical", conf.level = 0.9, quantile.type = 6)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.