Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Repeated time values within panel in levpet STATA output


From   Worku Gebeyehu <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: Repeated time values within panel in levpet STATA output
Date   Sun, 28 Feb 2010 00:09:10 -0800 (PST)

Dear Sir/Madam,
I am a PhD student doing my research on TFP of a panel of firms for the period 1996 to 2007 and the total number of observations are 8395. I have been trying to excute the following levpet command. 
levpet lny , free(lnl2 lnirm lnlrm) proxy (lnpower) capital (lnk) revenue justid grid i (eid) t (yr) reps (50)

However, I have been facing a problem of 'repeated time values within panel'. I have not faced a similar problem while estimating the same using FE, RE, OP, etc. I also tried to check the existence of dublications of years or firm idenity numbers using the stata 'dublicate report' command, I got a report of 'surplus=0'. Using set tr on, I found the following report. Because I am unable to understand what it means due to lack of knowldge in programming, I sent you with all the junk. I am sorry for that. I am stuck and strongly need your support. 

Sincerly yours, 

version 10
  - if `"`0'"' == "" {
  = if `"eid yr"' == "" {
    _ts tvar pvar, panel
    local fmt: format `tvar'
    local tsdelta : char _dta[_TSdelta]
    if "`tsdelta'" == "" {
    local tsdelta 1
    }
    tsset `pvar' `tvar', format(`fmt') delta((`tsdelta'))
    ret add
    exit
    }
  - syntax [varlist(numeric max=2 default=none)] [, CLEAR Daily Format(passthru) Generic Halfy
> early Monthly Quarterly Weekly Yearly DELta(string) Clocktime FORCE ]
  - if "`clear'" != "" {
  = if "" != "" {
    syntax [, CLEAR]
    Clear
    exit
    }
  - if "`varlist'"=="" {
  = if "eid yr"=="" {
    _ts tvar pvar, panel
    tsset `pvar' `tvar', `daily' `format' `generic' `halfyearly' `monthly' `quarterly' `weekly
> ' `yearly' `clocktime'
    ret add
    exit
    }
  - syntax varlist(numeric max=2 default=none) [ , CLEAR Daily Format(string) Generic Halfyear
> ly Monthly Quarterly Weekly Yearly DELta(string) Clocktime FORCE ]
  - local ct : word count `varlist'
  = local ct : word count eid yr
  - if `ct'==2 {
  = if 2==2 {
  - tokenize `varlist'
  = tokenize eid yr
  - local panel `1'
  = local panel eid
  - local timevar `2'
  = local timevar yr
  - }
  - else {
    local timevar `varlist'
    }
- local period `daily' `weekly' `monthly' `quarterly' `halfyearly' `yearly' `generic' `clock
> time'
  = local period        
  - if `"`format'"'!="" {
  = if `""'!="" {
    local dfltfmt "no"
    if "`period'" != "" {
    di in red "may not specify both format() and `period'"
    exit 198
    }
    local try : di `format' 2
    }
  - else if "`period'" != "" {
  = else if "" != "" {
    local ct : word count `period'
    if `ct' > 1 {
    di in red "may only specify one time-scale from " "daily, weekly, monthly, "
    di in red "quarterly, halfyearly, yearly, and generic"
    exit 198
    }
    local curfmt : format `timevar'
    local fmttype = substr("`curfmt'", 2, 1)
    if "`fmttype'" != "d" & "`fmttype'" != "t" {
    local format = "%t" + substr("`period'",1,1)
    if substr("`period'", 1, 1) == "c" {
    local dfltfmt "yes"
    }
    }
    else {
    local format `curfmt'
    }
    }
  - else {
  - local format : format `timevar'
  = local format : format yr
  - }
  - capture assert int(`timevar')==`timevar'
 = capture assert int(yr)==yr
  - if _rc {
    di in red "time variable must contain only integer values"
    exit 451
    }
  - sort `panel' `timevar'
  = sort eid yr
  - if "`panel'" != "" {
  = if "eid" != "" {
  - local bypfx "by `panel': "
  = local bypfx "by eid: "
  - }
  - if `"`format'"' != "" {
  = if `"%8.0g"' != "" {
  - format `timevar' `format'
  = format yr %8.0g
  - }
  - tempname scdelta
  - mata: _TS_p_delta("`scdelta'", "`delta'", "`timevar'")
  = mata: _TS_p_delta("__000002", "", "yr")
  - if `scdelta' == -2 {
  = if __000002 == -2 {
    di as err "invalid time-series format on `timevar'"
    exit 120
    }
  - if `scdelta' == -1 {
  = if __000002 == -1 {
    di as err "invalid argument in delta()"
    exit 198
    }
  - tempvar timedif
  - qui `bypfx' gen double `timedif' = `timevar'[_n+1] - `timevar'
  = qui by eid:  gen double __000003 = yr[_n+1] - yr
  - qui sum `timedif', meanonly
  = qui sum __000003, meanonly
  - if r(min) == 0 {
    if "`panel'" != "" {
 di in red "repeated time values within panel"
    }
    else {
    di in red "repeated time values in sample"
    }
    exit 451
    }
  - if "`force'" == "" {
  = if "" == "" {
  - if r(min) < `scdelta' {
  = if r(min) < __000002 {
    di in red "time values with period less than delta() found"
    exit 451
    }
  - }
  - Clear
    -------------------------------------------------------------------- begin tsset.Clear ---
    - char _dta[_TStvar]
    - char _dta[_TSpanel]
    - char _dta[_TSdelta]
    - char _dta[_TSitrvl]
    - char _dta[tis]
    - char _dta[iis]
    ---------------------------------------------------------------------- end tsset.Clear ---
  - nobreak {
  - char _dta[_TStvar] "`timevar'"
  = char _dta[_TStvar] "yr"
  - char _dta[_TSpanel] "`panel'"
  = char _dta[_TSpanel] "eid"
  - char _dta[_TSdelta] `: di %21x `scdelta''
  = char _dta[_TSdelta] +1.0000000000000X+000
  - char _dta[_TSitrvl] 1
  - char _dta[tis] "`timevar'"
  = char _dta[tis] "yr"
  - char _dta[iis] "`panel'"
  = char _dta[iis] "eid"
- if "`dfltfmt'" == "yes" & substr("`format'", 3, 1) == "c" {
  = if "" == "yes" & substr("%8.0g", 3, 1) == "c" {
    format `timevar' %tcDDmonCCYY_HH:MM:SS.sss
    }
  - Query
    -------------------------------------------------------------------- begin tsset.Query ---
    - local timevar `_dta[_TStvar]'
    = local timevar yr
    - local panel `_dta[_TSpanel]'
    = local panel eid
    - local delta : char _dta[_TSdelta]
    - if "`panel'" == "" {
    = if "eid" == "" {
      qui count if `timevar' - `timevar'[_n-1] != `delta' & `timevar' != . in 2/l
      local gaps = r(N)
      }
    - else {
    - qui count if `timevar' - `timevar'[_n-1] != `delta' & `timevar' != . & `panel' == `panel
> '[_n-1] in 2/l
    = qui count if yr - yr[_n-1] != +1.0000000000000X+000 & yr != . & eid == eid[_n-1] in 2/l
    - local gaps = r(N)
    - }
    - if "`panel'" == "" {
    = if "eid" == "" {
      tempvar seenvar
      local t0 = `timevar'[1]
      gen long `seenvar' = sum(`timevar' != .)
      local t1 = `timevar'[`seenvar'[_N]]
      }
    - else {
    - tempname firstob lastob
    - qui gen byte `firstob' = `panel' != . & `panel' != `panel'[_n-1]
    = qui gen byte __000004 = eid != . & eid != eid[_n-1]
    - qui sum `timevar' if `firstob', meanonly
    = qui sum yr if __000004, meanonly
    - local t0 = r(min)
    - qui gen byte `lastob' = `panel' != . & `timevar' != . & (`panel' != `panel'[_n+1] | `tim
> evar'[_n+1] == .)
    = qui gen byte __000005 = eid != . & yr != . & (eid != eid[_n+1] | yr[_n+1] == .)
    - qui sum `timevar' if `lastob', meanonly
    = qui sum yr if __000005, meanonly
    - local t1 = r(max)
    - local npanel = r(N)
    - sum `panel', meanonly
    = sum eid, meanonly
    - ret scalar imin = r(min)
    - ret scalar imax = r(max)
    - tempvar tmin tmax tcount
    - qui by `panel' : gen double `tcount' = _N if !missing(`timevar')
    = qui by eid : gen double __000008 = _N if !missing(yr)
    - capture assert `tcount' == `tcount'[1]
    = capture assert __000008 == __000008[1]
    - if c(rc) {
    - local bal unbalanced
    - }
    - else {
      CheckStrongBal `npanel' `panel' `timevar'
      if r(rc) {
      local bal "weakly balanced"
      }
      else {
      local bal "strongly balanced"
      }
      }
    - di in gr _col(8) "panel variable:  " in ye "`panel' (`bal')"
    = di in gr _col(8) "panel variable:  " in ye "eid (unbalanced)"
    - return local balanced "`bal'"
    = return local balanced "unbalanced"
    - }
    - local fmt : format `timevar'
    = local fmt : format yr
    - local t0s = trim(string(`t0', "`fmt'"))
    = local t0s = trim(string(1996, "%8.0g"))
    - local t1s = trim(string(`t1', "`fmt'"))
 = local t1s = trim(string(2007, "%8.0g"))
    - di in gr _col(9) "time variable:  " _c
    - local i 1
    - local line`i' `=abbrev("`timevar'",13)',
    = local line1 yr,
    - local linelen = length(`"`line`i''"')
    = local linelen = length(`"yr,"')
    - if (`linelen' + length(`"`t0s'"')) < 53 {
    = if (3 + length(`"1996"')) < 53 {
    - local line`i' `line`i'' `t0s'
    = local line1 yr, 1996
    - local linelen = length(`"`line`i''"')
    = local linelen = length(`"yr, 1996"')
    - }
    - else {
      local `++i'
      local line`i' `t0s'
      local linelen = length(`"`line`i''"')
      }
    - if (`linelen' + 3) < 53 {
    = if (8 + 3) < 53 {
    - local line`i' `"`line`i'' to"'
    = local line1 `"yr, 1996 to"'
    - local linelen = length(`"`line`i''"')
    = local linelen = length(`"yr, 1996 to"')
    - }
    - else {
      local `++i'
      local line`i' "to"
      local linelen = 3
      }
    - if (`linelen' + length(`"`t1s'"')) < 53 {
    = if (11 + length(`"2007"')) < 53 {
    - local line`i' `line`i'' `t1s'
    = local line1 yr, 1996 to 2007
    - local linelen = length(`"`line`i''"')
    = local linelen = length(`"yr, 1996 to 2007"')
 - }
    - else {
      local `++i'
      local line`i' `t1s'
      local linelen = length(`"`t1s'"')
      }
    - if `gaps' > 0 {
    = if 0 > 0 {
      if `gaps' == 1 {
      local note "but with a gap"
      }
      else {
      local note "but with gaps"
      }
      if (`linelen' + length(`", `note'"')) < 53 {
      local line`i' `line`i'', `note'
      }
      else {
      local `++i'
      local line`i' `note'
      }
      }
    - forvalues j = 1/`i' {
    = forvalues j = 1/1 {
    - di in ye _col(25) `"`line`j''"'
    = di in ye _col(25) `"yr, 1996 to 2007"'
    - }
    - tempname fancyd
    - mata:_TS_p_delta2str("`fancyd'", `=`delta'', "`timevar'")
    = mata:_TS_p_delta2str("__000009", 1, "yr")
    - di in gr _col(17) "delta:  " in ye "`=`fancyd''"
    = di in gr _col(17) "delta:  " in ye "1 unit"
    - ret scalar tmin = `t0'
    = ret scalar tmin = 1996
    - ret scalar tmax = `t1'
    = ret scalar tmax = 2007
    - ret scalar tdelta = `delta'
 - ret scalar tdelta = `delta'
    = ret scalar tdelta = +1.0000000000000X+000
    - ret local tmins `t0s'
    = ret local tmins 1996
    - ret local tmaxs `t1s'
    = ret local tmaxs 2007
    - ret local tdeltas "`=`fancyd''"
    = ret local tdeltas "1 unit"
    ---------------------------------------------------------------------- end tsset.Query ---
  - if "`dfltfmt'" == "yes" & substr("`format'", 3, 1) == "c" {
  = if "" == "yes" & substr("%8.0g", 3, 1) == "c" {
    format `timevar' %tc
    }
  - ret add
  - local fmt : format `timevar'
  = local fmt : format yr
  - return local tsfmt `fmt'
  = return local tsfmt %8.0g
  - return local unit1 = substr("`fmt'", 3, 1)
  = return local unit1 = substr("%8.0g", 3, 1)
  - Period per : "`period'" `return(unit1)'
  = Period per : "" .
    ------------------------------------------------------------------- begin tsset.Period ---
    - args newper colon per unit1
    - if "`per'" == "" {
    = if "" == "" {
    - if "`unit1'" != "" {
    = if "." != "" {
    - local c "clocktime"
    - local g "generic"
    - local d "daily"
    - local w "weekly"
    - local m "monthly"
    - local q "quarterly"
    - local h "halfyearly"
    - local y "yearly"
    - capture c_local `newper' ``unit1''
    = capture c_local per 
  - }
    - else {
      c_local `newper' "generic"
      }
    - }
    - else {
      c_local `newper' `per'
      }
    --------------------------------------------------------------------- end tsset.Period ---
  - return local unit `per'
  = return local unit 
  - ret local timevar "`timevar'"
  = ret local timevar "yr"
  - ret local panelvar "`panel'"
  = ret local panelvar "eid"
  ------------------------------------------------------------------------------ end tsset ---
- }
- if (`level' < 10 | `level' > 99) {
= if (95 < 10 | 95 > 99) {
  di as error "level must be between 10 and 99"
  error 198
  }
- if ("`revenue'" != "" & "`valueadded'" != "") {
= if ("revenue" != "" & "" != "") {
  di as error "Only one of revenue and valueadded can be specified."
  exit 198
  }
- if ("`revenue'" != "") {
= if ("revenue" != "") {
- local model "revenue"
- }
- else {
  local model "valueadded"
  }
- local numprox : word count `proxy'
= local numprox : word count lnpower
- if ("`model'" == "revenue" & `numprox' > 1) {
= if ("revenue" == "revenue" & 1 > 1) {
  di as error "Only one proxy variable can be used with revenue."
  exit 198
  }
- if (`reps' < 2) {
= if (50 < 2) {
  di as error "reps() must be at least 2."
  exit 198
  }
- local just = 0
- if ("`justid'" != "" & "`model'" != "revenue") {
= if ("justid" != "" & "revenue" != "revenue") {
  di as error "justid can only be used with revenue (GMM) model."
  exit 198
  }
- else if "`justid'" != "" {
= else if "justid" != "" {
- local just = 1
- }
- local gsrch = 0
- if ("`grid'" != "" & "`model'" != "revenue") {
= if ("grid" != "" & "revenue" != "revenue") {
  di as error "grid can only be used with revenue (GMM) model."
  exit 198
  }
- else if "`grid'" != "" {
= else if "grid" != "" {
- local gsrch = 1
- }
- qui count if `touse'
= qui count if __000001
- loc capn = r(N)
- local rmacs ""
- foreach var in `free' `capital' {
= foreach var in lnl2 lnirm lnlrm lnk {
- foreach var in `free' `capital' {
- local rmacs "`rmacs' (r(`var'))"
= local rmacs " (r(lnl2))"
- }
- local rmacs "`rmacs' (r(`var'))"
= local rmacs " (r(lnl2)) (r(lnirm))"
- }
- local rmacs "`rmacs' (r(`var'))"
= local rmacs " (r(lnl2)) (r(lnirm)) (r(lnlrm))"
- }
- local rmacs "`rmacs' (r(`var'))"
= local rmacs " (r(lnl2)) (r(lnirm)) (r(lnlrm)) (r(lnk))"
- }
- if ("`model'" == "revenue") {
= if ("revenue" == "revenue") {
- local rmacs "`rmacs' (r(`proxy'))"
= local rmacs " (r(lnl2)) (r(lnirm)) (r(lnlrm)) (r(lnk)) (r(lnpower))"
- }
- quietly {
- tempfile postfile datafile
- tempname post
- tempvar idvar
- gen `idvar' = `i'
= gen __000003 = eid
- preserve
- keep if `touse'
= keep if __000001
- loc cmd "`depvar' , free(`free') proxy(`proxy') capital(`capital') "
= loc cmd "lny , free(lnl2 lnirm lnlrm) proxy(lnpower) capital(lnk) "
- tsset `idvar' `t'
= tsset __000003 yr
  ---------------------------------------------------------------------------- begin tsset ---
  - version 10
  - if `"`0'"' == "" {
  = if `"__000003 yr"' == "" {
    _ts tvar pvar, panel
    local fmt: format `tvar'
    local tsdelta : char _dta[_TSdelta]
    if "`tsdelta'" == "" {
 local tsdelta 1
    }
    tsset `pvar' `tvar', format(`fmt') delta((`tsdelta'))
    ret add
    exit
    }
  - syntax [varlist(numeric max=2 default=none)] [, CLEAR Daily Format(passthru) Generic Halfy
> early Monthly Quarterly Weekly Yearly DELta(string) Clocktime FORCE ]
  - if "`clear'" != "" {
  = if "" != "" {
    syntax [, CLEAR]
    Clear
    exit
    }
  - if "`varlist'"=="" {
  = if "__000003 yr"=="" {
    _ts tvar pvar, panel
    tsset `pvar' `tvar', `daily' `format' `generic' `halfyearly' `monthly' `quarterly' `weekly
> ' `yearly' `clocktime'
    ret add
    exit
    }
  - syntax varlist(numeric max=2 default=none) [ , CLEAR Daily Format(string) Generic Halfyear
> ly Monthly Quarterly Weekly Yearly DELta(string) Clocktime FORCE ]
  - local ct : word count `varlist'
  = local ct : word count __000003 yr
  - if `ct'==2 {
  = if 2==2 {
  - tokenize `varlist'
  = tokenize __000003 yr
  - local panel `1'
  = local panel __000003
  - local timevar `2'
  = local timevar yr
  - }
  - else {
    local timevar `varlist'
    }
  - local period `daily' `weekly' `monthly' `quarterly' `halfyearly' `yearly' `generic' `clock
> time'
  = local period        
  - if `"`format'"'!="" {
  = if `""'!="" {
    local dfltfmt "no"
    if "`period'" != "" {
    di in red "may not specify both format() and `period'"
    exit 198
    }
    local try : di `format' 2
    }
  - else if "`period'" != "" {
  = else if "" != "" {
    local ct : word count `period'
    if `ct' > 1 {
    di in red "may only specify one time-scale from " "daily, weekly, monthly, "
    di in red "quarterly, halfyearly, yearly, and generic"
    exit 198
    }
    local curfmt : format `timevar'
    local fmttype = substr("`curfmt'", 2, 1)
    if "`fmttype'" != "d" & "`fmttype'" != "t" {
    local format = "%t" + substr("`period'",1,1)
    if substr("`period'", 1, 1) == "c" {
    local dfltfmt "yes"
    }
    }
    else {
    local format `curfmt'
    }
    }
  - else {
  - local format : format `timevar'
  = local format : format yr
  - }
 - capture assert int(`timevar')==`timevar'
  = capture assert int(yr)==yr
  - if _rc {
    di in red "time variable must contain only integer values"
    exit 451
    }
  - sort `panel' `timevar'
  = sort __000003 yr
  - if "`panel'" != "" {
  = if "__000003" != "" {
  - local bypfx "by `panel': "
  = local bypfx "by __000003: "
  - }
  - if `"`format'"' != "" {
  = if `"%8.0g"' != "" {
  - format `timevar' `format'
  = format yr %8.0g
  - }
  - tempname scdelta
  - mata: _TS_p_delta("`scdelta'", "`delta'", "`timevar'")
  = mata: _TS_p_delta("__000004", "", "yr")
  - if `scdelta' == -2 {
  = if __000004 == -2 {
    di as err "invalid time-series format on `timevar'"
    exit 120
    }
  - if `scdelta' == -1 {
  = if __000004 == -1 {
    di as err "invalid argument in delta()"
    exit 198
    }
  - tempvar timedif
  - qui `bypfx' gen double `timedif' = `timevar'[_n+1] - `timevar'
  = qui by __000003:  gen double __000005 = yr[_n+1] - yr
  - qui sum `timedif', meanonly
  = qui sum __000005, meanonly
  - if r(min) == 0 {
 - if "`panel'" != "" {
  = if "__000003" != "" {
  - di in red "repeated time values within panel"
repeated time values within panel
  - }
  - else {
    di in red "repeated time values in sample"
    }
  - exit 451
    }
  ------------------------------------------------------------------------------ end tsset ---
  if ("`model'" == "valueadded") {
  lp_srch `cmd' i(`idvar') t(`t')
  }
  else {
  global LPone = 1
  lp_gmm `cmd' i(`idvar') t(`t') converrs(0) just(`just') grid(`gsrch')
  global LPone = 0
  }
  local converrs = 0
  foreach x of local rmacs {
  if (`x' >= .) {
  local converrs = 1
  noi di as error "Insufficient variation to identify the capital and intermediate input"
  noi di as error "coefficients separately.  Bootstrapping for first-stage parameters only."
  }
  }
  if ("`model'" == "valueadded") {
  postfile `post' `free' `capital' using `"`postfile'"', double replace
  local rmacs ""
  foreach var in `free' `capital' {
  local rmacs "`rmacs' (r(`var'))"
  }
  }
  else {
  if `converrs' == 0 {
  postfile `post' `free' `capital' `proxy' using `"`postfile'"', double replace
local rmacs ""
  foreach var in `free' `capital' {
  local rmacs "`rmacs' (r(`var'))"
  }
  local rmacs "`rmacs' (r(`proxy'))"
  }
  else {
  postfile `post' `free' using `"`postfile'"', double replace
  local rmacs ""
  foreach var in `free' {
  local rmacs "`rmacs' (r(`var'))"
  }
  }
  }
  post `post' `rmacs'
  forvalues cnt = 1/`reps' {
  noi di "." _continue
  restore, preserve
  keep if `touse'
  tempvar idvar
  bsample, cluster(`i') idcluster(`idvar')
  if ("`model'" == "valueadded") {
  lp_srch `cmd' i(`idvar') t(`t')
  }
  else {
  lp_gmm `cmd' i(`idvar') t(`t') converrs(`converrs') just(`just') grid(`gsrch')
  }
  post `post' `rmacs'
  }
  postclose `post'
  if ("`model'" == "revenue") {
  macro drop LPone
  mat drop LPmoments
  }
  tempname evar eb
  use `"`postfile'"', clear
  mat accum `evar' = * in 2/l , deviations noconstant

if ("`model'" == "revenue") {
  macro drop LPone
  mat drop LPmoments
  }
  tempname evar eb
  use `"`postfile'"', clear
  mat accum `evar' = * in 2/l , deviations noconstant
  mat `evar' = `evar' / (r(N) - 1)
  mkmat * in 1, matrix(`eb')
  if `converrs' == 0 {
  tempname capr diff rvri waldcrs junk
  loc bsize = colsof(`eb')
  mat `capr' = J(1, `bsize', 1)
  mat `rvri' = syminv(`capr'*`evar'*`capr'')
  mat `diff' = `eb'*`capr'' - 1
  mat `junk' = `diff'*`rvri'*`diff'
  scalar `waldcrs' = trace(`junk')
  }
  restore
  estimates post `eb' `evar' , esample(`touse') depname(`"`depvar'"') obs(`capn')
  if `converrs' == 0 {
  estimates scalar waldcrs = `waldcrs'
  }
  estimates local depvar `depvar'
  if ("`model'" == "revenue") {
  estimates local model "revenue"
  }
  else {
  estimates local model "value added"
  }
  estimates local predict "levpet_p"
  estimates local cmd "levpet"
  tsset `i' `t'
  }
------------------------------------------------------------------------------- end levpet ---
r(451);

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index