英文:
Backtranform lsmeans in R
问题
我已在R中创建了一个简单的线性回归模型,其中我对响应进行了对数变换。自变量是分类变量,具有80个级别。然后我使用emmeans进行成对测试。如何将emmeans反变换为与响应相同的刻度(而不是对数刻度)?我在R中使用emmeans包。
英文:
I have created a simple linear regression model in R where I have log transformed the response. The independent variable is categorical with 80 levels. Then I use emmeans for pairwise tests. How can I backtransform the emmeans to have the same scale as the response (not the log scale)? I use the emmeans package in R.
答案1
得分: 3
我认为这只是
summary(emmeans(...), type = "response")
吗?关于转换和链接函数的说明可以在这里找到:转换和链接函数的文档
例如:
library(emmeans)
m1 <- lm(log(mpg) ~ factor(cyl), mtcars)
summary(emmeans(m1, ~cyl), type = "response")
cyl response SE df lower.CL upper.CL
4 26.3 1.268 29 23.9 29.0
6 19.7 1.190 29 17.4 22.3
8 14.9 0.636 29 13.6 16.2
使用的置信水平:0.95
区间从对数尺度反变换
请注意,如果您使用pairs(emmeans(m1, ~cyl), type = "response")
,它将为您提供成对的比率,但请注意测试是在对数尺度上执行的(正如应该的那样)。
英文:
I think this is just
summary(emmeans(...), type = "response")
? There is a vignette on transformations and link functions
e.g.
library(emmeans)
m1 <- lm(log(mpg) ~ factor(cyl), mtcars)
summary(emmeans(m1, ~cyl), type = "response")
cyl response SE df lower.CL upper.CL
4 26.3 1.268 29 23.9 29.0
6 19.7 1.190 29 17.4 22.3
8 14.9 0.636 29 13.6 16.2
Confidence level used: 0.95
Intervals are back-transformed from the log scale
Note that if you use pairs(emmeans(m1, ~cyl), type = "response")
it will give you the pairwise ratios, but notes that the tests are performed on the log scale (as they should be)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论