class TestReturns(object):
    """ Class for testing correct parameters are returned from firststage"""

    def __init__(self):
        self.opts = {'tables': 0, 'reaction': 'simple', 'entrance': 1,
                     'verbose': 1}
        self.bbl = BBL(self.opts['tables'], self.opts['reaction'],
                       self.opts['entrance'], self.opts['verbose'])
        self.bbl._firststage()
        self.fs_params = self.bbl.fs_params
    
    def test_demand(self):
        tvars = [
            'tuition_hat', 'MedianLSAT', 'UndergraduatemedianGPA',
            'OverallRank', 'treat', 'RankTreat', 'AL', 'AR', 'WY'
        ]
        expected = np.array([
            -0.927284, 19.286605, -203.475186, -1.167404, -22.917197,
            0.354199, -1749.431023, -1799.828207, -1875.056317
        ])
        print("Actual")
        print(self.fs_params['demand'][tvars])
        assert np.allclose(self.fs_params['demand'][tvars], expected)

    def test_react(self):
        pass

    def test_entry(self):
        pass

    def test_rank(self):
        pass
 def __init__(self):
     opts = {'tables': 0, 'reaction': 'simple', 'entrance': 1, 'verbose': 1}
     bbl = BBL(opts)
     data = bbl.data
     bbl._firststage()
     self.fs_params = bbl.fs_params
     path = dirname(dirname(dirname(__file__)))
     path = join(path, 'Results', 'SecondStage', 'SSEst.npy')
     ss_params = np.load(path)
     self.countersim = lps.CounterfactualSim(data, self.fs_params,
                                             ss_params, opts)
 def __init__(self):
     self.opts = {'tables': 0, 'reaction': 'simple', 'entrance': 1,
                  'verbose': 1}
     self.bbl = BBL(self.opts['tables'], self.opts['reaction'],
                    self.opts['entrance'], self.opts['verbose'])
     self.bbl._firststage()
     self.fs_params = self.bbl.fs_params
class Second(object):
    """ Base class for testing Second Stage classes/methods """

    def __init__(self):
        self.opts = {'tables': 0, 'reaction': 'simple', 'entrance': 1,
                     'verbose': 1}
        self.bbl = BBL(self.opts)
        self.data = self.bbl.data
        self.fs_params = self.first_stage()
        self.sim = ss.Simulation(
            fs_params=self.fs_params, ss_params=[],
            constants={'n_periods': 2, 'n_sims': 2},
            opts=self.opts
        )

    def first_stage(self):
        """ Get first-stage coefficients """
        self.bbl._firststage()
        return self.bbl.fs_params
 def __init__(self):
     self.opts = {'tables': 0, 'reaction': 'simple', 'entrance': 1,
                  'verbose': 1}
     self.bbl = BBL(self.opts)
     self.data = self.bbl.data
     self.fs_params = self.first_stage()
     self.sim = ss.Simulation(
         fs_params=self.fs_params, ss_params=[],
         constants={'n_periods': 2, 'n_sims': 2},
         opts=self.opts
     )
Example #6
0
def driver(opts):
    """
    Replicate paper results

    Args:
        opts: Dict with members:
            data: 1 to format data
            tables: 1 to recreate latex tables and figures
            react: 'simple' to use median quality reaction variables
                   'full' to use 25, 50, and 75 quantiles
            entrance: 1 to estimate with entrance/exit decision
            verbose: 1 to print estimation and simulation output to screen
                     during runtime
            nose: 1 to run tests before program
    """
    path = dirname(realpath(__file__))

    if opts['pylint']:
        run_pylint()
        return 0

    if opts['nose']:
        run_nosetests()
        return 0

    if opts['clean']:
        #clear_results()
        opts['generate'] = 1  # SS results need to be regenerated now
        reset_results = ResetResults(path)
        reset_results.reset()

    if opts['tables']:
        initial_tables(path)
    
    if opts['data']:
        data_format()

    my_bbl = BBL(opts)
    if not my_bbl.data_check():
        my_bbl.estimate()
        my_bbl.simulate()

    if opts['tables']:
        post_tables(path)

    if opts['latex']:
        typeset_latex(path)

    if opts['beamer']:
        typeset_beamer(path)

    print("* ------------------ *")
    print("*    RUN COMPLETE    *")
    print("* ------------------ *")