*! version 1.1, 11 Aug 1999 Modified from mlfit.ado by C F Baum
*! Thanks to Vince Wiggins of StataCorp
*! version 1.1.12, 15 May 1998  STB-45 sg90 by A. Tobias & M.J. Campbell

program define arimafit, rclass
	version 6.0

	if ("`e(cmd)'"=="arima" & "`e(k_dv)'"=="1") {
    	local n  e(N)
		local ll2  = -2*e(ll)
		local np = e(df_m)+1
	}
	else  {
		display in red "ERROR: Last estimates not found"
		display in red "Can only be used after single-equation arima command"
		exit
	}

	local aic `ll2'+2*`np'
	local sic = `ll2'+`np'*ln(`n')
	display
	display in green " Criteria for assessing ARIMA model fit for `e(depvar)'"
	display in green " Akaike's Information Criterion (AIC) and Schwarz's Criterion (SIC)"
	display
	display in green "------------------------------------------------------------------------------"
	display in green _col(2) "AIC" _col(16) "SIC" _col(29) "| -2 Log Likelihood" _col(52) "Num.Parameters"
	display in green "----------------------------+-------------------------------------------------"
	display _col(2) `aic' _col(16) `sic' _col(29) in green "|" _col(32) in ye `ll2' _col(55) `np'
	display in green "------------------------------------------------------------------------------"

    return scalar  np = `np'
    return scalar llf = `ll2'
    return scalar aic = `aic'
    return scalar sic = `sic'
end