Skip to content
Prev 14536 / 15274 Next

Speed up for loop

Hello everyone,

I would like to ask you how I can speed up this for loop.  In the following code I generate a sample of 200 of the NIG distribution and then I fit to them the NIG distribution. My aim is to estimate 1mln times the mean parameter of this NIG distribution.
Any ideas?

library(GeneralizedHyperbolic)
mu=0;delta = 1;alpha = 1;beta = 0
m=numeric(1000000)
for(i in 1:1000000){
m[i]=coef(nigFit(rnig(200, param = c(mu, delta, alpha, beta))
))[1]
}

Thank you in advance.
Best,
Andreas