strengejacke / sjPlot

sjPlot - Data Visualization for Statistics in Social Science
https://strengejacke.github.io/sjPlot
608 stars 91 forks source link

what do plevel and showCI do for sjp.int with mixed models? #22

Closed rubenarslan closed 8 years ago

rubenarslan commented 9 years ago

This was unclear to me from the docs and from the way the function behaves: plevel does not make sense, if you permit only lme4::lmer (which does not give _p_s) and showCI does not seem to do anything. I can share some code that I use for simple and bootstrapped CIs on predictions, if you're interested.

That concludes it, sorry for the many issues filed, really like the package, but these issues made for a discouraging experience for the student that I recommended the package to (not yet at the level to debug this sort of stuff).

sjPlot commented 9 years ago

plevel only applies to models that do actually compute p-values. I think, glmer does produce p-values. In sjp.lmer, I use car::Anova to get approximate p-values, however, I cannot apply this function properly to sjp.int because I don't know how to deal with factors - the anova computes a p-value for the whole predictor, not for each factor level (thus, you would have to create dummy values for each factor level).

showCI only works for plot types eff and emm in sjp.int, just because the packages I use to compute these interactions provide CI-values. I don't know how to compute confidence intervals on conditional interaction / moderation effects - I appreciate any help!

(see this sjPlot-manual for what I understood as "conditional effect")

rubenarslan commented 9 years ago

lmerTest and mixed do p-values for lmer (for each level), but of course Douglas Bates has some doubts about those (and I think when I use the function I prefer to just plot all defined interactions without regard to p-values (i.e. set plevel to 1), so I can compare different plots visually).

I didn't notice showCI works for eff, I don't have smart ideas about how to compute CIs for "cond" either. Maybe you could put this in the docs, though?

"emm" with lmer fails for me, if I use lmerTest I get

Error in summary(fit)$coefficients[-1, 4] : subscript out of bounds

and with plain lme4

Error in colnames<-(*tmp*, value = c("x", "y", "grp", "l.ci", "u.ci", : 'names' attribute [6] must be the same length as the vector [5]

So you pass the fits to another package to compute CIs?

Maybe you can put this on the wishlist then: I would sometimes like to customise options for predictions:

  1. e.g. I prefer to use bootstrapping for SEs/CIs/predictions and
  2. one use case for which I wrote my own prediction function for interactions once involved extrapolating (i.e. going over the range of the real data in newdata) and
  3. in some cases choosing the mean of the covariates for "eff" is not unambiguous (e.g. three equally large birth cohorts) and the user might want a choice

If I get a handle on your codebase, maybe I can contribute something along those lines, I really like the package and dislike that I'm always writing my own not-very-reusable functions for plotting coefficients, predictions etc.

sjPlot commented 9 years ago

@1 I have not much experience with bootstrapping yet, so I'm not sure what you are thinking of exactly, and how to implement it?

@2 Would be possible for type = "cond", but I'm not sure how to set custom ranges for predictors in the effects package / effect function (which is the base for type = "eff")?

@3 Which other options may be useful? You can specify the "averaging" effect via the typical parameter (in effect), which must be a function. Median?

rubenarslan commented 9 years ago

wrote you an email regarding 1. Re2: I haven't used effects before, but it seems like this (and the bool problem) would be some things to submit to the maintainer?

Re3: I wasn't familiar with that, thanks!

sjPlot commented 9 years ago

mixed models and type = "emm" should work now. CI's are calculated by the lsmeans package.

sjPlot commented 8 years ago

What about this issue? What parts are still "open"?

rubenarslan commented 8 years ago

This works now. You could get pvalues from lmerTest instead of anova.

sjPlot commented 8 years ago

Only if you fit the model with lmerTest::lmer, afaik. There's no method in the lmerTest package to obtain p-values from an merMod-object from lame. So, you have to use lmerTest to fit your models, and if you do so, sjPlot will take those p-values provided by lmerTest.