Announcement

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

  • Levpet r(2000)

    Hello,

    I am using the levpet command on a subsample of my observations (specific sector and year). Here is the code I am executing:

    levpet ln_real_VA if NACESHORT==10 & year==2005, free(ln_L) proxy(ln_real_M) capital(ln_real_K) reps(20) level(99)

    Unfortunately, Stata keeps sending me back this error message:

    "no observations
    r(2000);"

    The error remains even if I change year or sector.
    If I instead use revenues I get a different, yet very similar message.


    . levpet ln_real_T if NACESHORT==10 & year==2005, free(ln_L) proxy(ln_real_M) capital(ln_real_
    > K) reps(20) level(99) revenue
    no observations
    error #2000 occurred in program nllp_bs_gmm
    r(196);

    I am fairly sure there are observation for the subsample since:

    count if !missing( ln_real_K, ln_real_M, ln_real_T, ln_real_VA, ln_L) & NACESHORT==10 & year
    > ==2005
    1167

    Where I am getting this wrong?

    Thank you for your help,

    Luca

  • #2
    Note that being not missing doesn't rule out being string, so check for accidental string variables in there.

    Code:
    . sysuse auto
    (1978 Automobile Data)
    
    . count if !missing(make)
       74
    
    . count if !missing(make, mpg)
       74

    Comment


    • #3
      Having read in the previous discussions, I also had checked for string variables, and seemed to me there was none. Anyway I post here the results:


      . describe ln* mark year

      storage display value
      variable name type format label variable label
      ----------------------------------------------------------------------------------------------------
      ln_real_K float %9.0g
      ln_real_M float %9.0g
      ln_real_T float %9.0g
      ln_real_VA float %9.0g
      ln_L float %9.0g
      mark float %9.0g
      year int %9.0g

      Am I wrong?

      Thank you for your prompt reply.

      Comment


      • #4
        You are right. The problem lies elsewhere and I can't say what it is. Perhaps use

        Code:
         
        set trace on
        to see where the program stops.

        Comment


        • #5
          I did so, altough I was not able to interpret the results. I post here the part where the code stops.

          I presume I could have started from later on.
          [...]


          ---------------------------------------------------------------- begin _get_diopts ---
          - version 11
          - local DIOPTS Level(cilevel) vsquish NOALLBASElevels ALLBASElevels NOBASElevels BASEl
          > evels noCNSReport FULLCNSReport NOEMPTYcells EMPTYcells NOOMITted OMITted NOLSTRETCH LSTRETCH COEF
          > Legend SELEGEND cformat(string) sformat(string) pformat(string) CODING COMPARE
          - syntax namelist(max=2) [, `DIOPTS' *]
          = syntax namelist(max=2) [, Level(cilevel) vsquish NOALLBASElevels ALLBASElevels NOBAS
          > Elevels BASElevels noCNSReport FULLCNSReport NOEMPTYcells EMPTYcells NOOMITted OMITted NOLSTRETCH
          > LSTRETCH COEFLegend SELEGEND cformat(string) sformat(string) pformat(string) CODING COMPARE *]
          - opts_exclusive "`allbaselevels' `noallbaselevels'"
          = opts_exclusive " "
          ----------------------------------------------------------- begin opts_exclusive ---
          - version 8.2
          - args opts optname errcode
          - local opts `opts'
          = local opts
          - local n 0
          - while `"`opts'"' != "" {
          = while `""' != "" {
          local ++n
          gettoken item`n' opts : opts, bind
          }
          - if `n' < 2 {
          = if 0 < 2 {
          - exit
          ------------------------------------------------------------- end opts_exclusive ---
          - opts_exclusive "`allbaselevels' `nobaselevels'"
          = opts_exclusive " "
          ----------------------------------------------------------- begin opts_exclusive ---
          - version 8.2
          - args opts optname errcode
          - local opts `opts'
          = local opts
          - local n 0
          - while `"`opts'"' != "" {
          = while `""' != "" {
          local ++n
          gettoken item`n' opts : opts, bind
          }
          - if `n' < 2 {
          = if 0 < 2 {
          - exit
          ------------------------------------------------------------- end opts_exclusive ---
          - opts_exclusive "`baselevels' `nobaselevels'"
          = opts_exclusive " "
          ----------------------------------------------------------- begin opts_exclusive ---
          - version 8.2
          - args opts optname errcode
          - local opts `opts'
          = local opts
          - local n 0
          - while `"`opts'"' != "" {
          = while `""' != "" {
          local ++n
          gettoken item`n' opts : opts, bind
          }
          - if `n' < 2 {
          = if 0 < 2 {
          - exit
          ------------------------------------------------------------- end opts_exclusive ---
          - opts_exclusive "`emptycells' `noemptycells'"
          = opts_exclusive " "
          ----------------------------------------------------------- begin opts_exclusive ---
          - version 8.2
          - args opts optname errcode
          - local opts `opts'
          = local opts
          - local n 0
          - while `"`opts'"' != "" {
          = while `""' != "" {
          local ++n
          gettoken item`n' opts : opts, bind
          }
          - if `n' < 2 {
          = if 0 < 2 {
          - exit
          ------------------------------------------------------------- end opts_exclusive ---
          - opts_exclusive "`omitted' `noomitted'"
          = opts_exclusive " "
          ----------------------------------------------------------- begin opts_exclusive ---
          - version 8.2
          - args opts optname errcode
          - local opts `opts'
          = local opts
          - local n 0
          - while `"`opts'"' != "" {
          = while `""' != "" {
          local ++n
          gettoken item`n' opts : opts, bind
          }
          - if `n' < 2 {
          = if 0 < 2 {
          - exit
          ------------------------------------------------------------- end opts_exclusive ---
          - opts_exclusive "`lstretch' `nolstretch'"
          = opts_exclusive " "
          ----------------------------------------------------------- begin opts_exclusive ---
          - version 8.2
          - args opts optname errcode
          - local opts `opts'
          = local opts
          - local n 0
          - while `"`opts'"' != "" {
          = while `""' != "" {
          local ++n
          gettoken item`n' opts : opts, bind
          }
          - if `n' < 2 {
          = if 0 < 2 {
          - exit
          ------------------------------------------------------------- end opts_exclusive ---
          - opts_exclusive "`cnsreport' `fullcnsreport'"
          = opts_exclusive " "
          ----------------------------------------------------------- begin opts_exclusive ---
          - version 8.2
          - args opts optname errcode
          - local opts `opts'
          = local opts
          - local n 0
          - while `"`opts'"' != "" {
          = while `""' != "" {
          local ++n
          gettoken item`n' opts : opts, bind
          }
          - if `n' < 2 {
          = if 0 < 2 {
          - exit
          ------------------------------------------------------------- end opts_exclusive ---
          - opts_exclusive "`coeflegend' `selegend'"
          = opts_exclusive " "
          ----------------------------------------------------------- begin opts_exclusive ---
          - version 8.2
          - args opts optname errcode
          - local opts `opts'
          = local opts
          - local n 0
          - while `"`opts'"' != "" {
          = while `""' != "" {
          local ++n
          gettoken item`n' opts : opts, bind
          }
          - if `n' < 2 {
          = if 0 < 2 {
          - exit
          ------------------------------------------------------------- end opts_exclusive ---
          - local K : list sizeof namelist
          - gettoken c_diopts c_opts : namelist
          - opts_exclusive "`coding' `compare'"
          = opts_exclusive " "
          ----------------------------------------------------------- begin opts_exclusive ---
          - version 8.2
          - args opts optname errcode
          - local opts `opts'
          = local opts
          - local n 0
          - while `"`opts'"' != "" {
          = while `""' != "" {
          local ++n
          gettoken item`n' opts : opts, bind
          }
          - if `n' < 2 {
          = if 0 < 2 {
          - exit
          ------------------------------------------------------------- end opts_exclusive ---
          - local allbaselevels `allbaselevels' `noallbaselevels'
          = local allbaselevels
          - local baselevels `baselevels' `nobaselevels'
          = local baselevels
          - local emptycells `emptycells' `noemptycells'
          = local emptycells
          - local omitted `omitted' `noomitted'
          = local omitted
          - local lstretch `lstretch' `nolstretch'
          = local lstretch
          - if "`allbaselevels'`baselevels'" == "" {
          = if "" == "" {
          - if c(showbaselevels) == "all" {
          local allbaselevels allbaselevels
          }
          - else if c(showbaselevels) == "on" {
          local baselevels baselevels
          }
          - }
          - if "`emptycells'" == "" {
          = if "" == "" {
          - if c(showemptycells) == "off" {
          local emptycells noemptycells
          }
          - }
          - if "`omitted'" == "" {
          = if "" == "" {
          - if c(showomitted) == "off" {
          local omitted noomitted
          }
          - }
          - if "`lstretch'" == "" {
          = if "" == "" {
          - if c(lstretch) == "off" {
          local lstretch nolstretch
          }
          - }
          - if `:length local cformat' {
          = if 0 {
          confirm numeric format `cformat'
          sreturn local cformat `"`cformat'"'
          local cformat `"cformat(`cformat')"'
          }
          - if `:length local sformat' {
          = if 0 {
          confirm numeric format `sformat'
          sreturn local sformat `"`sformat'"'
          local sformat `"sformat(`sformat')"'
          }
          - if `:length local pformat' {
          = if 0 {
          confirm numeric format `pformat'
          sreturn local pformat `"`pformat'"'
          local pformat `"pformat(`pformat')"'
          }
          - if `K' == 1 & `:length local options' {
          = if 2 == 1 & 0 {
          syntax namelist(max=2) [, `DIOPTS']
          }
          - if reldif(`level', c(level)) > 1e-3 {
          = if reldif(95, c(level)) > 1e-3 {
          local levelopt level(`level')
          }
          - c_local `c_diopts' `levelopt' `vsquish' `allbaselevels' `baselevels' `cnsreport' `fu
          > llcnsreport' `emptycells' `omitted' `lstretch' `coeflegend' `selegend' `cformat' `sformat' `pforma
          > t' `coding' `compare'
          = c_local diopts
          - if `K' == 2 {
          = if 2 == 2 {
          - c_local `c_opts' `"`options'"'
          = c_local options `""'
          - }
          - sreturn local coding `coding'
          = sreturn local coding
          - sreturn local compare `compare'
          = sreturn local compare
          - sreturn local level `level'
          = sreturn local level 95
          ------------------------------------------------------------------ end _get_diopts ---
          - if _by() {
          `version' `BY' BYREG `anything' `if' `in' [`weight'`exp'], `options' `diopts0' `diopts
          > ' `robust' `cluster'
          }
          - else {
          - `version' _regress `anything' `if' `in' [`weight'`exp'], `diopts0' `diopts' `options'
          > `robust' `cluster'
          = version 7, missing : _regress __00000X __00000Y __00000Z __000010 [],
          no observations
          }
          ------------------------------------------------------------------------ end regress ---
          ------------------------------------------------------------------------------ end reg ---
          --------------------------------------------------------------------------- end lp_bs_ss ---
          ----------------------------------------------------------------------------- end _linemax ---
          macro drop LP_*
          }
          -------------------------------------------------------------------------------- end lp_srch --

          [...]
          Then it keeps on going.

          Comment


          • #6
            Sorry, can't diagnose that.

            Comment


            • #7
              Hi Luca,
              The previous observations made by Nick are very thoughtful. I just want to add that levpet works with panel data. As you may know, you need to have observations for the study subject, a firm for example, at least in two years (or points in time). Then, before running the command you should use the xtset command or specify i() t().
              Nevertheless, I experienced that after checking that variables are numeric, the behavior of missing values and declaring the panel data, among others, the message "r(2000) no observations" kept appearing. What worked for me is to have consecutive years in the variable that sets the time for the panel data (xtset panelid year). My "year" variable was 2003 and 2009. When I changed this to consecutive values, for example, 1 and 2, the program worked. I wanted to share this just in case. If you can, please let us know if it works or how you solved the problem. Cheers!
              Last edited by Erick Gonzales; 19 Apr 2017, 08:00.

              Comment

              Working...
              X