Fit models 1 and 2 to data and return the empirical goodnesses of fit as well as the difference in goodness of fit.

empirical.GoF(
  data,
  fun1,
  fun2,
  args1 = NULL,
  args2 = NULL,
  verbose = TRUE,
  GoFname = "GoF"
)

Arguments

data

Data frame

fun1

Modelling function 1

fun2

Modelling function 2

args1

List of arguments passed to fun1

args2

List of arguments passed to fun2

verbose

If TRUE, warnings are printed to the console

GoFname

Name of the element returned by fun1 and fun2 holding the goodness of fit

Value

A 1-row data frame of three columns:

GoF1

Goodness of fit for model 1

GoF2

Goodness of fit for model 2

DeltaGoF

Equal to GoF1 - GoF2

Details

Functions fun1 and fun2 must accept data as an argument in addition to any arguments specified in args1 and args2. They must return a list with an element carrying the calculated goodness of fit; by default the name of this element is taken to be the string "GoF" but this behaviour can be changed through the GoFname argument.

Examples

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)) } empirical.GoF(mockdata, fun1=myfitfun, fun2=myfitfun, args1=list(p=1), args2=list(p=2))
#> GoF1 GoF2 DeltaGoF #> 1 26.71353 27.77766 -1.064127