Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python scipy.stats.linregresse-获取截距的p值_Python_Statistics_Scipy_Statsmodels - Fatal编程技术网

Python scipy.stats.linregresse-获取截距的p值

Python scipy.stats.linregresse-获取截距的p值,python,statistics,scipy,statsmodels,Python,Statistics,Scipy,Statsmodels,返回与坡度对应的p值,但不返回截距的p值。从DOCS中考虑下面的例子: >>> from scipy import stats >>> import numpy as np >>> x = np.random.random(10) >>> y = np.random.random(10) >>> slope, intercept, r_value, p_value, std_err = stats.linr

返回与坡度对应的p值,但不返回截距的p值。从DOCS中考虑下面的例子:

>>> from scipy import stats
>>> import numpy as np
>>> x = np.random.random(10)
>>> y = np.random.random(10)
>>> slope, intercept, r_value, p_value, std_err = stats.linregress(x,y)
>>> p_value
0.40795314163864016
根据文档,
p值
是“假设检验的双边p值,其无效假设是斜率为零。”我想得到相同的统计数据,但是截距而不是斜率

立即返回两个系数的p值:

>>> import numpy as np

>>> import statsmodels.api as sm

>>> X = sm.add_constant(x)
>>> model = sm.OLS(y,X)
>>> results = model.fit()
>>> results.pvalues
array([ 0.00297559,  0.40795314])    
仅使用scipy,如何获取截取的p值(0.40795314163864016)?

来自scipy.org文档:

输入:打印“r平方:”,r_值**2

输出:r平方:0.15286643777

对于其他参数,请尝试:

print ('Intercept is: ', (intercept))
print ('Slope is: ', (slope))
print ('R-Value is: ', (r_value))
print ('Std Error is: ', (std_err))
print ('p-value is: ', (p_value))

问题是是否需要截距的p值。这不是答案。