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
2
votes
2 answers

Least square means

I'm having problems understanding the behaviour of least square means. Below is a toy example that uses a random data set to demonstrate my issue. The scenario is this: there are 10 stations that are sampled for a metric called density in either…
Dan
  • 11,370
  • 4
  • 43
  • 68
2
votes
1 answer

Error in R lsmeans() function: Error in format.default(nm[j], width = nchar(m[1, j]), just = "left")

I'm trying to find the least square mean of "post" by "group". Values of "group" are "TEST" or "CONTROL". mixed_data <- data.frame(group, pre, post) mixed_lm <- lm(post ~ group + pre, data=mixed_data) mixed_lsmean <- lsmeans(mixed_lm, "group") But…
Bing Cui
  • 45
  • 3
2
votes
1 answer

R lsmeans adjust multiple comparison

I used lme4 to run a mixed effects logistig regression (by calling glmer) in R and now I am trying to do post-hoc comparisons. As they are pairwise, Tukey should be OK,but I would like to manually adjust for how many tests the correction should be…
LaNeu
  • 105
  • 14
1
vote
2 answers

How to narrow down to specific contrasts with lsmeans

I would like to use contrast() with an lsmeans object to perform some specific planned comparisons, but I cannot find a method to perform the comparisons I want. I want to compare whether one factor has an effect at either of two factor levels. For…
1
vote
0 answers

How to avoid error “requires numeric/complex matrix/vector arguments”?

I first upload the table. The table contains 9 rows, 6 of them are factors and the 3 left are discrete measures of growth rate of 152 individuals (n01,n02,n03). Then I specify the factors: `r$feed <- factor (r$feed)` `r$ph <- factor (r$ph)` `r$aq…
1
vote
1 answer

Box-Cox back transformation with emmeans not working properly

I am doing a linear regression with data that needs transformation, for it, I am using a Box-Cox power transformation, followed by back-transformation to write a report using the original scale. I've been trying to do this with the emmeans packages,…
andapo
  • 21
  • 4
1
vote
2 answers

Visualizing adjusted means (LS means or Estimated Marginal means) procedure in ANCOVA (ggplot2)

Trying to figure out how to visually demonstrate how adjusted means works in ANCOVA. There are some good published examples in the primary literature, but I haven't been able to replicate their visualizations with ggplot2. Examples I am trying to…
1
vote
1 answer

lsmeans: Error in eval(predvars, data, env) : object 'location' not found

So I ran a Two-way Ordinal Regression with CLM with the specific columns: gra, location, species and it worked: gra.f <- clm(gra ~ location + species + location:species, data = gra) now I'm tring to run the pairwise using the lsmeans…
kjgrad
  • 21
  • 2
1
vote
3 answers

How to prevent LS means analysis from producing NAs?

I am running an linear model regression analysis script and I am running emmeans (ls means) on my model but I am getting a whole of NA's not sure why... Here is what I have run: setwd("C:/Users/wkmus/Desktop/R-Stuff") ### yeild-twt …
wardah m
  • 27
  • 1
  • 7
1
vote
1 answer

Calculate confidence intervals for pairwise comparison using lsmeans/emmeans in R

I am using the lsmeans/emmeans package in R to create a plot of pairwise comparisons in the response between levels of treatA (binary/factor variable). I can get the difference estimates using lsmeans (contrast), but it only provides the SE for the…
antares
  • 35
  • 8
1
vote
1 answer

I'm getting not significance differences in ANOVA lsmeans, but there are some really significance data. What's wrong with my scripts?

I'm getting not significance differences in ANOVA lsmeans, but there are some really significance data. What's wrong with my scripts? df <- structure(list(value = c(1.693086732, 0.25167691, 1.100272527, 1.60428654, 0.908237338, 1.449864567,…
Dendrobium
  • 323
  • 5
  • 13
1
vote
1 answer

Edited: How to write Loop for PostHoc Tukey test and multiple comparision

This is my sample of a big data matrix & and each column has named with multiple information and separated by an underscore. structure(list(Gene = c("AGI4120.1_UBQ", "AGI570.1_Acin"), WT_Tissue_0T_1 = c(0.886461437, 1.093164915), WT_Tissue_0T_2 =…
Dendrobium
  • 323
  • 5
  • 13
1
vote
0 answers

Change vegan::adonis class to lm?

I am running a perm-manova using the adonis2 function in vegan package. I have a significant interaction in my model, so would like to perform tukey-adjusted comparisons for the interaction using the lsmeans package. However, while lsmeans accepts…
J.Con
  • 4,101
  • 4
  • 36
  • 64
1
vote
1 answer

Error in lmer model and lsmeans output

I'm running an LME model with the lme4 package and then following up with pairwise comparisons using the lsmeans package. Here is my code: lmer_full <- lmer (VOT ~ Place*Laryngeal + (1+Place+Laryngeal|Sp), data =…
candle786
  • 41
  • 7
1
vote
1 answer

Perform hypothesis testing on coefficients from separate linear models

Imagine I have two separate lm objects data(mtcars) lm1 <- lm(mpg ~ wt, data = mtcars) lm2 <- lm(mpg ~ wt + disp, data = mtcars) In this case I'd like to compare both wt coefficients, and perform a hypothesis test on the null that the coefficients…
tomw
  • 3,114
  • 4
  • 29
  • 51