Impact Calculation Tool for R

From Testiwiki
Jump to: navigation, search

Life table calculations

Input data

Population structure in the beginning of the assessment follow-up period (pop_data)

population(-)
ObsAgeResultKuvaus
1056683
2156683
3256683
435668
5456683
6560615
7660615
8760615
9860615
10960615
111066167
121166167
131266167
14136616
151466167
161563786
171663786
181763786
191863786
201963786
212066423
222166423
232266423
242366424
252466423
262565882
272665882
282765882
292865882
302965882
313061495
323161495
333261495
343361495
353461495
363572474
373672474
383772474
393872474
403972474
414075917
424175917
434275917
444375917
454475917
464576977
474676977
484776977
494876977
504976977
515080206
525180206
535280206
545380206
555480206
565580291
575680291
585780291
595880291
605980291
616054300
626154300
636254300
646354300
656454300
666548077
676648077
686748077
696848077
706948077
717041475
727141475
737241475
747341475
757441475
767534987
777634987
787734987
797834987
807934987
818023300
828123300
838223300
848323300
858423300
868511292
878611292
888711292
898811292
908911292
91904394
92914394
93924394
94934394
95944394
9695886
9796886
9897886
9998886
10099886

Annual birth rate (birth_rate)

birth.rate(-)
ObsFollow-up periodResultKuvaus
1201057000
2201157000
3201257000
4201357000
5201457000
6201557000
7201657000
8201757000
9201857000
10201957000
11202057000
12202157000
13202257000
14202357000
15202457000
16202557000
17202657000
18202757000
19202857000
20202957000

Annual mortality rate (mort_rate)

mortality(-)
ObsAgeResultKuvaus
1049.8
2149.8
3249.8
4349.8
5449.8
6510.2
7610.2
8710.2
9810.2
10910.2
111010.6
121110.6
131210.6
141310.6
151410.6
161530.6
171630.6
181730.6
191830.6
201930.6
212050
222150
232250
242350
252450
262547
272647
282747
292847
302947
313048.6
323148.6
333248.6
343348.6
353448.6
363599.4
373699.4
383799.4
393899.4
403999.4
4140156.6
4241156.6
4342156.6
4443156.6
4544156.6
4645247.6
4746247.6
4847247.6
4948247.6
5049247.6
5150395.8
5251395.8
5352395.8
5453395.8
5554395.8
5655555
5756555
5857555
5958555
6059555
6160534
6261534
6362534
6463534
6564534
6665702.4
6766702.4
6867702.4
6968702.4
7069702.4
7170975
7271975
7372975
7473975
7574975
76751372.4
77761372.4
78771372.4
79781372.4
80791372.4
81801619.6
82811619.6
83821619.6
84831619.6
85841619.6
86851399.8
87861399.8
88871399.8
89881399.8
90891399.8
9190934
9291934
9392934
9493934
9594934
9695313
9796313
9897313
9998313
10099313

Mortality risk (mort_risk)

mort_rate / pop_data

Start year (start-year)

2010

Follow-up time in years (followup_time)

20


Analytica codes

Variables, which need to be translated into ovariables:

Population in time, child (pop_in_time_child)

var k: Birth_rate[Fu_year=Year_lt];

k:= if k = null then 0 else k;

var a:= if @Year_lt = 1 then Pop_data else (if @Age=1 then k else 0);

a:= a[Age=age_child];

var j:= Mort_risk[Age=age_child];

j:=j[Fu_period=Period_lt];

j:= Si_pi(j, 5, Period_lt, Year_lt, Year_help)*5;

j:= if j = null then j[Period_lt=max(Fu_period)] else j;

j:= if j < 0 then 0 else j;

j:= if j > 1 then 1 else j;

j:= 1-j;

var x:= 1;

while x<= min([size(age_child),size(Year_lt)]) do (

var b:= a*j; b:= b[@age_child=@age_child-1, @Year_lt=@Year_lt-1];

a:= if b=null then a else b;

x:= x+1);

sum(if Year_lt = period_vs_year then a else 0,Year_lt)



Population in time, beginning of time step (pop_in_time_beg)

var a:= sum(if floor(Age/5)+1 = @Age_cat then Pop_data else 0 , Age);

a:= if @Age_cat=1 then sum(Pop_in_time_child, Age_child) else (if @period_lt = 1 then a else 0);

var j:= Mort_risk;

j:=j[Fu_period=Period_lt];

j:= if j = null then j[Period_lt=max(Fu_period)] else j;

j:= if j < 0 then 0 else j;

j:= if j > 1 then 1 else j;

j:= 1-j;

j:= sum(if floor(Age/5)+1 = @Age_cat then j else 0 , Age)/5;

var m:=j[@Age_cat=@Age_cat+1];

m:= if m=null then 0 else m;

var n:=((j^5)+(j^4*m)+(j^3*m^2)+(j^2*m^3)+(j*m^4))/5;

var x:= 1;

while x<= min([size(Age_cat),size(Period_lt)]) do ( var b:= a*n;

b:= b[@Age_cat=@Age_cat-1, @Period_lt=@Period_lt-1];

a:= if b=null then a else b;

x:= x+1);

a


Indices and function used in the code above:

Follow-up year (fu_year)

sequence(Start_year,Start_year+(Followup_time-1),1)


Year in life table (year_lt)

sequence(Start_year,Start_year+Followup_time+99,1)


Follow-up period in 5-year time steps (fu_period)

sequence(Start_year,Start_year+(Followup_time-1),5)


5-year period in life table (period_lt)

sequence(Start_year,Start_year+Followup_time+99,5)


Age of child (age_child)

sequence(0,4,1)


Si_pi function (si_pi)

Parameters: (data, kerroin;karkea,tarkka:indextype;indtieto)

Description

  • Data = data to be divided into more detailed parts
  • Kerroin = relative weight inside a cluster
  • Karkea = index for the clustered data
  • Tarkka = index for the detailed data
  • Indtieto = Data about which detailed item belongs to which cluster

Analytica code:

var a:=sum((if indtieto=karkea then kerroin else 0), tarkka);

a:= sum((if indtieto=karkea then a else 0), karkea);

a:= kerroin/a;

sum((if indtieto=karkea then data*a else 0), karkea)