在 R 中呈现线性回归模型的调节效应时如何反转对数变换?
How to reverse log transformation when presenting moderation effect from linear regression models in R?
## load the dataset
library(car)
library(texreg)
library(effects)
library(psych)
Prestige$lnincome <- log(Prestige$income)
PrestigeSubset <- Prestige[!rownames(Prestige) %in% c("MINISTERS","BABYSITTERS","NEWSBOYS"), ]
m1 <- lm(lnincome ~ prestige + women + education + type, data = PrestigeSubset)
m2 <- lm(lnincome ~ prestige*women + education + type, data = PrestigeSubset)
anova(m1, m2)
# Analysis of Variance Table
# Model 1: lnincome ~ prestige + women + education + type
# Model 2: lnincome ~ prestige * women + education + type
# Res.Df RSS Df Sum of Sq F Pr(>F)
# 1 91 4.3773
# 2 90 4.2661 1 0.11127 2.3473 0.129
plot(effect("prestige:women", m2), xlevels = list(women = c(0, 25, 50, 75, 97.51)), multiline = T)
我首先做了一个回归模型 m1,然后是另一个带有交互项(职业声望和女性在该职业中所占比例)的回归模型。比较两个模型,看交互是否显着(与summary(m2)中交互的p值相同)。这里的图是使用声望数据集(用于实践)的职业声望对不同比例的女性职业收入的影响。想法是女性较少的职业会得到较少的回报(引出性别平等问题)。
这里的收入(y轴)其实是自然对数变换的。但我想出示原始收入。 我该怎么做?
另外,交互项其实并不显着。但是当我使用原始价值收入时,它是显着的。我知道 "women"(女性比例)对 "prestige → income" 有调节作用。 有没有办法解决不一致的问题?
我已经解决了第一个问题。添加一些参数到effect函数即可。
plot(effect("prestige:women", m2, xlevels = list(women = c(0, 25, 50, 75, 97.51)),
transformation = list(link = log, inverse = exp)),
multiline = T, type = "response", add = T)
## load the dataset
library(car)
library(texreg)
library(effects)
library(psych)
Prestige$lnincome <- log(Prestige$income)
PrestigeSubset <- Prestige[!rownames(Prestige) %in% c("MINISTERS","BABYSITTERS","NEWSBOYS"), ]
m1 <- lm(lnincome ~ prestige + women + education + type, data = PrestigeSubset)
m2 <- lm(lnincome ~ prestige*women + education + type, data = PrestigeSubset)
anova(m1, m2)
# Analysis of Variance Table
# Model 1: lnincome ~ prestige + women + education + type
# Model 2: lnincome ~ prestige * women + education + type
# Res.Df RSS Df Sum of Sq F Pr(>F)
# 1 91 4.3773
# 2 90 4.2661 1 0.11127 2.3473 0.129
plot(effect("prestige:women", m2), xlevels = list(women = c(0, 25, 50, 75, 97.51)), multiline = T)
我首先做了一个回归模型 m1,然后是另一个带有交互项(职业声望和女性在该职业中所占比例)的回归模型。比较两个模型,看交互是否显着(与summary(m2)中交互的p值相同)。这里的图是使用声望数据集(用于实践)的职业声望对不同比例的女性职业收入的影响。想法是女性较少的职业会得到较少的回报(引出性别平等问题)。
这里的收入(y轴)其实是自然对数变换的。但我想出示原始收入。 我该怎么做?
另外,交互项其实并不显着。但是当我使用原始价值收入时,它是显着的。我知道 "women"(女性比例)对 "prestige → income" 有调节作用。 有没有办法解决不一致的问题?
我已经解决了第一个问题。添加一些参数到effect函数即可。
plot(effect("prestige:women", m2, xlevels = list(women = c(0, 25, 50, 75, 97.51)),
transformation = list(link = log, inverse = exp)),
multiline = T, type = "response", add = T)