Questions tagged [lsmeans]

An R package for obtaining least-squares means for many linear, generalized linear, and mixed models. Compute contrasts or linear functions of least-squares means, and comparisons of slopes. Plots and compact letter displays.

111 questions
3
votes
3 answers

How to obtain lsmeans() pairwise contrasts with custom vcov?

I would like to get pairwise comparisons of adjusted means using lsmeans(), while supplying a robust coefficient-covariance matrix (e.g. vcovHC). Usually functions on regression models provide a vcov argument, but I can't seem to find any such…
landroni
  • 2,902
  • 1
  • 32
  • 39
2
votes
1 answer

glmmTMB: Pairwise comparison post-hoc tests for factors interaction

In my example: # Packages library(glmmTMB) library(DHARMa) library(multcomp) library(lsmeans) library(car) # My data set ds <- read.csv("https://raw.githubusercontent.com/Leprechault/trash/main/temp_ger_ds.csv") str(ds) #'data.frame': 140 obs. of …
Leprechault
  • 1,531
  • 12
  • 28
2
votes
1 answer

Making a matrix from lsmeans contrasts return

To create the data frame: num <- sample(1:25, 20) x <- data.frame("Day_eclosion" = num, "Developmental" = c("AP", "MA", "JU", "L"), "Replicate" = 1:5) model <- glmer(Day_eclosion ~ Developmental + (1 | Replicate), family = "poisson", data= x) I…
2
votes
0 answers

Post-hoc test for LMM with interaction terms

I've defined an lmer model in R with 2 fixed interacting effects, and three random effects. The first fixed effect, 'A' is categorical, whilst the second fixed effect 'B' is continuous: library(lme4) model1<-…
2
votes
1 answer

Using BCNPower Transform (car) and emmeans

The car package in R implements Box-Cox with non-positives (BCN). This is not a standard Box-Cox transformation, although it builds on it. The emmeans package can handled transformed data. It can back transform if the proper functions are defined.…
2
votes
1 answer

write lsmeans into a function with "%>%"

Using "mpg" data as an example, I wrote some code to call lsmeans function in the non-function format, and the output is good to me (as shown below). I try to modify the codes into a function format to generate the same output, but the columns of…
2
votes
2 answers

Get emmeans in sommer's mmer?

Additional keywords: Best linear unbiased Estimator (BLUE), adjusted means, mixed model, fixed effects, linear combination, contrast, R After fitting a model with mmer() of the sommer package - is it possible to obtain estimated marginal means…
Paul Schmidt
  • 1,072
  • 10
  • 23
2
votes
1 answer

Extract probabilities from pairwise contrast in emmeans

I'm trying to perform a pairwise comparison after a glm with a binomial dv, and emmeans reports odds ratios, whereas I require a difference in probabilities. library(magrittr) library(emmeans) glm( am ~ wt * factor(vs), family = binomial(), …
tomw
  • 3,114
  • 4
  • 29
  • 51
2
votes
2 answers

Pairwise comparisons on lmer using lsmeans or difflsmeans

I am doing a reading experiment, comparing reading times in 2 groups across 4 conditions. I ran a lmer model with reading condition (factor w 4 levels) and group (factor w 2 levels) as the predictors and fixation duration as the dependent variable…
Anna Tsiola
  • 21
  • 1
  • 2
2
votes
1 answer

lsmeans contrast for interaction term

I'm attempting use lsmeans and its contrast for an F-test on an interaction. Basically, I'd like to replicate what Stata does with its contrast command. I'd like to do this for two reasons: within a regression model that has an interaction between…
Michael
  • 31
  • 3
2
votes
0 answers

Error when applying lsmeans to model

I have a dataset (data1) as below: T,D,P,R 1,0,1,1 2,1,1,3 3,0,1,7 1,0,2,2 2,1,2,3 3,1,2,7 1,0,3,1 2,1,3,4 3,1,3,7 1,1,4,1 2,1,4,3 3,0,4,7 To start with, all variables except the response (which is R) are specified as factors (so D, T…
2
votes
1 answer

What is the most appropriate method for contrasts in lme (nlme)?

I have a question regarding conducting post-hoc contrasts in a mixed glmm model. Essentially, my data is a series of response variables with fixed factors of 'Subject Type' (three types of subjects), 'Treatment' (four treatments), and 'Year' (two…
choppedpete
  • 29
  • 1
  • 3
2
votes
2 answers

Line plot of mixed models / lsmeans results (with ggplot?)

I have longitudinal repeated measures on individuals over 4 timepoints. Following a mixed models analysis with time as fixed effect and random slopes I have used lsmeans to estimate the mean values at each time point as well as 95% confidence…
Fabian L
  • 43
  • 1
  • 5
2
votes
1 answer

How to see all output from Ismeans?

I have run the linear mixed model using lme4 package. Then to see all pair of contrasts, I have to run the lsmeans function using lsmeans package. This is the function I run: library('lme4') library('lsmeans') lsmeans(lmer1, pairwise ~ vowel *…
user3288202
  • 313
  • 1
  • 4
  • 14
2
votes
1 answer

Lsmeans package in R - degrees of freedom with lme models

I have a question regarding the degrees of freedom that are used by the lsmeans package in the case of a linear mixed model built with the nlme package. Here is an example to illustrate my question based on the Oats dataset. I am not trying to…
Aurélie
  • 75
  • 2
  • 7