1

How do I get P Value at different confidence level other than the default (95%) in python scipy t test or other statistical tests? For example:

import scipy
from scipy import stats
data = [10,12,34,34,45,67,56,78,90,67,80,45,47,58]
stats.ttest_1samp(data,40)

Results are as below --

Out[7]: Ttest_1sampResult(statistic=1.808, pvalue=0.093) 

but I need p-value at 90% and 99% confidence level too.

Only one answer is there but not very clear about where its confidence level is specified. Python p-value from t-statistic

Is there any other alternate to Scipy in Python for it, if it can't be done with Scipy?

erip
  • 16,374
  • 11
  • 66
  • 121
Luke
  • 46
  • 4
  • 3
    I think you're misunderstanding p-values. You compare the p-value to significance levels when your confidence is 0.9 or 0.95, etc. More concretely: p-values are _not_ a function of confidence. – erip Jun 03 '18 at 15:19
  • @erip-Thanks for your answer very sure about how to interpret but was looking for same functionality as in R -[https://www.rdocumentation.org/packages/stats/versions/3.5.0/topics/t.test] – Luke Jun 03 '18 at 16:38
  • I don't know anything about R, but my guess is that given a confidence interval, it tells you whether you reject or fail to reject a hypothesis given the data... Is that right? – erip Jun 03 '18 at 22:06
  • @erip -I agree with you and accept this as Answer..you made my day .thanks a lot.I am very new to coding and stack overflow..coming from SPSS /SAS/Mintab background still was not able catch very basic stuff.Not sure how to accept this answer not seeing any option..sorry for that.. Please link this answer to this question also https://stackoverflow.com/questions/17559897/python-p-value-from-t-statistic – Luke Jun 04 '18 at 14:14
  • Mine is just a comment. You can accept [this](https://stackoverflow.com/a/50668019/2883245) which states basically what I wrote, but more eloquently. :) – erip Jun 04 '18 at 18:50

1 Answers1

0

There will only be a single p-value for the T-test of equality between the mean of an independent sample and the given population mean.

This may subjectively be considered significant at a given confidence level based on its value.

In your test, the p-value of 0.093 indicates that there is a 9.3% chance of the observed sample mean arising from an independent sample from a population with mean 40. This would be considered significant (i.e. would lead to rejection of the null hypothesis) at the 90% confidence level (since 9.3% <= 10%), but not at the 95% confidence level or 99% confidence level.

twolffpiggott
  • 1,063
  • 8
  • 13