问题标签 [loess]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
4 回答
9909 浏览

r - 黄土拟合和结果方程

我是俄勒冈州波特兰市的一名开发人员。我想知道是否有人可以提供帮助:

我正在使用 R 研究 Loess 拟合模型,一旦我完成拟合,我希望退出拟合非线性曲线的方程,想知道是否有办法在 R 中确定这个方程?我一直在寻找,但找不到任何文献。对我来说,函数的图表很棒,但是没有图表的方程,我有点死在水中了。

0 投票
3 回答
1118 浏览

r - 在黄土的局部多项式函数中提取拟合项(在 R 中)(不预测())

对于我的数据的特定 x,如何提取黄土函数适合它使用的多项式函数的参数?

例如,在:

当 cars.lo$x == 5 时它适合什么?

更新:我想要多项式函数的参数,而不是黄土的预测(predict)。

我要求它估算该点的斜率。

谢谢, 塔尔

0 投票
2 回答
5964 浏览

r - 使用 `loess.smooth` 但不是 `loess` 或 `lowess` 时出错

我需要平滑一些模拟数据,但是当要平滑的模拟坐标大多是相同的值时,偶尔会遇到问题。这是最简单情况的一个可重复的小示例。

loess(y~x), lowess(x,y), 和它们在 MATLAB 中的类似物在这个例子中产生了预期的结果而没有错误。我在loess.smooth这里使用是因为我需要在一定数量的点上评估估计值。根据文档,我相信loess.smooth并且loess正在使用相同的估计函数,但前者是处理评估点的“辅助函数”。错误似乎来自 C 函数:

loess也调用simpleLoess,但似乎有不同的论点。当然,如果你改变足够多的 y 值使其不为零,loess.smooth则运行不会出错,但我需要程序在最极端的情况下运行。

希望有人可以帮助我完成以下一项和/或全部工作:

  1. 了解为什么只有loess.smooth而不是其他函数会产生此错误并找到解决此问题的方法。
  2. 找到一种解决方法,使用loess但仍评估与向量 x 不同的指定点数的估计值。例如,我可能只想x <- seq(0,50,10)在平滑中使用,但在 处评估估计x <- 0:50。据我所知,使用predict新的数据框无法正确处理这种情况,但如果我在那里遗漏了什么,请告诉我。
  3. 以不会阻止程序移动到下一个模拟数据集的方式处理错误。

在此先感谢您对此问题的任何帮助。

0 投票
1 回答
2704 浏览

r - Is there an implementation of loess in R with more than 3 parametric predictors or a trick to a similar effect?

Calling all experts on local regression and/or R!

I have run into a limitation of the standard loess function in R and hope you have some advice. The current implementation supports only 1-4 predictors. Let me set out our application scenario to show why this can easily become a problem as soon as we want to employ globally fit parametric covariables.

Essentially, we have a spatial distortion s(x,y) overlaid over a number of measurements z:

These measurements z can be grouped by the same underlying undistorted measurement value v for each group g. The group membership g_i is known for each measurement, but the underlying undistorted measurement values v_g for the groups are not known and should be determined by (global, not local) regression.

We need to estimate the two-dimensional spatial trend s(x,y), which we then want to remove. In our application, say there are 20 groups of at least 35 measurements each, in the most simple scenario. The measurements are randomly placed. Taking the first group as reference, there are thus 19 unknown offsets.

The below code for toy data (with a spatial trend in one dimension x) works for two or three offset groups.

Unfortunately, the loess call fails for four or more offset groups with the error message

I tried overriding the restriction and got

How easy would that be to do? I cannot find a definition of d2MAX anywhere, and it seems this might be hardcoded -- the error is apparently triggered by line #1359 in loessf.f

Alternatively, does anyone know of an implementation of local regression with global (parametric) offset groups that could be applied here?

Or is there a better way of dealing with this? I tried lme with correlation structures but that seems to be much, much slower.

Any comments would be greatly appreciated!

Many thanks,
David

0 投票
2 回答
3815 浏览

r - 如何使用ggplot2标记黄土曲线的斜率变化?

我有一些时间序列数据,我正在 ggplot2 中拟合黄土曲线,如附件所示。数据呈“S”形曲线。我真正需要找出的是数据开始趋于平稳的日期,这看起来是在时间“550”或“600”左右

是否有某种定量方式可以在图中标出?

数据集链接: http: //dl.dropbox.com/u/75403/stover_data.txt

dput()数据集的A :

图形: 在此处输入图像描述

代码:

0 投票
1 回答
4143 浏览

r - 黄土线没有正确绘制

我无法将黄土平滑加置信限拟合到残差散点图。

我的模型是身高~体重+胸围。为了检查胸围的线性度,我拟合了一个没有胸围的模型(即身高~体重),并绘制了这个模型的残差与胸围的关系。到现在为止还挺好。然后我尝试使用loess()predict()绘制一条黄土线,加上置信限。结果看起来像这样(在图片中我只绘制了中心线,但 CI 线看起来一样):

散点图中的黄土问题

这些点是正确的(当我将黄土拟合为看起来正确的点时),但由于某种原因,这条线没有按照我的预期绘制。我的代码如下:

希望你能帮忙。非常感谢,

0 投票
1 回答
1811 浏览

r - 带有黄土线的散点图,黄土在给定区域中不显示线

我在这里绘制染色体的长度值

在此处输入图像描述

没有点的中间区域没有数据,不应该得到黄土线。如何修改我的代码以阻止该区域上的黄土线?数据是连续的,但我可以添加行以使用一些特殊值标记空白区域或添加带有标签的列?但是如何在命令中使用它?

我当前的命令:

0 投票
1 回答
10167 浏览

r - 将黄土平滑应用于时间序列

我想通过应用黄土函数来平滑我绘制的时间曲线,但我无法让它工作。一个例子:

我收到以下消息:

是否可以对时间序列应用黄土平滑

非常感谢任何帮助或指导!

0 投票
1 回答
2415 浏览

r - R中黄土的标准误

我试图找到一个参考来解释如何计算局部多项式回归的标准误差?具体来说,在 R 中,可以使用 loess 函数获取模型对象,然后使用 predict 函数检索标准误差。在某处是否有实际发生的事情的参考?在残差中可能存在序列相关的情况下,必须使用 Newey-West 类型的方法对此进行调整,有没有一种方法可以像使用 lm 的常规 OLS 一样使用三明治包来做到这一点?

我尝试查看源代码,但标准错误计算调用了 C 函数。

0 投票
3 回答
2531 浏览

java - R.loess 和 org.apache.commons.math LoessInterpolator 的区别

我正在尝试使用apache.commons.math库计算将 R 脚本转换为 java。我可以使用org.apache.commons.math.analysis.interpolation.LoessInterpolator代替R loess吗?我无法得到相同的结果。

编辑

这是一个 java 程序,它创建一个随机数组 (x,y) 并使用 LoessInterpolator 或调用 R 计算黄土。最后,打印结果。

编译和执行:

输出:

y 的输出值在 R 和 Java 之间显然不一样;Y.R 列看起来不错(它接近原始 Y 列)。我应该如何改变它以获得 Y.java ~ YR ?