Announcement

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

  • nlsur_AIDS

    Hi,
    I developed a script for a 9-good AIDS demand system based on the example given in the nlsur manual. But, when I run it it keeps keeps giving me error messages. I was searching the internet for an exact solution for the problem and trying different suggestions but without a success. I really appreciate if somebody can have a look on my script and identify where i have gone wrong. I am using STATA/IC 13.1. The error messages I am getting are like "nlsuraids returned 102 verify that nlsuraids is a function evaluator program" (Earlier I got number 199 as well). Quick response is much appreciated.
    Manoj

    * function evaluator program ***************************** program nlsuraids
    version 13
    syntax varlist(min=18 max=18) if, at(name)
    tokenize `varlist'
    args w1 w2 w3 w4 w5 w6 w7 w8 lnp1 lnp2 lnp3 lnp4 lnp5 lnp6 lnp7 lnp8 lnp9 lnm
    tempname a1 a2 a3 a4 a5 a6 a7 a8 a9
    scalar `a1' = `at'[1,1]
    scalar `a2' = `at'[1,2]
    scalar `a3' = `at'[1,3]
    scalar `a4' = `at'[1,4]
    scalar `a5' = `at'[1,5]
    scalar `a6' = `at'[1,6]
    scalar `a7' = `at'[1,7]
    scalar `a8' = `at'[1,8]
    scalar `a9' = 1 - `a1' - `a2' - `a3'- `a4' - `a5' - `a6'- `a7' - `a8'
    tempname b1 b2 b3 b4 b5 b6 b7 b8
    scalar `b1' = `at'[1,9]
    scalar `b2' = `at'[1,10]
    scalar `b3' = `at'[1,11]
    scalar `b4' = `at'[1,12]
    scalar `b5' = `at'[1,13]
    scalar `b6' = `at'[1,14]
    scalar `b7' = `at'[1,15]
    scalar `b8' = `at'[1,16]
    tempname g11 g12 g13 g14 g15 g16 g17 g18 g19
    tempname g21 g22 g23 g24 g25 g26 g27 g28 g29
    tempname g31 g32 g33 g34 g35 g36 g37 g38 g39
    tempname g41 g42 g43 g44 g45 g46 g47 g48 g49
    tempname g51 g52 g53 g54 g55 g56 g57 g58 g59
    tempname g61 g62 g63 g64 g65 g66 g67 g68 g69
    tempname g71 g72 g73 g74 g75 g76 g77 g78 g79
    tempname g81 g82 g83 g84 g85 g86 g87 g88 g89
    tempname g91 g92 g93 g94 g95 g96 g97 g98 g99
    scalar `g11' = `at'[1,17]
    scalar `g12' = `at'[1,18]
    scalar `g13' = `at'[1,19]
    scalar `g14' = `at'[1,20]
    scalar `g15' = `at'[1,21]
    scalar `g16' = `at'[1,22]
    scalar `g17' = `at'[1,23]
    scalar `g18' = `at'[1,24]
    scalar `g19' = -`g11'-`g12'-`g13'-`g14'-`g15'-`g16'-`g17'-`g18'
    scalar `g21' = `g12'
    scalar `g22' = `at'[1,25]
    scalar `g23' = `at'[1,26]
    scalar `g24' = `at'[1,27]
    scalar `g25' = `at'[1,28]
    scalar `g26' = `at'[1,29]
    scalar `g27' = `at'[1,30]
    scalar `g28' = `at'[1,31]
    scalar `g29' = -`g21'-`g22'-`g23'-`g24'-`g25'-`g26'-`g27'-`g28'
    scalar `g31' = `g13'
    scalar `g32' = `g23'
    scalar `g33' = `at'[1,32]
    scalar `g34' = `at'[1,33]
    scalar `g35' = `at'[1,34]
    scalar `g36' = `at'[1,35]
    scalar `g37' = `at'[1,36]
    scalar `g38' = `at'[1,37]
    scalar `g39' = -`g31'-`g32'-`g33'-`g34'-`g35'-`g36'-`g37'-`g38'
    scalar `g41' = `g14'
    scalar `g42' = `g24'
    scalar `g43' = `g34'
    scalar `g44' = `at'[1,38]
    scalar `g45' = `at'[1,39]
    scalar `g46' = `at'[1,40]
    scalar `g47' = `at'[1,41]
    scalar `g48' = `at'[1,42]
    scalar `g49' = -`g41'-`g42'-`g43'-`g44'-`g45'-`g46'-`g47'-`g48'
    scalar `g51' = `g15'
    scalar `g52' = `g25'
    scalar `g53' = `g35'
    scalar `g54' = `g45'
    scalar `g55' = `at'[1,43]
    scalar `g56' = `at'[1,44]
    scalar `g57' = `at'[1,45]
    scalar `g58' = `at'[1,46]
    scalar `g59' = -`g51'-`g52'-`g53'-`g54'-`g55'-`g56'-`g57'-`g58'
    scalar `g61' = `g16'
    scalar `g62' = `g26'
    scalar `g63' = `g36'
    scalar `g64' = `g46'
    scalar `g65' = `g56'
    scalar `g66' = `at'[1,47]
    scalar `g67' = `at'[1,48]
    scalar `g68' = `at'[1,49]
    scalar `g69' = -`g61'-`g62'-`g63'-`g64'-`g65'-`g66'-`g67'-`g68'
    scalar `g71' = `g17'
    scalar `g72' = `g27'
    scalar `g73' = `g37'
    scalar `g74' = `g47'
    scalar `g75' = `g57'
    scalar `g76' = `g67'
    scalar `g77' = `at'[1,50]
    scalar `g78' = `at'[1,51]
    scalar `g79' = -`g71'-`g72'-`g73'-`g74'-`g75'-`g76'-`g77'-`g78'
    scalar `g81' = `g18'
    scalar `g82' = `g28'
    scalar `g83' = `g38'
    scalar `g84' = `g48'
    scalar `g85' = `g58'
    scalar `g86' = `g68'
    scalar `g87' = `g78'
    scalar `g88' = `at'[1,52]
    scalar `g89' = -`g81'-`g82'-`g83'-`g84'-`g85'-`g86'-`g87'-`g88'
    scalar `g91' = `g19'
    scalar `g92' = `g29'
    scalar `g93' = `g39'
    scalar `g94' = `g49'
    scalar `g95' = `g59'
    scalar `g96' = `g69'
    scalar `g97' = `g79'
    scalar `g98' = `g89'
    scalar `g99' = -`g91'-`g92'-`g93'-`g94'-`g95'-`g96'-`g97'-`g98'

    quietly {
    tempvar
    gen double `lnpindex' = 5 + `a1'*`lnp1' + `a2'*`lnp2' + `a3'*`lnp3' + ///
    `a4'*`lnp4' + `a5'*`lnp5' + `a6'*`lnp6' + ///
    `a7'*`lnp7' + `a8'*`lnp8' + `a9'*`lnp9'

    forvalues i = 1/9 {
    forvalues j = 1/9 {
    replace `lnpindex' = `lnpindex' + 0.5*`g`i'`j''*`lnp`i''*`lnp`j''
    }
    }
    replace `w1' = `a1' + `g11'*`lnp1' + `g12'*`lnp2' + `g13'*`lnp3' +///
    `g14'*`lnp4' + `g15'*`lnp5'+ `g16'*`lnp6' +///
    `g17'*`lnp7' + `g18'*`lnp8'+ `g19'*`lnp9' +///
    `b1'*(`lnm' - `lnpindex')


    replace `w2' = `a2' + `g21'*`lnp1' + `g22'*`lnp2' + `g23'*`lnp3' +///
    `g24'*`lnp4' + `g25'*`lnp5'+ `g26'*`lnp6' +///
    `g27'*`lnp7' + `g28'*`lnp8'+ `g29'*`lnp9' +///
    `b2'*(`lnm' - `lnpindex')



    replace `w3' = `a3' + `g31'*`lnp1' + `g32'*`lnp2' + `g33'*`lnp3' +///
    `g34'*`lnp4' + `g35'*`lnp5'+ `g36'*`lnp6' +///
    `g37'*`lnp7' + `g38'*`lnp8'+ `g39'*`lnp9' +///
    `b3'*(`lnm' - `lnpindex')


    replace `w4' = `a4' + `g41'*`lnp1' + `g42'*`lnp2' + `g43'*`lnp3' +///
    `g44'*`lnp4' + `g45'*`lnp5'+ `g46'*`lnp6' +///
    `g47'*`lnp7' + `g48'*`lnp8'+ `g49'*`lnp9' +///
    `b4'*(`lnm' - `lnpindex')


    replace `w5' = `a5' + `g51'*`lnp1' + `g52'*`lnp2' + `g53'*`lnp3' +///
    `g54'*`lnp4' + `g55'*`lnp5'+ `g56'*`lnp6' +///
    `g57'*`lnp7' + `g58'*`lnp8'+ `g59'*`lnp9' +///
    `b5'*(`lnm' - `lnpindex')



    replace `w6' = `a6' + `g61'*`lnp1' + `g62'*`lnp2' + `g63'*`lnp3' +///
    `g64'*`lnp4' + `g65'*`lnp5'+ `g66'*`lnp6' +///
    `g67'*`lnp7' + `g68'*`lnp8'+ `g69'*`lnp9' +///
    `b6'*(`lnm' - `lnpindex')


    replace `w7' = `a7' + `g71'*`lnp1' + `g72'*`lnp2' + `g73'*`lnp3' +///
    `g74'*`lnp4' + `g75'*`lnp5'+ `g76'*`lnp6' +///
    `g77'*`lnp7' + `g78'*`lnp8'+ `g79'*`lnp9' +///
    `b7'*(`lnm' - `lnpindex')


    replace `w8' = `a8' + `g81'*`lnp1' + `g82'*`lnp2' + `g83'*`lnp3' +///
    `g84'*`lnp4' + `g85'*`lnp5'+ `g86'*`lnp6' +///
    `g87'*`lnp7' + `g88'*`lnp8'+ `g89'*`lnp9' +///
    `b8'*(`lnm' - `lnpindex')


    }
    end


    nlsur aids @ w1 w2 w3 w4 w5 w6 w7 w8 lnp1 lnp2 lnp3 lnp4 lnp5 lnp6 lnp7 lnp8 lnp9 lnm,parameters(a1 a2 a3 a4 a5 a6 a7 a8 b1 b2 b3 b4 b5 b6 b7 b8 g11 g12 g13 g14 g15 g16 g17 g18 g22 g23 g24 g25 g26 g27 g28 g33 g34 g35 g36 g37 g38 g44 g45 g46 g47 g48 g55 g56 g57 g58 g66 g67 g68 g77 g78 g88) nequations(8) ifgnls


  • #2
    Almost ideal demand systems no longer have to be coded by hand unless you are doing something different from the standard model. Are you aware of Brian Poi's quaids command? Type
    Code:
    ssc install quaids
    Jorge Eduardo Pérez Pérez
    www.jorgeperezperez.com

    Comment


    • #3
      You have tempvar

      by itself just before you try to generate `lnpindex'

      You presumably mean tempvar lnpindex

      Comment


      • #4
        Dear Stata listers,

        I am Estimating QUAIDS model for 4 goods with Stata 12, I installed Brian poi's package, then tried the

        Code:

        quaids w1-w4, anot(0) prices(p1-p4) expenditure(exp)

        I received the following message:
        nlsur__quaids returned 198
        verify that nlsur__quaids is a function evaluator program

        so, I tried this

        code:
        nlsur__quaids w1-w4, anot(0) prices(p1-p4) expenditure(exp)

        but got this message:
        if exp required

        your help and response would be appreciated, thanks in advance



        Comment


        • #5
          Are you using the latest version of Brian Poi's package? Try to update the package first:

          Code:
          adoupdate, update
          If your code is still not working after the update, does the following example work for you?

          Code:
          webuse food, clear
          quaids w1-w4, anot(0) prices(p1-p4) expenditure(exp)
          Jorge Eduardo Pérez Pérez
          www.jorgeperezperez.com

          Comment


          • #6
            Dear Mr. Perez,

            Did the update, and found that installed package is up to date, tried to run your example but received same message;

            nlsur__quaids returned 198
            verify that nlsur__quaids is a function evaluator program

            Comment


            • #7
              What may be happening is that the latest version of quaids requires Stata 13, and you only have Stata 12. I forgot about that but I experienced this issue. There are two approaches you can take:

              1. (Recommended) Recompile the mata library in Stata 12, following the instructions in this thread.


              http://www.stata.com/statalist/archi.../msg00684.html

              After that, try the example again.

              2. Uninstall the latest version of quaids, and install the previous version. This has a caveat: The old version has a couple of bugs and the new version adds functionality, as documented here:

              http://www.stata-journal.com/sjpdf.h...iclenum=up0041

              In any case, if you want to use the old version, type this to install it:

              Code:
              ado uninstall st0268_1
              net sj 12-3 st0268
              net install st0268
              Jorge Eduardo Pérez Pérez
              www.jorgeperezperez.com

              Comment


              • #8
                Dear Mr. Perez,

                I did recompile Mata library, still refuses to run the code,

                code:
                quaids w1-w4, anot(0) prices(p1-p4) expenditure(exp) noquadratic

                but suggests running:
                nlsur__quaids w1-w4, anot(0) prices(p1-p4) expenditure(exp) noquadratic

                to get rid of the message : nlsur__quaids returned 198
                verify that nlsur__quaids is a function evaluator program


                but require adding: if exp , so it be in the form

                nlsur__quaids w1-w4 [if] [in] , anot(0) prices(p1-p4) expenditure(exp) noquadratic

                My problem is what to specify in this if exp?

                Best regards


                Comment


                • #9
                  Ok, so you recompiled the library. Are you trying the example, or is it failing to run with your data? If the example runs, the problem is with your data. If the example doesn't run, then the problem is with the quaids routine.

                  Code:
                  webuse food
                  Code:
                  quaids w1-w4, anot(0) prices(p1-p4) expenditure(exp)


                  Jorge Eduardo Pérez Pérez
                  www.jorgeperezperez.com

                  Comment


                  • #10
                    The example also doesn't run, only works if i added nslur to the code

                    code:
                    nlsur__quaids w1-w4, anot(0) prices(p1-p4) expenditure(exp) but then asks for this:
                    if exp required
                    r(100);

                    Comment


                    • #11
                      This one is proving hard to pin down. Please copy and paste this in the Stata command window and post the produced log file. I want the output for the quaids command.

                      Code:
                      cap log close
                      log using error.txt, text replace
                      set trace on
                      set tracedepth 2
                      which quaids.ado
                      webuse food, clear
                      quaids w1-w4, anot(0) prices(p1-p4) expenditure(exp)
                      set trace off
                      log close
                      Jorge Eduardo Pérez Pérez
                      www.jorgeperezperez.com

                      Comment


                      • #12
                        here it is:

                        --------------------------------------------------------------------------------------------------------------------------------------------
                        name: <unnamed>
                        log: E:\books MEPS\Prof. Beck\Stata12_WinX86_x64\error.txt
                        log type: text
                        opened on: 20 Aug 2015, 21:08:26

                        .
                        . set trace on

                        .
                        . set tracedepth 2

                        .
                        . which quaids.ado
                        c:\ado\plus\q\quaids.ado
                        *! version 1.1.0 24jul2013

                        .
                        . webuse food, clear
                        --------------------------------------------------------------------------------------------------------------------------- begin webuse ---
                        - version 8
                        - if `"`0'"' == "" {
                        = if `"food, clear"' == "" {
                        error 198
                        }
                        - gettoken sub : 0, parse(" ,") quotes
                        - if `"`sub'"'=="set" | `"`sub'"'=="query" {
                        = if `"food"'=="set" | `"food"'=="query" {
                        gettoken sub 0 : 0, parse(" ,")
                        if "`sub'"=="set" {
                        Set `0'
                        }
                        else Query `0'
                        exit
                        }
                        - local 0 `"using `0'"'
                        = local 0 `"using food, clear"'
                        - syntax using/ [, CLEAR noLabel]
                        - GetDefault prefix
                        -------------------------------------------------------------------------------------------------------------- begin webuse.GetDefault ---
                        - args d
                        - if `"$S_WEB"'=="" {
                        = if `""'=="" {
                        - c_local `d' "http://www.stata-press.com/data/r12"
                        = c_local prefix "http://www.stata-press.com/data/r12"
                        - }
                        - else c_local `d' `"$S_WEB"'
                        = else c_local prefix `""'
                        ---------------------------------------------------------------------------------------------------------------- end webuse.GetDefault ---
                        - capture noisily use `"`prefix'/`using'"', `clear' `label'
                        = capture noisily use `"http://www.stata-press.com/data/r12/food"', clear
                        - if _rc==0 {
                        - capture window menu add_recentfiles `"`prefix'/`using'"', rlevel(1)
                        = capture window menu add_recentfiles `"http://www.stata-press.com/data/r12/food"', rlevel(1)
                        - }
                        - else {
                        exit _rc
                        }
                        ----------------------------------------------------------------------------------------------------------------------------- end webuse ---

                        .
                        . quaids w1-w4, anot(0) prices(p1-p4) expenditure(exp)
                        --------------------------------------------------------------------------------------------------------------------------- begin quaids ---
                        - version 12
                        - if replay() {
                        if "`e(cmd)'" != "quaids" {
                        error 301
                        }
                        Display `0'
                        exit
                        }
                        - Estimate `0'
                        = Estimate w1-w4, anot(0) prices(p1-p4) expenditure(exp)
                        ---------------------------------------------------------------------------------------------------------------- begin quaids.Estimate ---
                        - version 12
                        - syntax varlist [if] [in] , ANOT(real) [ LNEXPenditure(varlist min=1 max=1 numeric) EXPenditure(varlist min=1 max=1 numeric) PRices(varli
                        > st numeric) LNPRices(varlist numeric) DEMOgraphics(varlist numeric) noQUadratic INITial(name) noLOg Level(cilevel) VCE(passthru) IFGNLSIte
                        > rate(integer 20) ITerate(integer 250) * ]
                        - local shares `varlist'
                        = local shares w1 w2 w3 w4
                        - if "`options'" != "" {
                        = if "" != "" {
                        di as error "`options' not allowed"
                        exit 198
                        }
                        - if "`prices'" != "" & "`lnprices'" != "" {
                        = if "p1 p2 p3 p4" != "" & "" != "" {
                        di as error "cannot specify both {cmd:prices()} and " as error "{cmd:lnprices()}"
                        exit 198
                        }
                        - if "`prices'`lnprices'" == "" {
                        = if "p1 p2 p3 p4" == "" {
                        di as error "must specify {cmd:prices()} or {cmd:lnprices()}"
                        exit 198
                        }
                        - if "`expenditure'" != "" & "`lnexpenditure'" != "" {
                        = if "expfd" != "" & "" != "" {
                        di as error "cannot specify both {cmd:expenditure()} " as error "and {cmd:lnexpenditure()}"
                        exit 198
                        }
                        - if "`expenditure'`lnexpenditure'" == "" {
                        = if "expfd" == "" {
                        di as error "must specify {cmd:expenditure()} or {cmd:lnexpenditure()}"
                        exit 198
                        }
                        - local neqn : word count `shares'
                        = local neqn : word count w1 w2 w3 w4
                        - if `neqn' < 3 {
                        = if 4 < 3 {
                        di as error "must specify at least 3 expenditure shares"
                        exit 498
                        }
                        - if `=`:word count `prices'' + `:word count `lnprices''' != `neqn' {
                        = if 4 != 4 {
                        if "`prices'" != "" {
                        di as error "number of price variables must " as error "equal number of equations " as error "(`neqn')"
                        }
                        else {
                        di as error "number of log price variables " as error "must equal number of " as error "equations (`neqn')"
                        }
                        exit 498
                        }
                        - marksample touse
                        - markout `touse' `prices' `lnprices' `demographics'
                        = markout __000000 p1 p2 p3 p4
                        - markout `touse' `expenditure' `lnexpenditure'
                        = markout __000000 expfd
                        - local i 1
                        - while (`i' < `neqn') {
                        = while (1 < 4) {
                        - local shares2 `shares2' `:word `i' of `shares''
                        = local shares2 w1
                        - local `++i'
                        = local 2
                        - }
                        - while (`i' < `neqn') {
                        = while (2 < 4) {
                        - local shares2 `shares2' `:word `i' of `shares''
                        = local shares2 w1 w2
                        - local `++i'
                        = local 3
                        - }
                        - while (`i' < `neqn') {
                        = while (3 < 4) {
                        - local shares2 `shares2' `:word `i' of `shares''
                        = local shares2 w1 w2 w3
                        - local `++i'
                        = local 4
                        - }
                        - while (`i' < `neqn') {
                        = while (4 < 4) {
                        local shares2 `shares2' `:word `i' of `shares''
                        local `++i'
                        }
                        - tempvar sumw
                        - egen double `sumw' = rsum(`shares') if `touse'
                        = egen double __000001 = rsum(w1 w2 w3 w4) if __000000
                        - cap assert reldif(`sumw', 1) < 1e-4 if `touse'
                        = cap assert reldif(__000001, 1) < 1e-4 if __000000
                        - if _rc {
                        di as error "expenditure shares do not sum to one"
                        exit 499
                        }
                        - if "`prices'" != "" {
                        = if "p1 p2 p3 p4" != "" {
                        - local usrprices 1
                        - local lnprices
                        - foreach x of varlist `prices' {
                        = foreach x of varlist p1 p2 p3 p4 {
                        - summ `x' if `touse', mean
                        = summ p1 if __000000, mean
                        - if r(min) <= 0 {
                        di as error "nonpositive value(s) for `x' found"
                        exit 499
                        }
                        - tempvar ln`x'
                        = tempvar lnp1
                        - qui gen double `ln`x'' = ln(`x') if `touse'
                        = qui gen double __000002 = ln(p1) if __000000
                        - local lnprices `lnprices' `ln`x''
                        = local lnprices __000002
                        - }
                        - summ `x' if `touse', mean
                        = summ p2 if __000000, mean
                        - if r(min) <= 0 {
                        di as error "nonpositive value(s) for `x' found"
                        exit 499
                        }
                        - tempvar ln`x'
                        = tempvar lnp2
                        - qui gen double `ln`x'' = ln(`x') if `touse'
                        = qui gen double __000003 = ln(p2) if __000000
                        - local lnprices `lnprices' `ln`x''
                        = local lnprices __000002 __000003
                        - }
                        - summ `x' if `touse', mean
                        = summ p3 if __000000, mean
                        - if r(min) <= 0 {
                        di as error "nonpositive value(s) for `x' found"
                        exit 499
                        }
                        - tempvar ln`x'
                        = tempvar lnp3
                        - qui gen double `ln`x'' = ln(`x') if `touse'
                        = qui gen double __000004 = ln(p3) if __000000
                        - local lnprices `lnprices' `ln`x''
                        = local lnprices __000002 __000003 __000004
                        - }
                        - summ `x' if `touse', mean
                        = summ p4 if __000000, mean
                        - if r(min) <= 0 {
                        di as error "nonpositive value(s) for `x' found"
                        exit 499
                        }
                        - tempvar ln`x'
                        = tempvar lnp4
                        - qui gen double `ln`x'' = ln(`x') if `touse'
                        = qui gen double __000005 = ln(p4) if __000000
                        - local lnprices `lnprices' `ln`x''
                        = local lnprices __000002 __000003 __000004 __000005
                        - }
                        - }
                        - if "`expenditure'" != "" {
                        = if "expfd" != "" {
                        - local usrexpenditure 1
                        - summ `expenditure' if `touse', mean
                        = summ expfd if __000000, mean
                        - if r(min) <= 0 {
                        di as error "nonpositive value(s) for " as error "`expenditure' found"
                        exit 499
                        }
                        - tempvar lnexp
                        - qui gen double `lnexp' = ln(`expenditure') if `touse'
                        = qui gen double __000006 = ln(expfd) if __000000
                        - local lnexpenditure `lnexp'
                        = local lnexpenditure __000006
                        - }
                        - if "`quadratic'" == "noquadratic" {
                        = if "" == "noquadratic" {
                        local np = 2*(`neqn'-1) + `neqn'*(`neqn'-1)/2
                        }
                        - else {
                        - local np = 3*(`neqn'-1) + `neqn'*(`neqn'-1)/2
                        = local np = 3*(4-1) + 4*(4-1)/2
                        - }
                        - if "`demographics'" == "" {
                        = if "" == "" {
                        - local demos "nodemos"
                        - local demoopt ""
                        - local ndemos = 0
                        - }
                        - else {
                        local demos ""
                        local demoopt "demographics(`demographics')"
                        local ndemos : word count `demographics'
                        local np = `np' + `ndemos'*(`neqn'-1) + `ndemos'
                        }
                        - if "`initial'" != "" {
                        = if "" != "" {
                        local rf = rowsof(`initial')
                        local cf = colsof(`initial')
                        if `rf' != 1 | `cf' != `np' {
                        di "Initial vector must be 1 x `np'"
                        exit 503
                        }
                        else {
                        local initialopt initial(`initial')
                        }
                        }
                        - nlsur __quaids @ `shares2' if `touse', lnp(`lnprices') lnexp(`lnexpenditure') a0(`anot') nparam(`np') neq(`=`neqn'-1') ifgnls noeqtab no
                        > coeftab `quadratic' `options' `demoopt' `initialopt' `log' `vce' ifgnlsiterate(`ifgnlsiterate') iterate(`iterate')
                        = nlsur __quaids @ w1 w2 w3 if __000000, lnp(__000002 __000003 __000004 __000005) lnexp(__000006) a0(0) nparam(15) neq(3) ifgnls noeqtab n
                        > ocoeftab ifgnlsiterate(20) iterate(250)
                        nlsur__quaids returned 198
                        verify that nlsur__quaids is a function evaluator program
                        ------------------------------------------------------------------------------------------------------------------ end quaids.Estimate ---
                        ----------------------------------------------------------------------------------------------------------------------------- end quaids ---
                        r(198);

                        .
                        . set trace off

                        .
                        . log close
                        name: <unnamed>
                        log: E:\books MEPS\Prof. Beck\Stata12_WinX86_x64\error.txt
                        log type: text
                        closed on: 20 Aug 2015, 21:08:31

                        Comment


                        • #13
                          This suggests that somehow you have a corrupted version of the quaids routine. Please try option 2) above and try to run the example again.
                          Jorge Eduardo Pérez Pérez
                          www.jorgeperezperez.com

                          Comment


                          • #14
                            Thanks, now it worked

                            Comment


                            • #15
                              Dear STATA users,
                              In order to try to incorporate demographics and correction for zero consumption, I am trying to run the following model using the nlsur program for four goods. However, when I run it STATA shows error message 'nlsurqaids returned 199 verify, that nlsurqaids is a function evaluator program'. I have tried several times but could not identify any errors. Any help would be greatly appreciated. My code is as follows:
                              program nlsurqaids
                              version 13
                              syntax varlist(min=17 max=17) if, at(name)
                              tokenize `varlist'
                              args w1 w2 w3 lnprice1 lnprice2 lnprice3 lnprice4 lnexptot dmem location poverty pdf1 pdf2 pdf3 cdf1 cdf2 cdf3
                              // With four goods, parameters can be // estimated, after eliminating one of the goods and // imposing adding up, symmetry, and homogeneity // constraints, in the QUAIDS model // Here, we extract those parameters from the `at'vector, and impose constraints as we go along
                              ///Here, since after incorporating cdf and pdf the right hand side will not add up to one, coefficients of all equations are obtained///
                              tempname a1 a2 a3 a4
                              scalar `a1' = `at'[1,1]
                              scalar `a2' = `at'[1,2]
                              scalar `a3' = `at'[1,3]
                              scalar `a4' = 1 - `a1' - `a2' - `a3'
                              tempname b1 b2 b3 b4
                              scalar `b1' = `at'[1,4]
                              scalar `b2' = `at'[1,5]
                              scalar `b3' = `at'[1,6]
                              scalar `b4' = - `b1' - `b2' - `b3'
                              tempname g11 g12 g13 g14
                              tempname g21 g22 g23 g24
                              tempname g31 g32 g33 g34
                              tempname g41 g42 g43 g44
                              scalar `g11' = `at'[1,7]
                              scalar `g12' = `at'[1,8]
                              scalar `g13' = `at'[1,9]
                              scalar `g14' = - `g11' - `g12' - `q13'
                              scalar `g21' = `g12'
                              scalar `g22' = `at'[1,10]
                              scalar `g23' = `at'[1,11]
                              scalar `g24' = - `g21' - `g22' - `g23'
                              scalar `g31' = `g13'
                              scalar `g32' = `g23'
                              scalar `g33' = `at'[1,12]
                              scalar `g34' = - `g31' - `g32' -`g33'
                              scalar `g41' = `g14'
                              scalar `g42' = `g24'
                              scalar `g43' = `g34'
                              scalar `g44' = - `g41' - `g42' - `g43'
                              tempname L1 L2 L3 L4
                              scalar `L1' = `at'[1,13]
                              scalar `L2' = `at'[1,14]
                              scalar `L3' = `at'[1,15]
                              scalar `L4' = - `L1' - `L2' - `L3'
                              // constant and household demographics
                              tempname r12 r13 r14
                              tempname r22 r23 r24
                              tempname r32 r33 r34
                              tempname r42 r43 r44
                              scalar `r12' = `at'[1,16]
                              scalar `r13' = `at'[1,17]
                              scalar `r14' = `at'[1,18]
                              scalar `r22' = `at'[1,19]
                              scalar `r23' = `at'[1,20]
                              scalar `r24' = `at'[1,21]
                              scalar `r32' = `at'[1,22]
                              scalar `r33' = `at'[1,23]
                              scalar `r34' = `at'[1,24]
                              scalar `r42' = `at'[1,25]
                              scalar `r43' = `at'[1,26]
                              scalar `r44' = `at'[1,27]
                              // pdf
                              tempname d1 d2 d3 d4
                              scalar `d1' = `at'[1,28]
                              scalar `d2' = `at'[1,29]
                              scalar `d3' = `at'[1,30]
                              scalar `d4' = `at'[1,31]
                              //// Okay, now that we have all the parameters, we can // calculate the expenditure shares.
                              // Okay, now that we have all the parameters, we can // calculate the expenditure shares.
                              quietly {
                              tempvar lnpindex
                              gen double `lnpindex' = 4 + `a1'*`lnprice1' + `a2'*`lnprice2' + `a3'*`lnprice3' + `a4'*`lnprice4'
                              forvalues i = 1/4 {
                              forvalues j = 1/4 {
                              replace `lnpindex' = `lnpindex' + 0.5*`g`i'`j''*`lnprice`i''*`lnprice`j''
                              }
                              }
                              // The b(p) term in the QUAIDS model:
                              tempvar bofp
                              gen double `bofp' = 0
                              forvalues i = 1/4 {
                              replace `bofp' = `bofp' + `lnprice`i''*`b`i''
                              }
                              replace `bofp' = exp(`bofp')


                              replace `w1' = (`a1' + `g11'*`lnprice1' + `g12'*`lnprice2' + `g13'*`lnprice3' + `g14'*`lnprice4' + `b1'*(`lnexptot' - `lnpindex') + `L1'/`bofp'*(`lnexptot' - `lnpindex')^2 + `r12'*`dmem' + `r13'*`location' + `r14'*`poverty')*`cdf1' + `d1'*`pdf1'

                              replace `w2' = (`a2' + `g21'*`lnprice1' + `g22'*`lnprice2' + `g23'*`lnprice3' + `g24'*`lnprice4' + `b2'*(`lnexptot' - `lnpindex') + `L2'/`bofp'*(`lnexptot' - `lnpindex')^2 + `r22'*`dmem' + `r23'*`location' + `r24'*`poverty')*`cdf2' + `d2'*`pdf2'

                              replace `w3' = (`a3' + `g31'*`lnprice1' + `g32'*`lnprice2' + `g33'*`lnprice3' + `g34'*`lnprice4' + `b3'*(`lnexptot' - `lnpindex') + `L3'/`bofp'*(`lnexptot' - `lnpindex')^2 + `r32'*`dmem' + `r33'*`location' + `r34'*`poverty')*`cdf3' + `d3'*`pdf3'


                              }
                              end

                              nlsur qaids @ w1 w2 w3 lnprice1 lnprice2 lnprice3 lnprice4 lnexptot dmem location poverty pdf1 pdf2 pdf3 cdf1 cdf2 cdf3, parameters(a1 a2 a3 b1 b2 b3 g11 g12 g13 g14 g22 g23 g24 g33 g34 L1 L2 L3 r12 r13 r14 r22 r23 r24 r32 r33 r34 d1 d2 d3) ifgnls nequations(3)



                              Comment

                              Working...
                              X