[R] why isn't integrate function working in a likelihood

2012-10-29 Thread stats12
Dear R users, I have been trying to solve for mle's of a function that involves an integral and I keep getting an error. I created an example to work on first and even the simple example doesn't give me the mle's. I am getting the error "Error in integrate(integrand, 0, Inf) : non-finite function

Re: [R] how to make simulation faster

2012-10-26 Thread stats12
ing the 'data.table' package: > >> require(data.table) >> system.time({ > + dt <- data.table(value = x, z = z) > + r3 <- dt[ > + , list(sum = sum(value)) > + , keyby = z > + ] > + }) >user system ela

Re: [R] how to make simulation faster

2012-10-26 Thread stats12
ll you where to concentrate your effort. > > Sent from my iPad > > On Oct 25, 2012, at 23:23, stats12 < > skarmv@ > > wrote: > >> Dear R users, >> >> I need to run 1000 simulations to find maximum likelihood estimates. I >> print my output

Re: [R] how to make simulation faster

2012-10-26 Thread stats12
Hi, Thank you for your reply. I updated my post with the code. Also, about posting from Nabble, since I am a new user I didn't know about that problem. If I post to the mailing list ( r-help@r-project.org), would it get rid of that problem? output1<-vector("numeric",length(1:r)) output2<-vector

[R] how to make simulation faster

2012-10-25 Thread stats12
Dear R users, I need to run 1000 simulations to find maximum likelihood estimates. I print my output as a vector. However, it is taking too long. I am running 50 simulations at a time and it is taking me 30 minutes. Once I tried to run 200 simulations at once, after 2 hours I stopped it and saw t

Re: [R] Error in integrate(integrand, 0, Inf) : non-finite function value

2012-10-21 Thread stats12
You are right. I ran the code again and got the same error again. But ran it for the second time, it didn't return an error and I got some values. It's my first time doing this kind of coding and I'm still learning. I agree that my code may look unorganized and wrong. I'll work on your comments a

Re: [R] Error in integrate(integrand, 0, Inf) : non-finite function value

2012-10-20 Thread stats12
Hi, Thank you for your comment. I worked on the code again and was able to make it work. The only problem I am having right now is that nlm depends on the initial value. When the initial value is 1, I get the following estimates 0.1230414 19.6271029 when it is 2, I get the following 29.46874 2

[R] Error in integrate(integrand, 0, Inf) : non-finite function value

2012-10-20 Thread stats12
Dear R users, When I run the code below, I get the error "Error in integrate(integrand, 0, Inf) : non-finite function value". The code works if the function returns only "sum(integ)". However, I want to add "cmh" to it. When I add "cmh" I get that error. I can't figure out why this is happening b

Re: [R] likelihood function involving integration, error in nlm

2012-10-19 Thread stats12
Thanks for pointing that out. Made some modifications and it worked. -- View this message in context: http://r.789695.n4.nabble.com/likelihood-function-involving-integration-error-in-nlm-tp4646697p4646764.html Sent from the R help mailing list archive at Nabble.com. ___

[R] likelihood function involving integration, error in nlm

2012-10-18 Thread stats12
Dear R users, I am trying to find the mle that involves integration. I am using the following code and get an error when I use the nlm function d<-matrix(c(1,1,0,0,0,0,0,0,2,1,0,0,1,1,0,1,2,2,1,0),nrow=10,ncol=2) h<-matrix(runif(20,0,1),10) integ<-matrix(c(0),nrow=10, ncol=2) ll<-function(p){

[R] for loop output

2012-10-17 Thread stats12
Dear R users, In the code below, I am trying to print the result of my loop function. The output first gives me the result for k=1, and then for k=1 and k=2. I only want the last output which is [,1] [,2] [1,] 0.1700065 0.5002659 [2,] 0.3080273 0.4954731 [3,] 0.4844886 0.454430