I'm running an R script for Markov Chain Monte Carlo with parallelization on for loops using "foreach" R package. I have been trying to run it for about 20000 iterations. But, after several thousand iterations, it stops with the following error.
Error in { :
task 217 failed - "'rho' must be an environment not promise: detected in C-level eval"
It appears on different occasions within the for loop. For example, if I run the same code several times, at one time it may appear in 3000th iteration, but at another time it may appear in the 2000th iteration.
Here's a part of the code with the for loop that produced the error this time.
u1i_i <- foreach(j = 1:Ni, .combine = 'c', .inorder = T, .packages = "dplyr") %dopar% { df_i <- subset(df, pid == pt[j]) f_u1i(beta10 = beta10[i-1], beta11 = beta11[i-1], tau1sq = tau1sq[i], sigma1sq = sigma1sq[i], w1ij = w1ij_i_1[ni_l[j]:ni_u[j]], B1ij = B1ij_i_1[ni_l[j]:ni_u[j]], u1i = u1i_i_1[j], beta20 = beta20[i-1], beta21 = beta21[i-1], w2ij = w2ij_i_1[ni_l[j]:ni_u[j]], B2ij = B2ij_i_1[ni_l[j]:ni_u[j]], u2i = u2i_i_1[j], gamma_h01 = gamma_h01[i-1], gamma_h02 = gamma_h02[i-1], gamma1 = gamma1[i-1], a1 = a1[i-1], a2 = a2[i-1], b1 = b1[i-1], b2 = b2[i-1], y1ij = df_i$FEV1, x1ij = df_i[c("timeSince_t0")], ni = ni[j], df_t_Ti = df_t_Ti[ni_l[j]:ni_u[j],], Ti = s_df$timeSince_t0[j], omegai = s_df[j,"omegai"], deltai = s_df$event[j], sd_u1i_star = 0.1) }
f_u1i - function which takes values from parameters updated in the previous iteration (i-1) and in this iteration (i).
The complete code is too long to share.
My OS is, macOS Big Sur Version 11.3, processor is Apple M1 chip, and RAM is 8 GB.
I'm running an R script for Markov Chain Monte Carlo with parallelization on for loops using "foreach" R package. I have been trying to run it for about 20000 iterations. But, after several thousand iterations, it stops with the following error.
It appears on different occasions within the for loop. For example, if I run the same code several times, at one time it may appear in 3000th iteration, but at another time it may appear in the 2000th iteration.
Here's a part of the code with the for loop that produced the error this time.
u1i_i <- foreach(j = 1:Ni, .combine = 'c', .inorder = T, .packages = "dplyr") %dopar% { df_i <- subset(df, pid == pt[j]) f_u1i(beta10 = beta10[i-1], beta11 = beta11[i-1], tau1sq = tau1sq[i], sigma1sq = sigma1sq[i], w1ij = w1ij_i_1[ni_l[j]:ni_u[j]], B1ij = B1ij_i_1[ni_l[j]:ni_u[j]], u1i = u1i_i_1[j], beta20 = beta20[i-1], beta21 = beta21[i-1], w2ij = w2ij_i_1[ni_l[j]:ni_u[j]], B2ij = B2ij_i_1[ni_l[j]:ni_u[j]], u2i = u2i_i_1[j], gamma_h01 = gamma_h01[i-1], gamma_h02 = gamma_h02[i-1], gamma1 = gamma1[i-1], a1 = a1[i-1], a2 = a2[i-1], b1 = b1[i-1], b2 = b2[i-1], y1ij = df_i$FEV1, x1ij = df_i[c("timeSince_t0")], ni = ni[j], df_t_Ti = df_t_Ti[ni_l[j]:ni_u[j],], Ti = s_df$timeSince_t0[j], omegai = s_df[j,"omegai"], deltai = s_df$event[j], sd_u1i_star = 0.1) }f_u1i - function which takes values from parameters updated in the previous iteration (i-1) and in this iteration (i).
The complete code is too long to share.
My OS is, macOS Big Sur Version 11.3, processor is Apple M1 chip, and RAM is 8 GB.