. Package gamlss used inside foreach() and %dopar% fails to find an object (Nik Tuzov)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

. Package gamlss used inside foreach() and %dopar% fails to find an object (Nik Tuzov)

Dimitrios Stasinopoulos-2
Dear Nik

Try the following code


loo_predict.mu <- function(model.obj, input.data) {
  yhat <- foreach(i = 1 : nrow(input.data), .packages="gamlss", .combine = rbind) %dopar% {
    updated.model.obj <- update(model.obj, data = input.data[-i, ])
    predict(updated.model.obj, what = "mu", data = input.data[-i, ],
            newdata = input.data[i,], type = "response")
  }
  return(data.frame(result = yhat[, 1], row.names = NULL))
}

par.run <- loo_predict.mu(model3, input.processed.cut)

The predict command in this case also need the old data.

Thanks
Mikis



Prof Dimitrios Mikis Stasinopoulos
[hidden email]




        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.