0
$\begingroup$

I have a simple linear model (earnings ~ age), and I want to test if the coefficient on age is significantly different for separate subgroups in my data (those with a bachelor's degree, and those without) in r, with the null hypothesis that 'coefficient(age_bachelor=0) = coefficient(age_bachelor=1'.

I created the following two models:

lm1 = lm(earnings ~ age, data=subset(mydata, bachelor==0))  

lm2 = lm(earnings ~ age, data=subset(mydata, bachelor==1))

How do I test if the coefficients of age between the two models are significantly different?

$\endgroup$
1

1 Answer 1

2
$\begingroup$

I was going to answer in comments, but:

lm(earnings ~ age*bachelor, data=mydata)

and look at the p-value for the interaction coefficient.

The interaction model is not identical to fitting separate models and comparing parameters — it assumes that the residual variance is the same in both groups — but it's sensible, and the standard approach.

$\endgroup$
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.