I have a dataset where I know how many units of each product I have in starting inventory. Then I know how many units of a given product were sold. I also know how many units of all other products were sold. The question I'm trying to answer is were the total number of units sold of a particular product significantly higher than I would expect based on the products percentage of starting inventory. I've read the documentation on proportions_ztest. It talks about numbers of observations, so I want to check if I'm using it correctly for units sold. With the code below I'm trying to get the p-value.
sold= total number of units sold of product1
tot_sld= total number of units sold including all products
perc_strt= (total number of units of product1 in starting inventory)/(total number of units from all products in starting invetory)
code:
import statsmodels.api as sm
sm.stats.proportions_ztest(x['sold'],
x['tot_sld'],
x['perc_strt'],
alternative='larger')[1]
Update Example:
product1 start inventory=20 units
product2 start inventory=30 units
prodcut3 start inventory=50 units
product1 perc_strt=20%
number of units sold of product1=10 units
number of units sold of product2=10 units
number of units sold of product3=20 units
tot_sld=40 units
so
x['sold']=10
x['tot_sld']=40
x['perc_strt']=0.2
Update:
the one population proportion test from this post seems to confirm my original approach