Tenis Common opponents R
You could help us by providing the output of the profiler:

Rprof(tmp &lt;- tempfile())
RESA &lt;- MAL(1, 2)
Rprof()
summaryRprof(tmp)
unlink(tmp)


, but I suspect the main bottleneck in your code is the use of parallel loops in TB and S, for operations that can be done faster using vectorized R functions. Please give this a try and let us know if it is faster for you:

G  &lt;- function(p)    p^4*(15-4*p-((10*p^2)/(1-2*p*(1-p))))
d  &lt;- function(p, q) p*q*(1-(p*(1-q)+(1-p)*q))^-1
TB &lt;- function(p, q) sum(A[,1] * p^A[,2] * (1-p)^A[,3] *
                         q^A[,4] * (1-q)^A[,5] * d(p,q)^A[,6])
S  &lt;- function(p, q) {
   Gp &lt;- G(p)
   Gq &lt;- G(q)
   sum(B[,1] * Gp^B[,2] * (1-Gp)^B[,3] * Gq^B[,4] * (1-Gq)^B[,5] *
      (Gp*Gq+(Gp*(1-Gq)+(1-Gp)*Gq)*TB(p,q))^B[,6])
}
M3 &lt;- function(p, q) {
   s &lt;- S(p,q)
   s^2*(1+2*(1-s))
}
DELTA_AB &lt;- function(spwAC,rpwAC,spwBC,rpwBC) (spwAC-(1-rpwAC)) -
                                              (spwBC-(1-rpwBC))
PR &lt;- function(spwAC,rpwAC,spwBC,rpwBC) {
   D &lt;- DELTA_AB(spwAC, rpwAC, spwBC, rpwBC)
  (M3(p = 0.6 + D, q = (1 - 0.6)) +
   M3(p = 0.6, q = 1 - (0.6 - D))) / 2
}