Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • is it any good way to improve the speed for command NLCOM

    Hi,

    I'm trying to be flexible,
    I am in the process of calculating flexibility.
    I used the NLCOM command to calculate the result.
    Then it took a lot of time.
    I think my coding is not efficient, but I don't know how to improve the speed.
    Do you have any good ideas?





    local i 1
    while `i' <= 11{
    local j 1
    while `j' <= 12{
    global mcf`i'_`j' "(w`i'_M_cross_flx_`j': [w`i']q`j'/mw`i' + [w`i']lnq_s/mw`i'* mw`j' )"
    local j= `j'+ 1

    }
    local i= `i'+ 1
    }

    local i 1
    while `i' <= 11{
    global mcf12_`i' "(w12_M_cross_flx_`i': -([w1]q`i'+ [w2]q`i'+ [w3]q`i'+ [w4]q`i'+ [w5]q`i'+ [w6]q`i'+ [w7]q`i'+ [w8]q`i'+ [w9]q`i'+ [w10]q`i'+ [w11]q`i')/mw12 - ([w1]lnq_s+ [w2]lnq_s+ [w3]lnq_s+ [w4]lnq_s+ [w5]lnq_s+ [w6]lnq_s+ [w7]lnq_s+ [w8]lnq_s+ [w9]lnq_s+ [w10]lnq_s+ [w11]lnq_s/ mw12)* mw`i' )"
    local i= `i'+ 1
    }



    nlcom $mcf1_2 $mcf1_3 $mcf1_4 $mcf1_5 $mcf1_6 $mcf1_7 $mcf1_8 $mcf1_9 $mcf1_10 $mcf1_11 $mcf1_12
    nlcom $mcf2_1 $mcf2_3 $mcf2_4 $mcf2_5 $mcf2_6 $mcf2_7 $mcf2_8 $mcf2_9 $mcf2_10 $mcf2_11 $mcf2_12
    nlcom $mcf3_1 $mcf3_2 $mcf3_4 $mcf3_5 $mcf3_6 $mcf3_7 $mcf3_8 $mcf3_9 $mcf3_10 $mcf3_11 $mcf3_12
    nlcom $mcf4_1 $mcf4_2 $mcf4_3 $mcf4_5 $mcf4_6 $mcf4_7 $mcf4_8 $mcf4_9 $mcf4_10 $mcf4_11 $mcf4_12
    nlcom $mcf5_1 $mcf5_2 $mcf5_3 $mcf5_4 $mcf5_6 $mcf5_7 $mcf5_8 $mcf5_9 $mcf5_10 $mcf5_11 $mcf5_12
    nlcom $mcf6_1 $mcf6_2 $mcf6_3 $mcf6_4 $mcf6_5 $mcf6_7 $mcf6_8 $mcf6_9 $mcf6_10 $mcf6_11 $mcf6_12
    nlcom $mcf7_1 $mcf7_2 $mcf7_3 $mcf7_4 $mcf7_5 $mcf7_6 $mcf7_8 $mcf7_9 $mcf7_10 $mcf7_11 $mcf7_12
    nlcom $mcf8_1 $mcf8_2 $mcf8_3 $mcf8_4 $mcf8_5 $mcf8_6 $mcf8_7 $mcf8_9 $mcf8_10 $mcf8_11 $mcf8_12
    nlcom $mcf9_1 $mcf9_2 $mcf9_3 $mcf9_4 $mcf9_5 $mcf9_6 $mcf9_7 $mcf9_8 $mcf9_10 $mcf9_11 $mcf9_12
    nlcom $mcf10_1 $mcf10_2 $mcf10_3 $mcf10_4 $mcf10_5 $mcf10_6 $mcf10_7 $mcf10_8 $mcf10_9 $mcf10_11 $mcf10_12
    nlcom $mcf11_1 $mcf11_2 $mcf11_3 $mcf11_4 $mcf11_5 $mcf11_6 $mcf11_7 $mcf11_8 $mcf11_9 $mcf11_10 $mcf11_12
    nlcom $mcf12_1 $mcf12_2 $mcf12_3 $mcf12_4 $mcf12_5 $mcf12_6 $mcf12_7 $mcf12_8 $mcf12_9 $mcf12_10 $mcf12_11






    ​​​​​​​

  • #2
    I assume you use -nlcom- to get the std error from the delta method.
    I also found -nlcom- to be quite slow and therefore I ended up implementing the delta method for my specific application using mata.
    In particular, see help mf_deriv to compute numerical derivatives.
    My code is available here (from line 184): https://github.com/anddis/med4way/bl...way_engine.ado

    Comment

    Working...
    X