I ran you script and it came back in less than 1 second:
> x <- rnbinom(100, mu = 10, size = 10)
> hdev <- function(par) {
+ -sum(dnbinom(x, mu = par[1], size = par[2], log = TRUE))
+ }> nlminb(c(9, 12), hdev)
$par
[1] 9.760001 13.802305
$objective
[1] 278.9434
$convergence
[1] 0
$message
[1] "relative convergence (4)"
$iterations
[1] 11
$evaluations
function gradient
12 31
>
On Wed, Jul 2, 2008 at 8:41 PM, Peng Jiang <jp021 at sjtu.edu.cn>
wrote:> Hi, dear R experts ,
> I am new. I met this problem when I am trying to learn how to use
> the nlminb() function. I tried the example which the document
> provides ( as the following code ) and R gives no response . I don't
> know whether it is running or not and it takes a very long time but
> still output nothing so I just close the session window. my question
> is is there any method that I can see the running status of a R
> program or what can I do if R gives no response??? thank you in advance.
> here is my sessionInfo
>
> i386-apple-darwin8.10.1
>
> locale:
> zh_CN.UTF-8/zh_CN.UTF-8/C/C/zh_CN.UTF-8/zh_CN.UTF-8
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>
> other attached packages:
> [1] mclust_3.1-5
> x <- rnbinom(100, mu = 10, size = 10)
> hdev <- function(par) {
> -sum(dnbinom(x, mu = par[1], size = par[2], log = TRUE))
> }
> nlminb(c(9, 12), hdev)
> -----------------------------------------------
> Peng Jiang ?? ,Ph.D. Candidate
> Antai College of Economics & Management
> ????????
> Department of Mathematics
> ???
> Shanghai Jiaotong University (Minhang Campus)
> 800 Dongchuan Road
> 200240 Shanghai
> P. R. China
>
>
> [[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.
>
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem you are trying to solve?