*! version 1.0  29aug2024
program magreg_est, eclass
	syntax varlist(ts fv) [if] [in] [, * ]
	quietly regress `varlist' `if' `in' [`weight'`exp'], `options'
	quietly summarize `=e(depvar)' if e(sample), meanonly
	mat b = e(b)
	mat b = e(b)/sqrt(e(r2))
	mat b[1,`:colsof(b)'] = b[1,`:colsof(b)'] + r(mean)*(1 - 1/sqrt(e(r2)))
	ereturn repost b = b
end