[R] Use optim with multiple processors
Eva Liliane Ujeneza
evaliliane at aims.ac.za
Wed Oct 19 10:59:40 CEST 2016
Dear all,
I am trying to estimate the parameters* 3N + 2 *of a function using optim,
using a big longitudinal dataset of *N* patients observations. I defined
two functions: funct0 which calculate the residual sum of square for a
single individual, and *funct1* which calls funct0 using multiple cores and
return the total sum of the residuals (I tried two different approaches,
both fail).
>> Code Desscription
funct1 <- (data,parameters){
test <- pbdLapply(data, funct0, parameters) # calculate individual RSS
res <- sum(unlist(test))
return(res)
# Total RSS
}
funct1 <- (data,parameters){
jid <- data[get.jid(length(data))]
test <- lapply(data, funct0, parameters) # calculate individual RSS
res <- sum(unlist(test))
return(res) # Total RSS
}
result <- optim(parmeters, fn = funct1, yyy = data, method = "L-BFGS-B",
control=list(maxit=100, trace= TRUE )
<< End Code
When I run the above with P processor
s, P-1 would complete
(I can see the output on the screen)
but the last one does not. There is no error, and no sign that the last
processor is still optimizing. The job just does not complete and seems
stack/still. Thus, I get no value output for *result*. Does anyone have an
idea about what could be going wrong here ?
Cheers,
Eva
=====================================================
Eva Liliane Ujeneza, PhD student
DST/NRF Centre of Excellence in Epidemiological
Modelling and Analysis (SACEMA)
[[alternative HTML version deleted]]
More information about the R-help
mailing list