Code Monkey home page Code Monkey logo

Comments (3)

DominiqueMakowski avatar DominiqueMakowski commented on August 20, 2024 1

As the error originates in the emmeans package, unfortunately, it's kinda hard to detect and throw relevant warnings in modelbased 😕

from modelbased.

DominiqueMakowski avatar DominiqueMakowski commented on August 20, 2024
df <- iris
df$factor1 <- ifelse(df$Sepal.Width > 3, "A", "B")
df$factor2 <- ifelse(df$Petal.Length > 3.5, "C", "D")
df$factor3 <- ifelse(df$Sepal.Length > 5, "E", "F")

model <- lm(Petal.Width ~ factor1 * factor2 * factor3, data=df)
emmeans::emmeans(model, "factor1")
#> NOTE: Results may be misleading due to involvement in interactions
#>  factor1 emmean    SE  df lower.CL upper.CL
#>  A       nonEst    NA  NA       NA       NA
#>  B         1.19 0.101 143    0.993     1.39
#> 
#> Results are averaged over the levels of: factor2, factor3 
#> Confidence level used: 0.95

Created on 2020-04-16 by the reprex package (v0.3.0)

It seems this is directly related to the marginal means estimation (as modelbased wraps around emmeans), I think it's because the model is ill-specified, but it should work on some data with enough observations in each combination of factors

from modelbased.

goesjon avatar goesjon commented on August 20, 2024

Hello @DominiqueMakowski

thank you for your message. Indeed, if I exclude the three way interaction factor1:factor2:factor3, the code works:

df <- iris
df$factor1 <- ifelse(df$Sepal.Width > 3, "A", "B")
df$factor2 <- ifelse(df$Petal.Length > 3.5, "C", "D")
df$factor3 <- ifelse(df$Sepal.Length > 5, "E", "F")

model <- lm(Petal.Width ~ factor1 * factor2 + factor3 + factor2:factor3, data=df)
modelbased::estimate_contrasts(model, levels = "factor1")
#> NOTE: Results may be misleading due to involvement in interactions
#> Level1 | Level2 | Difference |   SE |        95% CI |    t |  df |     p | Difference (std.)
#> --------------------------------------------------------------------------------------------
#> A      |      B |       0.05 | 0.07 | [-0.08, 0.18] | 0.69 | 144 | 0.489 |              0.06

As soon as I add the three way interaction again, the previous error messages reappear. A warning would be nice, which tells, that the model is ill-specified for this purpose, because the current error messages are difficult to interpret (which lead me to believe it might be a bug, although it was my inability all along).

The point is, that I get the previous error messages also with my original code, which deals with a big lmer model. Now I must assume that this big lmer model is ill-specified? I have to see how I deal with that.

Anyway, thank you very much for your time and help. I really appreciate it.

I close this issue.

from modelbased.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.