审稿人:你的模型结果汇报的太含糊!请给出预测变量效应图,谢谢!
install.packages("effects")
library(effects)
summary(Arrests)
str(Arrests)


mydata <- Arrests
mymodel <- glm(released ~ checks + employed + colour*year + colour*age,
family = binomial, data = mydata)
summary(mymodel)

checks_effects <- predictorEffect("checks", mymodel)
checks_effects

summary(checks_effects)

plot(checks_effects)

checks5_effects <- predictorEffect("checks", mymodel,
focal.levels = 5)
summary(checks5_effects)

# 查看employed的效应
employed_effects <- predictorEffect("employed", mymodel)
plot(employed_effects)
# 查看age的效应
age_effects <- predictorEffect("age", mymodel)
plot(age_effects)
# 查看year的效应
year_effects <- predictorEffect("year", mymodel)
plot(year_effects)



plot(age_effects,
main = "",
xlab = "Age",
ylab = "Probability (released)",
rug = FALSE)

mydata1 <- Prestige
summary(mydata1)
str(mydata1)


mymodel1 <- lm(prestige ~ education + women + log(income)*type, data = mydata1)
summary(mymodel1)

eall_model1 <- predictorEffects(mymodel1)
plot(eall_model1)

plot(predictorEffects(mymodel1, ~ education))
plot(predictorEffects(mymodel1, ~ women))
plot(predictorEffects(mymodel1, ~ income))
plot(predictorEffects(mymodel1, ~ type))




plot(predictorEffects(mymodel1, ~ income),
lines = list(multiline = TRUE))


[1] Visualizing Fit and Lack of Fit in Complex Regression Models with Predictor Effect Plots and Partial Residuals
2024-04-15 14:43