Survey statistics
survey rakesurvey rakesurvey poststratifysurvey poststratifysurvey estimatesurvey estimatesurvey marginsurvey marginsurvey sample_sizesurvey sample_sizesurvey allocationsurvey allocationsurvey crosstabsurvey crosstab
survey rake <json_rows> <json_margins>
Description
Raking (iterative proportional fitting): weights of the respondents so that the weighted shares match the known margins of several variables; design effect and effective sample size of the weights
Raking (iterative proportional fitting): weights of the respondents so that the weighted shares match the known margins of several variables; design effect and effective sample size of the weights
Parameters
json_rows: The respondents - String - required
json_margins: {"variable": {"category": share or count, ...}, ...} - String - required
json_rows: The respondents - String - required
json_margins: {"variable": {"category": share or count, ...}, ...} - String - required
admin
survey rake "[{\"id\": 0, \"sex\": \"M\", \"age\": \"18-34\", \"vote\": \"yes\", \"score\": 4.2}, {\"id\": 1, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 5.9}, {\"id\": 2, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"no\", \"score\": 2.7}, {\"id\": 3, \"sex\": \"M\", \"age\": \"65+\", \"vote\": \"no\", \"score\": 2.2}, {\"id\": 4, \"sex\": \"M\", \"age\": \"18-34\", \"vote\": \"no\", \"score\": 3.3}, {\"id\": 5, \"sex\": \"F\", \"age\": \"65+\", \"vote\": \"yes\", \"score\": 5.4}, {\"id\": 6, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 6.8}, {\"id\": 7, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 5.3}, {\"id\": 8, \"sex\": \"F\", \"age\": \"65+\", \"vote\": \"no\", \"score\": 5.5}, {\"id\": 9, \"sex\": \"F\", \"age\": \"35-64\", \"vote\": \"no\", \"score\": 3.2}, {\"id\": 10, \"sex\": \"F\", \"age\": \"35-64\", \"vote\": \"no\", \"score\": 4.6}, {\"id\": 11, \"sex\": \"M\", \"age\": \"65+\", \"vote\": \"no\", \"score\": 7.3}, {\"id\": 12, \"sex\": \"M\", \"age\": \"65+\", \"vote\": \"no\", \"score\": 2.4}, {\"id\": 13, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"no\", \"score\": 1.0}, {\"id\": 14, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"no\", \"score\": 4.5}, {\"id\": 15, \"sex\": \"M\", \"age\": \"18-34\", \"vote\": \"no\", \"score\": 6.3}, {\"id\": 16, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 7.7}, {\"id\": 17, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 6.0}, {\"id\": 18, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 7.2}, {\"id\": 19, \"sex\": \"M\", \"age\": \"65+\", \"vote\": \"yes\", \"score\": 0.7}, {\"id\": 20, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"no\", \"score\": 6.4}, {\"id\": 21, \"sex\": \"M\", \"age\": \"18-34\", \"vote\": \"yes\", \"score\": 7.6}, {\"id\": 22, \"sex\": \"M\", \"age\": \"18-34\", \"vote\": \"yes\", \"score\": 4.3}, {\"id\": 23, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 5.7}]" "{\"sex\": {\"M\": 0.48, \"F\": 0.52}, \"age\": {\"18-34\": 0.28, \"35-64\": 0.48, \"65+\": 0.24}}"
mentdb
{"iterations": 15, "converged": true, "max_margin_gap": 7.967608531463574E-7, "sum_weights": 24.000000000000007, "min_weight": 0.2257348962264811, "max_weight": 3.811460231322728, "design_effect_kish": 2.1444224281638244, "effective_n": 11.191824747211843, "weights": [1.3440000000000003, 0.35427995794132267, 0.35427995794132267, 0.2257348962264811, 1.3440000000000003, 2.428530207547037, 0.35427995794132267, 0.35427995794132267, 2.428530207547037, 3.811460231322728, 3.811460231322728, 0.2257348962264811, 0.2257348962264811, 0.35427995794132267, 0.35427995794132267, 1.3440000000000003, 0.35427995794132267, 0.35427995794132267, 0.35427995794132267, 0.2257348962264811, 0.35427995794132267, 1.3440000000000003, 1.3440000000000003, 0.35427995794132267]}
Complete: respondents -> raking weights -> weighted estimate
admin
-> "[rows]" "[{\"id\": 0, \"sex\": \"M\", \"age\": \"18-34\", \"vote\": \"yes\", \"score\": 4.2}, {\"id\": 1, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 5.9}, {\"id\": 2, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"no\", \"score\": 2.7}, {\"id\": 3, \"sex\": \"M\", \"age\": \"65+\", \"vote\": \"no\", \"score\": 2.2}, {\"id\": 4, \"sex\": \"M\", \"age\": \"18-34\", \"vote\": \"no\", \"score\": 3.3}, {\"id\": 5, \"sex\": \"F\", \"age\": \"65+\", \"vote\": \"yes\", \"score\": 5.4}, {\"id\": 6, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 6.8}, {\"id\": 7, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 5.3}, {\"id\": 8, \"sex\": \"F\", \"age\": \"65+\", \"vote\": \"no\", \"score\": 5.5}, {\"id\": 9, \"sex\": \"F\", \"age\": \"35-64\", \"vote\": \"no\", \"score\": 3.2}, {\"id\": 10, \"sex\": \"F\", \"age\": \"35-64\", \"vote\": \"no\", \"score\": 4.6}, {\"id\": 11, \"sex\": \"M\", \"age\": \"65+\", \"vote\": \"no\", \"score\": 7.3}, {\"id\": 12, \"sex\": \"M\", \"age\": \"65+\", \"vote\": \"no\", \"score\": 2.4}, {\"id\": 13, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"no\", \"score\": 1.0}, {\"id\": 14, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"no\", \"score\": 4.5}, {\"id\": 15, \"sex\": \"M\", \"age\": \"18-34\", \"vote\": \"no\", \"score\": 6.3}, {\"id\": 16, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 7.7}, {\"id\": 17, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 6.0}, {\"id\": 18, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 7.2}, {\"id\": 19, \"sex\": \"M\", \"age\": \"65+\", \"vote\": \"yes\", \"score\": 0.7}, {\"id\": 20, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"no\", \"score\": 6.4}, {\"id\": 21, \"sex\": \"M\", \"age\": \"18-34\", \"vote\": \"yes\", \"score\": 7.6}, {\"id\": 22, \"sex\": \"M\", \"age\": \"18-34\", \"vote\": \"yes\", \"score\": 4.3}, {\"id\": 23, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 5.7}]"; json load "tuto_w" (survey rake [rows] "{\"sex\": {\"M\": 0.48, \"F\": 0.52}, \"age\": {\"18-34\": 0.28, \"35-64\": 0.48, \"65+\": 0.24}}"); #The answers in the order of the rows, then the weighted share of each answer; json load "tuto_e" (survey estimate (ml prep vector [rows] "vote") (json select "tuto_w" "/weights")); -> "[res]" (concat "yes: " (math round (* 100 (json select "tuto_e" "/estimates/[1]/proportion")) 1) " % (se " (math round (* 100 (json select "tuto_e" "/estimates/[1]/se")) 1) "), effective n " (math round (json select "tuto_w" "/effective_n") 1)); json unload "tuto_w"; json unload "tuto_e"; [res]
mentdb
yes: 38.2 % (se 13.7), effective n 11.2
survey rake <json_rows> <json_margins> <json_params>
Description
Raking with parameters: weight (field of the initial weights), total (sum of the weights: population size), bounds ([low, high] ratios to the initial weight: trimming), max_iterations, tolerance
Raking with parameters: weight (field of the initial weights), total (sum of the weights: population size), bounds ([low, high] ratios to the initial weight: trimming), max_iterations, tolerance
Parameters
json_rows: The respondents - String - required
json_margins: The margins - String - required
json_params: The parameters - String - required
json_rows: The respondents - String - required
json_margins: The margins - String - required
json_params: The parameters - String - required
admin
survey rake "[{\"id\": 0, \"sex\": \"M\", \"age\": \"18-34\", \"vote\": \"yes\", \"score\": 4.2}, {\"id\": 1, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 5.9}, {\"id\": 2, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"no\", \"score\": 2.7}, {\"id\": 3, \"sex\": \"M\", \"age\": \"65+\", \"vote\": \"no\", \"score\": 2.2}, {\"id\": 4, \"sex\": \"M\", \"age\": \"18-34\", \"vote\": \"no\", \"score\": 3.3}, {\"id\": 5, \"sex\": \"F\", \"age\": \"65+\", \"vote\": \"yes\", \"score\": 5.4}, {\"id\": 6, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 6.8}, {\"id\": 7, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 5.3}, {\"id\": 8, \"sex\": \"F\", \"age\": \"65+\", \"vote\": \"no\", \"score\": 5.5}, {\"id\": 9, \"sex\": \"F\", \"age\": \"35-64\", \"vote\": \"no\", \"score\": 3.2}, {\"id\": 10, \"sex\": \"F\", \"age\": \"35-64\", \"vote\": \"no\", \"score\": 4.6}, {\"id\": 11, \"sex\": \"M\", \"age\": \"65+\", \"vote\": \"no\", \"score\": 7.3}, {\"id\": 12, \"sex\": \"M\", \"age\": \"65+\", \"vote\": \"no\", \"score\": 2.4}, {\"id\": 13, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"no\", \"score\": 1.0}, {\"id\": 14, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"no\", \"score\": 4.5}, {\"id\": 15, \"sex\": \"M\", \"age\": \"18-34\", \"vote\": \"no\", \"score\": 6.3}, {\"id\": 16, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 7.7}, {\"id\": 17, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 6.0}, {\"id\": 18, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 7.2}, {\"id\": 19, \"sex\": \"M\", \"age\": \"65+\", \"vote\": \"yes\", \"score\": 0.7}, {\"id\": 20, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"no\", \"score\": 6.4}, {\"id\": 21, \"sex\": \"M\", \"age\": \"18-34\", \"vote\": \"yes\", \"score\": 7.6}, {\"id\": 22, \"sex\": \"M\", \"age\": \"18-34\", \"vote\": \"yes\", \"score\": 4.3}, {\"id\": 23, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 5.7}]" "{\"sex\": {\"M\": 0.48, \"F\": 0.52}}" "{\"total\": 850000, \"bounds\": [0.3, 3]}"
mentdb
{"iterations": 100, "converged": false, "max_margin_gap": 0.02, "sum_weights": 833000, "min_weight": 20400, "max_weight": 106250, "design_effect_kish": 1.8497292794668887, "effective_n": 12.974871656309107, "weights": [20400, 20400, 20400, 20400, 20400, 106250, 20400, 20400, 106250, 106250, 106250, 20400, 20400, 20400, 20400, 20400, 20400, 20400, 20400, 20400, 20400, 20400, 20400, 20400]}
Used in use cases (1 recipe)
Statistician & biostatistician › Opinion poll: raking on sex and age, weighted estimate and margin of error
Statistician & biostatistician › Opinion poll: raking on sex and age, weighted estimate and margin of error
survey poststratify <json_rows> <cell> <json_population>
Description
Post-stratification: weights so that the weighted count of each cell equals its population count
Post-stratification: weights so that the weighted count of each cell equals its population count
Parameters
json_rows: The respondents - String - required
cell: The cell field - String - required
json_population: {"cell": count, ...} - String - required
json_rows: The respondents - String - required
cell: The cell field - String - required
json_population: {"cell": count, ...} - String - required
admin
survey poststratify "[{\"id\": 0, \"sex\": \"M\", \"age\": \"18-34\", \"vote\": \"yes\", \"score\": 4.2}, {\"id\": 1, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 5.9}, {\"id\": 2, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"no\", \"score\": 2.7}, {\"id\": 3, \"sex\": \"M\", \"age\": \"65+\", \"vote\": \"no\", \"score\": 2.2}, {\"id\": 4, \"sex\": \"M\", \"age\": \"18-34\", \"vote\": \"no\", \"score\": 3.3}, {\"id\": 5, \"sex\": \"F\", \"age\": \"65+\", \"vote\": \"yes\", \"score\": 5.4}, {\"id\": 6, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 6.8}, {\"id\": 7, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 5.3}, {\"id\": 8, \"sex\": \"F\", \"age\": \"65+\", \"vote\": \"no\", \"score\": 5.5}, {\"id\": 9, \"sex\": \"F\", \"age\": \"35-64\", \"vote\": \"no\", \"score\": 3.2}, {\"id\": 10, \"sex\": \"F\", \"age\": \"35-64\", \"vote\": \"no\", \"score\": 4.6}, {\"id\": 11, \"sex\": \"M\", \"age\": \"65+\", \"vote\": \"no\", \"score\": 7.3}, {\"id\": 12, \"sex\": \"M\", \"age\": \"65+\", \"vote\": \"no\", \"score\": 2.4}, {\"id\": 13, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"no\", \"score\": 1.0}, {\"id\": 14, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"no\", \"score\": 4.5}, {\"id\": 15, \"sex\": \"M\", \"age\": \"18-34\", \"vote\": \"no\", \"score\": 6.3}, {\"id\": 16, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 7.7}, {\"id\": 17, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 6.0}, {\"id\": 18, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 7.2}, {\"id\": 19, \"sex\": \"M\", \"age\": \"65+\", \"vote\": \"yes\", \"score\": 0.7}, {\"id\": 20, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"no\", \"score\": 6.4}, {\"id\": 21, \"sex\": \"M\", \"age\": \"18-34\", \"vote\": \"yes\", \"score\": 7.6}, {\"id\": 22, \"sex\": \"M\", \"age\": \"18-34\", \"vote\": \"yes\", \"score\": 4.3}, {\"id\": 23, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 5.7}]" "sex" "{\"M\": 4800, \"F\": 5200}"
mentdb
{"cells": 2, "sum_weights": 10000, "min_weight": 240, "max_weight": 1300, "design_effect_kish": 1.89888, "effective_n": 12.639029322548028, "weights": [240, 240, 240, 240, 240, 1300, 240, 240, 1300, 1300, 1300, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240]}
survey poststratify <json_rows> <cell> <json_population> <json_params>
Description
Post-stratification with parameters: weight (initial weights)
Post-stratification with parameters: weight (initial weights)
Parameters
json_rows: The respondents - String - required
cell: The cell field - String - required
json_population: The counts - String - required
json_params: The parameters - String - required
json_rows: The respondents - String - required
cell: The cell field - String - required
json_population: The counts - String - required
json_params: The parameters - String - required
admin
survey poststratify "[{\"g\": \"a\", \"w\": 2}, {\"g\": \"a\", \"w\": 1}, {\"g\": \"b\", \"w\": 1}]" "g" "{\"a\": 60, \"b\": 40}" "{\"weight\": \"w\"}"
mentdb
{"cells": 2, "sum_weights": 100, "min_weight": 20, "max_weight": 40, "design_effect_kish": 1.08, "effective_n": 2.7777777777777777, "weights": [40, 20, 40]}
survey estimate <json_values> <json_weights>
Description
Weighted estimate of a mean (numbers) or of the proportion of each category (labels), with its standard error by linearization, interval and design effect
Weighted estimate of a mean (numbers) or of the proportion of each category (labels), with its standard error by linearization, interval and design effect
Parameters
json_values: The values - String - required
json_weights: The weights - String - required
json_values: The values - String - required
json_weights: The weights - String - required
admin
survey estimate "[\"yes\", \"no\", \"yes\", \"yes\", \"no\", \"yes\"]" "[1.2, 0.8, 1.1, 0.9, 1.5, 0.5]"
mentdb
{"n": 6, "sum_weights": 6, "effective_n_kish": 5.454545454545455, "estimates": [{"category": "no", "proportion": 0.3833333333333333, "se": 0.2341058639922451, "lower": -0.07550572866109934, "upper": 0.842172395327766, "design_effect": 1.1592244418331374}, {"category": "yes", "proportion": 0.6166666666666666, "se": 0.2341058639922451, "lower": 0.15782760467223395, "upper": 1.0755057286610992, "design_effect": 1.1592244418331374}]}
survey estimate <json_values> <json_weights> <json_params>
Description
Estimate with parameters: strata, clusters (primary units: one label per value), level, total (estimate the total instead of the mean)
Estimate with parameters: strata, clusters (primary units: one label per value), level, total (estimate the total instead of the mean)
Parameters
json_values: The values - String - required
json_weights: The weights - String - required
json_params: The parameters - String - required
json_values: The values - String - required
json_weights: The weights - String - required
json_params: The parameters - String - required
admin
survey estimate "[12, 15, 9, 22, 25, 19, 30, 28]" "[50, 50, 50, 40, 40, 40, 20, 20]" "{\"strata\": [\"a\", \"a\", \"a\", \"a\", \"b\", \"b\", \"b\", \"b\"], \"clusters\": [1, 1, 2, 2, 3, 3, 4, 4]}"
mentdb
{"n": 8, "sum_weights": 310, "effective_n_kish": 7.33587786259542, "estimates": [{"mean": 18.06451612903226, "se": 0.6518434789602295, "lower": 16.786926386712917, "upper": 19.342105871351603, "design_effect": 0.06672351111141124}]}
Used in use cases (1 recipe)
Statistician & biostatistician › Opinion poll: raking on sex and age, weighted estimate and margin of error
Statistician & biostatistician › Opinion poll: raking on sex and age, weighted estimate and margin of error
survey margin <proportion> <n>
Description
Margin of error of a proportion (with the Wilson interval)
Margin of error of a proportion (with the Wilson interval)
Parameters
proportion: The observed proportion - Number - required
n: The sample size - Number - required
proportion: The observed proportion - Number - required
n: The sample size - Number - required
admin
survey margin 0.52 1000
mentdb
{"margin_of_error": 0.030964949889274063, "lower": 0.48903505011072596, "upper": 0.5509649498892741, "wilson_lower": 0.4890177246575191, "wilson_upper": 0.5508292050030589, "effective_n": 1000}
survey margin <proportion> <n> <json_params>
Description
Margin of error with parameters: level (0.95), deff (design effect), population (finite population correction)
Margin of error with parameters: level (0.95), deff (design effect), population (finite population correction)
Parameters
proportion: The proportion - Number - required
n: The sample size - Number - required
json_params: The parameters - String - required
proportion: The proportion - Number - required
n: The sample size - Number - required
json_params: The parameters - String - required
admin
survey margin 0.52 1000 "{\"deff\": 1.6, \"population\": 20000}"
mentdb
{"margin_of_error": 0.038177108579379865, "lower": 0.4818228914206202, "upper": 0.5581771085793799, "wilson_lower": 0.4808295428799515, "wilson_upper": 0.5589261056214755, "effective_n": 625}
Used in use cases (1 recipe)
Statistician & biostatistician › Opinion poll: raking on sex and age, weighted estimate and margin of error
Statistician & biostatistician › Opinion poll: raking on sex and age, weighted estimate and margin of error
survey sample_size <margin>
Description
Sample size for a margin of error on a proportion (p = 0.5, 95 %)
Sample size for a margin of error on a proportion (p = 0.5, 95 %)
Parameters
margin: The margin of error - Number - required
margin: The margin of error - Number - required
admin
survey sample_size 0.03
mentdb
{"sample_size": 1068, "without_correction": 1068, "contacts_needed": 1068}
survey sample_size <margin> <json_params>
Description
Sample size with parameters: p, level, deff, population, response_rate (gives the contacts needed)
Sample size with parameters: p, level, deff, population, response_rate (gives the contacts needed)
Parameters
margin: The margin - Number - required
json_params: The parameters - String - required
margin: The margin - Number - required
json_params: The parameters - String - required
admin
survey sample_size 0.03 "{\"population\": 5000, \"deff\": 1.5, \"response_rate\": 0.4}"
mentdb
{"sample_size": 1213, "without_correction": 1601, "contacts_needed": 3033}
survey allocation <json_strata> <n>
Description
Allocation of a sample between strata (Neyman: N_h x sd_h), at least 1 per stratum, with the standard error of the mean
Allocation of a sample between strata (Neyman: N_h x sd_h), at least 1 per stratum, with the standard error of the mean
Parameters
json_strata: [{"name", "N", "sd", "cost"}, ...] - String - required
n: The total sample size - Number - required
json_strata: [{"name", "N", "sd", "cost"}, ...] - String - required
n: The total sample size - Number - required
admin
survey allocation "[{\"name\": \"small\", \"N\": 500, \"sd\": 2}, {\"name\": \"medium\", \"N\": 300, \"sd\": 8}, {\"name\": \"large\", \"N\": 50, \"sd\": 40}]" 100
mentdb
{"method": "neyman", "n": 100, "strata": [{"stratum": "small", "N": 500, "n": 19, "sampling_fraction": 0.038}, {"stratum": "medium", "N": 300, "n": 44, "sampling_fraction": 0.14666666666666667}, {"stratum": "large", "N": 50, "n": 37, "sampling_fraction": 0.74}], "se_of_mean": 0.5134169110171893, "total_cost": 100}
survey allocation <json_strata> <n> <json_params>
Description
Allocation with parameters: method (proportional, neyman, optimal: with the cost of an interview in each stratum)
Allocation with parameters: method (proportional, neyman, optimal: with the cost of an interview in each stratum)
Parameters
json_strata: The strata - String - required
n: The total - Number - required
json_params: The parameters - String - required
json_strata: The strata - String - required
n: The total - Number - required
json_params: The parameters - String - required
admin
survey allocation "[{\"name\": \"town\", \"N\": 8000, \"sd\": 10, \"cost\": 1}, {\"name\": \"rural\", \"N\": 2000, \"sd\": 12, \"cost\": 4}]" 400 "{\"method\": \"optimal\"}"
mentdb
{"method": "optimal", "n": 400, "strata": [{"stratum": "town", "N": 8000, "n": 348, "sampling_fraction": 0.0435}, {"stratum": "rural", "N": 2000, "n": 52, "sampling_fraction": 0.026}], "se_of_mean": 0.5327262681211077, "total_cost": 556}
survey crosstab <json_rows> <variable1> <variable2>
Description
Weighted crosstab of two variables: shares, row shares and chi-square test with a Rao-Scott correction by the design effect of the weights
Weighted crosstab of two variables: shares, row shares and chi-square test with a Rao-Scott correction by the design effect of the weights
Parameters
json_rows: The respondents - String - required
variable1: The row variable - String - required
variable2: The column variable - String - required
json_rows: The respondents - String - required
variable1: The row variable - String - required
variable2: The column variable - String - required
admin
survey crosstab "[{\"id\": 0, \"sex\": \"M\", \"age\": \"18-34\", \"vote\": \"yes\", \"score\": 4.2}, {\"id\": 1, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 5.9}, {\"id\": 2, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"no\", \"score\": 2.7}, {\"id\": 3, \"sex\": \"M\", \"age\": \"65+\", \"vote\": \"no\", \"score\": 2.2}, {\"id\": 4, \"sex\": \"M\", \"age\": \"18-34\", \"vote\": \"no\", \"score\": 3.3}, {\"id\": 5, \"sex\": \"F\", \"age\": \"65+\", \"vote\": \"yes\", \"score\": 5.4}, {\"id\": 6, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 6.8}, {\"id\": 7, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 5.3}, {\"id\": 8, \"sex\": \"F\", \"age\": \"65+\", \"vote\": \"no\", \"score\": 5.5}, {\"id\": 9, \"sex\": \"F\", \"age\": \"35-64\", \"vote\": \"no\", \"score\": 3.2}, {\"id\": 10, \"sex\": \"F\", \"age\": \"35-64\", \"vote\": \"no\", \"score\": 4.6}, {\"id\": 11, \"sex\": \"M\", \"age\": \"65+\", \"vote\": \"no\", \"score\": 7.3}, {\"id\": 12, \"sex\": \"M\", \"age\": \"65+\", \"vote\": \"no\", \"score\": 2.4}, {\"id\": 13, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"no\", \"score\": 1.0}, {\"id\": 14, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"no\", \"score\": 4.5}, {\"id\": 15, \"sex\": \"M\", \"age\": \"18-34\", \"vote\": \"no\", \"score\": 6.3}, {\"id\": 16, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 7.7}, {\"id\": 17, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 6.0}, {\"id\": 18, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 7.2}, {\"id\": 19, \"sex\": \"M\", \"age\": \"65+\", \"vote\": \"yes\", \"score\": 0.7}, {\"id\": 20, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"no\", \"score\": 6.4}, {\"id\": 21, \"sex\": \"M\", \"age\": \"18-34\", \"vote\": \"yes\", \"score\": 7.6}, {\"id\": 22, \"sex\": \"M\", \"age\": \"18-34\", \"vote\": \"yes\", \"score\": 4.3}, {\"id\": 23, \"sex\": \"M\", \"age\": \"35-64\", \"vote\": \"yes\", \"score\": 5.7}]" "sex" "vote"
mentdb
{"cells": [{"sex": "F", "vote": "no", "weighted": 3, "share": 0.125, "row_share": 0.75}, {"sex": "F", "vote": "yes", "weighted": 1, "share": 0.041666666666666664, "row_share": 0.25}, {"sex": "M", "vote": "no", "weighted": 9, "share": 0.375, "row_share": 0.45}, {"sex": "M", "vote": "yes", "weighted": 11, "share": 0.4583333333333333, "row_share": 0.55}], "chi2_unweighted_scale": 1.2000000000000002, "design_effect_kish": 1, "chi2_rao_scott": 1.2000000000000002, "df": 1, "p_value": 0.27332167829229803}
survey crosstab <json_rows> <variable1> <variable2> <json_params>
Description
Weighted crosstab with parameters: weight (field)
Weighted crosstab with parameters: weight (field)
Parameters
json_rows: The respondents - String - required
variable1: The rows - String - required
variable2: The columns - String - required
json_params: The parameters - String - required
json_rows: The respondents - String - required
variable1: The rows - String - required
variable2: The columns - String - required
json_params: The parameters - String - required
admin
survey crosstab "[{\"a\": \"x\", \"b\": \"u\", \"w\": 2}, {\"a\": \"x\", \"b\": \"v\", \"w\": 1}, {\"a\": \"y\", \"b\": \"u\", \"w\": 1}, {\"a\": \"y\", \"b\": \"v\", \"w\": 3}]" "a" "b" "{\"weight\": \"w\"}"
mentdb
{"cells": [{"a": "x", "b": "u", "weighted": 2, "share": 0.2857142857142857, "row_share": 0.6666666666666666}, {"a": "x", "b": "v", "weighted": 1, "share": 0.14285714285714285, "row_share": 0.3333333333333333}, {"a": "y", "b": "u", "weighted": 1, "share": 0.14285714285714285, "row_share": 0.25}, {"a": "y", "b": "v", "weighted": 3, "share": 0.42857142857142855, "row_share": 0.75}], "chi2_unweighted_scale": 0.6944444444444444, "design_effect_kish": 1.2244897959183674, "chi2_rao_scott": 0.5671296296296297, "df": 1, "p_value": 0.45140178484183646}
