statsmodels

How to save each iterating Statsmodel as a file to be used later?

How to save each iterating Statsmodel as a file to be used later? Question: I have the following table generated: import pandas as pd import numpy as np from matplotlib import pyplot as plt # Generate ‘random’ data np.random.seed(0) X = 2.5 * np.random.randn(10) + 1.5 res = 0.5 * np.random.randn(10) y = 2 + …

Total answers: 2

Loop through each row and build regression model & plot (n-1 row step through)

Loop through each row and build regression model & plot (n-1 row step through) Question: I have a simple linear regression model below, that has been fit to a 10 row data. import pandas as pd import numpy as np from matplotlib import pyplot as plt # Generate ‘random’ data np.random.seed(0) X = 2.5 * …

Total answers: 2

Statsmodels Clustered Logit Model With Robust Standard Errors

Statsmodels Clustered Logit Model With Robust Standard Errors Question: I have the following dataframe: df.head() id case volfluid map rr o2 fluid 1044 36 3 3.0 1.0 3.0 2.0 0.0 1045 37 3 2.0 3.0 1.0 2.0 1.0 1046 38 3 3.0 2.0 2.0 1.0 0.0 1047 36 4 2.0 3.0 1.0 3.0 1.0 1048 …

Total answers: 1

ImportError: DLL load failed while importing _fblas

ImportError: DLL load failed while importing _fblas Question: While I was importing statsmodels.api as sm it shows this error, how can I fix it? the same error appeared when I tried to import scipy.stats. And both of them worked well while doing the import statsmodel and import scipy ErrorDescription ErrorDescription I tried to reinstall it …

Total answers: 1

Fitted regression line parameters in python

Fitted regression line parameters in python Question: How can I get the intercept and the slope of the fitted regression line in qqplot? Here’s a small working example, where I want the parameters of the red regression line: import statsmodels.api as sm import scipy.stats as stats import numpy as np np.random.seed(100) a = np.random.normal(0, 4, …

Total answers: 2

Custom Standard Errors with Statsmodels / Stargazer

Custom Standard Errors with Statsmodels / Stargazer Question: I am running a series of OLS regressions in Python, where I am using standard errors that I calculate using a custom function. I am now exporting my regression results into tables, and plan on using the stargazer package (linked here). However, stargazer relies on regression results …

Total answers: 1

add numpy array to pandas df

add numpy array to pandas df Question: Im experimenting with time series predictions something like this: import pandas as pd from statsmodels.tsa.statespace.sarimax import SARIMAX model = SARIMAX(data.values, order=order, seasonal_order=seasonal_order) result = model.fit() train = data.sample(frac=0.8,random_state=0) test = data.drop(train.index) start = len(train) end = len(train) + len(test) – 1 # Predictions for one-year against the test …

Total answers: 1

How to get/isolate the p-value from 'AnovaResults' object in python?

How to get/isolate the p-value from 'AnovaResults' object in python? Question: I want to use one way repeated measures anova in my dataset to test whether the values of 5 patients differ between the measured 3 days. I use AnovaRM from statsmodels.stats.anova and the result is an ‘AnovaResults’ object. I can see the p-value with …

Total answers: 2

How to get Effect Size from tt_ind_solve_power?

How to get Effect Size from tt_ind_solve_power? Question: I am trying to get the Effect Size given my alpha, power, sample size, ratio. I found tt_ind_solve_power to do this but how would this work for 4 variants + 1 control? This is how I have it currently from statsmodels.stats.power import tt_ind_solve_power effect_size = tt_ind_solve_power(nobs1=X, alpha=0.05, …

Total answers: 1