[R] Speed up code with for() loop

From: hck <hans-christian.krumholz_at_uni-ulm.de>
Date: Thu, 28 Apr 2011 10:27:35 -0700 (PDT)

Hallo everybody,

I'm wondering whether it might be possible to speed up the following code:

Error<-rnorm(10000000, mean=0, sd=0.05)


DCF_korrigiert<-(1/(exp(1/(exp(0.5*(-estimate)^2/(0.05^2))*sqrt(2*pi/(0.05^2))*(1-pnorm(0,((-estimate)/(0.05^2)),sqrt(1/(0.05^2))))))-1)) D<-100000
for(i in 1:D)

The calculation of the for-loop takes several hours even on a very quick machine (4GHz, 8 GB RAM Windows 2008 Server 64bit). Has anybody an idea, how to improve the for-line?

Thanks for helping me.

View this message in context: http://r.789695.n4.nabble.com/Speed-up-code-with-for-loop-tp3481680p3481680.html
Sent from the R help mailing list archive at Nabble.com.

R-help_at_r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Thu 28 Apr 2011 - 17:36:40 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 29 Apr 2011 - 21:00:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive