Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
232 views
in Technique[技术] by (71.8m points)

r - How to estimate a regression with both variables i and t simultaneously

I want to estimate a regression for a variable, LWAGE (log wage), against EXP (years of work experience). The data that I have has participants tracked across 7 years, so each year their number of years of work experience increases by 1.

When I do the regression for

???????????? = ??0 + ??1?????? + ????

I used

reg1 <- lm(LWAGE~EXP, data=df)

Now I'm trying to do the following regression:

?????????????? = ??0 + ??1?????????? + ??i.

But I'm not sure how to include my the time based component into my regression. I searched around but couldn't find anything relevant.

question from:https://stackoverflow.com/questions/65876357/how-to-estimate-a-regression-with-both-variables-i-and-t-simultaneously

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Are you attempting to include time-fixed effects in your model or an interaction between your variable EXP and time (calling this TIME for this demonstration)?

For time fixed effects using lm() you can just include time as a variable in your model. Time should be a factor.

reg2 <- lm(LWAGE~EXP + TIME, data = df)

As an interaction between EXP and TIME it would be

reg3 <- lm(LWAGE~EXP*TIME, data = df)

Based on your description it sounds like you might be looking for the interaction. I.e. How does the effect of experience on log of wages vary by time?

You can also take a look at the plm package for working with panel data.

https://cran.r-project.org/web/packages/plm/vignettes/plmPackage.html


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...