Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import statsmodels.api as sm
- import matplotlib.pyplot as plt
- N, M = 100, 10
- b_N, b_M = [], []
- for i in range(5000):
- x = np.random.random(N)
- y = 2*x + 1 + np.random.random(N)
- _, b_1 = sm.OLS(y, sm.add_constant(x)).fit().params
- b_N.append(b_1)
- _, b_1 = sm.OLS(y[:M], sm.add_constant(x[:M])).fit().params
- b_M.append(b_1)
- plt.hist(b_M)
- plt.hist(b_N)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement