## 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,然后是另一个带有交互项的回归模型(职业声望和该职业中女性的比例)。比较两个模型以查看交互是否显着(与摘要(m2)中的交互的p值相同)。这里的情节是使用Prestige数据集(实践),职业声望对不同职业女性水平的职业收入的影响。想法是,女性较少的职业会得到较少的回报(以引起性别平等问题)。
这里的收入(y轴)实际上是自然对数变换。但我想提出原始收入。 我该怎么做?
此外,互动术语实际上并不重要。但是,当我使用原始价值收入时,它是重要的。我知道&#34;女性&#34;(女性的比例)对声望→收入&#34;有适度的影响。 无论如何都要解决不一致问题?
答案 0 :(得分:1)
我已经解决了第一个问题。添加一些参数来实现功能就可以了。
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)