Learning objectives

By the end of the lecture, you will be able to …

  • Generate and communicate predictions from OLS regression models.
  • Estimate, visualize, and communicate interaction effects in OLS regression models.

Packages

Load the standard packages.

library(tidyverse) 
library(haven) # not core tidyverse
library(gssr)
library(gssrdoc)
library(summarytools)
library(gtsummary) 
library(modelbased)

Load your data

# Load GSS 2024
gss24 <- gss_get_yr(2024)

Variables

  • realrinc R’s income in constant $
  • age Age of respondent
  • educ Respondents highest edu credit
  • hrs1 How many hours did you work last week
  • sex Respondents sex
  • marital R’s marital status

Make a df with only the (pretty) categorical and continuous variables we’ll analyze.

# Categorical Variables
my_cat <- gss24 |>
  select(id, sex, marital) |>
  zap_missing() |>
  mutate(
    sex = as_factor(sex),
    marital = as_factor(marital)) |> 
  droplevels()

# Continuous Variables
my_con <- gss24 |>
  select(id, age, educ, hrs1, realrinc) |>
  mutate(
    age = as.numeric(age),
    educ = as.numeric(educ),
    hrs1 = as.numeric(hrs1),
    realrinc = as.numeric(realrinc))

# Combine the two dataframes
my_data <- full_join(my_cat, my_con, by = c("id")) |> 
  drop_na() |>
  mutate(
    marital = recode(
      marital,
      "married"       = "Married",
      "never married" = "Never married",
      "widowed"       = "Div/Wid/Sep",
      "divorced"      = "Div/Wid/Sep",
      "separated"     = "Div/Wid/Sep"),
    marital = factor(
      marital,
      levels = c("Never married", "Div/Wid/Sep", "Married"))
  )

remove(my_con) # clean up the Environment
remove(my_cat)

Predictions

OLS Regression Predicting Annual Income

Characteristic Beta1 SE
(Intercept) -34,540*** 3,230
educ 2,845*** 187
hrs1 424*** 38.0
Women -6,544*** 1,018
Marital status (ref. = never married)

    Div/Wid/Sep 5,512*** 1,402
    Married 11,182*** 1,124
R² 0.243
No. Obs. 1,823
1 p<0.05; p<0.01; p<0.001

Typical-person predictions

What does “holding other variables constant” mean?


For a typical-person prediction, we set:

  • continuous variables to their means
  • categorical variables to the category we want to describe (e.g., a never-married woman)
mean(my_data$educ)
[1] 14.78332
mean(my_data$hrs1)
[1] 39.79046

Education = 14.78
Hours worked = 39.79

Typical-person predictions

preds <- estimate_means(
  model,
  estimate = "typical")

preds
Estimated Marginal Means

sex    | marital       |     Mean |      SE |               95% CI | t(1817)
----------------------------------------------------------------------------
male   | Never married | 24386.18 |  969.85 | [22484.05, 26288.32] |   25.14
female | Never married | 17842.68 |  973.15 | [15934.08, 19751.29] |   18.34
male   | Div/Wid/Sep   | 29897.76 | 1295.96 | [27356.03, 32439.50] |   23.07
female | Div/Wid/Sep   | 23354.26 | 1188.22 | [21023.84, 25684.68] |   19.65
male   | Married       | 35567.77 |  874.88 | [33851.90, 37283.64] |   40.65
female | Married       | 29024.27 |  941.75 | [27177.25, 30871.30] |   30.82

Variable predicted: realrinc
Predictors modulated: sex, marital
Predictors averaged: educ (15), hrs1 (40)

Typical-person predictions

\[ \operatorname{realrinc} = \alpha + \beta_{1}(\operatorname{educ}) + \beta_{2}(\operatorname{hrs1}) + \beta_{3}(\operatorname{sex}_{\operatorname{female}}) + \beta_{4}(\operatorname{marital}_{\operatorname{Div/Wid/Sep}}) + \beta_{5}(\operatorname{marital}_{\operatorname{Married}}) + \epsilon \]

Typical never-married man
\(\color{#18bc9c}{-34,540} \color{#3498db}{+(2,845_{educ}*14.8)}\) \(\color{#fd7e14}{+(424_{hrs1}*39.79)}\)


Typical never married woman
\(\color{#18bc9c}{-34,540} \color{#3498db}{+(2,845_{educ}*14.8)}\) \(\color{#fd7e14}{+(424_{hrs1}*39.79)}\) \(\color{#e74c3c}{-6,544_{female}}\)


Typical married man
\(\color{#18bc9c}{-34,540} \color{#3498db}{+(2,845_{educ}*14.8)}\) \(\color{#fd7e14}{+(424_{hrs1}*39.79)}\) \(\color{#9b59b6}{+11,182_{married}}\)


Typical divorced woman
\(\color{#18bc9c}{-34,540} \color{#3498db}{+(2,845_{educ}*14.8)}\) \(\color{#fd7e14}{+(424_{hrs1}*39.79)}\) \(\color{#e74c3c}{-6,544_{female}}\) \(\color{#9b59b6}{+5,512_{divorced}}\)

Marginal Means

Marginal means are adjusted group averages.
Calculated from the regression model by setting continuous predictors to their means and averaging over the categories of other categorical predictors, giving each category equal weight.


marginal_means <- estimate_means(
  model,
  by = "sex",
  estimate = "typical")

marginal_means
Estimated Marginal Means

sex    |     Mean |     SE |               95% CI | t(1817)
-----------------------------------------------------------
male   | 29950.57 | 749.17 | [28481.24, 31419.90] |   39.98
female | 23407.07 | 717.41 | [22000.05, 24814.10] |   32.63

Variable predicted: realrinc
Predictors modulated: sex
Predictors averaged: educ (15), hrs1 (40), marital

Average Adjusted Predictions (AAP)

Average adjusted predictions are adjusted population averages.
Calculated by setting everyone in the data to each group in turn (first all male, then all female) while keeping their other characteristics as observed, then averaging the predictions. Categories are weighted by how common they are in the data.


aap <- estimate_means(
  model,
  by = "sex",
  estimate = "population")

aap
Average Counterfactual Predictions

sex    |     Mean |     SE |               95% CI | t(1817)
-----------------------------------------------------------
male   | 30409.31 | 709.70 | [29017.39, 31801.23] |   42.85
female | 23865.81 | 712.50 | [22468.40, 25263.22] |   33.50

Variable predicted: realrinc
Predictors modulated: sex
Predictors averaged: educ (15), hrs1 (40), marital

3 ways to hold variables constant:

Continuous predictors Categorical predictors
Typical-person prediction
A hypothetical person
Set to their means Set to the category we choose (e.g., never-married woman)
Marginal mean
An adjusted group average
Set to their means Averaged over categories, equal weight for each
Average adjusted prediction (AAP)
An adjusted population average
Kept at each person’s observed values Everyone set to each group in turn, other characteristics as observed, then averaged

Example

Method Men Women Gap
Typical never-married 24,386 17,843 -6,544
Marginal mean 29,951 23,407 -6,544
AAP 30,409 23,866 -6,544


In this additive model, the gap between men and women is always the sex coefficient (-6,544).


The predicted income for each group changes because each method assumes a different mix of marital statuses.

Group-Average Predictions

What if we don’t hold anything constant?
Predict income for every person using their own characteristics, then average the predictions within each group.


group_avg <- estimate_means(
  model,
  by = "sex",
  estimate = "average") |>
  mutate(method = "Group-average prediction")
Method Men Women Gap
Typical never-married 24,386 17,843 -6,544
Marginal mean 29,951 23,407 -6,544
AAP 30,409 23,866 -6,544
Group-average prediction 31,195 23,074 -8,121

Same Idea, Different Names

In this lecture You may also see
Typical-person prediction Adjusted prediction at the means (APM); adjusted prediction at representative values (APR); “holding other variables at their means”
Marginal mean Estimated marginal mean (EMM); least-squares mean (LS-mean); predictions on a balanced grid
Average adjusted prediction (AAP) Predictive margins; marginal standardization; average predicted values; “observed values approach”
Group-average prediction Predictions averaged “over” groups; observed group means of predicted values

Same Idea, Different Code

Concept modelbased marginaleffects Stata
Typical person estimate = "typical", by = c("sex", "marital") predictions(newdata = datagrid(...)) margins sex, atmeans
Marginal mean estimate = "typical", by = "sex" avg_predictions(newdata = "balanced", by = "sex") margins sex, asbalanced
AAP estimate = "population" avg_predictions(variables = "sex") margins sex
Group-average estimate = "average" avg_predictions(by = "sex") margins, over(sex)

Interactions

Interactions test a conditional relationship

Interactions

Without an interaction, the effect of \(X_1\) on Y is \(b_1\)

\[ \hat{Y} = b_0 + b_1X_1 + b_2X_2 \]


With an interaction, the effect of \(X_1\) on Y changes as \(X_2\) changes
Effect of \(X_1\) on Y depends on the level of \(X_2\)

\[ \hat{Y} = b_0 + b_1X_1 + b_2X_2 + {\color{#18bc9c}{b_3(X_1X_2)}} \]

Categorical X Continuous

Average Counterfactual Predictions

marital       | educ |     Mean |      SE |               95% CI | t(1816)
--------------------------------------------------------------------------
Never married |   12 | 14172.36 | 1007.71 | [12195.96, 16148.75] |   14.06
Div/Wid/Sep   |   12 | 17892.87 | 1260.35 | [15420.97, 20364.76] |   14.20
Married       |   12 | 24168.27 |  957.92 | [22289.52, 26047.02] |   25.23
Never married |   13 | 16984.93 |  933.35 | [15154.37, 18815.49] |   18.20
Div/Wid/Sep   |   13 | 20705.44 | 1207.41 | [18337.38, 23073.49] |   17.15
Married       |   13 | 26980.84 |  856.43 | [25301.15, 28660.52] |   31.50
Never married |   14 | 19797.50 |  892.52 | [18047.03, 21547.96] |   22.18
Div/Wid/Sep   |   14 | 23518.01 | 1181.92 | [21199.94, 25836.07] |   19.90
Married       |   14 | 29793.41 |  786.81 | [28250.25, 31336.57] |   37.87
Never married |   15 | 22610.07 |  889.82 | [20864.88, 24355.25] |   25.41
Div/Wid/Sep   |   15 | 26330.58 | 1185.67 | [24005.16, 28655.99] |   22.21
Married       |   15 | 32605.98 |  757.93 | [31119.48, 34092.48] |   43.02
Never married |   16 | 25422.64 |  925.61 | [23607.27, 27238.01] |   27.47
Div/Wid/Sep   |   16 | 29143.15 | 1218.38 | [26753.58, 31532.72] |   23.92
Married       |   16 | 35418.55 |  774.34 | [33899.87, 36937.23] |   45.74
Never married |   17 | 28235.21 |  995.73 | [26282.31, 30188.11] |   28.36
Div/Wid/Sep   |   17 | 31955.72 | 1277.83 | [29449.55, 34461.89] |   25.01
Married       |   17 | 38231.12 |  833.37 | [36596.66, 39865.58] |   45.88
Never married |   18 | 31047.78 | 1093.61 | [28902.92, 33192.64] |   28.39
Div/Wid/Sep   |   18 | 34768.29 | 1360.52 | [32099.94, 37436.64] |   25.56
Married       |   18 | 41043.69 |  926.92 | [39225.75, 42861.63] |   44.28
Never married |   19 | 33860.35 | 1212.54 | [31482.24, 36238.46] |   27.93
Div/Wid/Sep   |   19 | 37580.86 | 1462.51 | [34712.47, 40449.25] |   25.70
Married       |   19 | 43856.26 | 1045.76 | [41805.24, 45907.28] |   41.94
Never married |   20 | 36672.92 | 1346.95 | [34031.19, 39314.65] |   27.23
Div/Wid/Sep   |   20 | 40393.43 | 1580.08 | [37294.47, 43492.39] |   25.56
Married       |   20 | 46668.83 | 1182.29 | [44350.03, 48987.63] |   39.47

Variable predicted: realrinc
Predictors modulated: marital, educ = c(12:20)
Predictors averaged: age (44), hrs1 (40), sex

model_02 <- lm(formula = realrinc ~ educ * marital
               + age + hrs1 + sex, data = my_data)

moderndive::get_regression_table(model_02)


term

estimate

std_error

statistic

p_value

lower_ci

upper_ci

intercept

-28,536.756

4,865.375

-5.865

0.000

-38,079.082

-18,994.430

educ

2,085.885

303.424

6.874

0.000

1,490.788

2,680.982

marital-Div/Wid/Sep

-4,415.821

7,577.829

-0.583

0.560

-19,278.009

10,446.367

marital-Married

-11,610.242

6,303.987

-1.842

0.066

-23,974.079

753.595

age

114.684

40.959

2.800

0.005

34.352

195.016

hrs1

445.561

38.160

11.676

0.000

370.720

520.402

sex-female

-6,518.477

1,013.733

-6.430

0.000

-8,506.683

-4,530.270

educ:marital-Div/Wid/Sep

559.883

511.105

1.095

0.273

-442.533

1,562.299

educ:marital-Married

1,454.912

417.299

3.486

0.001

636.474

2,273.350

Interpretation

When interactions are included:
Interpret significance levels for interaction coefficients,
NOT the significance levels for the main variables.


If interactions are significant (or some are):
then you can still interpret main effects.

Interpretation

term

estimate

std_error

statistic

p_value

lower_ci

upper_ci

intercept

-28,536.756

4,865.375

-5.865

0.000

-38,079.082

-18,994.430

educ

2,085.885

303.424

6.874

0.000

1,490.788

2,680.982

marital-Div/Wid/Sep

-4,415.821

7,577.829

-0.583

0.560

-19,278.009

10,446.367

marital-Married

-11,610.242

6,303.987

-1.842

0.066

-23,974.079

753.595

age

114.684

40.959

2.800

0.005

34.352

195.016

hrs1

445.561

38.160

11.676

0.000

370.720

520.402

sex-female

-6,518.477

1,013.733

-6.430

0.000

-8,506.683

-4,530.270

educ:marital-Div/Wid/Sep

559.883

511.105

1.095

0.273

-442.533

1,562.299

educ:marital-Married

1,454.912

417.299

3.486

0.001

636.474

2,273.350

Interpretation

The interaction tells you whether the effect of X becomes stronger or weaker for a particular group.


Main Effect Interaction Result
+ + stronger effect
+ - weaker effect
- + less negative effect
- - more negative effect

Interpretation

Among never married people, every one year increase in education is associated with a $2,086 increase in income, holding other factors constant (p < .05).


At 0 years of education, married people report -$11,610 less income than never married people, adjusting for other model variables. 

Not a realistic effect of 0 education, so not meaningful.

The effect of education is $1,455 stronger for married respondents compared with never married respondents.

Interpretation

p_inc <- estimate_means(
  model_02,
  by = c("marital", "educ = c(12:20)"),
  estimate = "population")

p_inc
Average Counterfactual Predictions

marital       | educ |     Mean |      SE |               95% CI | t(1814)
--------------------------------------------------------------------------
Never married |   12 | 15995.38 | 1169.01 | [13702.64, 18288.13] |   13.68
Div/Wid/Sep   |   12 | 18298.16 | 1564.25 | [15230.23, 21366.08] |   11.70
Married       |   12 | 21844.08 | 1181.26 | [19527.32, 24160.85] |   18.49
Never married |   13 | 18081.27 |  997.13 | [16125.62, 20036.92] |   18.13
Div/Wid/Sep   |   13 | 20943.92 | 1329.39 | [18336.62, 23551.23] |   15.75
Married       |   13 | 25384.88 |  978.21 | [23466.35, 27303.41] |   25.95
Never married |   14 | 20167.15 |  897.83 | [18406.27, 21928.03] |   22.46
Div/Wid/Sep   |   14 | 23589.69 | 1194.76 | [21246.44, 25932.94] |   19.74
Married       |   14 | 28925.68 |  826.27 | [27305.13, 30546.23] |   35.01
Never married |   15 | 22253.04 |  895.57 | [20496.59, 24009.49] |   24.85
Div/Wid/Sep   |   15 | 26235.46 | 1194.72 | [23892.29, 28578.63] |   21.96
Married       |   15 | 32466.47 |  756.90 | [30981.98, 33950.96] |   42.89
Never married |   16 | 24338.92 |  991.02 | [22395.26, 26282.59] |   24.56
Div/Wid/Sep   |   16 | 28881.23 | 1329.29 | [26274.12, 31488.34] |   21.73
Married       |   16 | 36007.27 |  792.08 | [34453.78, 37560.76] |   45.46
Never married |   17 | 26424.81 | 1160.32 | [24149.11, 28700.51] |   22.77
Div/Wid/Sep   |   17 | 31526.99 | 1564.11 | [28459.34, 34594.65] |   20.16
Married       |   17 | 39548.07 |  919.90 | [37743.89, 41352.24] |   42.99
Never married |   18 | 28510.69 | 1376.48 | [25811.05, 31210.34] |   20.71
Div/Wid/Sep   |   18 | 34172.76 | 1861.62 | [30521.61, 37823.91] |   18.36
Married       |   18 | 43088.86 | 1108.77 | [40914.27, 45263.46] |   38.86
Never married |   19 | 30596.58 | 1620.86 | [27417.64, 33775.52] |   18.88
Div/Wid/Sep   |   19 | 36818.53 | 2196.49 | [32510.62, 41126.44] |   16.76
Married       |   19 | 46629.66 | 1332.98 | [44015.33, 49243.99] |   34.98
Never married |   20 | 32682.46 | 1882.49 | [28990.38, 36374.55] |   17.36
Div/Wid/Sep   |   20 | 39464.30 | 2554.07 | [34455.06, 44473.53] |   15.45
Married       |   20 | 50170.46 | 1577.54 | [47076.47, 53264.44] |   31.80

Variable predicted: realrinc
Predictors modulated: marital, educ = c(12:20)
Predictors averaged: age (44), hrs1 (40), sex

Interpretation

Interpretation

You can predict the marginal effect of your continuous IV on your DV at different levels of your categorical IV:


term

estimate

std_error

statistic

p_value

lower_ci

upper_ci

intercept

-28,536.756

4,865.375

-5.865

0.000

-38,079.082

-18,994.430

educ

2,085.885

303.424

6.874

0.000

1,490.788

2,680.982

marital-Div/Wid/Sep

-4,415.821

7,577.829

-0.583

0.560

-19,278.009

10,446.367

marital-Married

-11,610.242

6,303.987

-1.842

0.066

-23,974.079

753.595

age

114.684

40.959

2.800

0.005

34.352

195.016

hrs1

445.561

38.160

11.676

0.000

370.720

520.402

sex-female

-6,518.477

1,013.733

-6.430

0.000

-8,506.683

-4,530.270

educ:marital-Div/Wid/Sep

559.883

511.105

1.095

0.273

-442.533

1,562.299

educ:marital-Married

1,454.912

417.299

3.486

0.001

636.474

2,273.350

never married: \(\color{#3498DB}{2086}\)


div/wid/sep: \(\color{#3498DB}{2086} + \color{#E74C3C}{560} = \color{#18BC9C}{2646}\)


married: \(\color{#3498DB}{2086} + \color{#E74C3C}{1455} = \color{#18BC9C}{3541}\)

estimate_slopes()

estimate_slopes(
  model_02,
  trend = "educ",
  by = "marital"
)
Estimated Marginal Effects

marital       |   Slope |     SE |             95% CI | t(1814) |      p
------------------------------------------------------------------------
Never married | 2085.88 | 303.41 | [1490.81, 2680.96] |    6.87 | < .001
Div/Wid/Sep   | 2645.77 | 412.20 | [1837.32, 3454.21] |    6.42 | < .001
Married       | 3540.80 | 286.67 | [2978.56, 4103.04] |   12.35 | < .001

Marginal effects estimated for educ
Type of slope was dY/dX

Interpretation

Among never married people, every one year increase in education is associated with a $2,086 rise in annual income, holding other factors constant.


Among div/wid/sep people, every one year increase in education is associated with a $2,646 rise in annual income, holding other factors constant.


Among married people, every one year increase in education is associated with a $3,541 rise in annual income, holding other factors constant.

term

estimate

std_error

statistic

p_value

lower_ci

upper_ci

intercept

-39,616.999

3,569.483

-11.099

0.000

-46,617.728

-32,616.271

sex-female

-3,133.293

1,646.863

-1.903

0.057

-6,363.241

96.655

marital-Div/Wid/Sep

6,175.199

2,291.522

2.695

0.007

1,680.900

10,669.498

marital-Married

12,861.277

1,630.622

7.887

0.000

9,663.183

16,059.370

age

101.802

41.174

2.472

0.014

21.048

182.555

hrs1

424.668

38.348

11.074

0.000

349.457

499.880

educ

2,824.051

186.579

15.136

0.000

2,458.118

3,189.984

sex-female:marital-Div/Wid/Sep

-4,365.909

2,855.077

-1.529

0.126

-9,965.493

1,233.675

sex-female:marital-Married

-5,821.733

2,244.613

-2.594

0.010

-10,224.030

-1,419.436


Men Women
Never Married 0 (ref)
Div/Wid/Sep
Married

term

estimate

std_error

statistic

p_value

lower_ci

upper_ci

intercept

-39,616.999

3,569.483

-11.099

0.000

-46,617.728

-32,616.271

sex-female

-3,133.293

1,646.863

-1.903

0.057

-6,363.241

96.655

marital-Div/Wid/Sep

6,175.199

2,291.522

2.695

0.007

1,680.900

10,669.498

marital-Married

12,861.277

1,630.622

7.887

0.000

9,663.183

16,059.370

age

101.802

41.174

2.472

0.014

21.048

182.555

hrs1

424.668

38.348

11.074

0.000

349.457

499.880

educ

2,824.051

186.579

15.136

0.000

2,458.118

3,189.984

sex-female:marital-Div/Wid/Sep

-4,365.909

2,855.077

-1.529

0.126

-9,965.493

1,233.675

sex-female:marital-Married

-5,821.733

2,244.613

-2.594

0.010

-10,224.030

-1,419.436


Men Women
Never Married 0 (ref) -3,133
Div/Wid/Sep
Married

term

estimate

std_error

statistic

p_value

lower_ci

upper_ci

intercept

-39,616.999

3,569.483

-11.099

0.000

-46,617.728

-32,616.271

sex-female

-3,133.293

1,646.863

-1.903

0.057

-6,363.241

96.655

marital-Div/Wid/Sep

6,175.199

2,291.522

2.695

0.007

1,680.900

10,669.498

marital-Married

12,861.277

1,630.622

7.887

0.000

9,663.183

16,059.370

age

101.802

41.174

2.472

0.014

21.048

182.555

hrs1

424.668

38.348

11.074

0.000

349.457

499.880

educ

2,824.051

186.579

15.136

0.000

2,458.118

3,189.984

sex-female:marital-Div/Wid/Sep

-4,365.909

2,855.077

-1.529

0.126

-9,965.493

1,233.675

sex-female:marital-Married

-5,821.733

2,244.613

-2.594

0.010

-10,224.030

-1,419.436


Men Women
Never Married 0 (ref) -3,133
Div/Wid/Sep 6,175
Married 12,861

term

estimate

std_error

statistic

p_value

lower_ci

upper_ci

intercept

-39,616.999

3,569.483

-11.099

0.000

-46,617.728

-32,616.271

sex-female

-3,133.293

1,646.863

-1.903

0.057

-6,363.241

96.655

marital-Div/Wid/Sep

6,175.199

2,291.522

2.695

0.007

1,680.900

10,669.498

marital-Married

12,861.277

1,630.622

7.887

0.000

9,663.183

16,059.370

age

101.802

41.174

2.472

0.014

21.048

182.555

hrs1

424.668

38.348

11.074

0.000

349.457

499.880

educ

2,824.051

186.579

15.136

0.000

2,458.118

3,189.984

sex-female:marital-Div/Wid/Sep

-4,365.909

2,855.077

-1.529

0.126

-9,965.493

1,233.675

sex-female:marital-Married

-5,821.733

2,244.613

-2.594

0.010

-10,224.030

-1,419.436


Men Women
Never Married 0 (ref) -3,133
Div/Wid/Sep 6,175 -3,133 + 6,175 - 4,366 = -1,324
Married 12,861

term

estimate

std_error

statistic

p_value

lower_ci

upper_ci

intercept

-39,616.999

3,569.483

-11.099

0.000

-46,617.728

-32,616.271

sex-female

-3,133.293

1,646.863

-1.903

0.057

-6,363.241

96.655

marital-Div/Wid/Sep

6,175.199

2,291.522

2.695

0.007

1,680.900

10,669.498

marital-Married

12,861.277

1,630.622

7.887

0.000

9,663.183

16,059.370

age

101.802

41.174

2.472

0.014

21.048

182.555

hrs1

424.668

38.348

11.074

0.000

349.457

499.880

educ

2,824.051

186.579

15.136

0.000

2,458.118

3,189.984

sex-female:marital-Div/Wid/Sep

-4,365.909

2,855.077

-1.529

0.126

-9,965.493

1,233.675

sex-female:marital-Married

-5,821.733

2,244.613

-2.594

0.010

-10,224.030

-1,419.436


Men Women
Never Married 0 (ref) -3,133
Div/Wid/Sep 6,175 -3,133 + 6,175 - 4,366 = -1,324
Married 12,861 -3,133 + 12,861 - 5,822 = 3,906

Among never married people, women’s income is $3,133 less than men, holding other model variables constant (p = .057).


Div/wid/sep men’s income is $6,175 more than never-married men, holding other model variables constant (p <. 01).


Married men’s income is $12,861 more than never-married men, holding other model variables constant (p < .001).


Compared with never-married individuals, being div/wid/sep is associated with a $4,366 smaller increase in income for women than for men, though the difference is not statistically significant.


The increase in income associated with being married compared with never married is $5,822 smaller for women than for men (p < .05).

estimate_means()

p_inc  <- estimate_means(
  model_03,
  by = c("marital", "sex"),
  estimate = "population")

p_inc
Average Counterfactual Predictions

marital       | sex    |     Mean |      SE |               95% CI | t(1814)
----------------------------------------------------------------------------
Never married | male   | 23484.99 | 1218.27 | [21095.63, 25874.34] |   19.28
Div/Wid/Sep   | male   | 29660.19 | 1880.87 | [25971.28, 33349.09] |   15.77
Married       | male   | 36346.26 | 1019.91 | [34345.95, 38346.58] |   35.64
Never married | female | 20351.69 | 1201.31 | [17995.60, 22707.78] |   16.94
Div/Wid/Sep   | female | 22160.98 | 1457.71 | [19302.02, 25019.95] |   15.20
Married       | female | 27391.24 | 1133.43 | [25168.27, 29614.21] |   24.17

Variable predicted: realrinc
Predictors modulated: marital, sex
Predictors averaged: age (44), hrs1 (40), educ (15)

Interpretation

estimate_contrasts()

estimate_contrasts(
  model_03,
  contrast = "sex",
  by = "marital",
  estimate = "population")
Counterfactual Contrasts Analysis (G-computation)

Level1 | Level2 | marital       | Difference |      SE |                95% CI
------------------------------------------------------------------------------
female | male   | Never married |   -3133.29 | 1646.87 | [ -6363.25,    96.66]
female | male   | Div/Wid/Sep   |   -7499.20 | 2336.37 | [-12081.47, -2916.94]
female | male   | Married       |   -8955.03 | 1526.24 | [-11948.41, -5961.64]

Level1 | t(1814) |      p
-------------------------
female |   -1.90 |  0.057
female |   -3.21 |  0.001
female |   -5.87 | < .001

Variable predicted: realrinc
Predictors contrasted: sex
Predictors averaged: age (44), hrs1 (40), educ (15)
p-values are uncorrected.

model_04 <- lm(formula = realrinc ~ age * educ + hrs1 + sex + marital, data = my_data)

moderndive::get_regression_table(model_04) 


term

estimate

std_error

statistic

p_value

lower_ci

upper_ci

intercept

-32,443.525

9,602.561

-3.379

0.001

-51,276.758

-13,610.292

age

-30.817

211.324

-0.146

0.884

-445.281

383.646

educ

2,390.116

645.403

3.703

0.000

1,124.304

3,655.927

hrs1

437.098

38.221

11.436

0.000

362.136

512.059

sex-female

-6,455.290

1,017.396

-6.345

0.000

-8,450.681

-4,459.899

marital-Div/Wid/Sep

3,750.787

1,549.148

2.421

0.016

712.486

6,789.088

marital-Married

10,014.947

1,204.935

8.312

0.000

7,651.742

12,378.153

age:educ

9.642

14.100

0.684

0.494

-18.012

37.297

When education is 0 years, every one-year increase in age predicts a $31 decrease in annual income, adjusting for other model variables.

This interpretation is helpful only for people with no formal education.


When age is 0 years, every additional year of education predicts a $2,390 increase in annual income, adjusting for other model variables.

This interpretation is helpful only for newborns, so it is not substantively meaningful.


For every one-year increase in age, the increase in income associated with an additional year of education is $9.6 greater, adjusting for other model variables, though it is not statistically significant.

estimate_means()

# age at selected values of educ
p_inc <- estimate_means(
  model_04,
  by = c(
    "educ = c(12, 14, 16)",
    "age = c(22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44)"  ),
  estimate = "population"
)

p_inc |> 
  head(5)
Average Counterfactual Predictions

educ | age |     Mean |      SE |               95% CI | t(1815)
----------------------------------------------------------------
12   |  22 | 17446.26 | 1370.16 | [14759.00, 20133.52] |   12.73
12   |  24 | 17616.03 | 1276.18 | [15113.10, 20118.97] |   13.80
12   |  26 | 17785.81 | 1185.17 | [15461.38, 20110.24] |   15.01
12   |  28 | 17955.59 | 1098.12 | [15801.88, 20109.30] |   16.35
12   |  30 | 18125.36 | 1015.89 | [16132.92, 20117.81] |   17.84

Variable predicted: realrinc
Predictors modulated: educ = c(12, 14, 16), age = c(22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44)
Predictors averaged: hrs1 (40), sex, marital

Interpretation