lme4

Standard Error of variance component from the output of lmer

自作多情 提交于 2019-12-01 00:03:51
I need to extract the standard error of variance component from the output of lmer . library(lme4) model <- lmer(Reaction ~ Days + (1|Subject), sleepstudy) The following produces estimates of variance component : s2 <- VarCorr(model)$Subject[1] It is NOT the standard error of the variance. And I want the standard error . How can I have it ? EDIT : Perhaps I am unable to make you understand what I meant by "standard error of the variance component". So I am editing my post . In Chapter 12 , Experiments with Random Factors , of the book Design and Analysis of Experiments , by Douglas C.

Confidence Interval of lmer model producing NA

廉价感情. 提交于 2019-11-30 21:22:47
问题 NA is occurring for confidence interval of lmer model ? How can I get rid of it ? simfun <- function(J,n_j,g00,g10,g01,g11,sig2_0,sig01,sig2_1){ N <- sum(rep(n_j,J)) x <- rnorm(N) z <- rnorm(J) mu <- c(0,0) sig <- matrix(c(sig2_0,sig01,sig01,sig2_1),ncol=2) u <- rmvnorm(J,mean=mu,sigma=sig) b_0j <- g00 + g01*z + u[,1] b_1j <- g10 + g11*z + u[,2] y <- rep(b_0j,each=n_j)+rep(b_1j,each=n_j)*x + rnorm(N,0,sqrt(0.5)) sim_data <- data.frame(Y=y,X=x,Z=rep(z,each=n_j),group=rep(1:J,each=n_j)) }

Standard Error of variance component from the output of lmer

若如初见. 提交于 2019-11-30 18:24:55
问题 I need to extract the standard error of variance component from the output of lmer . library(lme4) model <- lmer(Reaction ~ Days + (1|Subject), sleepstudy) The following produces estimates of variance component : s2 <- VarCorr(model)$Subject[1] It is NOT the standard error of the variance. And I want the standard error . How can I have it ? EDIT : Perhaps I am unable to make you understand what I meant by "standard error of the variance component". So I am editing my post . In Chapter 12 ,

How do I extract the Correlation of fixed effects part of the lmer output

独自空忆成欢 提交于 2019-11-30 15:19:28
When you have a multilevel model with lots of factors and interactions the size of the correlation of fixed effects matrix can become quite big and unclear. I can use the symbolic.cor=T parameter in the print method to make a clearer print of the summary like below: ratbrain <- within(read.delim("http://www-personal.umich.edu/~bwest/rat_brain.dat"), { treatment <- factor(treatment, labels = c("Basal", "Carbachol")) region <- factor(region, labels = c("BST", "LS", "VDB")) }) print(mod<-lmer(activate ~ region * treatment + (0 + treatment | animal),ratbrain),symbolic.cor=T) This plots a somewhat

R: Interaction Plot with a continuous and a categorical variable for a GLMM (lme4)

依然范特西╮ 提交于 2019-11-30 13:31:57
问题 I would like to make an interaction plot to visually display the difference or similarity in slopes of interaction of a categorical variable (4 levels) and a standardized continuous variable from the results of a regression model. with(GLMModel, interaction.plot(continuous.var, categorical.var, response.var)) Is not what I am looking for. It produces a plot in which the slope changes for each value of the continuous variable. I'm looking to make a plot with constant slopes as in the following

How to get covariance matrix for random effects (BLUPs/conditional modes) from lme4

試著忘記壹切 提交于 2019-11-30 08:42:42
问题 So, I've fitted a linear mixed model with two random intercepts in R: Y = X beta + Z b + e_i, where b ~ MVN (0, Sigma) ; X and Z are the fixed- and random-effects model matrices respectively, and beta and b are the fixed-effect parameters and random-effects BLUPs/conditional modes. I would like to get my hands on the underlying covariance matrix of b , which doesn't seem to be a trivial thing in lme4 package. You can get only the variances by VarCorr , not the actual correlation matrix.

R: Interaction Plot with a continuous and a categorical variable for a GLMM (lme4)

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 07:32:08
I would like to make an interaction plot to visually display the difference or similarity in slopes of interaction of a categorical variable (4 levels) and a standardized continuous variable from the results of a regression model. with(GLMModel, interaction.plot(continuous.var, categorical.var, response.var)) Is not what I am looking for. It produces a plot in which the slope changes for each value of the continuous variable. I'm looking to make a plot with constant slopes as in the following plot: Any ideas? I fit a model of the form fit<-glmer(resp.var ~ cont.var*cat.var + (1|rand.eff) ,

increase iterations for new version of lmer?

夙愿已清 提交于 2019-11-30 06:38:10
问题 I just updated lme4 to version 1.0-4 and when I run lmer() my mixed effects model, which was converging before, now prints this warning: Warning message: In (function (fn, par, lower = rep.int(-Inf, n), upper = rep.int(Inf, : failure to converge in 10000 evaluations So, I'd like to try to increase the number of iterations to see if I can fix this. (I must say I have no idea what is causing the warning, as the first part of the message sounds a bit opaque). In any case, I read in the

Is there a way of getting “marginal effects” from a `glmer` object

穿精又带淫゛_ 提交于 2019-11-30 06:18:27
I am estimating random effects logit model using glmer and I would like to report Marginal Effects for the independent variables. For glm models, package mfx helps compute marginal effects. Is there any package or function for glmer objects? Thanks for your help. A reproducible example is given below mydata <- read.csv("http://www.ats.ucla.edu/stat/data/binary.csv") mydata$rank <- factor(mydata$rank) #creating ranks id <- rep(1:ceiling(nrow(mydata)/2), times=c(2)) #creating ID variable mydata <- cbind(mydata,data.frame(id,stringsAsFactors=FALSE)) set.seed(12345) mydata$ran <- runif(nrow(mydata

Error message in lme4::glmer: “ 'what' must be a character string or a function”

风流意气都作罢 提交于 2019-11-29 11:01:17
I am running a multi-level model. I use the following commands with validatedRS6 as the outcome, random as the predictor and clustno as the random effects variable. new<-as.data.frame(read.delim("BABEX.dat", header=TRUE)) install.packages("lme4") library(lme4) model1<- glmer(validatedRS6 ~ random + (1|clustno), data=new, family=binomial("logit"), nAGQ = 1L) However, I get the following error Error in do.call(new, c(list(Class = "glmResp", family = family), ll[setdiff(names(ll), : 'what' must be a character string or a function I have absolutely no idea what has gone wrong and have searched the