Closed paviaishu16 closed 4 weeks ago
What should the output of this task be @paviaishu16?
R-squared, RMSE, AIC and plots for each well?
Let us just consider this as a steps for the next issues! Fitting the model is the first part which is gompertz and richards model and get the plots with the predicted and actual data. And goodness of fit is the second part from which is decided by AIC
As a next step we also identify the BIC, Bayesian Information Criterion.
def calculate_bic(n, k, sse):
# Calculate log likelihood from Sum of Squared Errors (SSE)
log_likelihood = -n / 2 * (np.log(2 * np.pi * (sse / n)) + 1)
# BIC formula
bic = k * np.log(n) - 2 * log_likelihood
return bic
sse is the sum of squared errors (the one that we get from the gompertz and richards curve fitting) n is the number of observation (in this case it would 146 I think i.e., number of rows) k is the number of parameters in the model ( 4 for richards and 3 for gompertz)
Next step is to identify the best model: The best model is the one with lowest AIC/BIC value
@paviaishu16 what if one has lower AIC and the other has lower BIC?
Do we have a situation like that? We have to give higher priority to BIC value in that case. However, it shouldn't be possible to have such a case where AIC is lower and BIC is high or the way around
Using Numpy and Scipy, one could fit the growth curve to different models. In this model we are expecting to fit the curve to Richards and Gompertz model. We can use the growth parameters obtained for this task.
Steps to Fit a Growth Model and Check Goodness of Fit:
[ ] Predict Values based on the Growth model (Richards and Gompertz): Use the growth model with the growth parameter estimates to predict the values for the dependent variable based on the independent variable.
[ ] Calculate Residuals: Compute the residuals, which are the differences between the observed values and the predicted values.
[ ] Minimize Squared Differences: Use an optimization method (e.g., least squares) to adjust the model parameters to minimize the squared differences (sum of squared residuals) between predicted and observed values.
[ ] Refit the Model: Refit the model using the optimized parameters and generate new predictions.
[ ] Evaluate Goodness of Fit: Assess the goodness of fit using metrics such as: R-squared (𝑅^2 ) Root Mean Squared Error (RMSE) Akaike Information Criterion (AIC) Visual inspections of residuals and predicted vs. observed plots.