[R] non-numeric argument in mle2

peter dalgaard pdalgd at gmail.com
Thu Apr 19 13:34:41 CEST 2012


On Apr 19, 2012, at 09:52 , Joachim Audenaert wrote:

> Hi all,
> 
> I have some problems with the mle2 function
> 
> 
>> RogersIIbinom <- function(N0,attackR3_B,Th3_B) 
> {N0-lambertW(attackR3_B*Th3_B*N0*exp(-attackR3_B*(24-Th3_B*N0)))/(attackR3_B*Th3_B)}
>> RogersII_B <- 
> mle2(FR~dbinom(size=N0,prob=RogersIIbinom(N0,attackR3_B,Th3_B)/N0),start=list(attackR3_B=1.5,Th3_B=0.04),method="Nelder-Mead",data=dat)
> Error in dbinom(x, size, prob, log) : 
>  Non-numeric argument to mathematical function
> 
> Can somenone explain met what this error means? All my parameters and data 
> are defined, so I don't understand what the non-numeric argument is??? 
> With different equations the script does work...........

traceback() indicates that the prob= argument is a vector of complex numbers when doing the call

minuslogl(attackR3_B = -0.262499999999999, Th3_B = 1.755625)



> 
> For this function to run you need packages: bbmle and emdbook.
> Testdata I pasted here
> 
> N0      FR
> 5       4
> 3       2
> 5       3
> 5       4
> 6       4
> 5       4
> 4       2
> 5       4
> 6       5
> 5       3
> 10      5
> 14      7
> 12      6
> 17      9
> 10      4
> 16      8
> 15      8
> 14      5
> 15      6
> 15      5
> 19      10
> 20      11
> 22      10
> 21      12
> 25      12
> 26      11
> 25      10
> 25      12
> 25      11
> 24      9
> 35      12
> 33      12
> 35      13
> 36      12
> 31      12
> 37      12
> 39      13
> 36      14
> 35      12
> 35      10
> 46      11
> 44      10
> 41      12
> 43      14
> 45      12
> 48      11
> 45      13
> 45      9
> 49      12
> 45      11
> 56      12
> 59      15
> 52      11
> 54      10
> 51      12
> 55      12
> 61      13
> 55      12
> 54      10
> 55      12
> 
> Kind regards,
> Met vriendelijke groeten,
> Joachim
> 
> Don't waste paper! Think about the environment before printing this e-mail
> 
> ______________________________________
> 
> Joachim Audenaert
> Adviesdienst Gewasbescherming
> Proefcentrum voor Sierteelt
> Schaessestraat 18
> B-9070 Destelbergen
> Belgium
> Tel. +32 9 353 94 71
> Fax +32 9 353 94 95
> E-mail: joachim.audenaert at pcsierteelt.be
> www.pcsierteelt.be
> ______________________________________
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list