<jupyter_start><jupyter_text>read the dataset<jupyter_code>df = pd.read_excel('C:/Users/dcmn1/Documents/Learning Files/Cass/Term 1/SMM248 Statistics in Finance/week 5/mortgage.xlsx')<jupyter_output><empty_output><jupyter_text>Plotting<jupyter_code># Scatter plot for mdebt and income
x = df['income']
y = df['mdebt']

plt.style.use('ggplot')
plt.scatter(x, y)
plt.xlabel('personal income (billion $)')
plt.ylabel('mortgage debt (billion $)')
plt.show()
# Scatter plot for mdebt and mcost
a = df['mcost']
b = df['mdebt']

plt.scatter(a, b)
plt.xlabel('mortgage cost (billion $)')
plt.ylabel('mortgage debt (billion $)')
plt.show()<jupyter_output><empty_output><jupyter_text>Estimation<jupyter_code># Regression for income and mcost
# Unestricted model
X = df[['income', 'mcost']]
X = sm.add_constant(X)
Y = df['mdebt']

model = sm.OLS(Y, X)
result = model.fit().summary()
print(result)
# Regression for restricted model
B = df['mdebt']

model2 = smf.ols('mdebt~', data=df)
result2 = model2.fit().summary()
print(result2)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16777883698760723, 'fraction_numerical': 0.009532888465204958, 'mean_word_length': 6.894736842105263, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '609029', 'license': 'MIT', 'n_tokens_mistral': 450, 'n_tokens_neox': 411, 'n_words': 81, 'path': 'lecture_exercises/comp_lab5.ipynb', 'repo_name': 'linusqzdeng/pyfinance', 'size': '1049'}