/***************************************************************************/ /* */ /* Title: GMML.GPG */ /* */ /* modified version of gmm to do levels, investment model only */ /* for macro annual */ /* Written: John H. Cochrane */ /* by: University of Chicago Graduate School of Business */ /* 1101 E. 58th Street, Rosenwald 2xx */ /* Chicago, Ill 60637 */ /* ph#: (312) 702-3059 */ /* e-mail: fac_jhc@gsbacd.uchicago.edu */ /* */ /*Modified: Caleb C. Wong */ /* by: University of Chicago Department of Economics */ /* 1126 East 59th St. */ /* Chicago, Ill 60637 */ /* ph#: (312) 702-8254 */ /* e-mail: wongcc@sam.spc.uchicago.edu */ /* */ /* Purpose: Main program for doing gmm with investment returns as factors. */ /* Sets up the proper 'switches' and datasets and passes them to */ /* doitc.g for estimation of factor premiums. */ /* */ /* Certain options are currently hard-wired: (1) selected param- */ /* eters for search include only mpk (i.e. selpar = 0|0|1) */ /* only levels as factors rather than excess in extra factor comparisons*/ /* */ /* Data: Quarterly averaged returns created by redodat.gpg and GAUSS */ /* formatted (indicated by .fmt extension) */ /* */ /* */ /* Pending Modifications: */ /* market + lagged market? */ /* add lagged investment as inst? */ /* lagged RI in m ? lead RI in m? */ /* do unconditional crr as extra */ /* */ /***************************************************************************/ /* ------------------------------------------------ */ /* Part I: (1) GAUSS library calls */ /* (2) reset globals on graphics, optmum */ /* (3) identify data path */ /* ------------------------------------------------ */ library pgraph,optmum,gmm; #include optmum.ext; optset; graphset; dpath(0); /* 0: John's datapath */ /* 1: Caleb's datapath */ clearg lgt; /* ------------------------------------------------ */ /* Part II:how it runs switches */ /* ------------------------------------------------ */ restart = 1; /* choices 0: load investment parameter values from last run */ /* 1: start with initial values (see resetp subrout.) */ /* last run must have same # of inv. returns! */ redogmm = 1; /* choices 1: do gmm estimation */ /* <>1: no gmm estimation performed */ nwlags = 4; /* newey west lags in test statistics. can be vector. */ step2 = 0; /* choices 0: no second stage */ /* 1: second stage */ /* 2: iterated */ __output = 0 ; /* choices 2: display optmum iterations to screen */ /* 0: no optmum iterations on screen */ _opalgr = 2; /* algorithm for optmum */ asstcode = 1; /* choices: 1: vw and t-bill */ /* 2: deciles and t-bill */ instcode = 1; /* choices: 1: const */ /* 3: const, term, lag tb, d/p */ invrcode = 1; /* choices: 1: nonres and res investment */ factcode = 1; /* choices: 1: use unscaled factors only */ /* 2: add scaled factors */ momcode = 1; /* choices: 1: do unconditional moments */ /* 2: use scaled returns */ load avdecret,avvwret,avewret,avustret; load qterm,qdef,qvwdp,qewdp; load gin82, gir82; /* use non-averaged returns from larsnber for compatibility */ load path = \j\larsnber\procs; #include \j\larsnber\procs\loaddat.gpg; load path = \j\newprod; avvwret = vw[2:rows(vw)]; avustret = ust[2:rows(ust)]; output file=gmm.out reset; "Algorithm used" _opalgr; /* -------------------------------------------------------------------- */ /* 1. set up asset returns, instruments, investment, and extra factors */ /* -------------------------------------------------------------------- */ if asstcode == 1; rassetx = avvwret~avustret ; "Assets = 10 deciles and UST, plus any investment returns" ; endif; if asstcode == 2; rassetx = avdecret~avustret ; "Assets = 10 deciles and UST, plus any investment returns" ; endif; if instcode == 1; inst = 0; "No instruments"; endif; if instcode == 3; inst = vwdp~(fygl-fygn3)~(vw-ust); inst = 1 + .2*(inst-meanc(inst)')./(stdc(inst)'); "using instruments"; endif; if invrcode == 1; invest = gin82~gir82; let invlbl = "nonres" "resid"; "investment series: " $invlbl'; endif; /* ----------------------------------- */ /* 2. set parameters to initial values */ /* ----------------------------------- */ alpha = 3; /* original starting values */ delta = .2/4; /* .15? */ mpk = .05; alpha = alpha*ones(cols(invest),1); delta = delta*ones(cols(invest),1); mpk = mpk *ones(cols(invest),1); /* --------------------------------------------------------------- */ /* 3. shorten series if you're going to use instruments, set howto */ /* --------------------------------------------------------------- */ if inst /= 0; inst = inst[1:rows(inst)-1,.]; /* inst from 47:1 to 90:3, */ invest = invest[1:rows(invest),.]; /* others from 47:2 to 90:4 */ rassetx = rassetx[1:rows(rassetx),.]; endif; selpar = 0|0|1; howto = 1|1|1; if (factcode == 1); /* nonscaled */ howto[2] = 1; endif; if (factcode == 2) ; /* scaled*/ howto[2] = 2; endif; howto[3] = momcode; /* howto[1] = 1: treat inv ret like any other asset; test for pricing * 2: like 1; hold b's constant for gradients, std. errors * howto[2] = 1: factors = investment returns * 2: factors = scaled investment returns * howto[3] = 1: use unconditional moments (even if scaled factors) * 2: use conditional moments (must provide inst!) */ /* ------------------------------ */ /* 4. do GMM to find parameters */ /* ------------------------------ */ if redogmm; {alpha,delta,mpk,b,m} = doitl(alpha,delta,mpk,selpar,howto,invest,rassetx,inst, nwlags,step2,invlbl); endif; "mean of m" meanc(m); "stddev m " stdc(m); "parameters" ; "alpha" alpha'; "delta" delta'; "mpk " mpk'; "b " b'; if momcode == 2; zm = ones(rows(inst),1)~inst; b = m/zm; eminv = zm*b; seminv = stdc(eminv); res = m - eminv; s2inv = (stdc(res)^2)*(rows(res)-1)/(rows(res)-cols(zm)); "100* std dev cond mean"; 100*seminv; "E(cond var)^1/2"; s2inv^(1/2); endif; "moments" lgt'; save path = \j\larsnber\procs; if instcode == 1; minvest = m; save minvest; parv = alpha|delta|mpk|b; save parv; endif; if instcode == 3; minvscf = m; save minvscf; endif; save path = \j\newprod; output off;