Search code examples
rdata-visualizationlinear-regressiondata-analysis

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)

enter image description here

I did first a regression model m1, then another regression model with a interaction term (profession prestige and share of women in that profession). Compare the two models to see if the interaction is significant(the same as the p value of interaction in summary(m2)). The plot here is the effect of profession prestige to profession income at different share of women levels using the Prestige dataset (for practice). Idea is that professions with fewer women would be rewarded less(to draw the gender equality issue).

The income (y axis) here is actually natural log transformed. But I want to present the original income. How would I do this?

In addition, the interaction term is actually not significant. But when I used the original value income it was significant. I know there is a moderation effect of "women"(share of women) to "prestige → income". Is there anyway to resolve the inconsistency?


Solution

  • I've solved the first question. Add some parameters to effect function will do it.

    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)