Re: [R] How to use mle2 function?

2020-07-01 Thread peter dalgaard
The basic problem is that holling() is not a (negative) loglikelihood function. nll() _is_ a negative loglikelihood, but it is not clear for what. You appear to be very confused as to what a likelihood even is (what is k? apparently your response variable? Then how can it be a scalar if X is a

Re: [R] How to use mle2 function?

2020-06-30 Thread Luigi Marongiu
Addendum: the optimization actually got a worse outcome than the original eyeball estimation: ``` actual <- c(8, 24, 39, 63, 89, 115, 153, 196, 242, 287, 344, 408, 473, 546, 619, 705, 794, 891, 999, 1096, 1242, 1363, 1506, 1648, 1753, 1851,

Re: [R] How to use mle2 function?

2020-06-30 Thread Luigi Marongiu
No, I got the same. I reckon the problem is with X: this was I scalar, I was providing a vector with the actual values. Ho can mle2 optimize without knowing what are the actual data? and what values should I give for X? Thank you On Tue, Jun 30, 2020 at 2:06 PM Eric Berger wrote: > > I have no

Re: [R] How to use mle2 function?

2020-06-30 Thread Eric Berger
I have no problem with the following code: library(bbmle) holling <- function( a, b, x ) { a*x^2 / (b^2 + x^2) } A=3261 B=10 X=30 foo <- mle2( minuslogl=holling, start=list(a=A,b=B,x=X) ) foo # Call: # mle2(minuslogl = holling, start = list(a = A, b = B, x = X)) # Coefficients: #a

Re: [R] How to use mle2 function?

2020-06-30 Thread Luigi Marongiu
Sorry for the typo, but I have the same error if using b instead of h: ``` > O = mle2(minuslogl = holling, start = list(a = A, b = B)) > Error in minuslogl(a = 3261, b = 10) : argument "x" is missing, with no default # let's add x X = c(8, 24, 39, 63, 89, 115, 153, 196, 242, 287,

Re: [R] How to use mle2 function?

2020-06-30 Thread Eric Berger
Hi Luigi, I took a quick look. First error: You wrote O = mle2(minuslogl = holling, start = list(a = A, h = B, x = X)) it should be b=B (h is not an argument of holling()) The error message gave very precise information! Second error: You wrote O = mle2(minuslogl = nll, start = list(a = A, h =

[R] How to use mle2 function?

2020-06-30 Thread Luigi Marongiu
Hello, I would like to optimize the function: ``` holling = function(a, b, x) { y = (a * x^2) / (b^2 + x^2) return(y) } ``` I am trying to use the function mle2 from bbmle, but how do I need to feed the data? If I give `holling` as function to be optimized, passing the starting values for `a`,