01 July 2021
In Stata: | In Julia: |
---|---|
bysort group1 group2 (t): egen sum = sum(freq) generate prob = freq/sum bysort group1 group2: gen cumul = sum(prob) |
sort!(df, [:group1, :group2, :t]) df = transform(groupby(df, [:group1, :group2]), :freq => sum => :sum) df[:, :prob] = df[:, :freq]./df[:, :sum] df = transform(groupby(df, [:group1, :group2]), :prob => cumsum => :cumul) |
In Stata: | In Julia: |
---|---|
collapse (sum) freq, by(group) | combine(groupby(df, group), :freq => sum => :freq) |