I am running exponential regression on my data, but when trying to plot the curve I get a Inf problem because the independent variable values seem to be too high. How can I solve this in order to be able to plot the real values of the independent variable and the regression line incl standard errors in the same plot?
DPUT
of my data:
structure(list(YR = c(1960, 1961, 1962, 1963, 1964, 1965, 1966,
1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977,
1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988,
1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
2011, 2012, 2013, 2014, 2015, 2016), count = c(1L, 3L, 2L, 4L,
3L, 5L, 3L, 10L, 9L, 6L, 9L, 7L, 7L, 10L, 7L, 10L, 13L, 7L, 10L,
12L, 15L, 12L, 11L, 9L, 10L, 16L, 21L, 9L, 10L, 9L, 18L, 19L,
14L, 14L, 13L, 21L, 20L, 18L, 28L, 21L, 27L, 26L, 25L, 24L, 25L,
34L, 37L, 31L, 59L, 45L, 49L, 42L, 48L, 65L, 52L, 62L, 49L)), .Names =
c("YR", "count"), class = "data.frame", row.names = 27:83)
And my script:
ggplot(data.df,aes(x=YR,y=count)) +
scale_y_continuous(limits=c(0,75),breaks=c(10,20,30,40,50,60,70),expand=c(0,0)) +
scale_x_continuous(limits=c(1960,2018),breaks=c(1960,1965,1970,
1975,1980,1985,1990,1995,
2000,2005,2010,2015)) +
geom_bar(stat='identity',width=0.8) +
stat_smooth(method="lm",formula=y~exp(x),se=T, col=2) +
xlab(" ") + ylab("count")