Backtranform lsmeans in R: 在R中反转换lsmeans:

huangapple go评论106阅读模式
英文:

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

我认为这只是

  1. summary(emmeans(...), type = "response")

吗?关于转换和链接函数的说明可以在这里找到:转换和链接函数的文档

例如:

  1. library(emmeans)
  2. m1 <- lm(log(mpg) ~ factor(cyl), mtcars)
  3. summary(emmeans(m1, ~cyl), type = "response")
  1. cyl response SE df lower.CL upper.CL
  2. 4 26.3 1.268 29 23.9 29.0
  3. 6 19.7 1.190 29 17.4 22.3
  4. 8 14.9 0.636 29 13.6 16.2
  5. 使用的置信水平:0.95
  6. 区间从对数尺度反变换

请注意,如果您使用pairs(emmeans(m1, ~cyl), type = "response"),它将为您提供成对的比率,但请注意测试是在对数尺度上执行的(正如应该的那样)。

英文:

I think this is just

  1. summary(emmeans(...), type = &quot;response&quot;)

? There is a vignette on transformations and link functions

e.g.

  1. library(emmeans)
  2. m1 &lt;- lm(log(mpg) ~ factor(cyl), mtcars)
  3. summary(emmeans(m1, ~cyl), type = &quot;response&quot;)
  1. cyl response SE df lower.CL upper.CL
  2. 4 26.3 1.268 29 23.9 29.0
  3. 6 19.7 1.190 29 17.4 22.3
  4. 8 14.9 0.636 29 13.6 16.2
  5. Confidence level used: 0.95
  6. Intervals are back-transformed from the log scale

Note that if you use pairs(emmeans(m1, ~cyl), type = &quot;response&quot;) it will give you the pairwise ratios, but notes that the tests are performed on the log scale (as they should be)

huangapple
  • 本文由 发表于 2023年5月24日 20:14:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/76323429.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定