def create_fortran_model(self, model_dir='__fortress_tmp', **kwargs): from fortress import make_smc from .translate import smc, write_prior_file smc_file = smc(self) model_linear = self.compile_model() other_files = {'data.txt': model_linear.yy, 'prior.txt': 'prior.txt'} make_smc(smc_file, model_dir, other_files=other_files, **kwargs) write_prior_file(model_linear.prior, model_dir)
def create_fortran_model(self): if self.smc_file is None: smc_file = smc(self.model) else: smc_file = self.smc_file model_linear = self.model.compile_model() other_files = {'data.txt': model_linear.yy, 'prior.txt': 'prior.txt'} make_smc(smc_file, other_files=other_files, output_directory=self.fortran_directory) write_prior_file(model_linear.prior, self.fortran_directory)
def make_fortran_model(model, **kwargs): t0 = kwargs.pop('t0',0) from fortress import make_smc model_file = smc(model, t0=t0) modelc = model.compile_model() r = make_smc(model_file, other_files={'data.txt': modelc.yy, 'prior.txt': 'prior.txt'}, **kwargs) output_dir = kwargs.pop('output_directory','_fortress_tmp') write_prior_file(modelc.prior, output_dir) return r
def make_fortran_model(model, **kwargs): t0 = kwargs.pop("t0", 0) from fortress import make_smc model_file = smc(model, t0=t0) modelc = model.compile_model() r = make_smc( model_file, other_files={"data.txt": modelc.yy, "prior.txt": "prior.txt"}, **kwargs ) output_dir = kwargs.pop("output_directory", "_fortress_tmp") write_prior_file(modelc.prior, output_dir) return r
modelfile = open('ms_minnpr.f90', 'r').read() modelfile = modelfile.format(data=dat, prior=args.prior, m=args.m, v=args.v, p=swz.p, cons=swz.cons, nA=6, nF=48, mu_prior=mu_prior) lib_path = '/home/eherbst/anaconda3/lib' inc_path = '/home/eherbst/anaconda3/include' smc = make_smc(modelfile, other_files=other_files, output_directory=args.output_dir, lib_path=lib_path, inc_path=inc_path) elif args.prior == 'rfb': print('You`ve selected the RFB prior') lam = [1.0, 1.2, 1.0, 1.0, 1.0, 1.0] rfb = MinnesotaPrior([], lam, presample_moments=premom, p=5) rfb.ny = 3 other_files = {'data.txt': dat, 'qmean.txt': qmean, 'qvar.txt': qvar} other_parameters = { 'lam{:d}'.format(d + 1): '{}_wp'.format(val) for d, val in enumerate(lam) }
varfile = open('svar.f90', 'r').read() varfile = varfile.format(assign_para='\n'.join(A0str + Apstr), **vars(ei)) other_files = { 'data.txt': data['1993':'2007-06'][model['yy']].values, 'proxy.txt': proxy.values, 'priordraws.txt': priorsim[:args.nsim].T, 'phistar.txt': phihatT.flatten(order='F'), 'iw_Psi.txt': S, 'Omega_inv.txt': np.linalg.inv(omega) } output_dir = '_fortress_' + args.model smc = make_smc(varfile, other_files=other_files, output_directory=output_dir) if 'fin' in args.model: print( "For financial shock, you need to impose the sign restriction manually in the fortran code!" ) smc.run(npart=args.nsim, nblocks=25, nproc=args.nproc, bend=2.7, conditional_covariance=True, initial_particles=output_dir + '/priordraws.txt', output_file='%s.json' % args.model)