0

I have a population that has an average weight of 5 lbs. I've taken sample of 5879 observations from the population. The sample has a total weight of 410522 lbs. I'm trying to figure out if the sample has a significantly higher average weight than the population. Assuming that the population has a normal distribution. I'm trying to use the proportions_ztest from stats model. I'm not sure if I'm using the counts and nobs variables correctly. Can someone please tell me if I'm using the function correctly, or suggest another function? I'm trying to get the p-value.

code:

import statsmodels.api as sm

cnt=410522
nbs=58759
vL=5


sm.stats.proportions_ztest(cnt, 
                                  nbs,
                                  vL, 
                                  alternative='larger')[1]
user3476463
  • 3,967
  • 22
  • 57
  • 117
  • weight is not a proportion, so the standard t-test can be used. proportion test does not apply in this form. – Josef Oct 30 '19 at 13:34

1 Answers1

1

You can use scipy.stats.ttest_1samp(a, popmean) to get t and p_value.

This is a two-sided test for the null hypothesis that the expected value (mean) of a sample of independent observations a is equal to the given population mean, popmean.

Read more detail here.

If you want to test if the samples has a significantly higher average weight than the population, you should divide the P-value/2 to get right-tailed P_value.

Ha Bom
  • 2,787
  • 3
  • 15
  • 29
  • Thank you for getting back to me this is just what I was looking for. – user3476463 Oct 30 '19 at 15:11
  • If I want to know if the sample mean is greater than the popuation mean do I need 1-p/2, or just p/2 if sample mean is greater than pop mean? – user3476463 Oct 30 '19 at 15:38
  • You should note that the H0 hypothesis is sample_mean = pop_mean, Ha hypothesis is sample_mean > pop_mean in this case, so if the P_value is less than the significant level, said 0.05, you can reject the H0 and conclude that the samples has a significantly higher average weight than the population. – Ha Bom Oct 31 '19 at 02:14