Guest User

Untitled

a guest
Mar 22nd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. classFitDist <- c(class(fe), class(flogis), class(fn), class(fp),class(fg))
  2.  
  3. distributions <- classFitDist == "fitdist"
  4.  
  5.  
  6. AIC <- data.frame()
  7. if(class(fe)=="fitdist") {AIC[1,ncol(AIC)+1] <- fe$aic}
  8. if(class(flogis)=="fitdist") {AIC[1,ncol(AIC)+1] <- flogis$aic}
  9. if(class(fn)=="fitdist") {AIC[1,ncol(AIC)+1] <- fn$aic}
  10. if(class(fp)=="fitdist") {AIC[1,ncol(AIC)+1] <- fp$aic}
  11. if(class(fg)=="fitdist") {AIC[1,ncol(AIC)+1] <- fg$aic}
  12.  
  13. names(AIC) <- c("exp", "logis", "norm", "pois", "gamma")[distributions]
  14.  
  15. fit <- names(AIC[which.min(AIC)])
  16.  
  17.  
  18. mean <- switch (fit,
  19. exp = 1/fe$estimate[[1]],
  20. logis = flogis$estimate[[1]],
  21. norm = fn$estimate[[1]],
  22. pois = fp$estimate[[1]],
  23. gamma = fg$estimate[[1]]/fg$estimate[[2]]
  24. )
  25.  
  26. sd <- switch (fit,
  27. exp = mean,
  28. logis = (flogis$estimate[[2]]*pi)/sqrt(3),
  29. norm = fn$estimate[[2]],
  30. pois = sqrt(mean),
  31. gamma = sqrt(fg$estimate[[1]]/(fg$estimate[[2]]^2))
  32. )
  33.  
  34. # etc, etc.
  35.  
  36. goodnessoffit <- gofstat(list(fe, flogis, fn, fp, fg)[distributions], fitnames = c("exp", "logis", "norm", "pois","gamma")[distributions])
  37. fit <- names(which(goodnessoffit$aic == min(goodnessoffit$aic)))
Add Comment
Please, Sign In to add comment