gamlss-dev / gamlss

gamlss: Generalized Additive Models for Location Scale and Shape
https://CRAN.R-project.org/package=gamlss
10 stars 4 forks source link

rGIG stuck at execution with no results #5

Closed kjayden closed 4 months ago

kjayden commented 8 months ago

Screenshot 2023-11-09 124304

I realised after passing my vector through the fistDist() function, the model indicates a GIG distribution and at my attempt on generating random vectors using the output of the fitDist() function being rGIG() it just keeps running that line of code without a result whatsoever. What could cause this? what are the limitations of the function?

zeileis commented 4 months ago

Thanks @kjayden for the report and apologies for the slow response. I just tried to run rGIG(50, 16.97, 1.815, 0.013512) which works ok for me without any obvious issues.

Then I tried to re-run your for() loop:

energymodel <- data.frame(energy_sample = c(1:50))
for(i in 1:5) {
  energy_sample <- rGIG(50, 16.97, 1.815, 0.013512)
  energymodel[i] <- cbind(energy_sample, energymodel)
}

This produced all sorts of errors because the data is not combined cleanly. Instead of cbind() within the loop you should first set up a 50 x 5 matrix or data frame and then fill its columns within the loop.

Or you can use replicate():

replicate(5, rGIG(50, 16.97, 1.815, 0.013512))

In any case, as far as I can see, there are no issues here with gamlss or gamlss.dist. If you still think, there is, then please provide a simple self-contained reproducible example and re-open the issue.