Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Another option, with <code>ldply</code>, <strong>but see hadley's comment below for a more efficient use of <code>ldply</code></strong>: </p> <pre><code> # prepare data x &lt;- seq(1:10) y &lt;- sin(x)^2 dat &lt;- data.frame(x,y) # create list of named models obviously these are not suited to the data here, just to make the workflow work... models &lt;- list(model1=lm(y~x, data = dat), model2=lm(y~I(1/x), data=dat), model3=lm(y ~ log(x), data = dat), model4=nls(y ~ I(1/x*a) + b*x, data = dat, start = list(a = 1, b = 1)), model5=nls(y ~ (a + b*log(x)), data=dat, start = setNames(coef(lm(y ~ log(x), data=dat)), c("a", "b"))), model6=nls(y ~ I(exp(1)^(a + b * x)), data=dat, start = list(a=0,b=0)), model7=nls(y ~ I(1/x*a)+b, data=dat, start = list(a=1,b=1)) ) library(plyr) library(AICcmodavg) # for small sample sizes # build table with model names, function, AIC and AICc data.frame(cbind(ldply(models, function(x) cbind(AICc = AICc(x), AIC = AIC(x))), model = sapply(1:length(models), function(x) deparse(formula(models[[x]]))) )) .id AICc AIC model 1 model1 15.89136 11.89136 y ~ x 2 model2 15.78480 11.78480 y ~ I(1/x) 3 model3 15.80406 11.80406 y ~ log(x) 4 model4 16.62157 12.62157 y ~ I(1/x * a) + b * x 5 model5 15.80406 11.80406 y ~ (a + b * log(x)) 6 model6 15.88937 11.88937 y ~ I(exp(1)^(a + b * x)) 7 model7 15.78480 11.78480 y ~ I(1/x * a) + b </code></pre> <p>It's not immediately obvious to me how to replace the <code>.id</code> with a column name in the <code>ldply</code> function, any tips?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload