Posts

Showing posts with the label statistics

Weibull distribution calculation Runtimewarning overflow

Image
Clash Royale CLAN TAG #URR8PPP Weibull distribution calculation Runtimewarning overflow I was trying to use the code below to calculate the Weibull distribution, but I am getting a runtime warning of overflow exp: given that my data is a list of 6 members , but containing big numbers, it seems that the calculation takes a lot and my plot is not like what I see in the link. I used the fit and got the error : too many values to unpack (expected 2) Weibull example code 1 import scipy.stats as s import numpy as np import matplotlib.pyplot as plt def weib(x,n,a): return (a / n) * (x / n)**(a - 1) * np.exp(-(x / n)**a) data = [ 79000 , 85900 , 95000, 101000, 155250 , 280000] (loc, scale) = s.exponweib.fit_loc_scale(data, 1, 1) print loc, scale x = np.linspace(data[0], data[-1], 1000) plt.plot(x, weib(x, loc, scale)) plt.hist(data, data[-1], normed=True) plt.show() Method 2 : I tried this code : using this source ( code 2 ) data = [ 79000 , 85900 , 95000, 101000, 155250 , 280000] xdata...

Extracting statiscal values from a list with multiple lists of results of statistical test

Image
Clash Royale CLAN TAG #URR8PPP Extracting statiscal values from a list with multiple lists of results of statistical test I did a Ljung-Box Test for independence in r with 36 lags and stored the results in a list. for (lag in c(1:36)){ box.test.list[[lag]] <- (Box.test(btcr, type = "Ljung", lag)) } I want to extract the p-values as well as the test statistic (X-squared) and print them out to look something like: X-squared = 100, p-value = 0.0001 I also want to pull it out p-value indivually but rather than just spit out numbers, I want something like: [1] p-value = 0.001 [2] p-value = 0.0001 and so on. Can this be done? By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

'Series' object is not callable Error / Statsmodels illegal variable name

Image
Clash Royale CLAN TAG #URR8PPP 'Series' object is not callable Error / Statsmodels illegal variable name Update: You can download my dataset here. I am running a simple OLS regression with statsmodels and pandas dataframe as following: import statsmodels.formula.api as sm import pandas as pd df=pd.read_csv("exp.csv") #df is a dataframe that I have containing many variable names such as AAPL, SPY, INF, etc. for column in df: result=sm.ols(formula="SPY"+" ~ "+column, data=df).fit() However, one of the column name in df is INF . I guess maybe INF is a reserved word for pasty, the code gives me the following error: INF INF Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/ap248/.local/easybuild/software/2017/Core/miniconda2/4.3.27/lib/python2.7/site-packages/statsmodels/base/model.py", line 155, in from_formula missing=missing) File "/home/ap248/.local/easybuild/softw...