Description Usage Arguments Details Value Author(s) References Examples
The data-informed Parametric Bootstrap Cross-fitting Method (PBCM) generates synthetic data from two models of a phenomenon parameterized by fits to an empirical dataset, and then cross-fits the models to these data. The result is two distributions of the goodness of fit metric Δ GoF = GoF_1 - GoF_2, where GoF_1 is the fit of model 1 and GoF_2 the fit of model 2.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
data |
Data frame |
fun1 |
First modelling function |
fun2 |
Second modelling function |
genfun1 |
Generator function for first model |
genfun2 |
Generator function for second model |
reps |
Number of Monte Carlo repetitions |
args1 |
List of arguments passed to |
args2 |
List of arguments passed to |
genargs1 |
List of arguments passed to |
genargs2 |
List of arguments passed to |
print_genargs |
Whether the generator argument values should be included in output (see Details) |
nonparametric_bootstrap |
Whether |
verbose |
If |
GoFname |
Name of the element returned by |
Functions fun1
and fun2
must take data
as an argument in addition to any arguments specified in args1
and args2
. Moreover, these functions must return a list with at least one element carrying the goodness of fit; the name of this element may be specified through the GoFname
argument, by default the string "GoF"
is assumed. Functions genfun1
and genfun2
must take an argument named model
(the output of fun1
and fun2
).
A data frame in long format with the following columns:
rep
Monte Carlo repetition number
generator
Generating model
GoF1
Goodness of fit of model 1
GoF2
Goodness of fit of model 2
DeltaGoF
Equals GoF1 - GoF2
In addition to these columns, if print_genargs == TRUE
, each argument in the lists genargs1
and genargs2
is included as a column of its own, with the argument's name prefixed by "genargs1_"
or "genargs2_"
.
Henri Kauhanen
Wagenmakers, E.-J., Ratcliff, R., Gomez, P. & Iverson, G. J. (2004) Assessing model mimicry using the parametric bootstrap. Journal of Mathematical Psychology, 48(1), 28–50. https://doi.org/10.1016/j.jmp.2003.11.004
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | x <- seq(from=0, to=1, length.out=100)
mockdata <- data.frame(x=x, y=x + rnorm(100, 0, 0.5))
myfitfun <- function(data, p) {
res <- nls(y~a*x^p, data, start=list(a=1.1))
list(a=coef(res), GoF=deviance(res))
}
mygenfun <- function(model, p) {
x <- seq(from=0, to=1, length.out=100)
y <- model$a*x^p + rnorm(100, 0, 0.5)
data.frame(x=x, y=y)
}
pbcm.di(data=mockdata, fun1=myfitfun, fun2=myfitfun, genfun1=mygenfun,
genfun2=mygenfun, reps=20, args1=list(p=1), args2=list(p=2),
genargs1=list(p=1), genargs2=list(p=2))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.