Hi all,
I'm working through the book Spatial Microsimulation with R and converting the code examples to Stata as I go.
The book provides a small toy dataset to demonstrate some concepts as below:
One of the exercises is to use iterative proportional fitting to weight these data to a population that has the following characteristics:
Age 1: 7
Age 2: 4
Sex 1: 3
Sex 2: 8
To do this in Stata I used the following code:
This appears to produce correct results, but if I edit the code to increase the population as below I get unexpected results.
Running this produces the following dataset. I've tested these numbers using ipfraking from SSC and that seems to produce correct result. Am I missing something about svycal that is causing this?
I'm working through the book Spatial Microsimulation with R and converting the code examples to Stata as I go.
The book provides a small toy dataset to demonstrate some concepts as below:
Code:
id sex_num age_num 1 1 2 2 1 2 3 1 1 4 2 2 5 2 1
Age 1: 7
Age 2: 4
Sex 1: 3
Sex 2: 8
To do this in Stata I used the following code:
Code:
svycal rake i.age_num i.sex_num, generate(weight) totals( /// _cons = 11 /// 1.age_num = 7 /// 2.age_num = 4 /// 1.sex_num = 3 /// 2.sex_num = 8)
Code:
svycal rake i.age_num i.sex_num, generate(weight10) totals( /// _cons = 110 /// 1.age_num = 70 /// 2.age_num = 40 /// 1.sex_num = 30 /// 2.sex_num = 80)
Code:
id sex_num age_num weight weight10 1 1 2 .72508278 6.517e-11 2 1 2 .72508278 6.517e-11 3 1 1 1.5498344 1.141e-10 4 2 2 2.5498344 40 5 2 1 5.4501656 70

Comment