New answers tagged

1 vote

How do you determine if there is a significant relationship between two variables with several factors affecting it, using R?

We assume that the question is how to determine whether stimulus is statistically significant in the presence of the other variables. First let us try a mixed model with colony as a random effect. ...
2 votes
Accepted

What should be normally distributed for a two-way repeated measures ANOVA? R

The linear regression model gives us a prediction that theoretically can take on any value in a continuous range when the regressor input is changed. In your data with the two categorical regressors, ...
  • 366
4 votes

What should be normally distributed for a two-way repeated measures ANOVA? R

In any kind of linear regression that requires normality, that normality applies to the error term. A) No, and this is impossible in an ANOVA, since your independent $x$ variables are categorical ...
  • 35.4k
8 votes

How do you determine if there is a significant relationship between two variables with several factors affecting it, using R?

I disagree with @frank's advice to include interactions (with $x$) but no main effects for the stimulus, lighting and ...
  • 5,662
1 vote
Accepted

How to specify a repeated measure in a Mixed Effect ANOVA?

The core_id should be your random effect in this analysis. Those are the units over which there are multiple observations. By my count that's 24 "clusters"...
  • 68.7k
7 votes

How do you determine if there is a significant relationship between two variables with several factors affecting it, using R?

I presume that you want to know whether the linear relation between $x$ and $y$ is different depending on those additional variables, which I also presume to not be confounders. Thus, you don't want ...
  • 7,576
2 votes
Accepted

Error in Fixed Effects Model

There's no such thing as a linear mixed model with only fixed effects. That's just linear regression/ordinary least squares, and you fit it using the lm function: <...
  • 6,161
0 votes

How to compare groups in different measurements using lmer (lme4)?

The article you refer to is: Watts JJ, Jacobson MR, Lalang N, et al. Imaging Brain Fatty Acid Amide Hydrolase in Untreated Patients With Psychosis. Biological Psychiatry, 88(9):727-735, 2020. DOI: 10....
  • 5,662
1 vote

Cross-validation/bootstrap validation for mixed models

I think CV is pretty directly possible for mixed models (not also that confidence interval estimation via bootstrap is done a lot for mixed models): I'd actually say that with a mixed model you have ...
0 votes

Backend process of lmer function

Check the paper by its authors that goes both through the math and implementational details: Bates, D., Mächler, M., Bolker, B., & Walker, S. (2015). Fitting Linear Mixed-Effects Models Using ...
  • 120k
0 votes

Mixed effects model for paired subjects in a complex design

These are good questions you are asking before moving forward with this model, which, in my opinion, has some issues. I'll address each of your questions and that should also address the problems with ...
  • 3,367
3 votes
Accepted

How do I specify which variables are at which levels in a hierarchical linear model?

Some notes on your model: You have coded race multiple times as variable. Don't. It makes far more sense to code it as one variable, Race, then it does to code it ...
3 votes
Accepted

Specify an lmer model for fully crossed data with replications

Each observation in the data you simulate is independent from all the other observations. This doesn't match your $2 \times 2 \times 3$ within-subjects design with $50$ observations per cell and ...
  • 2,350
1 vote
Accepted

Choosing experimental design and sample size based on power analysis for mixed models using pilot data

Here's the problem: the estimated effect sizes you used for your power analysis are likely to be highly noisy because they come from a small dataset of 20 subjects. So much so that you probably ...
  • 14.3k
1 vote

How do I calculate weights for weighted means?

The lmer function in the lme4 package allows you to specify an argument weights that gives ...
  • 102k
7 votes
Accepted

Can we have NAs (missing data) in a linear-mixed model?

Software like lmer() will typically omit any row of data that has an NA value for any variable that's in the model, outcome or predictor. From that perspective, if ...
  • 68.7k
8 votes

Can we have NAs (missing data) in a linear-mixed model?

Part 1 of the question For the outcome variable, if one does not explicitly impute missing values (whether you leave records with NA in or delete them, as long as you leave the non-missing records for ...
  • 24.1k
4 votes
Accepted

Should I do pairwise NA deletion for the predictors in regression and delete NAs from outcome?

This is a follow-up question to your first question about this data and I have a follow-up answer. I take advantage of your comments to the previous question to rename ...
  • 5,662
4 votes
Accepted

Lmer violating residuals' normality assumption: What should I do? When "enough data" is enough?

First let's look at the data to gain a bit of understanding about the problem. ...
  • 5,662
1 vote
Accepted

Error lme: covariate must have unique values within groups

I guess that in the correlation structure of the error you have to provide the ID like this ...
  • 1,323
2 votes

Lmer violating residuals' normality assumption: What should I do? When "enough data" is enough?

You could consider log-transforming your outcome variable. This would imply a multiplicative relationship between your predictors and $score$. I.e., changing your predictor variables changes score by ...
  • 531
2 votes

Specify an lmer model for fully crossed data with replications

This can be done by using lmerTest, which is an extension for lmer. The correct formula is ...
1 vote
Accepted

How to transform variance-covariance matrix into `theta` parameters in `lme4`

This is due to the formulation of the likelihood function that is optimized. Lme4 uses REML by default, which profiles out the fixed effect and the residual term. This reformulation reduces the number ...
1 vote

How to transform variance-covariance matrix into `theta` parameters in `lme4`

Looking at the code of the function mkVarCorr it seems that I was missing scaling by residual variance ...
  • 2,873
3 votes

Should the repeated measures variable be coded as a factor or as a numeric variable in lmer function?

Since all subjects belong to the same class, you don't need the (1|class) component, which corresponds to a random class intercept. And since the dependent variable ...
  • 5,662

Top 50 recent answers are included