All problems
Clustered Standard Error of the Mean
Problem
Return the cluster-robust standard error of the mean: sqrt(G/(G-1) * sum_g (sum over i in g of (x_i - xbar))^2) / n. Inputs are the data and cluster ids. Return 0.0 when lengths differ, input is empty, or there are fewer than two clusters.
Hint
Cluster-level score sums carry the sampling uncertainty.
Test cases
case 1
in: [[1,2,3,4],["a","a","b","b"]]
expected: 1
case 2
in: [[1,1,2,2],["a","a","b","b"]]
expected: 0.5
case 3
in: [[1,2,3,4],["a","b","c","d"]]
expected: 0.6454972243679028
case 4
in: [[5,5],["a","b"]]
expected: 0
case 5
in: [[],[]]
expected: 0
Starter codePython
def clustered_se_mean(data, ids):
# Your code here
pass5 test cases · run your code against them in the editor