estimate(test-ref) and lsmeans in bear [🇷 for BE/BA]
Dear Yung-jin,
Thank you for the explanation.
The question is how do you obtain LSMeans or what do you output as
Here's a little code where I show that the LSMeans difference is a point estimate irrespective of the sequence balance.
Thank you for the explanation.
❝ Estimate(test-ref) in bear is not obtained directly from the difference of mean values or lsmean. It is obtained from one of coefficients of lm() function.
The question is how do you obtain LSMeans or what do you output as
MEAN-ref = 7.32951
MEAN-test = 7.40146
❝ please browse "Interpreting regression coefficient in R" for more details (the explanations for the coefficient x32). Does anyone know the name of this coefficient in statistics? Thanks.
Here's a little code where I show that the LSMeans difference is a point estimate irrespective of the sequence balance.
library(data.table)
library(curl)
library(emmeans)
alpha <- 0.05
PKdf <- fread("https://static-content.springer.com/esm/art%3A10.1208%2Fs12248-014-9661-0/MediaObjects/12248_2014_9661_MOESM1_ESM.txt")
setorder(PKdf, Subj)
factorcols <- colnames(PKdf)[-5]
PKdf[,(factorcols) := lapply(.SD, as.factor), .SDcols = factorcols]
ow <- options()
options(contrasts=c("contr.treatment","contr.poly"))
# get rid of 3 subjects in one sequence
PKdf_1 <- PKdf[which(Subj!=1L&Subj!=2L&Subj!=4L),]
logmeans <- data.frame(PKdf_1[, lapply(.SD, function(x){mean(log(x))}), by = Trt, .SDcols="Var"])
colnames(logmeans) <- c("Trt", "logmean")
muddle <- lm(log(Var)~Trt+Per+Seq+Subj, data=PKdf_1)
print(table(PKdf_1[, Seq]))
# RT TR
# 12 18
# in the standard contrasts option "contr.treatment"
# the coefficient TrtT is the difference T-R since TrtR is set to zero
lnPE <- coef(muddle)["TrtT"]
cat("The contrast from lm() is ", lnPE)
# The contrast from lm() is -0.04975903
print(logmeans)
# Trt logmean
# 1 T 4.916300
# 2 R 4.980382
# compare with LSMeans
LSMobj <- lsmeans(muddle, 'Trt')
print(cbind.data.frame(Trt = summary(LSMobj)$Trt,LSMean = summary(LSMobj)$lsmean))
# Trt LSMean
# 1 R 4.988564
# 2 T 4.938805
cat("LSMeans difference is ", summary(LSMobj)$lsmean[2] - summary(LSMobj)$lsmean[1])
# LSMeans difference is -0.04975903
LSMpair <- pairs(LSMobj, reverse = T)
cat("The contrast from LSMeans difference is ", summary(LSMpair)$estimate)
# The contrast from LSMeans difference is -0.04975903
lnCI <- confint(muddle,c("TrtT"), level=1-2*alpha)
print(lnCI)
# 5 % 95 %
# TrtT -0.1013179 0.001799863
print(confint(LSMpair, level =0.9))
# contrast estimate SE df lower.CL upper.CL
# T - R -0.04975903 0.02911397 13 -0.1013179 0.001799863
#
# Results are averaged over the levels of: Per, Subj, Seq
# Results are given on the log (not the response) scale.
# Confidence level used: 0.9
#reset options
options(ow)
—
Kind regards,
Mittyri
Kind regards,
Mittyri
Complete thread:
- PE vs GMR roman_max 2018-12-10 17:53 [🇷 for BE/BA]
- PE vs GMR Ohlbe 2018-12-11 00:28
- PE vs GMR roman_max 2018-12-12 16:31
- PE vs GMR in Bear mittyri 2018-12-12 17:40
- estimate(test-ref) in bear yjlee168 2018-12-12 18:58
- estimate(test-ref) and lsmeans in bearmittyri 2018-12-12 22:57
- estimate(test-ref) and lsmeans in bear yjlee168 2018-12-13 12:20
- estimate(test-ref) and lsmeans in bearmittyri 2018-12-12 22:57
- estimate(test-ref) in bear yjlee168 2018-12-12 18:58
- PE vs GMR in Bear mittyri 2018-12-12 17:40
- PE vs GMR roman_max 2018-12-12 16:31
- PE vs GMR mittyri 2018-12-11 16:30
- PE vs GMR roman_max 2018-12-12 16:41
- PE vs GMR ElMaestro 2018-12-12 21:39
- PE vs GMR roman_max 2018-12-13 23:11
- SPSS vs lm mittyri 2018-12-14 15:35
- SPSS vs lm roman_max 2018-12-15 13:37
- SPSS BE code mittyri 2018-12-15 22:07
- SPSS vs lm roman_max 2018-12-15 13:37
- PE vs GMR ElMaestro 2018-12-14 16:11
- SPSS vs lm mittyri 2018-12-14 15:35
- PE vs GMR roman_max 2018-12-13 23:11
- PE vs GMR Ohlbe 2018-12-11 00:28