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?