get ols regression results with for loop for dataframe against a constant
The solution for “get ols regression results with for loop for dataframe against a constant” can be found here. The following code will assist you in solving the problem.
import pandas as pd
import numpy as np
import statsmodels.api as sm
df = pd.DataFrame(np.random.randint(low=0, high=10, size=(5, 5)),
columns=[‘Historic_Rate’, ‘Overnight’, ‘1M’, ‘3M’, ‘6M’])
fit_d = {} # This will hold all of the fit results and summaries
for col in [x for x in df.columns if x != ‘Historic_Rate’]:
Y = df[‘Historic_Rate’] – df[‘Historic_Rate’].shift(1)
# Need to remove the NaN for fit
Y = Y[Y.notnull()]
X = df[col] – df[col].shift(1)
X = X[X.notnull()]
X = sm.add_constant(X) # Add a constant to the fit
fit_d[col] = sm.OLS(Y,X).fit()
More questions on [categories-list]
- tss from gene granges
- ixl ansers ixl ansers
- get coin prices node-binance
- how to setup netflix workflow worker
- spritesheets in pyqt spritesheets in pyqt
- cahokia mounds pictures cahokia mounds pictures cahokia mounds pictures
- python 2 decimal places how to get decimal part of a double in python set number of decimals python
- how to find nuber of tweets per day using python how to find nuber of tweets per day using python how to find nuber of tweets per day using python how to find nuber of tweets per day using python how to find nuber of tweets per day using python
- haskell get specific elements of a String
- vb net code snippets for storing password
- error TS2307: Cannot find module ‘@ngx-meta/core’.
- inline scripts encapsulated in tags