I have this data, data frame fit1
:
fit1
x y
1 0 2.36
2 1 1.10
3 2 0.81
4 3 0.69
5 4 0.64
6 5 0.61
I would find the best exponential fit of the data: I tried with stat_smooth in ggplot, the code is:
p_fit <- ggplot(data = fit1, aes(x = x, y = y)) +
stat_smooth(method="glm", se=TRUE,formula=y ~ exp(x),colour="red") +
geom_point(colour="red",size=4,fill="white",shape=1)+ theme_bw()+theme(panel.border = element_blank(), panel.grid.major = element_blank(),
panel.grid.minor = element_blank(), axis.line = element_line(colour = "black"))
p_fit + geom_text(colour="blue",x = 0.25, y = 1, label = lm_eqn(fit1), parse = TRUE)+annotate("text",label=pval,x=0.9,y=0.3)
but is not what i find. My exponential fit should start from the first point (x=0) and fit all point (best fit if is possible) How can do it?