pandas - Margin of Error for Complex Sample in Python -
i have weighted stata dataset of national survey (n=6342). data has been weighted, i.e. each respondent represents 4000 respondents on average.
i reading dataset pandas.read_stata
function. basically, need achieve extract data each question respected frequencies(%) along margin of error each frequency.
i have written python code , works fine frequency itself, i.e. calculating sum of weighted value in each frequency , divide total weighted value sum.
pseudo-code looks this:
q_5 = dataset['q5'].unique()` frequencies = {} value in q_5: variable = dataset[dataset['q5'] == value] freq = ((variable['indwt'].sum()/weights_sum)*100) freq = round(freq,0) frequencies.update({value : freq})
however, cannot proper confidence intervals or margin of error since complex sample. advised use r instead, taking consideration syntax learning curve, rather stick python.
is there statistical package python calculate me complex sample?
Comments
Post a Comment