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

Dimitrios Stasinopoulos dmh.stasinopoulos at gmail.com
Sat Mar 10 14:34:59 CET 2018


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
stasinom at staff.londonmet.ac.uk




	[[alternative HTML version deleted]]



More information about the R-help mailing list