I installed the R package AER, from which you get the data `PSID1982`. Then I define this model:

selectedobs = sample.int(nrow(PSID1982),size = 400, replace = FALSE)
experiencesq = experience^2
dgender = 1*(gender=="male")
dmarried = 1*(married=="yes")
dunion = 1*(union=="yes")
dindustry = 1*(industry=="yes")

outreg = lm(log(wage) ~ experience + experiencesq + education + dgender + dmarried + dunion + dindustry)

And now I need to find out if the impact of the amount of work `experience` on the `log(wage)` is different for women compared to men, and what do I expect it to be intuitively?

I want to divide the set of data into 2 subsets being men and women and perform a linear regression each dataset, so i do this. but then i get this error message and i dont know how to fix this....

> outreg = lm(wage~ experience+experiencesq+education+dmarried+dunion+dindustry, subset(PSID1982,gender=="male"))
Error in model.frame.default(formula = wage ~ experience + experiencesq + :
variable lengths differ (found for 'experiencesq')

Thanks in advance!