335
questions
0
votes
0
answers
24
views
emmeans and mmrm when there are missing timepoints
I use the mrmm package to fit a model for repeated mesures.
I use a structured covariance matrix, ante-dependence (ad).
I kept unobserved timepoints in order to keep the correct distance between the ...
0
votes
1
answer
62
views
Different plots of marginal effects with interaction term and offset when using different packages
I'm trying to understand why when I plot marginal effects using different packages I get different plots. Admittedly, I suspect it's because I do not understand how data transformations and offsets ...
0
votes
0
answers
16
views
Am I correct in using lsmeans or emmeans
Good day,
I have some data I am trying to analyze and want to make sure I am doing so correctly. My data consists in a set of 10 samples which I inoculated with a pathogen in different days (I named ...
0
votes
1
answer
28
views
Tukey post-hoc test not giving exact p-value
I am running a model in R to look at differences between subareas and age classes over many years.
(snippet of what the data looks like)
This is my model: m1<-glmmTMB(Quantity ~ Subarea+ AgeClass,...
0
votes
1
answer
97
views
Linear mixed model EMMEANS using multiply imputed datasets (mids) adds level to factor variable
I'm using a multiply imputed dataset (mids) to run a linear mixed model in R, and then I tried the emmeans package to obtain my emmeans with p-values. X2 is a factor which I'm interested in, that was ...
1
vote
1
answer
60
views
Obtaining mean effect size estimates and confidence intervals when a factor level combination is missing
I fitted a model using the metafor package with a moderator interaction for which there is no data for a combination of factor levels.
library(orchaRd)
data(fish)
warm_dat <- fish
warm_dat$factor2&...
2
votes
2
answers
65
views
Bug report when emmeans() is used along with fct_na_value_to_level()
This is an MRE that shows an inconsistency in the use of emmeans() along with fct_na_value_to_level().
It wasn't easy to get the why of the error from my initial code ;)
I prefer to put it here ...
0
votes
0
answers
57
views
Degrees of Freedom in Emmeans
I am using the 'emmeans' package in R to compute estimated marginal means for my (liner mixed-effects) model. However, I am enountering a warning message related to the number of observations ...
2
votes
1
answer
69
views
Why do I need to hardcode the formula in emmeans() instead of dynamically extracting the formula from a dynamic linear model?
Edit: added a non-Shiny MRE, though that has a different error than the Shiny one...
Consider the following MRE (note that the app will not display correctly, this code is just to get it running for ...
2
votes
2
answers
117
views
How to back-transform inverse transformation in emmeans when using contrast function
I am trying to calculate pairwise comparisons using the {emmeans} package after fitting a linear model with an inverse-transformed response. Here is the data and fitted model. The data comes from the {...
0
votes
0
answers
27
views
R emmeans for outer nesting variable (unbalanced nested variables)
I have a model with a nested variable that is only meaningful within one level of another variable, i.e. the case described in this question and explanation on CrossValidated.
The reproducible example ...
0
votes
1
answer
65
views
How to change the order of terms on the x axis using emmip or emmip_ggplot?
I need some help. I am trying to change the x axis terms while using the emmip function. Both of the items in question have been coded as factors (Ploidy and P). x is my data.
x$Ploidy <- as.factor(...
0
votes
0
answers
58
views
How to create a function in R to add emmeans-contrasts output to a ggplot-graphic?
I hope someone can help me with this problem. I have no background in computer science or programing, which makes it hard to understand why my code doesn't work.
My goal is to create a number of plots,...
0
votes
2
answers
135
views
How do I produce a customizable interaction plot using the estimated marginal means? [closed]
I am currently looking at how the effect of two factors (temperature, species) on the duration of the egg stage in insects using a linear model and ANOVA analysis as follows:
## Model
type3.egg <- ...
1
vote
1
answer
86
views
Post-hoc comparisons of quasi-family glmer models with emmeans
Since "quasi" families cannot be used in glmer, there is an efficient approach to adjust the standard errors of the parameters and the associated statistics post-fitting (https://bbolker....
0
votes
0
answers
86
views
How is it possible for a glm and an emmeans on the same model to get different results?
I'm running a model comparing percent abnormality across two factors, mate pair and treatment. I ran the code:
model <- glm(Percent~Treatment+MatePair, data=sub_plut_abnorm) summary(model)
enter ...
0
votes
0
answers
15
views
How can I identify with letters differences between groups using emmeans
I have performed an anova and plot the differences between groups (YOB_tn) with emmeans. But I need to identify which levels arrange togheter (the letters netween contrasts) because it is impossible ...
0
votes
0
answers
34
views
Selecting contrasts in emmeans
So, I have this model of a dataset I've build with a lot of information and now I'm trying to compare some of the variables I have with some others, but not everything with everything as tukey does.
...
0
votes
1
answer
43
views
Attempting to order emmeans by ascending order
Hey so I have the following code:
emmeans(tgmod, specs = c("dose", "supp"))%>%as_tibble() %>% arrange(mean)
where tgmod is a linear regression model of a dataset including ...
0
votes
0
answers
22
views
Level probabilites from emmeans don't seem to match predicted means from emmeans
When I ask emmeans for model level probabilities I get the highest probabilities near levels 6 and 7 of my ordinal DV:enter image description here
> emmeans(clm_gid_no,
+ ~ value | ...
1
vote
1
answer
125
views
How to calculate a contrast of continuous variable in emmeans
I have a contrast using lrm in the rms package. How can I recreate this in emmeans?
# example from rms package
library("rms")
set.seed(1)
age <- rnorm(200,40,12)
sex <- factor(sample(c(...
1
vote
1
answer
179
views
How does emmeans adjust the p-values when using "Tukey" as adjustment method?
I want to calculate a critical difference for my pairwise comparisons. For this I need to understand how the p-values are adjusted, since I want to have the tukey method active.
I was able to ...
0
votes
0
answers
19
views
lme4 - Cannot get emmeans when have a nested factor?
So I have a treatment with 3 factors (Air Temperature, Water Temperature, and Region), but within each Region, there are populations, that work as replicates, e.g., Region A has 4 populations (...
0
votes
0
answers
41
views
emmeans to calculate simple effects for significant GLMM interaction
Using R, the following GLMM model converged with significant interactions between window conditions ("window" and "no window") for all sound conditions using treatment contrasts (i....
2
votes
1
answer
127
views
Interaction risk ratio from logistic regression in marginaleffects package in R
I'm have a logistic regression model predicting interest (0=no interest, 1=interest) with randomised experimental condition (0=control, 1=experimental), sex, sex:condition interaction, and several ...
0
votes
1
answer
71
views
What needs to be done to include a categorical and numerical covariate (eg gender and age)?
I have the following code, and Gender is a dummy variable as M0, F1:
Example Data:
ID Feature Age Gender Category
1 96 30 0 category 1
2 57 42 0 category 1
3 82 37 0 category 1
4 ...
0
votes
0
answers
61
views
Getting fitted values using the emmeans and predict functions
I want to get the difference between the "average" scores on a five-point scale using the emmeans library. However, I found that this is only possible for the models of the ordinal library. ...
0
votes
0
answers
397
views
How to sensibly calculate effect sizes for linear mixed models?
I ran a linear mixed model analysis on my data and specified a rather "simple" LMM. The data come from a within-subject design were participants rated the same stimulus in three different ...
0
votes
0
answers
74
views
How to create a plot from emmeans function and add p-value significance?
I ran this code to get p-value significance.
em2023 <- emmeans(model1, pairwise ~ Nutrient, adjust = "BH")
pairs(em2023)
I have attached a picture of the output.
How do I make a boxplot ...
0
votes
1
answer
53
views
Custom emmeans contrasts
I have a longitudinal study in which there are two treatments on day -3 but then individuals in each of these two treatments are further split into four treatments on day 0 and onward into day 2. In ...
0
votes
0
answers
160
views
What does the CHOLMOD error mean and how do I solve it for my mixed linear regression model?
I am running a mixed regression model
lmer(Shock.ct.cumPeriod ~ tlag + Grazing_strategy +
(1|Stocking_rate)+(1|Year), data = d.shock2b)
summary(m.shock)
and then using the emmeans ...
2
votes
1
answer
42
views
package emmeans: if including less variables in an emmip model, what are the other variables set to in the emmeans model?
Say I have a linear model:
fullmodel <-glm(outcome ~ map * pressor + group + x + y + z, data=data, family="binomial")
And then want to construct a plot of a interaction terms analysis:
...
4
votes
1
answer
124
views
Using/post-hoc testing 'survreg' with 'emmeans' in r when certain experimental treatments are 75% censored
I am running into problems post-hoc testing (package 'emmeans', functions 'emmeans'/'contrast') a survival model (package 'survival', function 'survreg') I've previously fitted to some experimental ...
1
vote
1
answer
195
views
how to output coefficients of multinomial regression with emmeans?
ml <- foreign::read.dta("https://stats.idre.ucla.edu/stat/data/hsbdemo.dta")
model.fit <- multinom(ses~female*prog+read, data=ml)
I have the following coefficients:
Call:
multinom(...
3
votes
3
answers
519
views
emmeans R package error: "Error in t(OO[[rr]]) : object 'unpackedMatrix_transpose' not found"
I am attempting to use the emmeans package in RStudio, which I have done successfully many times, but now it is giving me an error that I can't solve:
shannon_site_emm <- emmeans(shannon_site, ...
0
votes
1
answer
39
views
How do I print 95% CI with pairs (emmeans)?
I want to print the difference between groups (control_str2) with emmeans, but pairs only prints mean +/- SE.
`em_means <- emmeans(ComPAS_MUAC115_LinearGrowth_ForAnalysis_completecases_2.1, specs = ...
0
votes
1
answer
46
views
Trouble extracting selected contrast pairs from either pairwise Summary() or Confint()
There are 190 pairwise contrasts that appear in a summary() or confint(). If I use summary() or confint() I can manually located the selected contrast in the console. Instead, I would like to find ...
0
votes
0
answers
56
views
How to implement a two-way linear mixed model for meta-analysis in R, following Piepho et al 2012
I am working on a meta-analysis, and a colleague has suggested following the approach outlined by Piepho et al 2012 in their paper here: https://www.jstor.org/stable/41806045.
I would like some advice ...
0
votes
0
answers
31
views
Error in names(temp_bhat) when using emmeans() on a lavaan() object
I am running a path analysis in lavaan that looks like this:
model <- '''
DV ~ Covariate1 + Covariate2 + Covariate3 +
Predictor0 + Predictor1 + Predictor2 + Predictor3 + Predictor4 +
...
0
votes
1
answer
452
views
How to interpret odds ratios by emmeans for glmmTMB-beta
I fit this mixed model with beta for the response variable: photochemical efficiency or Fv/Fm and the predictor variables are categorical:
Family: beta ( logit )
Formula: FvFm ~ hora * ...
0
votes
0
answers
245
views
How to properly use lme4 and emmeans to perform contrasts on a population basis across a variable with 2 levels (treatment yes vs no)
For some context, I have detected some cell populations and their associated counts in my cytometry data samples using FAUST.
I have some meta information that groups my samples into treatment groups (...
0
votes
0
answers
215
views
Emmeans, pairs, contrasts, and all different p-values
The main regression formula I am using is as follows (Both the Group and Time variables are binary):
lmer.fit <- lmerTest::lmer(corrmcc ~ Group * Time + (1|ID),
data = ...
0
votes
1
answer
83
views
cumulative probability at different levels of the response with emmeans
Given this model:
library(ordinal)
wine2 <- wine
wine2$rating[wine2$rating==5] <- 1
wine2$rating <- ordered(wine2$rating)
fm <- clm(rating ~ response*temp, data=wine2)
how can I ...
0
votes
1
answer
153
views
BACI design: How to account for the difference in Before-After Control?
I ran a BACI experiment looking at the effect of artificial light at night on fish reproduction, and one of our response variable is the yolk area in their eggs. My raw data looks like the attached ...
1
vote
1
answer
57
views
emmeans adds Days together
I want to do a posthoc / pairwise comparison with emmeans. My model says, as soon as I add Day as an explanatory variable, it gets significant. But when I do posthoc analyses, it gets weird and I get ...
0
votes
0
answers
155
views
How to plot interaction effects of pooled regression coefficents of multiple imputed data using mice in R?
I've conducted a multilevel regression analysis using imputed data in R, utilizing the mice package. Here's my workflow:
I initially imputed my dataset using the mice package.
Next, I performed a ...
1
vote
1
answer
185
views
Finding the effect of a covariate averaged over all other covariates and interactions in R
I am running a linear mixed model in R using data with repeated measures for a project and as part of my analysis I need to determine what the effect of time is (how much the outcome changes from one ...
0
votes
1
answer
405
views
Interpretation of hurdle models with estimated marginal means
My goal is to interpret the coefficients of a hurdle model through estimated marginal means. I prefer to interpret probabilities (back-transformed from the logit scale), rather than log-odds (model ...
8
votes
2
answers
2k
views
Predictions computed by ggpredict() and ggemmeans() for a mixed-effect model differ: why?
I used functions ggpredict() and ggemmeans() from package ggeffects 1.3.0 to calculate mean estimates and confidence intervals (hereafter: CI) for a mixed-effect model. These functions rely on predict(...
1
vote
1
answer
35
views
joint_tests omits covariate transformed with asin(sqrt()) via make.tran()
Relating to joint_tests doesn't recognize asin.sqrt transformation via make.tran() I have emmeans 1.8.8
set.seed(83)
library(emmeans)
dummy <- expand.grid(
covar = runif(72, min = 0, max = 1)...