/******************************************************************************************* LIKELIHOOD FOR MVMETA.ADO *! version 3.5.0 # Ian White # 15nov2021 corrected single to double precision that affected shortparm results version 3.2.3 # Ian White # 16jun2020 modifies ll and rll if MVMETA_penalty is set version 3.0.1 Ian White 27may2015 version 2.2.1 31may2011 corrected the constant term in log L and log RL, as suggested by Antonio Gasparrini: affects L/RL (only) in models with missing outcomes and models with covariates version 1.7.1 3jun2010 drops any observations with all missing outcomes *******************************************************************************************/ prog def mvmeta_lmata // Parse args todo b lnf local y $MVMETA_ymat local S $MVMETA_Smat local X $MVMETA_Xmat local p $MVMETA_p forvalues j=1/`p' { local xvars_`j' ${MVMETA_xvars_`j'} } local ynames $MVMETA_ylist local bsest $MVMETA_bsest local parmtype $MVMETA_parmtype local xcons $MVMETA_xcons local riley = ("$MVMETA_wscorr"=="riley") local add2pi = ("$MVMETA_2pi"=="") local bscovariance $MVMETA_bscovariance local fixedparms = cond("$MVMETA_quick"=="quick",0,$MVMETA_fixedparms) // Set up qui count if $ML_samp local n = r(N) local N=_N tempname BETA Sigma varparms tempvar mu // Form Sigma from parameters b if `fixedparms'0)) ll = ll + penalty * log(det(corr(fullSigma))) rl = ll - log(det(XWXsum))/2 + add2pi*q*log(2*pi())/2 if(debug==1) printf("rl is %9.0g\n", rl) st_numscalar("r(ll)",ll) st_numscalar("r(rl)",rl) } end