Questions tagged [lme4-nlme]

lme4 and nlme are R packages used for fitting linear, generalized linear and nonlinear mixed effects models. For general questions about mixed models use [mixed-model] tag.

835 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
13
votes
0answers
5k views

Specify correlation structure for different groups in mixed-effects model (lme4/nlme)

I am trying to account for spatial autocorrelation in a linear mixed-effects model in R with measurements repeated in time. BodyMass has been collected once per <...
8
votes
0answers
184 views

Correlation between two binary variables within one categorical variable

The Problem: I have measured two binary variables within 1 categorical variable with 5 levels. Initially, I thought I'd be able to use Fisher's Exact test or some N x M x K version of it. However I ...
8
votes
0answers
2k views

glmer in R: Significance estimates are not robust to order of data frame

I'm using a mixed effects model with logistic link function (using lme4 version 1.1-7 in R). However, I noticed that the estimates of significance for fixed effects change depending on the order of ...
7
votes
0answers
2k views

Interpretation of crossed random effect interactions in lme4

I'm considering a model in lme4 in which I am estimating random effects for two crossed factors, very similar to the Machines example in Bates' 2010 draft book (http://lme4.r-forge.r-project.org/lMMwR/...
6
votes
0answers
566 views

How to estimate random-effects for new subjects for predictions (example in GNU R's lme4)

I'm wondering how to make predictions for new subjects from a fitted mixed-effects model (in a frequentist framework). Specifically, we have multiple observations on a set of subjects to which we can ...
6
votes
0answers
313 views

Mixed models formulation (GAMM, GLS, nlme): from R to mathematical notation

I have just finalised the analysis of a dataset fitting Generalised additive mixed models (GAMMs) with mgcv package in R v3.3.0. But I am having trouble in writing my models into their correct ...
6
votes
0answers
1k views

Differences between logistic regression parameter estimates and Cox-proportional hazard parameters

We have been working on a survival analysis. We are examining tree seedling survival over a decade with annual to biannual census intervals. We have been using the package coxme in R for a mixed ...
6
votes
0answers
5k views

Confidence intervals for glmer() from lme4

I'm running a mixed model on some data. I want to calculate confidence intervals for my model. For this I have adapted the following code section from Predictions and/or confidence (or prediction) ...
6
votes
0answers
457 views

Programming a new random effects structure in lme

I am seeking advice on programming a new random effects variance-covariance matrix/structure (pdmat) in R for use in lme()? I've checked out the lme source code (as suggested if you want to program ...
5
votes
0answers
434 views

Longitudinal mixed model: What random effects are possible?

I'm faced with analyzing the following design: In a longitudinal study, the muscle tissue of about 25 subjects are analyzed at 8 timepoints. Specifically, 7 measurements are taken during a race ...
5
votes
0answers
609 views

Minimum number of repeated measures and levels per nested random effect

I often read the guideline that a random factor should at least have 5-6 levels. However, it is not yet really clear to me if there is (i) a minimum number of levels for a nested factor within a block ...
5
votes
0answers
786 views

Can a factor be regarded as both random and fixed effect?

I have a question about nested mixed effect model. For example I have species A with different populations; these populations belong to two kinds of habitat types (with or without predators). So I ...
5
votes
0answers
1k views

Linear mixed effect model with fractional/proportional outcome: choosing between binomial and beta

I'm looking to run a linear mixed effect model using lme4, where my dependent variable one_syllable_words / total_words_generated is a proportion and my random ...
5
votes
0answers
481 views

data visualization following glmm in lmer

Everything I know about glmms is from the internet, and after extensive searching, I haven't come across a good clearcut guide for how to visualize your data in a way that is relevant to hypotheses ...
5
votes
0answers
474 views

Computing likelihood of a mixed-effect model manually

My question has to do with how to manually compute the likelihood of a mixed-effect model. I understand how to determine the likelihood of a fixed-effect model manually. For example, if I make up ...
5
votes
0answers
613 views

Survival analysis with Frailty on large dataset

I am trying to fit a survival analysis in R with non-recurrent events and time-varying coefficients. The baseline distribution is exponential or Weibull and the ...
5
votes
0answers
646 views

Different estimates of crossed random factor variance using nlme and lme4

I want to fit a model with two crossed random factors that also allow heteroscedasticity. Whereas nlme4 allows non-constant error variance, I was not sure how to ...
5
votes
0answers
8k views

Mixed effect logistic regression in R: choosing random effects

I conducted an experiment which measured a binary response for each subject. The subjects were in 1 of 3 groups. There were two other fixed factors, each of which were continuums (cont1, cont2) ...
5
votes
0answers
312 views

When using lmer is a random intercept being estimated more than once if specified in seperate grouping factors?

I know there are a slew of lmer specification questions already floating around. Please let me know if this is a duplicate, or if it is deemed off-topic, and I'll delete it. I am using a forward ...
4
votes
0answers
47 views

Is the algorithm of calculating SEs of beta coefficients calculated by the nlme gls finally fixed?

I can read here: https://www4.stat.ncsu.edu/~davidian/st732/examples/dental_pa.R and here: https://math.unm.edu/~luyan/stat57918/week14.pdf that: WARNING: There is a MISTAKE in gls(), and it DOES ...
4
votes
0answers
112 views

How does random variable nesting in GAMs work (mgcv)?

Consider me very new to the world of GAMs, I am actually using it out of necessity rather than by choice but I thought it could be a chance to learn something new anyway. Originally I had hoped to ...
4
votes
0answers
100 views

Is this a random or a fixed effect?

I have a question about one of the variables in my study and whether or not it should be considered a random effect. I'm conducting a study of my school's 24 general learning outcomes (or "skills".) ...
4
votes
0answers
71 views

using `lmer` to fit the linear mixed effects models

Edit: I know some people vote this question is off-topic since it is more like a Cross Validated question. However, I am not here to ask about the coding thing (but I might word in the wrong way). I ...
4
votes
0answers
116 views

Mixed-effects logistic regression

I'm new to data analysis and I'm trying to perform a mixed-effect logistic regression. My data look like this: ...
4
votes
0answers
133 views

Is the use of loglik or AIC to compare logit/probit/cloglog models valid?

I would like to know whether I can use AIC, or if the models have the same number of predictors, the log-likelihood, to compare logit vs probit vs cloglog models (fitted for instance with glmer or ...
4
votes
0answers
401 views

How to handle crossed and nested terms in a crossover design

Here comes my case: I conducted an experiment with the following design: 30 participants, each with a unique id, were screened and classified according to a trait. Then, all participants were tested ...
4
votes
1answer
608 views

Why are results different between MuMIn::r.squaredGLMM and piecwiseSEM::sem.model.fits?

MuMIn::r.squaredGLMM and piecwiseSEM::sem.model.fits should be preforming the same calculations. They are implementing Schielzeth and Nakagawa's R2 for generalized linear mixed effects models. However,...
4
votes
0answers
66 views

Basics relative to chi square, likelihood, fits,

I'm confused to separate all the different meanings and connections. The background of my question: On the one hand related to lmer models and on the other hand to the goodness of a fit. And their ...
4
votes
0answers
1k views

How to write mathematical formula describing my lmer model?

I have the following model fitted using the lme4 package in R: mod <- lmer(var1 ~ var2 * var3 + (1|var4) , data=s1, REML=F) ...
4
votes
0answers
67 views

GLMM for binomially distributed outcome, testing differential hypothesis

I am trying to find a way, to investigate differences between conditions in an experiment. The design is as follows: Depended Variable: Logical (answer is correct [correct accepted or correct ...
4
votes
0answers
1k views

Predict with stats::lm() versus lme4::lmer()

What are the difference between a linear mixed model with random slope and intercept and a linear model with an interaction effect? If I predict the effect of 1) the main effect and 2) the random ...
4
votes
0answers
2k views

Random or fixed effects? GLM or GLMM?

I am interested in the behavioral response of floral visitors to a treatment, applied in a paired fashion within plants. That is, one stem on each plant receives the treatment, and another stem serves ...
4
votes
0answers
537 views

Testing for differences between time series with many timepoints

I think the easiest way to describe my question is with plots. I've run an experiment where I recorded data from animals' brains (EEG) at 6 depths. The animals are recorded at baseline for 25 minutes,...
4
votes
0answers
515 views

Including seasons and months into GLMM: should they be crossed or nested effects?

I have collected data from five consecutive fishing seasons (five factor levels). Each fishing season has five months within (five factor levels). Considering that I have a temporal correlation in my ...
4
votes
0answers
4k views

How to interpret lsmeans output for my lmer model?

I've defined an lmer model in R with 2 fixed effects, 2 random intercepts and a random slope: ...
4
votes
0answers
505 views

Identical mixed models in SPSS and R nlme, with different degrees of freedom. Which to trust and why?

I am analyzing a multilevel dataset with an AR(1) error structure and random intercept and slope. I fit what I believe is the exact same model in SPSS and R- my coefficients and standard errors are ...
4
votes
0answers
4k views

How to validate a Poisson GLMM model?

I’m using the glmer function from the lme4 package in R to model species richness adjacent ...
4
votes
0answers
263 views

Testing Fixed and Random Effect of Mixed Model

This pdf illustrates nicely how is to test the random effect of multilevel model . But I am simulating data from a two-level model and estimating the parameters of the model for various combination of ...
4
votes
0answers
2k views
4
votes
0answers
6k views

Nested random effects group size using lme (in nlme)

I'm wrestling with a question regarding random effects that I haven't been able to figure out with my regular resources. I am examining the effects of two treatments (heat and water) on plant biomass ...
4
votes
0answers
2k views

Can I use an automated model selection approach on an lmer object?

I am attempting to use MuMIn to run a model selection analysis on a mixed model fitted using lme4. Because this model is fit ...
4
votes
0answers
2k views

Adjusted / marginal means estimation in linear mixed effect model in R / Stata

I am a new R user, having some difficulties validating/replicating results from Stata (which a colleague uses) in R. We are investigating the time (TIME<-c(1:7))...
4
votes
0answers
4k views

Weights argument in glmer() when predicting proportion data: why is it needed when all weights are around the same?

What do the weights argument in glmer refer to? I used sample sizes as weights with ...
4
votes
0answers
849 views

Mixed-effect modeling with paired observations & bounded response variables

I am quite new in the field of mixed-effect modeling. For a beginner like me, I guess I combine several levels of complication in my analysis: paired observations & bounded response variables. I ...
4
votes
0answers
2k views

When using repeated-measures ANOVA in R, what does it mean to specify Error(subject) instead of Error(subject/(A*B))?

For a two-way repeated measures design, we can specify the model using aov in the following fashion: ...
4
votes
0answers
233 views

Is it reasonable to calculate AIC of a subset of the data set which was used to fit the model?

There is a factor variable called "Treatment" in my data set. This factor consists of two levels, "C" and "H". I want to test whether there is there any significant difference between two levels. I ...
4
votes
0answers
836 views

Testing for mediation using LMER and a Freedman and Schatzkin's method (in R)

I'm trying to analyse, whether the effect of answer correctness ($X$, binary) on confidence ratings ($Y$, continuous) in some psychological task is mediated by another rating ($M$, continuous). In ...
4
votes
0answers
2k views

Strange pattern in residual plot from mixed effect model

I've run a mixed effect model in R by using lme. The explanatory (Temp_Diff & Distance) and responsive (LF_Diff) factors are continued variables. ...
4
votes
0answers
1k views

Toeplitz variance matrix with nlme

I would like to specify a Toeplitz variance matrix for the random effects of my nlme model in R. Is it possible ? More precisely,...
4
votes
0answers
202 views

Dynamic consistency and multilevel models using lmer

I've been using nlme and more recently lmer to fit multi-level models of time course data using orthogonal polynomials. My ...

1 2 3 4 5 17