0
$\begingroup$

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)

because 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?

$\endgroup$
  • 1
    $\begingroup$ Read the "and" like "plus". They include a variable $age^2$ plus a variable $driver dummy$. That is, "the baseline specification contains (a quadratic in age) + (drivers dummies)". $\endgroup$ – coffeinjunky Apr 26 '14 at 13:02
2
$\begingroup$

No, it seems you misinterpreted the sentence. Squaring a factor is not meaningful. The paper includes a quadratic term for age. There is also a dummy variable for the driver.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.