## Example 1: Two-steps fitting-------------------------------------------------
## We can use the example dataset
data(example_coupled_twosteps)
## We need to define initial guesses for every parameter
guess <- c(logC0 = -1, b = .1, Tmin = 5)
## We can now call the fitting function
my_fit <- fit_coupled_growth(example_coupled_twosteps,
start = guess,
mode = "two_steps")
## Common S3 methods are included
print(my_fit)
coef(my_fit)
summary(my_fit)
plot(my_fit)
## Any model parameter can be fixed using the known argument
known <- c(b = .01)
## Please note that the guess must be updated, as now parameter can appear both as a guess and known
guess <- c(logC0 = -1, Tmin = 0)
fixed_fit <- fit_coupled_growth(example_coupled_twosteps,
start = guess,
known = known,
mode = "two_steps")
print(fixed_fit)
coef(fixed_fit)
summary(fixed_fit)
plot(fixed_fit)
## Example 2: One-step fitting--------------------------------------------------
## We can use an example dataset with the right format
data("example_coupled_onestep")
## The function requires initial guesses for every model parameter
guess <- c(logN0 = 2, logNmax = 8, b = 0.04, logC0 = -4, Tmin = 5)
## We can now call the fitting function
my_fit <- fit_coupled_growth(example_coupled_onestep,
start = guess,
mode = "one_step")
## The package includes common S3 methods
print(my_fit)
coef(my_fit)
summary(my_fit)
plot(my_fit)
## Any model parameter can be fixed before fitting
known <- c(logNmax = 7)
## Guesses must be updated, so no parameter appears twice
guess <- c(logN0 = 2, b = 0.04, logC0 = -4, Tmin = 5)
## We can now call the fitting function
my_fit <- fit_coupled_growth(example_coupled_onestep,
start = guess,
known = known,
mode = "one_step")
## The package includes common S3 methods
print(my_fit)
coef(my_fit)
summary(my_fit)
plot(my_fit)
Run the code above in your browser using DataLab