using aictab() for lmer and glmer modelsFunction not defined when calling aictabError message in lme4::glmer: “ 'what' must be a character string or a function”After trying various optimzers, model simplification running more iterations, when fitting GLMMs, R still produces warning messagesGeneralised linear mixed model error (binary response)glmer with user-defined link function giving error: (maxstephalfit) PIRLS step-halvings failed to reduce devianceA loop to incorporate random effects into generalized linear mixed models using the function lmer()Getting error messages when comparing negative binomial models (glm.nb) using aictabGetting AICc for multiple negative binomial glm modelsR Structural Equation Model in R with random effect errorMixed GLMM Model - Issues with using weights (Using R package 'lme4'Percentage and glmer
Smoothness of finite-dimensional functional calculus
Are the number of citations and number of published articles the most important criteria for a tenure promotion?
What typically incentivizes a professor to change jobs to a lower ranking university?
Problem of parity - Can we draw a closed path made up of 20 line segments...
How does one intimidate enemies without having the capacity for violence?
Why do falling prices hurt debtors?
Why Is Death Allowed In the Matrix?
What are the differences between the usage of 'it' and 'they'?
Why dont electromagnetic waves interact with each other?
Dragon forelimb placement
How do we improve the relationship with a client software team that performs poorly and is becoming less collaborative?
"to be prejudice towards/against someone" vs "to be prejudiced against/towards someone"
Can I ask the recruiters in my resume to put the reason why I am rejected?
Why was the small council so happy for Tyrion to become the Master of Coin?
Can divisibility rules for digits be generalized to sum of digits
Email Account under attack (really) - anything I can do?
What is the word for reserving something for yourself before others do?
To string or not to string
How can I make my BBEG immortal short of making them a Lich or Vampire?
Fencing style for blades that can attack from a distance
What would happen to a modern skyscraper if it rains micro blackholes?
Do I have a twin with permutated remainders?
How can bays and straits be determined in a procedurally generated map?
What do the dots in this tr command do: tr .............A-Z A-ZA-Z <<< "JVPQBOV" (with 13 dots)
using aictab() for lmer and glmer models
Function not defined when calling aictabError message in lme4::glmer: “ 'what' must be a character string or a function”After trying various optimzers, model simplification running more iterations, when fitting GLMMs, R still produces warning messagesGeneralised linear mixed model error (binary response)glmer with user-defined link function giving error: (maxstephalfit) PIRLS step-halvings failed to reduce devianceA loop to incorporate random effects into generalized linear mixed models using the function lmer()Getting error messages when comparing negative binomial models (glm.nb) using aictabGetting AICc for multiple negative binomial glm modelsR Structural Equation Model in R with random effect errorMixed GLMM Model - Issues with using weights (Using R package 'lme4'Percentage and glmer
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am trying to do AICc model selection using aictab()
output. This posting is similar (Function not defined when calling aictab) but does not apply to my problem because it used glm.nb
models and I am using lmer
models and also glmer(family=binomial)
. The aictab
documentation (https://www.rdocumentation.org/packages/AICcmodavg/versions/2.2-1/topics/aictab) says the function can handle lm
, lme
and glm
models: does that include lmer
and glmer
?
My code actually worked a few days ago, but recently broke and returned this error code
Error in aictab.default() : Function not yet defined for this object class
m1 <- lmer(y ~ x + (1|z), data=df)
m2 <- lmer(y ~ w + (1|z), data=df)
m3 <- lmer(y ~ v + (1|z), data=df)
cand.set <- list(m1, m2, m3)
names <- list("x", "w", "v")
aictab(cand.set, modnames=names, second.ord=TRUE, nobs=NULL, sort=TRUE)
r lme4
add a comment |
I am trying to do AICc model selection using aictab()
output. This posting is similar (Function not defined when calling aictab) but does not apply to my problem because it used glm.nb
models and I am using lmer
models and also glmer(family=binomial)
. The aictab
documentation (https://www.rdocumentation.org/packages/AICcmodavg/versions/2.2-1/topics/aictab) says the function can handle lm
, lme
and glm
models: does that include lmer
and glmer
?
My code actually worked a few days ago, but recently broke and returned this error code
Error in aictab.default() : Function not yet defined for this object class
m1 <- lmer(y ~ x + (1|z), data=df)
m2 <- lmer(y ~ w + (1|z), data=df)
m3 <- lmer(y ~ v + (1|z), data=df)
cand.set <- list(m1, m2, m3)
names <- list("x", "w", "v")
aictab(cand.set, modnames=names, second.ord=TRUE, nobs=NULL, sort=TRUE)
r lme4
add a comment |
I am trying to do AICc model selection using aictab()
output. This posting is similar (Function not defined when calling aictab) but does not apply to my problem because it used glm.nb
models and I am using lmer
models and also glmer(family=binomial)
. The aictab
documentation (https://www.rdocumentation.org/packages/AICcmodavg/versions/2.2-1/topics/aictab) says the function can handle lm
, lme
and glm
models: does that include lmer
and glmer
?
My code actually worked a few days ago, but recently broke and returned this error code
Error in aictab.default() : Function not yet defined for this object class
m1 <- lmer(y ~ x + (1|z), data=df)
m2 <- lmer(y ~ w + (1|z), data=df)
m3 <- lmer(y ~ v + (1|z), data=df)
cand.set <- list(m1, m2, m3)
names <- list("x", "w", "v")
aictab(cand.set, modnames=names, second.ord=TRUE, nobs=NULL, sort=TRUE)
r lme4
I am trying to do AICc model selection using aictab()
output. This posting is similar (Function not defined when calling aictab) but does not apply to my problem because it used glm.nb
models and I am using lmer
models and also glmer(family=binomial)
. The aictab
documentation (https://www.rdocumentation.org/packages/AICcmodavg/versions/2.2-1/topics/aictab) says the function can handle lm
, lme
and glm
models: does that include lmer
and glmer
?
My code actually worked a few days ago, but recently broke and returned this error code
Error in aictab.default() : Function not yet defined for this object class
m1 <- lmer(y ~ x + (1|z), data=df)
m2 <- lmer(y ~ w + (1|z), data=df)
m3 <- lmer(y ~ v + (1|z), data=df)
cand.set <- list(m1, m2, m3)
names <- list("x", "w", "v")
aictab(cand.set, modnames=names, second.ord=TRUE, nobs=NULL, sort=TRUE)
r lme4
r lme4
edited Mar 22 at 0:38
Ben Bolker
136k13229322
136k13229322
asked Mar 21 at 23:57
user7898623user7898623
83
83
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
tl;dr you loaded the lmerTest
package, so your models have a different class, which is confusing aictab()
. You could either make sure you have lme4
and not lmerTest
loaded when you fit the models, or use bbmle::AICctab()
, which seems slightly more robust. (It might be worth contacting the package maintainer of AICcmodavg
about this ...)
Set up with lme4
:
library(lme4)
library(AICcmodavg)
ss <- transform(sleepstudy, junk1=rnorm(nrow(sleepstudy)),
junk2=rnorm(nrow(sleepstudy)))
m1 <- lmer(Reaction ~ Days + (1|Subject), data=ss, REML=FALSE)
m2 <- update(m1, . ~ . - Days + junk1)
m3 <- update(m1, . ~ . - Days + junk2)
cand.set <- list(m1, m2, m3)
names <- c("Days", "junk1", "junk2") ## this should be a vector, not a list ...
This works fine:
aictab(cand.set, modnames=names, second.ord=TRUE, nobs=NULL, sort=TRUE)
## K AICc Delta_AICc AICcWt Cum.Wt LL
## Days 4 1802.31 0.00 1 1 -897.04
## junk2 4 1918.47 116.16 0 1 -955.12
## junk1 4 1918.71 116.40 0 1 -955.24
Now load lmerTest
and refit the models (we could just do e.g. m1 <- as(m1, "lmerModLmerTest")
but it's easy enough to refit).
library(lmerTest)
m1 <- lmer(Reaction ~ Days + (1|Subject), data=ss, REML=FALSE)
m2 <- update(m1, . ~ . - Days + junk1)
m3 <- update(m1, . ~ . - Days + junk2)
cand.set <- list(m1, m2, m3)
aictab(cand.set, modnames=names, second.ord=TRUE, nobs=NULL, sort=TRUE)
Error in aictab.default(cand.set, modnames = names, second.ord = TRUE, :
Function not yet defined for this object class
The bbmle::AICctab()
function is a little bit more robust because it relies only on the logLik
method being defined for a class (by default it gives a table with only the delta-AIC and df)
library(bbmle)
AICctab(m1, m2, m3, mnames=names, base=TRUE, weights=TRUE, logLik=TRUE)
## logLik AICc dLogLik dAICc df weight
## Days -897.0 1802.3 58.2 0.0 4 1
## junk2 -955.1 1918.5 0.1 116.2 4 <0.001
## junk1 -955.2 1918.7 0.0 116.4 4 <0.001
Thank you so much for the response. Detaching the lmerTest package worked perfectly.
– user7898623
Mar 22 at 0:59
if this answered your question you're encouraged to click the check-mark to accept it ...
– Ben Bolker
Mar 22 at 1:03
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55290938%2fusing-aictab-for-lmer-and-glmer-models%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
tl;dr you loaded the lmerTest
package, so your models have a different class, which is confusing aictab()
. You could either make sure you have lme4
and not lmerTest
loaded when you fit the models, or use bbmle::AICctab()
, which seems slightly more robust. (It might be worth contacting the package maintainer of AICcmodavg
about this ...)
Set up with lme4
:
library(lme4)
library(AICcmodavg)
ss <- transform(sleepstudy, junk1=rnorm(nrow(sleepstudy)),
junk2=rnorm(nrow(sleepstudy)))
m1 <- lmer(Reaction ~ Days + (1|Subject), data=ss, REML=FALSE)
m2 <- update(m1, . ~ . - Days + junk1)
m3 <- update(m1, . ~ . - Days + junk2)
cand.set <- list(m1, m2, m3)
names <- c("Days", "junk1", "junk2") ## this should be a vector, not a list ...
This works fine:
aictab(cand.set, modnames=names, second.ord=TRUE, nobs=NULL, sort=TRUE)
## K AICc Delta_AICc AICcWt Cum.Wt LL
## Days 4 1802.31 0.00 1 1 -897.04
## junk2 4 1918.47 116.16 0 1 -955.12
## junk1 4 1918.71 116.40 0 1 -955.24
Now load lmerTest
and refit the models (we could just do e.g. m1 <- as(m1, "lmerModLmerTest")
but it's easy enough to refit).
library(lmerTest)
m1 <- lmer(Reaction ~ Days + (1|Subject), data=ss, REML=FALSE)
m2 <- update(m1, . ~ . - Days + junk1)
m3 <- update(m1, . ~ . - Days + junk2)
cand.set <- list(m1, m2, m3)
aictab(cand.set, modnames=names, second.ord=TRUE, nobs=NULL, sort=TRUE)
Error in aictab.default(cand.set, modnames = names, second.ord = TRUE, :
Function not yet defined for this object class
The bbmle::AICctab()
function is a little bit more robust because it relies only on the logLik
method being defined for a class (by default it gives a table with only the delta-AIC and df)
library(bbmle)
AICctab(m1, m2, m3, mnames=names, base=TRUE, weights=TRUE, logLik=TRUE)
## logLik AICc dLogLik dAICc df weight
## Days -897.0 1802.3 58.2 0.0 4 1
## junk2 -955.1 1918.5 0.1 116.2 4 <0.001
## junk1 -955.2 1918.7 0.0 116.4 4 <0.001
Thank you so much for the response. Detaching the lmerTest package worked perfectly.
– user7898623
Mar 22 at 0:59
if this answered your question you're encouraged to click the check-mark to accept it ...
– Ben Bolker
Mar 22 at 1:03
add a comment |
tl;dr you loaded the lmerTest
package, so your models have a different class, which is confusing aictab()
. You could either make sure you have lme4
and not lmerTest
loaded when you fit the models, or use bbmle::AICctab()
, which seems slightly more robust. (It might be worth contacting the package maintainer of AICcmodavg
about this ...)
Set up with lme4
:
library(lme4)
library(AICcmodavg)
ss <- transform(sleepstudy, junk1=rnorm(nrow(sleepstudy)),
junk2=rnorm(nrow(sleepstudy)))
m1 <- lmer(Reaction ~ Days + (1|Subject), data=ss, REML=FALSE)
m2 <- update(m1, . ~ . - Days + junk1)
m3 <- update(m1, . ~ . - Days + junk2)
cand.set <- list(m1, m2, m3)
names <- c("Days", "junk1", "junk2") ## this should be a vector, not a list ...
This works fine:
aictab(cand.set, modnames=names, second.ord=TRUE, nobs=NULL, sort=TRUE)
## K AICc Delta_AICc AICcWt Cum.Wt LL
## Days 4 1802.31 0.00 1 1 -897.04
## junk2 4 1918.47 116.16 0 1 -955.12
## junk1 4 1918.71 116.40 0 1 -955.24
Now load lmerTest
and refit the models (we could just do e.g. m1 <- as(m1, "lmerModLmerTest")
but it's easy enough to refit).
library(lmerTest)
m1 <- lmer(Reaction ~ Days + (1|Subject), data=ss, REML=FALSE)
m2 <- update(m1, . ~ . - Days + junk1)
m3 <- update(m1, . ~ . - Days + junk2)
cand.set <- list(m1, m2, m3)
aictab(cand.set, modnames=names, second.ord=TRUE, nobs=NULL, sort=TRUE)
Error in aictab.default(cand.set, modnames = names, second.ord = TRUE, :
Function not yet defined for this object class
The bbmle::AICctab()
function is a little bit more robust because it relies only on the logLik
method being defined for a class (by default it gives a table with only the delta-AIC and df)
library(bbmle)
AICctab(m1, m2, m3, mnames=names, base=TRUE, weights=TRUE, logLik=TRUE)
## logLik AICc dLogLik dAICc df weight
## Days -897.0 1802.3 58.2 0.0 4 1
## junk2 -955.1 1918.5 0.1 116.2 4 <0.001
## junk1 -955.2 1918.7 0.0 116.4 4 <0.001
Thank you so much for the response. Detaching the lmerTest package worked perfectly.
– user7898623
Mar 22 at 0:59
if this answered your question you're encouraged to click the check-mark to accept it ...
– Ben Bolker
Mar 22 at 1:03
add a comment |
tl;dr you loaded the lmerTest
package, so your models have a different class, which is confusing aictab()
. You could either make sure you have lme4
and not lmerTest
loaded when you fit the models, or use bbmle::AICctab()
, which seems slightly more robust. (It might be worth contacting the package maintainer of AICcmodavg
about this ...)
Set up with lme4
:
library(lme4)
library(AICcmodavg)
ss <- transform(sleepstudy, junk1=rnorm(nrow(sleepstudy)),
junk2=rnorm(nrow(sleepstudy)))
m1 <- lmer(Reaction ~ Days + (1|Subject), data=ss, REML=FALSE)
m2 <- update(m1, . ~ . - Days + junk1)
m3 <- update(m1, . ~ . - Days + junk2)
cand.set <- list(m1, m2, m3)
names <- c("Days", "junk1", "junk2") ## this should be a vector, not a list ...
This works fine:
aictab(cand.set, modnames=names, second.ord=TRUE, nobs=NULL, sort=TRUE)
## K AICc Delta_AICc AICcWt Cum.Wt LL
## Days 4 1802.31 0.00 1 1 -897.04
## junk2 4 1918.47 116.16 0 1 -955.12
## junk1 4 1918.71 116.40 0 1 -955.24
Now load lmerTest
and refit the models (we could just do e.g. m1 <- as(m1, "lmerModLmerTest")
but it's easy enough to refit).
library(lmerTest)
m1 <- lmer(Reaction ~ Days + (1|Subject), data=ss, REML=FALSE)
m2 <- update(m1, . ~ . - Days + junk1)
m3 <- update(m1, . ~ . - Days + junk2)
cand.set <- list(m1, m2, m3)
aictab(cand.set, modnames=names, second.ord=TRUE, nobs=NULL, sort=TRUE)
Error in aictab.default(cand.set, modnames = names, second.ord = TRUE, :
Function not yet defined for this object class
The bbmle::AICctab()
function is a little bit more robust because it relies only on the logLik
method being defined for a class (by default it gives a table with only the delta-AIC and df)
library(bbmle)
AICctab(m1, m2, m3, mnames=names, base=TRUE, weights=TRUE, logLik=TRUE)
## logLik AICc dLogLik dAICc df weight
## Days -897.0 1802.3 58.2 0.0 4 1
## junk2 -955.1 1918.5 0.1 116.2 4 <0.001
## junk1 -955.2 1918.7 0.0 116.4 4 <0.001
tl;dr you loaded the lmerTest
package, so your models have a different class, which is confusing aictab()
. You could either make sure you have lme4
and not lmerTest
loaded when you fit the models, or use bbmle::AICctab()
, which seems slightly more robust. (It might be worth contacting the package maintainer of AICcmodavg
about this ...)
Set up with lme4
:
library(lme4)
library(AICcmodavg)
ss <- transform(sleepstudy, junk1=rnorm(nrow(sleepstudy)),
junk2=rnorm(nrow(sleepstudy)))
m1 <- lmer(Reaction ~ Days + (1|Subject), data=ss, REML=FALSE)
m2 <- update(m1, . ~ . - Days + junk1)
m3 <- update(m1, . ~ . - Days + junk2)
cand.set <- list(m1, m2, m3)
names <- c("Days", "junk1", "junk2") ## this should be a vector, not a list ...
This works fine:
aictab(cand.set, modnames=names, second.ord=TRUE, nobs=NULL, sort=TRUE)
## K AICc Delta_AICc AICcWt Cum.Wt LL
## Days 4 1802.31 0.00 1 1 -897.04
## junk2 4 1918.47 116.16 0 1 -955.12
## junk1 4 1918.71 116.40 0 1 -955.24
Now load lmerTest
and refit the models (we could just do e.g. m1 <- as(m1, "lmerModLmerTest")
but it's easy enough to refit).
library(lmerTest)
m1 <- lmer(Reaction ~ Days + (1|Subject), data=ss, REML=FALSE)
m2 <- update(m1, . ~ . - Days + junk1)
m3 <- update(m1, . ~ . - Days + junk2)
cand.set <- list(m1, m2, m3)
aictab(cand.set, modnames=names, second.ord=TRUE, nobs=NULL, sort=TRUE)
Error in aictab.default(cand.set, modnames = names, second.ord = TRUE, :
Function not yet defined for this object class
The bbmle::AICctab()
function is a little bit more robust because it relies only on the logLik
method being defined for a class (by default it gives a table with only the delta-AIC and df)
library(bbmle)
AICctab(m1, m2, m3, mnames=names, base=TRUE, weights=TRUE, logLik=TRUE)
## logLik AICc dLogLik dAICc df weight
## Days -897.0 1802.3 58.2 0.0 4 1
## junk2 -955.1 1918.5 0.1 116.2 4 <0.001
## junk1 -955.2 1918.7 0.0 116.4 4 <0.001
answered Mar 22 at 0:37
Ben BolkerBen Bolker
136k13229322
136k13229322
Thank you so much for the response. Detaching the lmerTest package worked perfectly.
– user7898623
Mar 22 at 0:59
if this answered your question you're encouraged to click the check-mark to accept it ...
– Ben Bolker
Mar 22 at 1:03
add a comment |
Thank you so much for the response. Detaching the lmerTest package worked perfectly.
– user7898623
Mar 22 at 0:59
if this answered your question you're encouraged to click the check-mark to accept it ...
– Ben Bolker
Mar 22 at 1:03
Thank you so much for the response. Detaching the lmerTest package worked perfectly.
– user7898623
Mar 22 at 0:59
Thank you so much for the response. Detaching the lmerTest package worked perfectly.
– user7898623
Mar 22 at 0:59
if this answered your question you're encouraged to click the check-mark to accept it ...
– Ben Bolker
Mar 22 at 1:03
if this answered your question you're encouraged to click the check-mark to accept it ...
– Ben Bolker
Mar 22 at 1:03
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55290938%2fusing-aictab-for-lmer-and-glmer-models%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown