Questions tagged [emmeans]

Refers to estimated marginal means. These are means predicted by statistical models. A package in R called emmeans is dedicated to predicting these estimates.

303 questions
10
votes
1 answer

Extracting elements from emmGrid of emmeans R package

I wonder how to extract emmean and SE columns from emmGrid of emmeans R package. MWE is given below. library(emmeans) warp.lm <- lm(breaks ~ wool * tension, data = warpbreaks) Test <- emmeans(warp.lm, specs = "wool") Test wool emmean SE…
MYaseen208
  • 22,666
  • 37
  • 165
  • 309
8
votes
3 answers

How to run the predicted probabilities (or average marginal effects) for individuals fixed effects in panel data using R?

These are three different ways to run an individual fixed effect method which gives more or less the same results (see below). My main question is how to get predictive probabilities or average marginal effects using the second model (model_plm) or…
Jack
  • 813
  • 4
  • 17
5
votes
1 answer

Can't get arcsin back-transformation with emmeans to work

I am doing a GAM with my response variable as a percentage (0-100). I have used an arcsin transformation to improve model fit (asin(sqrt(myvariable/100))). I now want to evaluate contrasts between levels of my explanatory factor variable on the…
evelyn
  • 63
  • 5
5
votes
1 answer

using lapply with emmeans list

I'm using the emmeans package and cannot understand why this works library(emmeans) mod <- lm(mpg ~ disp + hp, data = mtcars) l1 <- emmeans(mod, list("disp","hp")) for (x in l1) {print(data.frame(x))} disp emmean SE df lower.CL…
locus
  • 387
  • 2
  • 9
4
votes
1 answer

error message when I tried to get marginal(adjusted) means by using emmeans

Hi I am doing linear regression in R and want to create marginal(adjusted) means for my subgroups. The linear regression includes age, gender, education, marital status, employ, ethnicity and health condition. I wanted to get means and SDs for each…
AFWWU
  • 41
  • 1
4
votes
2 answers

Why is converting emmeans contrasts to a data.frame not reporting correct p-values?

The p-values for the contrasts I am running are not being converted correctly to a data.frame. Why is this and how do I fix it? Console output for emmeans: > pairs(emmeans(lmer.mod, ~ Status*Stim*Treatment), simple = "each") $`simple contrasts for…
iastatecy
  • 67
  • 7
4
votes
1 answer

Getting estimated means after multiple imputation using the mitml, nlme & geepack R packages

I'm running multilevel multiple imputation through the package mitml (using the panimpute() function) and am fitting linear mixed models and marginal models through the packages nlme and geepack and the mitml:with() function. I can get the…
n00n
  • 41
  • 3
4
votes
2 answers

Estimating effect size with emmenas for post hoc

Is there a way to have effect size (such as Cohen's d or the most appropriate) directly using emmeans()? I cannot find anything for obtaining effect size by using emmeans() post <- emmeans(fit, pairwise~ favorite.pirate | sex) emmip(fit, ~…
atnplab
  • 107
  • 1
  • 7
4
votes
2 answers

get significance of simple effects with emtrends

I can get the significance of pairwise comparisons with the following code m <- lmer(angle ~ recipe*temp + (1|replicate), data=cake) emtrends(m, pairwise~recipe, var="temp") $emtrends recipe temp.trend SE df lower.CL upper.CL A …
locus
  • 387
  • 2
  • 9
4
votes
1 answer

How are the SE calculated in emmeans package in R

Im interested in calculating the SE for a mix model. For that, first I have play around with one of the dataset that the package include, in a simpler model. pigs$percent <- as.factor(pigs$percent) Doc_lm_1 <- lm(conc~percent, pigs)…
Chino Chiang
  • 91
  • 2
  • 6
3
votes
2 answers

How to get emmeans to print degrees of freedom for glmer class

I'm trying to get the degrees of freedom from emmeans of a glmer model for reporting reasons, but they just show Inf. Here's some sample data. In the real data, there is no nesting structure, this is just a consequence of how I built the data…
myfatson
  • 354
  • 2
  • 14
3
votes
1 answer

Redefining R's nnet::multinom predict.multinom predict method to support type="link"

I would like to have R's nnet::multinom function being supported by the new marginaleffects package, but marginaleffects::predictions() relies on the predict() methods supplied by the modeling packages to compute predicted values on both the…
Tom Wenseleers
  • 7,535
  • 7
  • 63
  • 103
3
votes
1 answer

Unexpected output of emmeans averaged accross variables

I transformed a variable (e.g. leaf_area) using a simple square transformation and then fitted to the following model containing an interaction: fit <- lmer(leaf_area^2 ~genotype*soil_type + date_measurement + light + (1|repetition) + (1|y_position)…
Elisa
  • 31
  • 1
3
votes
1 answer

How to only test select pairwise comparisons using emmeans?

I have seen several examples how it might be possible to select desired pairwise comparisons, but unfortunately do not know how to apply that to my data. Here is my abbreviated data set: https://www.dropbox.com/s/x9xjc9o0222rg0w/df.csv?dl=0 # FIXED…
user7395965
  • 397
  • 5
  • 17
3
votes
1 answer

emmeans - can you use a baseline measure in a contrast (i.e. as a different variable)?

Best practice when analysing data from an RCT is to adjust for the baseline measure (ancova). However, researchers often still ask for change from baseline in each group and their relative difference (given by the treatment x time interaction). When…
LucaS
  • 887
  • 1
  • 9
  • 22
1
2 3
20 21