Error in geom_smooth

Hello,
I do a regression with R and i want to represent the smooth in a graph, my code is this

ggplot(essence, aes(x=Y, y=GPOP))+
  ggtitle("Relation entre le revenu par tête et la conso. par tête")+
  xlab("Logarithme du revenu par tête")+
  ylab("Logarithme de la conso; par tête")+
  geom_point()+
  geom_smooth(method="glm", **formula=y~(x^(6.04963))/exp(6.04963)**)

I have this error : Warning message:
Computation failed in stat_smooth():
invalid power in formula

why ?

Outside of a model formula the hat symbol ^ does indeed represent the raising x to power y , but in the model formula context it has some other meaning (limit crossing, i dont know) but i know that if you want it treated in the numericalnwaybyou want you wrap its expression within I()

Thanks you but i have an other error
Computation failed in stat_smooth():
[variable length differs](found for exp(6.04963)')

What is the purpose of ** ?

It's not important just to highlight the formula in the forum it's not in my code

What happens if you simply use geom_smooth()

It's the loess formula, not the formula of my model

library(tidyverse)

df_ <- data.frame(x=(0:30)/30,
                  y =(x^6)/exp(6))
ggplot(df_, aes(x=x, y=y)) +
  geom_point()+
  geom_smooth(method="glm", formula=y~I((x^6.04963)/exp(6.04963)))

image

2 Likes