Questions tagged [loess]

Local regression - a form of non-parametric regression.

Local regression - a form of non-parametric regression. Useful for scatter plot smoothing. See https://en.wikipedia.org/wiki/Local_regression

200 questions
32
votes
3 answers

Confidence interval for LOWESS in Python

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…
pir
  • 5,513
  • 12
  • 63
  • 101
26
votes
3 answers

Fit a line with LOESS in R

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…
leo
  • 3,677
  • 7
  • 34
  • 46
22
votes
2 answers

Fill region between two loess-smoothed lines in R with ggplot

I'd like to know how to fill the area between to loess-smoothed lines in ggplot. The following data frame is used for the pictures: x y ymin ymax grp ydiff 1 1 3.285614 3.285614 10.14177 min 6.8561586 2 1 10.141773 …
Daniel
  • 7,252
  • 6
  • 26
  • 38
20
votes
4 answers

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

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…
meenaparam
  • 1,949
  • 2
  • 17
  • 29
14
votes
1 answer

Can't reproduce stat_smooth using `loess` when x-axis is Date

I am using ggplot2 to get a smoothed estimation of my data ggplot(yy)+geom_smooth(aes(x=Date,y=value),method='loess') It works fine. Now, when try to reproduce this using loess function directly, I get an error: loess(value~Date,yy) Error in…
agstudy
  • 119,832
  • 17
  • 199
  • 261
13
votes
2 answers

What does the span argument control in geom_smooth?

I am using geom_smooth from the ggplot2 package to create a smoothed line on a time series scatter plot (one point for each day of the year, so I have 365 points). One of the arguments is called span, and going into the help file (?geom_smooth) the…
amccnnll
  • 387
  • 1
  • 2
  • 15
13
votes
4 answers

loess predict with new x values

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…
Alex
  • 19,533
  • 37
  • 126
  • 195
12
votes
2 answers

R - loess prediction returns NA

I am struggling with "out-of-sample" prediction using loess. I get NA values for new x that are outside the original sample. Can I get these predictions? x <- c(24,36,48,60,84,120,180) y <- c(3.94,4.03,4.29,4.30,4.63,4.86,5.02) lo <-…
Pepacz
  • 881
  • 3
  • 9
  • 24
12
votes
4 answers

Loess Fit and Resulting Equation

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…
christian miner
  • 149
  • 1
  • 1
  • 4
12
votes
3 answers

Difference between R.loess and org.apache.commons.math LoessInterpolator

I'm trying to compute the convert a R script to java using the apache.commons.math library. Can I use org.apache.commons.math.analysis.interpolation.LoessInterpolator in place of R loess ? I cannot get the same result. EDIT. here is a java program…
Pierre
  • 34,472
  • 31
  • 113
  • 192
10
votes
1 answer

coplot in R - how to tell which plot is which

I am using coplot in R to plot some conditioning plots: coplot(var1 ~ var2 | var3, data=dtb, number=5, overlap=.1, panel=function(x,y, col, pch) {idx = order(x); lines(x[idx], predict(loess(y ~ x))[idx], pch = pch, col = col)}) How can one tell…
Alex
  • 19,533
  • 37
  • 126
  • 195
9
votes
2 answers

How to mark slope changes in LOESS curve using ggplot2?

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…
user1062293
  • 133
  • 3
  • 7
9
votes
3 answers

loess regression on each group with dplyr::group_by()

Alright, I'm waving my white flag. I'm trying to compute a loess regression on my dataset. I want loess to compute a different set of points that plots as a smooth line for each group. The problem is that the loess calculation is escaping the…
Alex Nesta
  • 393
  • 2
  • 13
9
votes
1 answer

Difficulty plotting data with ggplot2 geom_smooth method=loess?

I'm very new at this and I don't actually understand the differences between the plotting methods, but loess seems to be giving me the most informative graphs, considering I have a small-ish data set (n=~300). I'm trying to split my data by gender…
geedlet
  • 143
  • 1
  • 8
9
votes
1 answer

Setting an upper bound of 0 on a 3d loess smoothing with negative values in R

I have a bit of a bizarre question, but hoping someone can help me. I am attempting to create a surface plot of the bottom of a lake and then add some points showing plant frequency for a visual of where aquatic plants are occurring throughout the…
1
2 3
13 14