根据我在网上搜索的结果,以下是我将用来对数据执行 2 次多项式回归的方法(这是从网络中挑选出来的……我目前无法访问实际命令我对我的数据进行了执行,但我模仿了这个):
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
我的数据集是一组数据的集合,每组有 70 多行对应于几个变量的月度数据测量值。我需要计算每组数据的回归,并找到二阶导数具有统计显着值的组。我想最终得到一个数据集,其中每个 group_id 包含一行,构成上面显示的摘要的每个数据点包含一列。