I'm trying to replicate models published in The Age-Productivity Gradient: Evidence from a Sample of F1 Drivers and am stumbling at first hurdle over a line "the baseline specification contains a quadratic in age and drivers dummies".
I can get quadratic
age (a numerical var) and linear
name dummy (a factor in the original dataset) with the following construction:
lm(pos ~ name + I(age) +I((age)^2),data=ergastData)
but I get an error on
lm(pos ~ name + I(name^2) + I(age) +I((age)^2),data=ergastData)
name is a factor and squaring it is not meaningful?
So how can I get a quadratic term for the dummy variable?
(I'm not a statistician.. I assume this is a meaningful thing to do and my interpretation of the original paper is correct!)
As an extension of this question, with ggplot2, I can chart the individual
name model results using:
g = ggplot(egastdata, aes(x=age,y=pos,col=name)) g = g + stat_smooth(method = "lm", formula = y ~ I(x) +I((x)^2)) +geom_point() g
This seems to group on
name and presumably generate separate models for each driver (i.e. a set of distinct
age coefficients for each driver). How would I use
ggplot to chart the result of a single set of
age coefficients and then separate
name dummy variable coefficients (both linear in
name and quadratic)? (That is, I want a single model around
age with a separate coefficients around
name for each driver.) Would the age coefficients be the same as if I ran the model over the whole set of driver data without distinguishing drivers?