import pyblp pyblp.__version__
In this example, we’ll design a matrix without an intercept, but with both prices and another numeric size variable.
formulation = pyblp.Formulation('0 + prices + size') formulation
prices + size
Next, we’ll design a second matrix with an intercept, with first- and second-degree size terms, with categorical product IDs and years, and with the interaction of the last two. The first formulation will include include the fixed effects as indicator variables, and the second will absorb them.
formulation1 = pyblp.Formulation('size + I(size ** 2) + C(product) * C(year)') formulation1
1 + size + I(size ** 2) + C(product) + C(year) + C(product):C(year)
formulation2 = pyblp.Formulation('size + I(size ** 2)', absorb='C(product) * C(year)') formulation2
size + I(size ** 2) + Absorb[C(product)] + Absorb[C(year)] + Absorb[C(product):C(year)]
Finally, we’ll design a third matrix with an intercept and with a yearly trend interacted with the natural logarithm of income and categorical education. Absorption of continuous variables is not supported, so we need to use dummy variables.
formulation = pyblp.Formulation('year:(log(income) + C(education))') formulation
1 + year:log(income) + year:C(education)