binless: binless

Description Usage Arguments Details Value See Also Examples

Description

Perform binless Visual Predictive Check (VPC)

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
binless(o, ...)

## S3 method for class 'tidyvpcobj'
binless(
  o,
  qpred = c(0.05, 0.5, 0.95),
  optimize = TRUE,
  optimization.interval = c(0, 7),
  conf.level = 0.95,
  loess.ypc = FALSE,
  lambda = NULL,
  span = NULL,
  ...
)

Arguments

o

tidyvpc object

...

other arguments

qpred

numeric vector of length 3 specifying quantiles (lower, median, upper) i.e. c(0.1, 0.5, 0.9)

optimize

logical indicating whether lambda and span should be optimized using AIC

optimization.interval

numeric vector of length 2 specifying interval for lambda optimization

conf.level

numeric confidence level for binless fit

loess.ypc

logical indicating loess precition corrected. Must first use predcorrect() if loess.ypc = TRUE

lambda

numeric vector of length 3 specifying lambda values for each quantile

span

numeric number between 0,1 specying smoothing paramter for loess prediction corrected

Details

Use this function in subsitute of traditional binning methods to derive VPC using additive quantile regression and loess for pcVPC.

Value

Updates tidyvpcobj with additive quantile regression fits for observed and simulated data for quantiles specified in qpred argument. If 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.

See Also

observed simulated censoring predcorrect stratify binning vpcstats

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
obs_data <- data.table::as.data.table(tidyvpc::obs_data)
sim_data <- data.table::as.data.table(tidyvpc::sim_data)

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) %>%
      predcorrect(pred = PRED) %>%
      binless(optimize = TRUE, loess.ypc = TRUE) %>%
      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(qpred = c(0.1, 0.5, 0.9), optimize = FALSE, lambda = lambda_strat) %>%
      vpcstats()

tidyvpc documentation built on Jan. 13, 2021, 6:31 a.m.