estimate(test-ref) and lsmeans in bear [🇷 for BE/BA]

posted by mittyri – Russia, 2018-12-12 23:57 (1953 d 04:48 ago) – Posting: # 19688
Views: 11,110

Dear Yung-jin,

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.

In your example the dataset is balanced.
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.

That is called as a contrast.

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

Complete thread:

UA Flag
Activity
 Admin contact
22,986 posts in 4,823 threads, 1,657 registered users;
44 visitors (0 registered, 44 guests [including 5 identified bots]).
Forum time: 05:45 CEST (Europe/Vienna)

Art is “I”; science is “we”.    Claude Bernard

The Bioequivalence and Bioavailability Forum is hosted by
BEBAC Ing. Helmut Schütz
HTML5