Hello,
I have fitted two curves to the data. How can I tell which one is more
fitted? By eye (see plot underneath) I would say that the function
Gompertz is better than the function Holling type III; how can I give
a number to this hunch?
This is an example:
```
# functions
holling = function(a, b, x) {
y = (a * x^2) / (b^2 + x^2)
return(y)
}
gompertz = function(a, b, c, x) {
y = a * exp(-b * exp(-c * x))
return(y)
}
# data
actual <- c(8, 24, 39, 63, 89, 115, 153)
holling <- c(4.478803, 17.404533, 37.384128, 62.492663, 90.683630,
120.118174, 149.347683)
gompertz <- c(11.30771, 22.39017, 38.99516, 61.19318, 88.23403,
118.77225, 151.19849)
# plot
plot(1:length(actual), actual, lty = 1 , type = "l", lwd = 2,
xlab = "Index", ylab = "Values")
points(1:length(actual), holling, lty = 2, type = "l", col = "red")
points(1:length(actual), gompertz, lty = 3, type = "l", col = "blue")
legend("bottomright",
legend = c("Actual values", "Holling III", "Gompertz"),
lty = c(1, 2, 3), lwd = c(2, 1,1), col = c("black", "red", "blue"))
```
Thank you
How to compare the fitting of function?
3 messages · Ivan Krylov, Luigi Marongiu
On Tue, 7 Jul 2020 08:57:28 +0200
Luigi Marongiu <marongiu.luigi at gmail.com> wrote:
I would say that the function Gompertz is better than the function Holling type III; how can I give a number to this hunch?
There are many different goodness-of-fit measures; typically, regression problems are solved by minimising the sums of squared residuals, so you can just take a look at those (sum((y.predicted - y.reference)^2)). Root-mean-square-error [*] is another widely used metric. When comparing different methods, one should be aware of multiple comparisons problem [**] and potential for overfitting [***]. All this and more is discussed in books on statistics and regression, such as Regression Modeling Strategies by Frank E. Harrell, Jr. [doi:10.1007/978-3-319-19425-7]. For more advice on statistics, consider dedicated communities such as <https://stats.stackexchange.com/>, since statistics advice is considered off-topic here in R-help.
Best regards, Ivan [*] https://en.wikipedia.org/wiki/RMSE [**] https://en.wikipedia.org/wiki/Multiple_testing [***] https://en.wikipedia.org/wiki/Overfitting
Thank you. The problem was the implementation of the goodness-of-fit in R (any method, really). regards
On Tue, Jul 7, 2020 at 1:31 PM Ivan Krylov <krylov.r00t at gmail.com> wrote:
On Tue, 7 Jul 2020 08:57:28 +0200 Luigi Marongiu <marongiu.luigi at gmail.com> wrote:
I would say that the function Gompertz is better than the function Holling type III; how can I give a number to this hunch?
There are many different goodness-of-fit measures; typically, regression problems are solved by minimising the sums of squared residuals, so you can just take a look at those (sum((y.predicted - y.reference)^2)). Root-mean-square-error [*] is another widely used metric. When comparing different methods, one should be aware of multiple comparisons problem [**] and potential for overfitting [***]. All this and more is discussed in books on statistics and regression, such as Regression Modeling Strategies by Frank E. Harrell, Jr. [doi:10.1007/978-3-319-19425-7]. For more advice on statistics, consider dedicated communities such as <https://stats.stackexchange.com/>, since statistics advice is considered off-topic here in R-help. -- Best regards, Ivan [*] https://en.wikipedia.org/wiki/RMSE [**] https://en.wikipedia.org/wiki/Multiple_testing [***] https://en.wikipedia.org/wiki/Overfitting
Best regards, Luigi