merTools | Convenience functions for working with merMod objects | Development Tools library
kandi X-RAY | merTools Summary
kandi X-RAY | merTools Summary
A package for getting the most of our multilevel models in R. by Jared E. Knowles and Carl Frederick. Working with generalized linear mixed models (GLMM) and linear mixed models (LMM) has become increasingly easy with advances in the lme4 package. As we have found ourselves using these models more and more within our work, we, the authors, have developed a set of tools for simplifying and speeding up common tasks for interacting with merMod objects from lme4. This package provides those tools.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of merTools
merTools Key Features
merTools Examples and Code Snippets
Community Discussions
Trending Discussions on merTools
QUESTION
I'm pretty new to R, and I'm trying to learn how to do some simulations. Currently I have a program that does the following:
- In one function, uses a DGP to create fake data, which is returned as a tibble
- In another function, randomly assign fake observations to treatment
- In the final function, merge random assignment results with fake data and run regression. I return a list that includes the estimate and p-value using the below code
ANSWER
Answered 2021-Mar-26 at 13:27Use can use map_df
from the purrr
package (part of tidyverse
):
QUESTION
I have implemented a mixed effects model for my experiment for how error rate affects reaction time. I now want to calculate prediction intervals and then plot them.
Here is an example of my df
...ANSWER
Answered 2019-Aug-21 at 13:00One way to have a line connecting the error_rate
values without the vertical lines, is to plot mean values of the y
variable fit
. This is done with stat_summary
as below.
QUESTION
This is two questions in one, I hope this is OK.
First, I am trying to obtain confidence interval values from an lmer
object from the lme4
package. I've previously used R v 3.4.4 and the models run just fine, and I can find and display the confidence intervals for the mean fit on the plot. I've recently upgraded to R v 3.6.1, and am now getting an error message when using the predict
function. I've shown this below as part of the code
My main question is, how do I calculate the upper and lower confidence limits for a given value? For traditional lm
I would use:
ANSWER
Answered 2019-Jul-18 at 20:46I figured out how to determine CI values. Hopefully others may benefit from the solution. As usual, it was quite simple.
First, round the CIs to 0 d.p
QUESTION
I am trying to shuffle my dataset by row and I have found function shuffle in package merTools. The code looks like this:
...ANSWER
Answered 2019-Jun-21 at 08:03May be it is an unexported function
QUESTION
I'm comparing the confidence-interval (CI
)s produced by arm's sim()
function and predictInterval()
from merTools
.
I'm using the sleepstudy
dataset from lme4
as an example.
I am expecting the same result from the two methods but that is not the case. What is the fundamental difference between the two methods what I am missing?
The code is the following:
importing test data ...ANSWER
Answered 2019-Jan-03 at 17:21The merTools CRAN page goes into this (https://cran.r-project.org/web/packages/merTools/vignettes/Using_predictInterval.html), making a direct comparison between sim and predictInterval. Basically, my understanding is that sim ignores uncertainty about the random intercepts, using the mode as a point estimate. The intervals for predictInterval are wider because they account for this additional uncertainty, and are therefore probably more realistic.
QUESTION
I can get predicted values of a mixed model like this:
...ANSWER
Answered 2018-Nov-28 at 00:54Setting which
to "fixed"
in predictInterval
should be enough, but it isn't. So, it looks like a bug. However, along with this parameter if we supply any value for the grouping variable, everything works.
QUESTION
library(lme4)
fm1 <- lmer(Reaction ~ Days + (Days|Subject), data = sleepstudy)
...ANSWER
Answered 2018-Jul-10 at 13:05You can get simulated values if you specify newdata in the predictInterval()
function.
QUESTION
It's not completely clear to me what the merTools::predictInterval
function exactly predicts for each component when the which
option is set to which = 'all'
. For example,
ANSWER
Answered 2017-Jul-10 at 13:37The key is that predictInterval
is simulating prediction intervals by drawing from the posterior distribution. The way it presents the components is the result of independent draws for the random, fixed, and combined effects. So while logically they should add up, with measurement error and the variance in the effects themselves, with a finite number of simulations the means or medians of those distributions will not line up to sum to the combined effect.
You can increase n.sims
to a very large number (~5000, 10,000) and this gap will be smaller.
But the key issue is that each of those rows is the result of independent draws from the posterior.
QUESTION
It's a bit of a long question so thanks for bearing with me.
Here's my data
https://www.dropbox.com/s/jo22d68a8vxwg63/data.csv?dl=0
I constructed a mixed effect model
...ANSWER
Answered 2017-Apr-07 at 19:47I'm not sure where predictInterval
comes from, but you can do this with predict
. The trick is just to make sure you set your random effects to 0. Here's how you can do that
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install merTools
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page