Skip to content

Commit

Permalink
Add regression intervals
Browse files Browse the repository at this point in the history
  • Loading branch information
mikamyrseth committed Sep 12, 2022
1 parent f5d24f3 commit 25d4564
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions linreg.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,18 @@ def regression(df: pd.DataFrame):
coefs = regression(df)
print("coeffs full data: ", coefs)

# set to 1 means two year intervals, 2 is 3 etc.
interval = 5

#split data into years
for i in range(2000, 2023):
for i in range(2000, 2023, interval):
# year_df = df[f"{i}-01-01":f"{i}-12-31"]
year_df = df.sort_index().loc[f"{i}-01-01":f"{i}-12-31", :]
print(year_df)
year_df = df.sort_index().loc[f"{i}-01-01":f"{i+(interval-1)}-12-31", :]
coefs = regression(year_df)
print(f"{i}-{i+(interval-1)}, {coefs[0]}, {coefs[1]}")
oil.append(coefs[0])
stocks.append(coefs[1])

print(oil)
print(stocks)
#print(oil)
#print(stocks)

Binary file modified regression data.xlsx
Binary file not shown.

0 comments on commit 25d4564

Please sign in to comment.