loess

How to mark slope changes in LOESS curve using ggplot2?

[亡魂溺海] 提交于 2019-12-03 19:09:16
问题 I have some time-series data that I'm fitting a loess curve in ggplot2, as seen attached. The data takes the shape of an "S" curve. What I really need to find out is the date where the data starts to level off, which looks to be right around time '550' or '600' Is there some kind of quantitative way that this can be marked off in the graph? A link to the dataset: http://dl.dropbox.com/u/75403/stover_data.txt A dput() of the dataset: structure(list(date = c(211L, 213L, 215L, 217L, 218L, 221L,

Confidence interval for LOWESS in Python

喜欢而已 提交于 2019-12-03 14:46:40
问题 How would I calculate the confidence intervals for a LOWESS regression in Python? I would like to add these as a shaded region to the LOESS plot created with the following code (other packages than statsmodels are fine as well). import numpy as np import pylab as plt import statsmodels.api as sm x = np.linspace(0,2*np.pi,100) y = np.sin(x) + np.random.random(100) * 0.2 lowess = sm.nonparametric.lowess(y, x, frac=0.1) plt.plot(x, y, '+') plt.plot(lowess[:, 0], lowess[:, 1]) plt.show() I've

loess predict with new x values

戏子无情 提交于 2019-12-03 12:12:36
问题 I am attempting to understand how the predict.loess function is able to compute new predicted values ( y_hat ) at points x that do not exist in the original data. For example (this is a simple example and I realize loess is obviously not needed for an example of this sort but it illustrates the point): x <- 1:10 y <- x^2 mdl <- loess(y ~ x) predict(mdl, 1.5) [1] 2.25 loess regression works by using polynomials at each x and thus it creates a predicted y_hat at each y . However, because there

Calibration (inverse prediction) from LOESS object in R

孤者浪人 提交于 2019-12-02 10:11:09
I have fit a LOESS local regression to some data and I want to be able to find the X value associated with a given Y value. plot(cars, main = "Stopping Distance versus Speed") car_loess <- loess(cars$dist~cars$speed,span=.5) lines(1:50, predict(car_loess,data.frame(speed=1:50))) I was hoping that I could use teh inverse.predict function from the chemCal package, but that does not work for LOESS objects. Does anyone have any idea how I might be able to do this calibrationa in a better way than predicticting Y values from a long vector of X values and looking through the resulting fitted Y for

Problems displaying LOESS regression line and confidence interval

假装没事ソ 提交于 2019-12-01 12:24:30
I am having some issues trying to compete a LOESS regression with a data set. I have been able to properly create the line, but I am unable to get it to plot correctly. I ran through the data like this. animals.lo <- loess(X15p5 ~ Period, animals, weights = n.15p5) animals.lo summary(animals.lo) plot(X15p5~ Period, animals) lines(animals$X15p5, animals.lo, col="red") At this point I received an error "Error in xy.coords(x, y) : 'x' and 'y' lengths differ" I searched around and read that this issue could be due to the points needing to be ordered, so I proceeded. a <- order(animals$Period)

Finding the elbow/knee in a curve

£可爱£侵袭症+ 提交于 2019-12-01 11:18:34
问题 I have these data: x <- c(6.626,6.6234,6.6206,6.6008,6.5568,6.4953,6.4441,6.2186,6.0942,5.8833,5.702,5.4361,5.0501,4.744,4.1598,3.9318,3.4479,3.3462,3.108,2.8468,2.3365,2.1574,1.899,1.5644,1.3072,1.1579,0.95783,0.82376,0.67734,0.34578,0.27116,0.058285) y <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32) which look like: plot(x,y) And I want to find a way to get the elbow/knee point at around x=6.5 I thought that fitting a loess curve and then taking

Fit a line with LOESS in R

ε祈祈猫儿з 提交于 2019-11-30 13:12:55
问题 This question was migrated from Cross Validated because it can be answered on Stack Overflow. Migrated 6 years ago . I have a data set with some points in it and want to fit a line on it. I tried it with the loess function. Unfortunately I get very strange results. See the plot bellow. I expect a line that goes more through the points and over the whole plot. How can I achieve that? How to reproduce it: Download the dataset from https://www.dropbox.com/s/ud32tbptyvjsnp4/data.R?dl=1 (only two

How to mark slope changes in LOESS curve using ggplot2?

被刻印的时光 ゝ 提交于 2019-11-29 04:30:47
问题 I have some time-series data that I'm fitting a loess curve in ggplot2, as seen attached. The data takes the shape of an "S" curve. What I really need to find out is the date where the data starts to level off, which looks to be right around time '550' or '600' Is there some kind of quantitative way that this can be marked off in the graph? A link to the dataset: http://dl.dropbox.com/u/75403/stover_data.txt A dput() of the dataset: structure(list(date = c(211L, 213L, 215L, 217L, 218L, 221L,

Loess Fit and Resulting Equation

时光总嘲笑我的痴心妄想 提交于 2019-11-27 23:10:43
I'm a developer up in Portland, OR. I'm wondering if anyone can assist: I'm working on Loess fit models using R, once I have the fit accomplished, I'm looking to back-out the equation of the fitted non-linear curve, wondering if there is a way to determine this equation in R? I've been looking but can't find any literature. For me, the graph of the function is great, but without the equation of the graph, I'm kinda dead in the water. Loess doesn't give you an equation [1]. If you just want to get the values returned by the loess function you use predict(loess.object, new.data) [1] From

How to use loess method in GGally::ggpairs using wrap function

馋奶兔 提交于 2019-11-27 02:11:22
问题 I am trying to replicate this simple example given in the Coursera R Regression Models course: require(datasets) data(swiss) require(GGally) require(ggplot2) ggpairs(swiss, lower = list(continuous = "smooth", params = c(method = "loess"))) I expect to see a 6x6 pairs plot - one scatterplot with loess smoother and confidence intervals for each combination of the 6 variables in the swiss data. However, I get the following error: Error in display_param_error() : 'params' is a deprecated argument