Announcement

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

  • expression too long error while using nlcom command

    Hi Stata listers

    I am getting an error message:

    expression too long
    r(130);
    right after the command:
    qui nlcom (elasexp`i': ${mu`i'}/w`i'mean + 1) (mu`i'`j'f: (1e+2)*(${mu`i'`j'})), post noheader

    The commands I am working with are given below. The commands are part of the elasticities estimations for QUAIDS model (Quadratic Almost Ideal Demand System) .
    I know that I have to split the command to avoid this problem and some splitting have been done with the commands - however I am not sure where it is going wrong

    Any advice/suggestions will be highly appreciated.
    Thank you in advance
    Mariko Wijekoon

    quietly {
    foreach x of varlist w* lnp* lnexp {
    sum `x'
    scalar `x'mean=r(mean)
    }
    * Price indexes
    glo asum "_b[a1]*lnp1mean"
    forv i=2(1)13 {
    glo asum "${asum} + _b[a`i']*lnp`i'mean"
    }
    glo gsum ""
    forv i=1(1)13 {
    forv j=1(1)13 {
    glo gsum "${gsum} + 0.5*_b[g`i'`j']*lnp`i'mean*lnp`j'mean"
    }
    }
    glo ap "6.11 + ${asum} ${gsum}"
    glo bp "_b[b1]*lnp1mean"
    forv i=2(1)13 {
    glo bp "${bp} + _b[b`i']*lnp`i'mean"
    }
    glo bp "(exp(${bp}))"
    * Mus
    forv i=1(1)13 {
    glo mu`i' "_b[b`i'] + 2*_b[l`i']/${bp}*(lnexpmean-(${ap}))"
    }
    forv j=1(1)13 {
    glo gsum2`j' ""
    forv k=1(1)13 {
    glo gsum2`j' "${gsum2`j'} + _b[g`j'`k']*lnp`k'mean"
    }
    }
    }
    forv i=1(1)13 {
    forv j=1(1)13 {
    glo delta=cond(`i'==`j',1,0)
    glo mu`i'`j' "_b[g`i'`j'] - ${mu`i'}*(_b[a`j'] ${gsum2`j'})-_b[l`i']*_b[b`j']/${bp}*(lnexpmean - (${ap}))^2"
    cap nlcom (elasexp`i': ${mu`i'}/w`i'mean + 1) (mu`i'`j': ${mu`i'`j'}), post noheader
    if _rc {
    *
    *expression too long- error message appears after the following command:
    *
    qui nlcom (elasexp`i': ${mu`i'}/w`i'mean + 1) (mu`i'`j'f: (1e+2)*(${mu`i'`j'})), post noheader
    qui nlcom (elasexp`i': _b[elasexp`i']) (mu`i'`j':_b[mu`i'`j'f]/(1e+2)), post noheader
    }
    * Uncompensated price elasticity
    nlcom (elasexp`i': _b[elasexp`i']) (elu`i'`j':_b[mu`i'`j']/w`i'mean - ${delta}) , post noheader
    * Compensated price elasticity
    nlcom (elc`i'`j': _b[elu`i'`j'] + _b[elasexp`i']*w`j'mean), noheader
    qui est restore quaidsmariko
    }
    }






  • #2
    Hi Mariko, did you ever found out how to fix this issue? As far as I understand it seems that the process to generate the elasticities using nlcom is a operation too long for the command (Brian Poi solved a few of this problems in the past). I have tried unsuccessfully to split the operation so far. Any ideas?

    Comment

    Working...
    X