I have a dataset like these
BirthYear | walking |
---|---|
50-70 | 500 |
70-90 | 700 |
90-10 | 200 |
70-90 | 450 |
70-90 | 850 |
70-90 | 890 |
30-50 | 660 |
70-90 | 760 |
70-90 | 450 |
30-50 | 230 |
30-50 | 120 |
50-70 | 120 |
70-90 | 340 |
90-10 | 920 |
I want to run a regression of walking on BirthYear and that the BirthYear 90-10 is the omitted category, to find out how much 70-90 people walk less than 90-10 people on average.
I gave this code but don't know how to fix with omitted category for 90-10.
feols(fml = walking ~ BirthYear, data = df)
CodePudding user response:
To put the 70-90 category in the reference/intercept simply use the relevel function
> df$BirthYear=factor(df$BirthYear)
> df$BirthYear=relevel(df$BirthYear,"70-90")
> summary(lm(walking~BirthYear,data=df))
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 634.29 105.62 6.006 0.000131 ***
BirthYear30-50 -297.62 192.83 -1.543 0.153754
BirthYear50-70 -324.29 224.05 -1.447 0.178396
BirthYear90-10 -74.29 224.05 -0.332 0.747062