Dear Statalisters,

I am trying to bootstrap the impulse response function that I obtain from a local projection. The tricky bit is that the object I want to bootstrap is a vector. This is the code that I have so far:

Code:
clear

set obs 200

set seed 12

gen xx=runiform()

gen e=rnormal(0,1)

gen lindpro=0.5*x+e

g time =_n
tsset time

local nlags 3
local irflag = 36
capture program drop lpirf
program lpirf, eclass
    args xx lindpro nlags irflag
    
    * compute IRFs
    local irflagp1 = `irflag'+1
    mat bbb = J(`irflagp1',1,0)

    forvalues h = 0/`irflag' {
        local hp1 = `h'+1
        qui reg F`h'.xx L(0/`nlags').xx L(1/`nlags').lindpro, r
        mat bbb[`hp1',1] = _b[xx]
    }
  
    tempname bb
    matrix `bb'=bbb'
    ereturn clear
    ereturn post `bb'
    ereturn local cmd="bootstrap"

end

lpirf xx lindpro `nlags' `irflag'

matrix list e(b)

bootstrap _b, reps(100) nowarn nodrop: lpirf xx lindpro `nlags' `irflag'
While the code successfully produces the impulse response, unfortunately, it does not work with the bootstrap. I get the error message "insufficient observations to compute bootstrap standard errors no results will be saved".

Now, I could easily compute the standard errors of the impulse responses in a different way, however, ultimately I want to bootstrap the historical decomposition, which is yet again a function of the impulse responses and the data:

Code:
cap drop hdlindpro
gen hdlindpro = 0
forvalues h = 1/`irflag' {
        qui replace hdlindpro = hdlindpro + bbb[`h',1]*L`h'.xx
}
mkmat hdlindpro if hdlindpro!= . , matrix(histdec)
Therefore, I think I have to do it this way. Does anyone have an idea what the problem could be? I tried to include the nodrop option but with no avail.

Many thanks in advance and all the best,

Diego