振荡数据的曲线拟合

计算科学 回归 曲线拟合 造型
2021-12-21 19:43:50

这是我的第一个问题。我想将以下数据近似为参数函数:

y=a+(bx1+cx2+dx3+ex1x2+fx1x3+gx2x3+hx1x2x3+i)(jsin(kx1x2x3)+lcos(mx1x2x3))

testdata <- read.csv('..path_to_file/gistfile1.txt', sep = "")
plot(1:35,testdata$X0, col = 'blue', pch = 19, ylim = c(0,8),type = "l",lwd = 2, xlab = "x", ylab = "y_i",cex.lab = 2)
lines(1:35,testdata$X1, col = 'red', pch = 19, ylim = c(0,1),lwd = 2)
lines(1:35,testdata$X1.1, col = 'green', pch = 19, ylim = c(0,1),lwd = 2)
lines(1:35,testdata$X8, col = 'magenta', pch = 19, ylim = c(0,1),lwd = 2)
leg.txt <- (c("y","x1","x2","x3"))
legend(18,8,leg.txt, col  =  c('blue','red','green','magenta'), lty = 1,lwd= 2,border = 'white')

在此处输入图像描述

在此处输入图像描述

有什么建议可以修改下面显示的函数以更贴合吗?

在此处输入图像描述

1个回答

模型选择的数值判断:

您使用由 12 或 13 个预测变量组成的模型对 36 个观测值进行建模。这很可能不是一个好的模型。即使您达到了很高的 $R^2_{adj}$,您也很可能会建模一个随机模式。尝试将此模型的计算 $AIC$(Akaike 信息准则)或 $BIC$(贝叶斯信息准则)与具有 2 个参数的简单正弦函数之一进行比较。您可能会看到您的模型被拒绝。Radj2, you most likely model a random pattern. Try to compare a computed AIC (Akaike information criterion) or BIC (Bayesian information criterion) of this model to the one of a simple sinus function with 2 parameters. You might see that your model gets rejected.

模型选择的解释能力:

一般来说,在统计学中,您希望能够解释模型中变量的相互作用。例如,您分析人口 $P_i$ 的死亡率 $DR_i$。您会发现 $DR_i$ 随着极端外部温度 $T$ 呈指数增长。所以你想拟合一个模型:DRi of a population Pi. You find out that DRi increases exponentially with extreme outside temperatures T. So you want to fit a model:

DRi=TDeviation(TTmean)²

在这里您很可能会找到生物学原因,例如 $T_{mean}$ 反映了 $P_i$ 自然环境的平均温度。另一个拟合模型参数 $t_{Deviation}$ 反映了 $P_i$ 的抵抗力(温血或冷血)。$P_i$ 是冷血动物,因此其拟合的 $t_{Deviation}$ 大于温血动物 $P_j$。Tmean reflects the average temperature of the natural surroundings of Pi. The other fitted model parameter tDeviation reflects Pi's resistance (warm or cold blooded). Pi is cold blooded an so its fitted tDeviation is larger than the one of warm blooded species Pj.

模型的可重用性:

最好看的拟合通常不是最好的统计拟合。推断您的预测线,看看它是否像您期望的那样。即使您不必预测外推值,您也可以将其作为模型与自然环境拟合程度的衡量标准。如果无法进行外推,则很可能第二组测量数据无法在您的模型上运行。这样的模型是不可转让的。

当然,在有限数量的领域中,您可以忽略这些内容。例如,在 CAD 中对表面进行 3D 重建。

从二维数据集生成模型的在线资源:

您将在此处找到用于非线性拟合的回归工具,其中最多包含三个变量 你输入你的 $x,y$ 矩阵,它会预测大量不同的模型。我认为早期版本包含 AIC,但也许它也在此页面的其他地方。x,y matrix and it predicts a huge variety of different models. I think earlier versions had AIC included but maybe it is also somewhere else on this page.