From what I have found searching the web, below is the approach that I would use to perform a polynomial regression of degree 2 on data (this is culled from the web...I don't have access at the moment to the actual commands I performed on my data, but I mimicked this):
Call:
lm(sample1$Population ~ poly(sample1$Year, 2, raw=TRUE))
Residuals:
Min 1Q Median 3Q Max
-46.888 -18.834 -3.159 2.040 86.748
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 5263.159 17.655 298.110 < 2e-16 ***
sample1$Year 29.318 3.696 7.933 4.64e-05 ***
I(sample1$Year^2) -10.589 1.323 -8.002 4.36e-05 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 38.76 on 8 degrees of freedom
Multiple R-squared: 0.9407, Adjusted R-squared: 0.9259
F-statistic: 63.48 on 2 and 8 DF, p-value: 1.235e-05
My dataset is a collection of groups of data, each group having 70+ rows corresponding to monthly data measurements of several variables. I need to calculate the regression on each group of data, and find the groups with statistically significant values for the second derivative. I'd like to end up with a data set which contains one row per group_id and one column for each of the data points that make up the summary displayed above.