Skip to content

Commit

Permalink
v__0.193
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredgalichon committed Dec 18, 2024
1 parent 8c4588f commit ef50637
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions mec/replication/blp99.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def tau_from_lin(K=5,theta_2 = np.array([43.501, 3.612, 4.628, 1.818, 1.05, 2.05
return np.block([[sigma.T],[gamma.flatten()]]).flatten()


def construct_car_blp_model():

def construct_car_blp_model(lin_compatible = False):
prod,_ = load_blp_car_data()
prod['ones'] = 1.
mkt_o = prod['market_ids'].to_numpy()
Expand All @@ -49,14 +50,18 @@ def construct_car_blp_model():
xis_y_ind = organize_markets(mkt_o, prod[['prices','ones', 'hpwt','air','mpd','space' ]].to_numpy() )
# zetas_y_d are the instruments for demand side
zetas_y_d = organize_markets(mkt_o, create_blp_instruments(collapse_markets(mkt_o,phis_y_k), prod[['market_ids','firm_ids','car_ids']] ))
# gammas_y_l are the regression matrices for supply side
# gammas_y_l are the regression matrices for supply side, and chis_y_s are the instruments for supply side
thegamma = prod[['ones','hpwt','air','mpg','space','trend' ]].to_numpy()
thegamma[:,[1,3,4] ]= np.log(thegamma[:,[1,3,4] ])
if lin_compatible:
thechi = create_blp_instruments(thegamma , prod[['market_ids','firm_ids','car_ids']] )
thegamma[:,-1] += 71.
else:
thechi = create_blp_instruments(thegamma , prod[['market_ids','firm_ids','car_ids']] )
gammas_y_l = organize_markets(mkt_o,thegamma)
# chis_y_s are the instruments for supply side
thechi = create_blp_instruments(thegamma , prod[['market_ids','firm_ids','car_ids']] )
thechi[:,-1] = prod['mpd'].to_numpy()
# thechi[:,5] += 71.
if lin_compatible:
thechi[:,5] += 71.
chis_y_s = organize_markets(mkt_o,thechi)
#
# eta is the vector of unobservable agents characteristics
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="mec",
version="0.192",
version="0.193",
authors=["Alfred Galichon"],
author_email="ag133@nyu.edu",
licence="",
Expand Down

0 comments on commit ef50637

Please sign in to comment.