非线性总最小 squares/Deming 回归

Nonlinear total least squares/Deming regression

我一直在使用 nls() 将自定义模型拟合到我的数据,但我不喜欢模型的拟合方式,我想使用一种方法来最小化 x 和y 轴。

我进行了大量搜索,找到了适合 线性 模型的解决方案,例如 deming 包 (http://cran.r-project.org/web/packages/deming/index.html) and these Whosebug posts: Total Least Square method using R, How to calculate Total least squares in R? (Orthogonal regression). I've also found matlab solutions (https://stats.stackexchange.com/questions/110772/total-least-squares-curve-fit-problem),但这些适合一秒钟阶多项式而不是自定义的用户定义模型。

我想要的是类似于 nls() 的东西,它可以进行 x 和 y 残差最小化。这将允许我输入我的自定义模型。有人知道 R 中的任何解决方案吗?

非常感谢!

编辑

这是一个示例,但请注意,我正在寻求有关非线性总最小二乘回归的一般解决方案的建议,而不是针对此数据集的特定解决方案(这只是基于 Modifying a curve to prevent singular gradient matrix at initial parameter estimates 的示例数据):

df <- structure(list(x = c(3, 4, 5, 6, 7, 8, 9, 10, 11), y = c(1.0385, 
1.0195, 1.0176, 1.01, 1.009, 1.0079, 1.0068, 1.0099, 1.0038)), .Names = c("x", 
"y"), row.names = c(NA, -9L), class = "data.frame")

(nlsfit <- nls(y ~ a^b^x, data = df, start = c(a=0.9, b=0.6)))

library(ggplot2)
ggplot(df, aes(x=x, y=y)) + 
    geom_point() + 
    geom_smooth(method="nls", formula = y ~ a^b^x, se=F, start = list(a=0.9, b=0.6))

克。 CrossValidated 的 Grothendieck 和 Brian Borchers 建议使用 onls 包,这正是我要找的。谢谢大家,非常感谢您的帮助。有关更多信息,请参见此处:http://www.r-bloggers.com/introducing-orthogonal-nonlinear-least-squares-regression-in-r/

这是一个使用上面相同数据的示例 - 这给出了与常规 nls() 相同的拟合参数,但是它确实对我的真实数据产生了影响。但这至少说明了如何进行操作。

df <- structure(list(x = c(3, 4, 5, 6, 7, 8, 9, 10, 11), y = c(1.0385, 
1.0195, 1.0176, 1.01, 1.009, 1.0079, 1.0068, 1.0099, 1.0038)), .Names = c("x", 
"y"), row.names = c(NA, -9L), class = "data.frame")

library(onls)
(onlsfit <- onls(y ~ a^b^x, data = df, start = c(a=0.9, b=0.6)))

# define function containing onls fitted parameters for plotting
fit.model <- function(x) {1.0934^0.7242^x}

library(ggplot2)
ggplot(df, aes(x=x, y=y)) + 
    geom_point() + 
    stat_function(fun=fit.model, color="black")