clear
estimates clear
eststo clear

local continuous : list global(imputable) | global(loggdp)
local continuous : list continuous | global(otherindispensable)

foreach dataset in basic imputed {	
foreach depvar in ln_IHME i_ln_pris {

	use MIdataset, clear
	
	if "`dataset'"=="basic" {
		mi extract 0, clear
		drop country ISO rgdp
		egen complete=rownonmiss(*)
		sum complete
		drop if complete<r(max)
		drop complete
		}	
	
	if "`dataset'"=="imputed" {
		if "`depvar'"=="ln_IHME" mi extract 1, clear
		else mi extract `=1+`: disp $imputations'', clear
		drop country ISO rgdp
		}

	
	fvrevar ($binary)##($binary)##($binary), stub(binary)
	fvrevar c.(`continuous')##c.(`continuous')##c.(`continuous'), stub(continuous)
	fvrevar ($binary)#c.(`continuous'), stub(bico)
	fvrevar ($binary)#c.(`continuous')#c.(`continuous'), stub(bicoco)
	fvrevar ($binary)#($binary)#c.(`continuous'), stub(bibico)
	
	local regressors "$binary `continuous' binary* continuous* bico* bicoco* bibico* "
	lassoShooting `depvar' `regressors', lasiter(100) verbose(0) fdisplay(0)
	local base_regressors `r(selected)'
	lassoShooting USA `regressors', lasiter(100) verbose(0) fdisplay(0)
	disp r(selected) // just to see if any have been selected; but not even a copy of USA was selected when I tried

	_eststo: reg `depvar' USA `base_regressors' `r(selected)'

}
}

esttab * using results/LASSO, replace csv b(2) se(2) star(* 0.10 ** 0.05 *** 0.01) nogaps nonumbers
