Getting Started

This notebook illustrates the key concepts of OpenFisca that you will find in the documentation.

Table of Contents

Calculate a variable

Do some imports

In [1]:
from openfisca_france import FranceTaxBenefitSystem

Initialize the french Tax and Benefit system : it launches the entire legislation.

In [2]:
tax_benefit_system = FranceTaxBenefitSystem()

Create a scenario: first step to give a familial situation for which you want to calculate taxes or benefits.

In [3]:
scenario = tax_benefit_system.new_scenario()

Initialize a test case (the familial situation) in the scenario: here we have one parent and two children.

In [4]:
    period = 2015,
    parent1 = dict(
        age = 30,
        salaire_de_base = 20000,
    enfants = [
        dict(age = 12),
        dict(age = 18),
<openfisca_france.scenarios.Scenario at 0x7f9e62bd6810>

Create a simulation: the OpenFisca frame for calculating taxes or benefits.

In [5]:
simulation = scenario.new_simulation()

Calculate a variable : af (allocations familiales) for example.

In [6]:
simulation.calculate('af', '2015-01')
array([129.99], dtype=float32)

Test the impact of a reform

A reform represents a modified version of the real Tax and Benefit legislation*

Reforms are gather in the module Reform of OpenFisca.

You have then to import the module extension corresponding to the reform of your concern.

Here we choose the fiscal reform of Landais, Piketty and Saez on the income tax (

It is already implemented in OpenFisca under the name landais_piketty_saez .

In [7]:
from openfisca_france.reforms import landais_piketty_saez

Create a modified version of the tax and benefit system, affected by the changes introduced by the reform

In [8]:
reform = landais_piketty_saez.landais_piketty_saez(tax_benefit_system)

Create the scenario you want to test.

In [9]:
def init_profile(scenario):
        period = '2013',
        parent1 = dict(
            age = 40,
            salaire_de_base = 50000,
    return scenario

With the reform

In [10]:
# Indicate that you want to perfom the reform on this scenario
reform_scenario = init_profile(reform.new_scenario())

#Simulate the reform
reform_simulation = reform_scenario.new_simulation() 

# Choose the variable you want to calcul : here the disposable income, "revenu_disponible"
reform_simulation.calculate('revenu_disponible', '2013')
array([13554.031], dtype=float32)

Without the reform: the baseline (counterfactual)

In [11]:
# Indicate that you want to perfom the standard system on this scenario
baseline_scenario = init_profile(tax_benefit_system.new_scenario())

# Simulate the standard scenario
baseline_simulation = baseline_scenario.new_simulation()

# Choose the variable you want to calcul
baseline_simulation.calculate('revenu_disponible', '2013')
array([33979.367], dtype=float32)
In [12]: