Guest User

Untitled

a guest
Mar 8th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. library('gamlss')
  2. library('foreach')
  3. library('doParallel')
  4.  
  5. registerDoParallel(cores = 4)
  6. # Generate data
  7. set.seed(314)
  8. sample.size <- 30
  9. input.processed.cut <- data.frame(TP = round(runif(sample.size) * 100),
  10. FP = round(runif(sample.size) * 100),
  11. x = runif(sample.size))
  12. # Fit Beta-binomial
  13. model3 <- gamlss(formula = cbind(TP, FP) ~ x,
  14. family = BB,
  15. data = input.processed.cut)
  16.  
  17. # Get the leave-one-out values
  18. loo_predict.mu <- function(model.obj, input.data) {
  19. yhat <- foreach(i = 1 : nrow(input.data), .packages="gamlss", .combine = rbind) %dopar% {
  20. updated.model.obj <- update(model.obj, data = input.data[-i, ])
  21. predict(updated.model.obj, what = "mu", newdata = input.data[i,], type = "response")
  22. }
  23. return(data.frame(result = yhat[, 1], row.names = NULL))
  24. }
  25.  
  26. par.run <- loo_predict.mu(model3, input.processed.cut)
  27. # Error in { : task 1 failed - "object 'input.data' not found"
  28.  
  29. > version
  30. _
  31. platform x86_64-w64-mingw32
  32. arch x86_64
  33. os mingw32
  34. system x86_64, mingw32
  35. status
  36. major 3
  37. minor 4.3
  38. year 2017
  39. month 11
  40. day 30
  41. svn rev 73796
  42. language R
  43. version.string R version 3.4.3 (2017-11-30)
  44. nickname Kite-Eating Tree
Add Comment
Please, Sign In to add comment