Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random "slopes" are not tagged as such (maybe not treated as such?) #160

Open
mattansb opened this issue May 19, 2022 · 3 comments
Open
Assignees

Comments

@mattansb
Copy link

When adding a random slope into a model, it does not appear in the dataTypes slot (easystats/insight#566):

library(BayesFactor)

mtcars$cyl <- factor(mtcars$cyl)
mtcars$gear <- factor(mtcars$gear)

model1 <- lmBF(mpg ~ cyl + gear + cyl:gear, mtcars, 
              progress = FALSE, whichRandom = c("gear", "cyl:gear"))

model1@numerator[[1]]@dataTypes
#>      cyl     gear 
#>  "fixed" "random"
@richarddmorey
Copy link
Owner

richarddmorey commented May 22, 2022

This is because the slopes are inferred from the types of the individual constituents. Adding cyl:gear to random won't do anything on top of making "gear" random. If gear is random and cyl is fixed, the constraints on the interaction are already set due to the way the interaction is produced using the Kronecker product.

@bwiernik
Copy link

That makes sense. It might be good to error or at least give a warning that the product term was ignored in whichRandom

@grocio
Copy link

grocio commented Nov 3, 2022

A relevant topic is "Mixed models" of the tutorial.
https://cran.r-project.org/web/packages/BayesFactor/vignettes/manual.html#mixed

In the tutorial, a classical ANOVA example is

summary(aov(RT ~ shape*color + Error(ID/(shape*color)), data=puzzles))

and an anovaBF equivalent is

bf = anovaBF(RT ~ shape*color + ID, data = puzzles, 
             whichRandom="ID")

When I read it, I thought anovaBF would be (for consistency with the classical ANOVA code)

bf = anovaBF(RT ~ shape*color + ID + ID:shape + ID:color, data = puzzles, 
             whichRandom=c("ID", "ID:shape", "ID:color"))

It may be good to mention that BayesFactor automatically infers slopes in the tutorial for novices as well as giving a warning message sugested by @bwiernik.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants