I have got a data frame like the following:
region group mid_pop
1 2 1146
2 4 1682
3 3 2891
4 1 7654
5 1 3289
6 2 1128
7 3 2121
8 4 3217
9 3 1616
10 1 1717
I ran a multinomial regression and got the probability of belonging to each group as follows:
mlogit <- multinom(group ~ mid_pop)
probs <- predict(mlogit, type="probs")
probs1 probs2 probs3 probs4
0.2 0.3 0.4 0.1
0.3 0.4 0.15 0.15
0.4 0.1 0.3 0.2
0.7 0.1 0.1 0.1
0.2 0.3 0.4 0.1
0.6 0.1 0.1 0.2
0.7 0.1 0.1 0.1
0.3 0.2 0.1 0.4
0.2 0.1 0.1 0.6
0.1 0.2 0.1 0.6
Then I created a weight for each region. The weight is "the probability of belonging to group one divided by the probability of belonging to the current group the region is in". The weight then was multiplied by mid_pop.
region group mid_pop weight mid_pop(weighted)
1 2 1146 0.66 756.36
2 4 1682 2 3364
3 3 2891 2 5782
4 1 7654 0.7 5357.8
5 1 3289 0.2 657.8
6 2 1128 0.3 338.4
7 3 2121 0.7 1484.7
8 4 3217 0.75 2412.75
9 3 1616 0.33 533.28
10 1 1717 0.16 274.72
Now I would like to do a standardized mean difference for groups and see the difference between the mean of mid_pop before and after weighting. The result will be something like this:
SDM (group 1 vs. group 2)=....
SDM (group 1 vs. group 3)=....
SDM (group 1 vs. group 4)= ....
Anyone can help us to do it? Thanks in advance.