Untitled

 avatar
unknown
plain_text
2 years ago
434 B
3
Indexable
#download data
cell_data <- read.csv(file = "IntroSysBio.csv", stringsAsFactors = FALSE)

#fit data to nonlinear regression


x <- cell_data$Time
y <- cell_data$CellLine1

N0 <- cell_data$CellLine1[1]
r1 <- 0.00001

exp_growth <- function(t, N, r){
  dy <- N * exp(r*t)
  return(dy)
}

exp_growth_fit <- nls(y ~ exp_growth(y, N, r), start = c(N = N0, r = r1))

plot(x, y, col = "red")
lines(x, predict(exp_growth_fit), col = "black")
Editor is loading...