<jupyter_start><jupyter_text>Modified CAPE<jupyter_code># period from 1881-2006
split_period = 2007.01
x = np.log((np.array(df_acc[(df_acc["Date_x"]<split_period)]["Accounting Adjusted CAPE"]).astype(float)))
x = sm.add_constant(x)
y = np.array(df_acc[(df_acc["Date_x"]<split_period)]["10 year anualized stock real return float"]).astype(float)

model = sm.OLS(y, x, missing="drop")
summary = model.fit()
print(summary.summary())
# period 2007-2021
split_period = 2007.01
x = np.log((np.array(df_acc[(df_acc["Date_x"]>=split_period)]["Accounting Adjusted CAPE"]).astype(float)))
x = sm.add_constant(x)
y = np.array(df_acc[(df_acc["Date_x"]>=split_period)]["10 year anualized stock real return float"]).astype(float)

model = sm.OLS(y, x, missing="drop")
summary = model.fit()
print(summary.summary())
# overall period
x = np.log((np.array(df_acc["Accounting Adjusted CAPE"]).astype(float)))
x = sm.add_constant(x)
y = np.array(df_acc["10 year anualized stock real return float"]).astype(float)

model = sm.OLS(y, x, missing="drop")
summary = model.fit()
print(summary.summary())
plt.figure(figsize=(10, 8))
sns.regplot(df_acc["Accounting Adjusted CAPE"], 
            df_acc["10 year anualized stock real return float"], 
            label="Real Returns", 
            color='lightcoral')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17526555386949924, 'fraction_numerical': 0.02959028831562974, 'mean_word_length': 6.129729729729729, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '574899', 'license': 'MIT', 'n_tokens_mistral': 517, 'n_tokens_neox': 483, 'n_words': 91, 'path': 'notebooks/accounting.ipynb', 'repo_name': 'yuchen-robin-cao/Modifying-Shiller-CAPE-Ratio', 'size': '1318'}