问题
I have data of fixed effects: genotypes = C, E, K, M; age = 30, 45, 60, 75, 90 days; random effects: block = 1, 2, 3; and variable = weight_DM.
The file is in: https://drive.google.com/open?id=1_H6YZbdesK7pk5H23mZtp5KhVRKz0Ozl
I have the slopes linear and quadratic of ages for each genotype, but I do not have the intercepts and standard errors. The R code is:
library(nlme)
library(lme4)
library(car)
library(carData)
library(emmeans)
library(ggplot2)
library(Matrix)
library(multcompView)
datos_weight <- read.csv2("D:/investigacion/publicaciones/articulos-escribiendo/pennisetum/pennisetum-agronomicas/data_weight.csv",header=T, sep = ";", dec = ",")
parte_fija_3 <- formula(weight_DM
~ Genotypes
+ Age
+ I(Age^2)
+ Genotypes*Age
+ Genotypes*I(Age^2))
heterocedasticidad_5 <- varComb(varExp(form = ~fitted(.)))
correlacion_4 <- corCompSymm(form = ~ 1|Block/Genotypes)
modelo_43 <- gls(parte_fija_3,
weights = heterocedasticidad_5,
correlation = correlacion_4,
na.action = na.omit,
data = datos_weight)
anova(modelo_43)
#response
Denom. DF: 48
numDF F-value p-value
(Intercept) 1 597.3828 <.0001
Genotypes 3 2.9416 0.0424
Age 1 471.6933 <.0001
I(Age^2) 1 22.7748 <.0001
Genotypes:Age 3 5.9425 0.0016
Genotypes:I(Age^2) 3 0.7544 0.5253
#################################
#test whether the linear age slopes of each genotype is equal to zero
################################
(tendencias_em_lin <- emtrends(modelo_43,
"Genotypes",
var = "Age"))
#response
Genotypes Age.trend SE df lower.CL upper.CL
C 1.693331 0.2218320 48 1.247308 2.139354
E 1.459517 0.2135037 48 1.030239 1.888795
K 2.001097 0.2818587 48 1.434382 2.567811
M 1.050767 0.1301906 48 0.789001 1.312532
Confidence level used: 0.95
(tendencias_em_lin_prueba <- update(tendencias_em_lin,
infer = c(TRUE,TRUE),
null = 0))
#response
Genotypes Age.trend SE df lower.CL upper.CL t.ratio p.value
C 1.693331 0.2218320 48 1.247308 2.139354 7.633 <.0001
E 1.459517 0.2135037 48 1.030239 1.888795 6.836 <.0001
K 2.001097 0.2818587 48 1.434382 2.567811 7.100 <.0001
M 1.050767 0.1301906 48 0.789001 1.312532 8.071 <.0001
Confidence level used: 0.95
########################################
#test differences between slope of the age linear for each genotype
########################################
CLD(tendencias_em_lin,
adjust = "bonferroni",
alpha = 0.05)
#response
Genotypes Age.trend SE df lower.CL upper.CL .group
M 1.050767 0.1301906 48 0.7128801 1.388653 1
E 1.459517 0.2135037 48 0.9054057 2.013628 12
C 1.693331 0.2218320 48 1.1176055 2.269057 12
K 2.001097 0.2818587 48 1.2695822 2.732611 2
Confidence level used: 0.95
Conf-level adjustment: bonferroni method for 4 estimates
P value adjustment: bonferroni method for 6 tests
significance level used: alpha = 0.05
Questions
- How to test whether the age intercepts of each genotype is equal to zero?
- How to test differences between intercepts of the age for each genotype?
- Which are the standard errors of the intercepts of each genotype?
Thanks for your help.
回答1:
You can answer these questions by using emmeans()
in similar ways to what you did with emtrends()
.
Also look at the documentation for summary.emmGrid
, and note that you can choose whether to do CIs, tests, or both. e.g.,
emm <- emmeans(...)
summary(emm, infer = c(TRUE,TRUE))
summary(emm, infer = c(TRUE,FALSE)) # or confint(emm)
summary(emm, infer = c(FALSE,TRUE)) # or test(emm)
True intercepts
If in fact you want the actual y intercepts, you can do that using
emm <- emmeans(..., at = list(age = 0))
The, predictions are made at age 0, which are the intercepts in the regression equations for each set of conditions. However, I would like to try to dissuade you from doing that because this because (a) these predictions are huge extrapolations, hence their standard errors are huge as well; and (b) it makes no practical sense to predict responses at age 0. For that reason, I think question #1 is basically meaningless.
If you leave that at
part out, then emmeans()
makes predictions at the mean age in the dataset. Those predictions will have a much smaller standard error than the intercepts do. Since you have interactions involving age
in the model, the predictions compare differently at each age. I suggest it would be useful to put
emm <- emmeans(..., cov.reduce = FALSE, by = "age")
which is equivalent to using at
to specify the set of age
values that occur in the dataset, and doing separate comparisons at each of those age values.
来源:https://stackoverflow.com/questions/52866203/hypothesis-test-for-intercepts-in-general-mixed-linear-models-with-r