<jupyter_start><jupyter_text>Deleting dummy-columns for reference-variables. In the area-dummy I remove those areas not defined for those to be the control-variable - all area-dummies are thus evaluated relative to this.In the year-dummy I delete both 2019 and 2020; 2020, because this year is already represented by the Opened-dummy, and 2019 for this year to be the control in the year dummy-vector. All year-dummies are thus evaluated relative to 2019<jupyter_code>area_dummy['Other'] = area_dummy['NaN']
del area_dummy['NaN']
year_dummy.columns = [str(i) for i in year_dummy.columns] # Setting columns to strings for pystout-module to work later.
del year_dummy['2019'] # For reference-year
del year_dummy['2020'] # Included in Opened-variable instead
# Generating regression-data:
X = pd.DataFrame()
X['Rooms'] = Event['Rooms']
X['Close'] = Event['Close to Metro']
X['Cityring'] = Event['Cityring']
X['Opened'] = Event['Opened']
X['sq_m'] = Event['sq_m']

X['OpenedXClose'] = Event['Opened']*Event['Close to Metro']
X['OpenedXCityring'] = Event['Opened']*Event['Cityring']
X['CityringXClose'] = Event['Close to Metro']*Event['Cityring']

X['OpenedXCityringXClose'] = Event['Close to Metro'] * Event['Opened'] * Event['Cityring']
X = pd.merge(X,area_dummy,left_index=True,right_index=True)
X = pd.merge(X,year_dummy,left_index=True,right_index=True)<jupyter_output><empty_output><jupyter_text>Describing data:<jupyter_code># Removing irrelevant description-variables.
describe = np.transpose(X.describe())
del describe['min']
del describe['25%']
del describe['50%']
del describe['75%']
del describe['max']
del describe['count']
# Setting up a three-rowed table of descriptions:
first = describe[:17]
first['Variable'] = first.index.to_list()
first.reset_index(inplace=True)
del first['index']

second = describe[17:30]
second['Variable'] = second.index.to_list()
second.reset_index(inplace=True)
del second['index']

third = describe[30:]
third['Variable'] = third.index.to_list()
third.reset_index(inplace=True)
del third['index']
table = pd.merge(first,second,how='outer',left_index=True,right_index=True)
table = pd.merge(table,third,how='outer',left_index=True,right_index=True)
table_sorted = table[['Variable_x','mean_x','std_x','Variable_y','mean_y','std_y','Variable','mean','std']]
table_sorted.columns = ['var1', 'mean1', 'std1', 'var2', 'mean2', 'std2','var3','mean3','std3']
table_sorted = table_sorted.round(decimals=3)
table_sorted
# Printing LaTeX-code for the assignment:
print(table_sorted.to_latex())<jupyter_output>\begin{tabular}{llrrlrrlrr}
\toprule
{} &                   var1 &   mean1 &    std1 &  var2 &  mean2 &   std2 &  var3 &  mean3 &   std3 \\
\midrule
0  &                  Rooms &   2.795 &   1.126 &  1994 &  0.003 &  0.057 &  2007 &  0.016 &  0.125 \\
1  &                  Close &   0.435 &   0.496 &  1995 &  0.005 &  0.068 &  2008 &  0.011 &  0.106 \\
2  &               Cityring &   0.419 &   0.493 &  1996 &  0.007 &  0.083 &  2009 &  0.016 &  0.125 \\
3  &                 Opened &   0.099 &   0.299 &  1997 &  0.008 &  0.089 &  2010 &  0.020 &  0.139 \\
4  &                   sq\_m &  84.954 &  38.281 &  1998 &  0.008 &  0.086 &  2011 &  0.022 &  0.145 \\
5  &           OpenedXClose &   0.046 &   0.210 &  1999 &  0.007 &  0.086 &  2012 &  0.028 &  0.165 \\
6  &        OpenedXCityring &   0.044 &   0.206 &  2000 &  0.008 &  0.087 &  2013 &  0.033 &  0.179 \\
7  &         CityringXClose &   0.213 &   0.410 &  2001 &  0.007 &  0.086 &  2014 &  0.054 &  0.227 \\
8  &  OpenedXCityringXClos[...]<jupyter_text>Regressing on data:<jupyter_code># Deleting 'Other'-location variable from vector for this to be the control.
del X['Other']
# Regressing:
X = sm.add_constant(X)
model = sm.OLS(Event['log_Price'],X)
results_1 = model.fit(cov_type='HC1')
print(results_1.summary())
pystout(models=[results_1],
        file='/Users/holger/Documents/Python/Harmsen_Repo/Metro-Study/Tex files/Metro Regressions 1.tex',
        digits=3,
        endog_names=['Opening'],
        varlabels={'const':'Constant','displacement':'Disp','mpg':'MPG'},
        mgroups={'y = log(Price per sq. m, DKK)':[1,3]},
        modstat={'nobs':'Obs','rsquared_adj':'Adj. R\sym{2}','fvalue':'F-stat'}
        )<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16423872180451127, 'fraction_numerical': 0.07918233082706767, 'mean_word_length': 3.8101694915254236, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '455171', 'license': 'MIT', 'n_tokens_mistral': 1746, 'n_tokens_neox': 1544, 'n_words': 331, 'path': 'Metro-Study (SDS Exam)/Code/5) Model 1 regression.ipynb', 'repo_name': 'Holger-Harmsen/NumEcon', 'size': '4256'}