How can I calculate factors elasticity in R? For example, "Calculate tenure elasticity of wage for all women in sample" from the dataset nlsw88
h <- read.dta("nlsw88.dta")
h1 <- mutate(h, age = log(h$age), wage = log(h$wage))
model2 <- lm(data = h1,
wage ~ age + race + married + never_married + grade + collgrad + industry + union + occupation + hours + ttl_exp + tenure + c_city)
I use this formula to calculate elasticity
elas1<-as.numeric(model2$coefficients["age"]*mean(h1$age)/mean(h1$wage))
-0.2217391
But using this formula i can't calculate "race" elasticity, because it's not numerical,
FUthermore, R write me NA_real_ if i put elas3<-as.numeric(model2$coefficients["hours"]*mean(h1$hours)/mean(h1$wage))
What's wrong?