lme4

estimate a repeated measures random effects model with a nested structure using `plm()`

北战南征 提交于 2020-07-08 20:38:14
问题 Is it possible to estimate a repeated measures random effects model with a nested structure using plm() from the plm package? I know it is possible with lmer() from the lme4 package. However, lmer() rely on a likelihood framework and I am curious to do it with plm() . Here's my minimal working example , inspired by this question. First some required packages and data, # install.packages(c("plm", "lme4", "texreg", "mlmRev"), dependencies = TRUE) data(egsingle, package = "mlmRev") the data-set

estimate a repeated measures random effects model with a nested structure using `plm()`

南楼画角 提交于 2020-07-08 20:38:05
问题 Is it possible to estimate a repeated measures random effects model with a nested structure using plm() from the plm package? I know it is possible with lmer() from the lme4 package. However, lmer() rely on a likelihood framework and I am curious to do it with plm() . Here's my minimal working example , inspired by this question. First some required packages and data, # install.packages(c("plm", "lme4", "texreg", "mlmRev"), dependencies = TRUE) data(egsingle, package = "mlmRev") the data-set

Restart mixed effect model estimation with previously estimated values

五迷三道 提交于 2020-06-09 11:38:06
问题 I'm using lmer() in package lme4 to estimate mixed effects models. This works well, but now I want to run the estimation process for a fixed number of iterations, then resume the process by specifying start values, as calculated by the last estimation process. According to the help for ?lmer this is possible, by setting the arguments: start - these are the new start values, and according to the help one can extract the value in slot ST from a fitted model and use these, i.e. use x@ST maxiter

Random Intercept GLM

怎甘沉沦 提交于 2020-06-09 05:39:13
问题 I want to fit a random-intercept complementary log-log regression in R, in order to check for unobserved user heterogeneity. I have searched through the internet and books and have only found one solution in Stata, maybe someone can adapt that to R. In Stata there are 2 commands available: xtcloglog for two-level random intercept gllamm for random-coefficient and and higher-levels models My data relates if activities from people are completed or not and affected by sunshine - completion is

Random Intercept GLM

我的梦境 提交于 2020-06-09 05:39:12
问题 I want to fit a random-intercept complementary log-log regression in R, in order to check for unobserved user heterogeneity. I have searched through the internet and books and have only found one solution in Stata, maybe someone can adapt that to R. In Stata there are 2 commands available: xtcloglog for two-level random intercept gllamm for random-coefficient and and higher-levels models My data relates if activities from people are completed or not and affected by sunshine - completion is

package emmeans in R not returning effect sizes

空扰寡人 提交于 2020-05-28 06:12:14
问题 I'm following this tutorial as well as ?eff_size from package emmeans to compute eff_size() for my regression model below. But I get the error: need an object with call component from the eff_size() call. Am I missing something? library(lme4) library(emmeans) h <- read.csv('https://raw.githubusercontent.com/hkil/m/master/h.csv') h$year <- as.factor(h$year) m <- lmer(scale~year*group + (1|stid), data = h) ems <- emmeans(m, pairwise ~ group*year, infer = c(T, T)) eff_size(ems, sigma = sigma(m),

Plotting results of logistic regression with binomial data from mixed effects model (lme4) with model averaging (MuMIn)

 ̄綄美尐妖づ 提交于 2020-02-02 16:11:43
问题 I'm trying to display the results of a logistic regression. My model was fit using glmer() from the lme4 package, I then used MuMIn for model averaging. Simplified version of my model using the mtcars dataset: glmer(vs ~ wt + am + (1|carb), database, family = binomial, na.action = "na.fail") My desired output is two plots that show the predicted probability that vs =1, one for wt , which is continuous, one for am , which is binomial. UPDATED: I got this much working after comments from

R: Covariance matrix for the random effect in mixed effects model

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-24 22:57:45
问题 According to this post, matrix Omega and sigma are in the results of lmer when we fitting the mixed effect model. And here is my result. Random effects: Groups Name Variance Std.Dev. Corr subject X21 8.558e+00 2.925380 X22 2.117e-03 0.046011 -1.00 X23 2.532e-05 0.005032 1.00 -1.00 Residual 1.453e+00 1.205402 Number of obs: 100, groups: subject, 20 Since my Omega is a 3x3 diagonal matrix, so the three numbers in the Variance should be the elements in the diagonal of Omega and the number on the

How to cope with a singular fit in a linear mixed model (lme4)?

邮差的信 提交于 2020-01-23 03:05:46
问题 I am running several linear mixed models for an study about birds with the variable nest as a random variable. The thing is that in some of these models I get what is called 'singular fit': my nest random variable has a variance and st error of 0.00. Some background: I am working with wild birds to see the effect of living in noisy environments on some oxidative stress parameters. For this, we took a blood sample for each of the nestlings of each nest to do the laboratory stuff. Because of

How to use lmer inside a function

做~自己de王妃 提交于 2020-01-21 11:52:29
问题 I'm trying to write a function that collects some calls I use often in scripts I use the sleepstudy data of the lme4 package in my examples Here's (a simplified version of) the function I started with: trimModel1 <- function(frm, df) { require(LMERConvenienceFunctions) require(lme4) lm<-lmer(frm,data=df) lm.trimmed = romr.fnc(lm, df) df = lm.trimmed$data # update initial model on trimmed data lm<-lmer(frm,data=df) # lm@call$formula<-frm mcp.fnc(lm) lm } When I call this function like below: