gpt4 book ai didi

r - 在 R 中呈现线性回归模型的调节效应时如何反转对数变换?

转载 作者:行者123 更新时间:2023-12-02 03:08:25 24 4
gpt4 key购买 nike

## 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)

enter image description here

我首先做了一个回归模型 m1,然后是另一个带有交互项(职业声望和女性在该职业中所占比例)的回归模型。比较两个模型,看交互是否显着(与summary(m2)中交互的p值相同)。这里的图是使用声望数据集(用于实践)的职业声望对不同比例的女性职业收入的影响。想法是女性较少的职业会得到较少的返回(引出性别平等问题)。

这里的收入(y轴)其实是自然对数变换的。但我想出示原始收入。 我该怎么做?

此外,交互项其实并不显着。但是当我使用原始值(value)收入时,它是显着的。我知道“女性”(女性比例)对“声望→收入”有调节作用。 有没有解决不一致的方法?

最佳答案

我已经解决了第一个问题。添加一些参数到 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)

关于r - 在 R 中呈现线性回归模型的调节效应时如何反转对数变换?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41130678/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com