statsmodels

Print 'std err' value from statsmodels OLS results

99封情书 提交于 2019-12-09 08:30:31
问题 (Sorry to ask but http://statsmodels.sourceforge.net/ is currently down and I can't access the docs) I'm doing a linear regression using statsmodels , basically: import statsmodels.api as sm model = sm.OLS(y,x) results = model.fit() I know that I can print out the full set of results with: print results.summary() which outputs something like: OLS Regression Results ============================================================================== Dep. Variable: y R-squared: 0.952 Model: OLS Adj.

How to have multiple groups in Python statsmodels linear mixed effects model?

筅森魡賤 提交于 2019-12-09 06:42:55
问题 I am trying to use the Python statsmodels linear mixed effects model to fit a model that has two random intercepts, e.g. two groups. I cannot figure out how to initialize the model so that I can do this. Here's the example. I have data that looks like the following (taken from here): subject gender scenario attitude frequency F1 F 1 pol 213.3 F1 F 1 inf 204.5 F1 F 2 pol 285.1 F1 F 2 inf 259.7 F1 F 3 pol 203.9 F1 F 3 inf 286.9 F1 F 4 pol 250.8 F1 F 4 inf 276.8 I want to make a linear mixed

error: Microsoft Visual C++ 14.0 is required when installing python package

时光总嘲笑我的痴心妄想 提交于 2019-12-09 06:40:48
问题 I’m trying to download the package statsmodels by running in command prompt(admin) this command: pip3 install statsmodels and I get this error “error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools” Please note that I already installed Visual Studio 2015 and I also have Visual Studio 2013 installed on my machine. 回答1: Please download Visual C++ Build Tools 2015 Install the visualcppbuildtools

Any Python Library Produces Publication Style Regression Tables

丶灬走出姿态 提交于 2019-12-09 04:04:02
问题 I've been using Python for regression analysis. After getting the regression results, I need to summarize all the results into one single table and convert them to LaTex (for publication). Is there any package that does this in Python? Something like estout in Stata that gives the following table: 回答1: Well, there is summary_col in statsmodels ; it doesn't have all the bells and whistles of estout , but it does have the basic functionality you are looking for (including export to LaTeX):

Statsmodel ARIMA multiple input

北战南征 提交于 2019-12-08 11:28:13
问题 I want to create my first (seasonal) ARIMA model but I find the Statsmodel ARIMA documentation insufficient. I lack information about calculating the prediction from multiple arrays (these are numpy arrays). These numpy arrays are series of values for each minute of a day. I want to make the prediction using data from each day of the last year. Any advice/suggestions/links/hints on how to do that? I am using Python 3.6. 回答1: You will need to put your arrays into a single multidimensional

Statsmodels.formula.api OLS does not show statistical values of intercept

断了今生、忘了曾经 提交于 2019-12-08 07:10:43
问题 I am running the following source code: import statsmodels.formula.api as sm # Add one column of ones for the intercept term X = np.append(arr= np.ones((50, 1)).astype(int), values=X, axis=1) regressor_OLS = sm.OLS(endog=y, exog=X).fit() print(regressor_OLS.summary()) where X is an 50x5 (before adding the intercept term) numpy array which looks like this: [[0 1 165349.20 136897.80 471784.10] [0 0 162597.70 151377.59 443898.53]...] and y is a a 50x1 numpy array with float values for the

Statsmodels gives different ANOVA results to SPSS

两盒软妹~` 提交于 2019-12-08 06:54:30
问题 I'm getting acquainted with Statsmodels so as to shift my more complicated stats completely over to python. However, I'm being cautious, so I'm cross-checking my results with SPSS, just to make sure I'm not making any obvious blunders. Most of time, there's no difference, but I have one example of a two-way ANOVA that's throwing up very different test statistics in Statsmodels and SPSS. (Relevant point: the sample sizes in the ANOVA are mismatched, so ANOVA may not be the appropriate model

Product of two beta distributions

China☆狼群 提交于 2019-12-08 02:22:02
问题 Say I have two random variables: X ~ Beta(α1,β1) Y ~ Beta(α2,β2) I would like to compute distribution of Z = XY (the product of the random variables) With scipy , I can get the pdf of a single Beta with: from scipy.stats import beta rv = beta(a, b) x = np.linspace(start=0, stop=1, num=200) my_pdf = rv.pdf(x) But what about the product of two Betas? Can I do this analytically ? (Python/Julia/R solutions are fine). 回答1: For an analytical solution, have a look at this paper and this answer. A

Weighted Non-negative Least Square Linear Regression in python [closed]

老子叫甜甜 提交于 2019-12-07 23:54:17
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I know there is an weighted OLS solver, and a constrained OLS solver. Is there a routine that combines the two? 回答1: You can simulate OLS weighting by modifying the X and y inputs. In OLS, you solve β for X t X β = X t y . In Weighted OLS, you solve X t X W β = X t W y . where W is a diagonal matrix with

SandboxViolation error when installing statsmodels with easy_install

一笑奈何 提交于 2019-12-07 13:48:14
问题 I tried to install statsmodels Python library on a Fedora 19 system. I used easy_install as follows: easy_install -U statsmodels But I get the following error while installing: error: SandboxViolation: os.open('/root/.matplotlib/tmpvjSAwn', 131266, 384) {} The package setup script has attempted to modify files on your system that are not within the EasyInstall build area, and has been aborted. This package cannot be safely installed by EasyInstall, and may not support alternate installation