Dear colleagues:
I'm trying to fit a model by Genetic Algorithms. In the GAFIT package the expression I use for fitting is:
fitness <- expression((Z - (X^a + Y^b))^2)
Y a and b are coefficients of the variables X and Y. Z is the output variable.
When I try to use another package (rgenoud, GA, etc...) I must put the syntax in function form. I use this:
fitness <- function(X,Y,Z) {
Z <- trees$BIOMASS
X <- trees$DIAMETER
Y <- trees$HEIGHT
observed <- (X + X^2 + Y + Y^2 + X*Y)
expected <- Z
error <- (observed-expected)^2
return(error)
}
I don't know what I'm doing wrong.
I'd appreciate a little help.
Thank you
**************************************************************************** Daniel Pat?n Numerical Ecology. Ecology Unit Department of Plant Biology, Ecology and Earth Sciences Faculty of Sciences. University of Extremadura Avda. Elvas s/n 06071 Badajoz (Spain) https://orcid.org/0000-0003-2500-3964 https://cvn.fecyt.es/0000-0003-2500-3964 http://unex.academia.edu/DanielPatonDominguez https://www.researchgate.net/profile/Daniel_Paton/ http://sites.google.com/site/numericalecologyuex/home http://twitter.com/NumericalEcolo1 https://www.youtube.com/channel/UCcDUrzoZQ5OID6uVxhcwBng