I was wondering if someone could help me solve my problem. So I am looking to find the perfect fit for my function on my variables in my dataframe (see example below). With looking around I came upon the function mle() and I thought yes this is it! But i got a warning message, can someone help me solve it?
And I am still not sure if this is the function I need... So maybe people have other sugguestions? The main point is that I want to define a formula with one parameter y = exp(-a*x), so the function should look for the perfect parameter fit
G <- c(1,0.86,0.72,0.56,0.33,0.09)
K <- c(0.53,1.11,1.5,2.01,3.3,5.1)
find1 <- data.frame(G,K)
library(bbmle)
functie1 <- function(a, sigma) {
G = exp(- a * K)
-sum(dnorm(find1, mean = G, sd = sigma, log = TRUE))
}
mle2.model <- mle2(functie1, start = list(a=1, sigma=1))
so this is the error massage I get:
Error in dnorm(find1, mean = G, sd = sigma, log = TRUE) :
Non-numeric argument to mathematical function