Learn R Programming

tidyvpc (version 1.1.0)

predcorrect: predcorrect

Description

Prediction corrected Visual Predictive Check (pcVPC)

Usage

predcorrect(o, ...)

# S3 method for tidyvpcobj predcorrect(o, pred, data = o$data, ..., log = FALSE)

Arguments

o

tidyvpc object

...

Other arguments to include

pred

prediction variable in observed data

data

observed data supplied in observed() function

log

logical indicating whether DV was modeled in logarithimic scale

Value

Updates tidyvpcobj with required information to performing prediction correction which include predcor logical indicating whether prediction corrected VPC is to be performed, predcor.log logical indicating whether the DV is on a log-scale, and the pred prediction column from the original data.

Details

Specify prediction variable for pcVPC

See Also

observed simulated censoring stratify binning binless vpcstats

Examples

Run this code
# NOT RUN {
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]

 # Add PRED variable to observed data from first replicate of 
 # simulated data
 
obs_data$PRED <- sim_data[REP == 1, PRED]

  vpc <- observed(obs_data, x=TIME, y=DV) %>%
       simulated(sim_data, y=DV) %>%
       binning(bin = NTIME) %>%
       predcorrect(pred=PRED) %>%
       vpcstats()
       
 
# }
# NOT RUN {
 # For binless loess prediction corrected, use predcorrect() before 
 # binless() and set loess.ypc = TRUE
 
  vpc <- observed(obs_data, x=TIME, y=DV) %>%
       simulated(sim_data, y=DV) %>%
       predcorrect(pred=PRED) %>%
       binless(loess.ypc = TRUE) %>%
       vpcstats()
       
# }
# NOT RUN {
       
# }

Run the code above in your browser using DataLab