Announcement

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

  • "last estimates not found" error

    I want to run the attached code, but the result is like below.

    last estimates not found
    r(301);

    I think this error comes from [**4.2 run the state-depentent estimation ] part, but I can't know how I change.

    code is from Corporate leverage and monetary policy effectiveness in the euro area - ScienceDirect


    =======================
    ************************************************** *****************
    * 27279 observations = 179*154-287
    * time: 179 = 18y - 3y (lags/leads) - 1m (growth)
    * cross: 154 = 22 (nace) * 7 (EZ countries)
    * missing: 287 = 179 (C15DE) + 96 (4y C30PT-33PT) + 12 (1y C33ES)
    ************************************************** *****************

    * 1 HOUSEKEEPING
    clear all // clear memory
    macro drop _all // drop all macros
    cls // clear results window
    set more off // do not display the "more" message
    set graphics off // do (not) show graphics in STATA
    set varabbrev off // do not use abbreviations
    set type double
    pause off // do (not) pause
    adopath ++ PLUS

    global path "/home/user/m397400/public/NFCfin_MP/ABC_EER/"
    global exper "bas"

    * 2 DATA and GLOBALS
    capture log close
    log using "${path}output/logs/${exper}.log", replace

    use "${path}data/data_ABC.dta", clear

    global maxhor=2*12
    global lags=1*12
    global stasample 2001m1
    global endsample 2018m12

    * 2.1 Time-dimension
    gen sample = .
    replace sample = 1 if month>=(tm(${stasample})+${lags}+1) & month<=(tm(${endsample})-${maxhor})

    * 2.2 Cross-dimension
    gen sampleC=1 if country=="AT" | ///
    country=="BE" | ///
    country=="DE" | ///
    country=="ES" | ///
    country=="FR" | ///
    country=="IT" | ///
    country=="PT"

    gen sampleN=1 if nace=="C10" | ///
    nace=="C11" | ///
    nace=="C13" | ///
    nace=="C14" | ///
    nace=="C15" | ///
    nace=="C16" | ///
    nace=="C17" | ///
    nace=="C18" | ///
    nace=="C20" | ///
    nace=="C21" | ///
    nace=="C22" | ///
    nace=="C23" | ///
    nace=="C24" | ///
    nace=="C25" | ///
    nace=="C26" | ///
    nace=="C27" | ///
    nace=="C28" | ///
    nace=="C29" | ///
    nace=="C30" | ///
    nace=="C31" | ///
    nace=="C32" | ///
    nace=="C33"

    keep if sampleC==1 & sampleN==1 // keep only select countries and sectors
    drop sampleC sampleN

    * 2.3 Horizon
    gen hor = _n-1
    replace hor = . if hor>${maxhor} // define horizon (useful for stored results and graphs)

    * 3 TRANSFORMATIONS
    ** 3.1 Shock
    gen sho = -kj_shock_mp
    sum sho if sample==1
    replace sho = sho/r(sd)

    ** 3.2 LHS variables
    tsset crossid month

    * indexed log levels
    gen yvar = 100*log(volume) // log-level

    forvalues j=0/$maxhor {
    gen yvarH`j' = F`j'.yvar - L1.yvar
    }

    * cumulative IRFs
    qui gen cum_yvar_temp=0
    forvalues j=0/$maxhor {
    gen cum_yvarH`j'=yvarH`j'+cum_yvar_temp // cumulative
    replace cum_yvar_temp=cum_yvarH`j'
    }
    drop cum_yvar_temp

    ** 3.3 RHS variables

    * lagged controls
    foreach var in yvarH0 sho {
    forvalues p=1/$lags {
    gen `var'L`p' = L`p'.`var'
    }
    }

    * state-variables
    gen stvar_pre = l_wm // leverage
    by crossid: ipolate stvar_pre month, gen(stvar_ipo) // 1-year lagged - linear interporlation
    gen stvar = L12.stvar_ipo

    * intercept
    gen ones = 1

    * interactions
    foreach sdvar of varlist ones sho shoL* yvarH0L* {
    gen `sdvar'_0p = `sdvar'
    gen `sdvar'_1p = `sdvar'*(stvar^1)
    gen `sdvar'_2p = `sdvar'*(stvar^2)
    }

    * effective list of regressors
    unab main: sho_*
    unab ctrs: ones_* shoL*_* yvarH0L*_*
    *
    unab main_drop: sho_0p
    unab ctrs_drop: ones_0p shoL*_0p
    *
    local main_eff: list main - main_drop
    local ctrs_eff: list ctrs - ctrs_drop

    * 4 REGRESSION
    ** 4.1 Pre-store beta coefficients
    foreach v in beta betau68 betal68 betau90 betal90 {
    foreach scen in 1p 2p t a b c d {
    gen `v'_`scen' = .
    }
    }

    ** 4.2 run the state-dependent estimation
    forval i= 0/$maxhor {
    local ord=`i'+1 // ord='i'+1 in ivreg2 is equivalent to ord='i' in xtscc (check "help ivreg2")
    ivreghdfe cum_yvarH`i' `main_eff' `ctrs_eff' if sample==1, absorb(countryid naceid month) partial(`ctrs_eff') dkraay(`ord') small
    capture gen esample = e(sample)
    if _rc==0 {
    latabstat cum_yvarH0 sho stvar if esample==1, statistics(n mean median sd p1 p99) columns(statistic) format(%9.2f)
    }
    local df = e(df_r)
    di "OBS " e(N) " DF " e(df_r) " PARAMETERS " e(rankxx)+e(partial_ct)+(e(N_clust)-1) // shock + controls and day-FE + intraday-FE
    pause
    * UNDERLYING PARAMETERS
    lincom sho_1p
    qui replace beta_1p =r(estimate) if hor==`i'
    qui replace betau68_1p =r(estimate)+invt(`df',(100+68)/2/100)*r(se) if hor==`i'
    qui replace betal68_1p =r(estimate)-invt(`df',(100+68)/2/100)*r(se) if hor==`i'
    qui replace betau90_1p =r(estimate)+invt(`df',(100+90)/2/100)*r(se) if hor==`i'
    qui replace betal90_1p =r(estimate)-invt(`df',(100+90)/2/100)*r(se) if hor==`i'
    *
    lincom sho_2p
    qui replace beta_2p =r(estimate) if hor==`i'
    qui replace betau68_2p =r(estimate)+invt(`df',(100+68)/2/100)*r(se) if hor==`i'
    qui replace betal68_2p =r(estimate)-invt(`df',(100+68)/2/100)*r(se) if hor==`i'
    qui replace betau90_2p =r(estimate)+invt(`df',(100+90)/2/100)*r(se) if hor==`i'
    qui replace betal90_2p =r(estimate)-invt(`df',(100+90)/2/100)*r(se) if hor==`i'
    * PEAK EFFECTS
    qui replace beta_t = -(1/2)*_b[sho_1p]/_b[sho_2p] if hor==`i'
    qui replace beta_t = . if hor==`i' & (beta_t<0 | beta_t>100)
    * EXCESS SENSITIVITIES
    lincom sho_1p*(55-45)+sho_2p*(55*55-45*45)
    qui replace beta_a =r(estimate) if hor==`i'
    qui replace betau68_a =r(estimate)+invt(`df',(100+68)/2/100)*r(se) if hor==`i'
    qui replace betal68_a =r(estimate)-invt(`df',(100+68)/2/100)*r(se) if hor==`i'
    qui replace betau90_a =r(estimate)+invt(`df',(100+90)/2/100)*r(se) if hor==`i'
    qui replace betal90_a =r(estimate)-invt(`df',(100+90)/2/100)*r(se) if hor==`i'
    *
    lincom sho_1p*(65-55)+sho_2p*(65*65-55*55)
    qui replace beta_b =r(estimate) if hor==`i'
    qui replace betau68_b =r(estimate)+invt(`df',(100+68)/2/100)*r(se) if hor==`i'
    qui replace betal68_b =r(estimate)-invt(`df',(100+68)/2/100)*r(se) if hor==`i'
    qui replace betau90_b =r(estimate)+invt(`df',(100+90)/2/100)*r(se) if hor==`i'
    qui replace betal90_b =r(estimate)-invt(`df',(100+90)/2/100)*r(se) if hor==`i'
    *
    lincom sho_1p*(75-65)+sho_2p*(75*75-65*65)
    qui replace beta_c =r(estimate) if hor==`i'
    qui replace betau68_c =r(estimate)+invt(`df',(100+68)/2/100)*r(se) if hor==`i'
    qui replace betal68_c =r(estimate)-invt(`df',(100+68)/2/100)*r(se) if hor==`i'
    qui replace betau90_c =r(estimate)+invt(`df',(100+90)/2/100)*r(se) if hor==`i'
    qui replace betal90_c =r(estimate)-invt(`df',(100+90)/2/100)*r(se) if hor==`i'
    *
    lincom sho_1p*(85-75)+sho_2p*(85*85-75*75)
    qui replace beta_d =r(estimate) if hor==`i'
    qui replace betau68_d =r(estimate)+invt(`df',(100+68)/2/100)*r(se) if hor==`i'
    qui replace betal68_d =r(estimate)-invt(`df',(100+68)/2/100)*r(se) if hor==`i'
    qui replace betau90_d =r(estimate)+invt(`df',(100+90)/2/100)*r(se) if hor==`i'
    qui replace betal90_d =r(estimate)-invt(`df',(100+90)/2/100)*r(se) if hor==`i'
    }

    * 5 SAVE RESULTS
    save "${path}output/dta/estres_${exper}",replace

    log close
    ==========================================
    Attached Files
    Last edited by Taehoon Kim; 07 Mar 2024, 01:29.
Working...
X