calc_NPC: Calculate and plot NPC.

Description Usage Arguments Details Value Note Author(s)

View source: R/calc_NPC.R

Description

Function for performing a Numeric Predictive Check (NPC).

Usage

1
2
3
calc_NPC(exp_data, sim_data, pct = c(10, 20, 30, 40, 50, 60, 70, 75, 80, 85,
  90), nreps, dv_col = "DV", full = TRUE, save_path = "",
  ind_var_col = "TAD", bins = FALSE, name_stub = "")

Arguments

exp_data

data frame containing experimental data.

sim_data

data frame containing all simulated data. Should have the same data points as exp_data, simply multiple simulations of them.

pct

vector of the sizes (in %) of the prediction intervals to be tested.

nreps

numeric. The number of simulations performed.

dv_col

name of column containing DV, for both exp_data and sim_data.

full

TRUE (default) or FALSE. If TRUE, then the function returns maximum output and plots (see Details).

save_path

path for folder to save plots.

ind_var_col

name of column for independent variable for normalised NPC plots (normally TIME or TAD), for both exp_data and sim_data.

bins

numeric vector defining bins for the normalised NPC plots. If set to FALSE then normalised NPC plots not generated.

name_stub

string to be added to the file names of the 3 plots that are saved by the function.

Details

If full==FALSE:
This function will return a named numeric vector, the same length as pct indicating what % of the experimental data lies within each prediction interval tested.

If full==TRUE:
This function will return a list with 8 elements:

$exp_count is simply the number of experimental data points.
$df_NPC is a copy of exp_data with some columns added: 5th, 50th, 95th percentiles of simulated data; normalised_NPC, defined as

normalised_NPC = (DV - median of simulations) / abs(5th OR 95th percentile of simulations - median of simulations),

where 95th percentile is used if DV > median and 5th percentile is used if DV < median.
If normalised_NPC = 0, then observation = median of simulations.
If normalised_NPC = +1, then observation = 95th percentile of simulations.
If normalised_NPC = -1, then observation = 5th percentile of simulations.
Note that

$pct_within_interval + $pct_above_interval + $pct_below_interval = 100.

Value

A series of NPC plots, as well as a list or vector of information (see Details).

Note

Deciding if a number is within the prediction interval is inclusive at both ends. i.e. if the number is equal to either of the quantile limits, it will be considered to be in the interval.

Author(s)

Rupert Austin, Aaron Hayman


jgrevel/BAST1-R-Library documentation built on May 21, 2019, 10:11 a.m.