Bookmark and Share

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

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

Re: st: levpet - loops and varying results

From   "Brian P. Poi" <>
Subject   Re: st: levpet - loops and varying results
Date   Tue, 09 Oct 2012 14:37:08 -0500

On Tue, Oct 9, 2012 at 6:54 PM, SAM MCCAW<>  wrote:
Hello All,

I am running into 2 problems with running levpet.

(Problem No. 1):

When I run levpet industry by industry it works fine. But when I do
the same thing with the following loop I get an error message.

So the individual command is as follows:

                  eststo: levpet lnY if industryno_5 == 1, free (lnl)
proxy (lnM) capital (lnK1) revenue

And, my loop command is as follows:

         foreach i of varlist  industryno_1 - industryno_23 {
                         eststo: levpet lnY if `i' == 1, free (lnl) proxy (lnM) capital
(lnK1) revenue reps (50)
                         predict lnY_hatind_`i', omega
                         gen lnTFPind_`i' = lnY -  lnY_hatind_`i'

The error message when using the loop is as follows for the same
industry which worked fine when run through an individual command:

         .......insufficient observations
         error #2001 occurred in program nllp_bs_gmm

(Problem no. 2)

When running levpet industry by industry, the stata output keeps
varying for P>|z| values. So everytime I run the same command I get a
different P>|z| value although the coeffecients remain the same. Is
there a way to restrict this?

On 10/09/2012 01:59 PM, Nick Cox wrote:
I'll guess that bootstrapping is behind #1 too. Look what is failing:

On Tue, Oct 9, 2012 at 7:45 PM, Nick Cox<>  wrote:
I've never used this, but the answer to #2 presumably follows from
Brian Poi's answer in

That is, the standard errors come from the bootstrapping, and so too
do any P-values.


Nick's batting a thousand.  Bootstrapping is the cause of both of Sam's problems.

Productivity estimators like -levpet- require you to have panel data, and they work better when you have more time periods for each firm and few gaps in the data.  Unfortunately, not all datasets are so nice.  In some cases, the original dataset happens to have enough observations so that the estimators will work properly.  However, when drawing bootstrap samples, it is possible to obtain a bootstrap dataset such that only firms with few observations or firms with gaps in their series are present.  In those cases, it's just not possible to carry out the estimation on the bootstrap sample, and so you get error messages like Sam did.

If you are mainly interested in getting estimates of productivity and don't care about the standard errors, you can specify the option reps(2) so that -levpet- only does two bootstrap replications:

.  levpet lny, free(lnl) capital(lnk) proxy(lnm) revenue reps(2)

reps(2) is the minimum -levpet- allows; unfortunately, there is no option on -levpet- to turn bootstrapping off.  With any luck, by doing only two bootstrap replications you'll be able to draw bootstrap samples that work for all your industries.  If you still have the same problem, changing the random-number-generator seed to a different value might solve the problem.  From the output above, -levpet- failed on the 8th bootstrap for the first industry, so you might be in the clear with reps(2).

   -- Brian Poi

*   For searches and help try:

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