Description Usage Arguments Details Value Author(s) References Examples
The data-uninformed Parametric Bootstrap Cross-fitting Method (PBCM) generates synthetic data from two models of a phenomenon with given model parameter values, 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 |
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) |
verbose |
If |
GoFname |
Name of the element returned by |
Functions fun1
and fun2
must take an argument named data
in addition to any arguments specified in args1
and args2
; this is used to pass the synthetic data generated by genfun1
and genfun2
. 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.
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 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | 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(a, p) {
x <- seq(from=0, to=1, length.out=100)
y <- a*x^p + rnorm(100, 0, 0.5)
data.frame(x=x, y=y)
}
pbcm.du(fun1=myfitfun, fun2=myfitfun, genfun1=mygenfun, genfun2=mygenfun,
reps=20, args1=list(p=1), args2=list(p=2),
genargs1=list(a=1.1, p=1), genargs2=list(a=1.1, p=2))
sweep <- lapply(X=seq(from=0.5, to=1.5, by=0.1),
FUN=function(X) {
pbcm.du(fun1=myfitfun, fun2=myfitfun, genfun1=mygenfun,
genfun2=mygenfun, reps=20,
args1=list(p=1), args2=list(p=2),
genargs1=list(a=X, p=1), genargs2=list(a=X, p=2))
})
sweep <- do.call(rbind, sweep)
sweep$parameter <- ifelse(is.na(sweep$genargs1_a), sweep$genargs2_a, sweep$genargs1_a)
## Not run:
library(ggplot2)
g <- ggplot(sweep, aes(x=DeltaGoF, fill=generator)) + geom_density(alpha=0.5)
g <- g + facet_wrap(.~parameter)
print(g)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.