log(c/c0) = (-lambda0/alpha)*(exp(-alpha*time)-1)

#c=virus conc., c0=initial virus conc., lambda0=initial inactivation rate, alpha =resistivity coefficient, time= days

I tried the nls function and ggplots. The fitted line does not "follow the data points" well. The fit is not good. In the following, you can see my R code. Can someone find a better solution for this?

Jan<-c(40312342.96,43718079.07,9376618.33,9797684.99,8833426.24,9618517.21,9618517.21,2446992.71, 2405524.38,3771978.56,1825224.29)

t<-c(0,1,6,9,12,15,19,22,26,29,33)

plot(t,Jan, main="e+d+s+")

mydata<-data.frame(t,Jan)

C0 <- Jan[1]

C_prime <- log(Jan/C0)

x<-t

y <- C_prime

lambda0 = 0.1 #"initial inactivation rate"

alpha = 0.01 #"resistivity coefficient"

fit = nls(y~((-lambda0/alpha)*(exp(-alpha*x)-1)),start=list(lambda0=0.1,alpha=0.01))

summary(fit)

xs<-seq(min(x), max(x), length.out=100)

plot(x,y)

lines(xs, predict(fit, data.frame(x=xs)))

library(ggplot2)

ggplot(mydata,aes(x,y)) +

geom_point() +

geom_smooth(method="nls", formula=y~(-lambda0/alpha)*(exp(-alpha*x)-1), se=FALSE, start=list(lambda0=0.1,alpha=0.01))

Thanks in advance! Lisanne