Home > OS >  Fitting LOESS function in ggplot
Fitting LOESS function in ggplot

Time:04-08

How can I modify the method= argument in ggplot so to customize my loess function?

Right now this is my code without implementing a function:

ggplot(data, aes(x = X, y = Y))  
  geom_point()  
  geom_smooth(method = "loess", fill='darkred', level=0.90)

And this is the function I would like to implement under the method= argument:

loess(Y ~ X, data=data, span=0.08, degree =1, family = 'gaussian')

CodePudding user response:

You can pass arguments to loess() via the method.args argument of geom_smooth():

Edit following comments:

ggplot(data, aes(x = X, y = Y))  
  geom_point()  
  geom_smooth(method = "loess", span=0.08, fill='darkred', level=0.90, method.args=list(degree =1, family = 'gaussian'))
  • Related