Hi,

I am trying to boostrap the average of a column over several iterations. The column values are generated by an ML estimation function. I inititate an empty variable g_1 which gets populated by my liklihood function Here is a sample of the code,

Code:
program nasheq

version 15.0

args lnf x1beta x2beta alpha_1 alpha_2 rho

quietly replace `lnf' = ln( binormal( -`x1beta', -`x2beta', `rho') - 0.5 * ( binormal( -`x1beta', -`x2beta', `rho' ) - binormal( -`x1beta', -`x2beta' -`alpha_2', `rho' ) - binormal( -`x1beta' - `alpha_1', -`x2beta', `rho' ) + binormal( -`x1beta' - `alpha_1', -`x2beta' - `alpha_2', `rho' ) ) )  if `alpha_1' >= 0 & `alpha_2' >= 0 & $ML_y1==0 & $ML_y2==0

quietly replace g_1 = exp(ln( binormal( -`x1beta', -`x2beta', `rho') - 0.5 * ( binormal( -`x1beta', -`x2beta', `rho' ) - binormal( -`x1beta', -`x2beta' -`alpha_2', `rho' ) - binormal( -`x1beta' - `alpha_1', -`x2beta', `rho' ) + binormal( -`x1beta' - `alpha_1', -`x2beta' - `alpha_2', `rho' ) ) )) if `alpha_1' >= 0 & `alpha_2' >= 0

I try this function

Code:
program nasheq

version 15.0

args lnf x1beta x2beta alpha_1 alpha_2 rho

quietly replace `lnf' = ln( binormal( -`x1beta', -`x2beta', `rho') - 0.5 * ( binormal( -`x1beta', -`x2beta', `rho' ) - binormal( -`x1beta', -`x2beta' -`alpha_2', `rho' ) - binormal( -`x1beta' - `alpha_1', -`x2beta', `rho' ) + binormal( -`x1beta' - `alpha_1', -`x2beta' - `alpha_2', `rho' ) ) )  if `alpha_1' >= 0 & `alpha_2' >= 0 & $ML_y1==0 & $ML_y2==0

quietly replace g_1 = exp(ln( binormal( -`x1beta', -`x2beta', `rho') - 0.5 * ( binormal( -`x1beta', -`x2beta', `rho' ) - binormal( -`x1beta', -`x2beta' -`alpha_2', `rho' ) - binormal( -`x1beta' - `alpha_1', -`x2beta', `rho' ) + binormal( -`x1beta' - `alpha_1', -`x2beta' - `alpha_2', `rho' ) ) )) if `alpha_1' >= 0 & `alpha_2' >= 0

summarize g_1

return scalar avg_value = r(mean)

I then run the bootstrap command with avg_value=r(avg_value) but I get the following error 'r(avg_value)' evaluated to missing in full sample. Is there a way to bootstrap the generated variable using the boostrap command and not use the coefficients of the estimation?