Attribute VB_Name = "b06_Health"
'**************************************************************************************
'*** Module b06_Health
'**************************************************************************************
'
' This module contains SESIM modules used in the BabyBoom project. The modules handles
' simulation of the following variables:
'  - Health index (i_health)
'  - Number of days with inpatient care (i_Inpatientcare)
'  - Level of care for the elderly (i_assistance_elderly)
'  - Excess mortality for individuals with assistance at homeor living in housing facility
'  - Funktionsnedsättning (i_ADL)
'  - Number of days with sickness absence (i_sickleave)
'  - Disability pension (i_ftp)
'  - Closeness to relative (h_close_relative)
'
'**************************************************************************************

Option Explicit
Option Base 1


'********************
'********************
'*** HEALTH INDEX ***
'********************
'********************
'
' GENERAL COMMENTS:
' - Variable coding scheme: 0 - missing value, 1 - severe illness, 2 - some illness,
'   3 - not full health, 4 - full health
' - Health index is modeled as an ordered probit model with an autoregressive structure (in the
'   latent variable). Simultaneous estimation of initial value and dynamic models. For further
'   information on estimation procedures see Eklöf (2005, CHECK REFERENCE!!)
' - Health is not simulated for emigrants. Upon re-immigration the health status will
'   initially be predicted using the initial value model.


Public Sub Health()
    
  status "Health"
  Printdok "Health"
  
  ' Local variables
  Dim temp_income() As Double, count_income As Long
  Dim median_taxinc As Double
  Dim i As Long
  Dim TAU1 As Double, TAU2 As Double, TAU3 As Double, sigma As Double

  ' Calculate deciles of taxable income (for individuals aged 20 and older living in Sweden)
  count_income = 0
  ReDim temp_income(1 To m_icount)
  For i = 1 To m_icount
    If i_age(i) >= 20 And i_abroad(i) = 0 Then
      count_income = count_income + 1
      temp_income(count_income) = i_inc_taxable(i)
    End If
  Next
  ReDim Preserve temp_income(1 To count_income)
  
  ' Calculate median taxable income
  median_taxinc = CDbl(arr_Percentile(temp_income, 50)(1, 2))
  
  ' Loop across population
  For i = 1 To m_icount
  
    ' Only individuals living in Sweden are "at risk"
    If i_abroad(i) = 0 Then

        '*** If the lagged value of latent health is zero (=missing) the initial value model is used,
        '*** if not, the dynamic model is used.
        '*** New comments 060103 (Matias Eklöf):
        '*** The latent health static imputation model is only valid for age groupd below 75 due to data reasons.
        '*** (ULF only contains individuals up to age 75. Extrapolation over this age induces errors)
        '*** Hence, if we try to use the imputation model for older age groups, we will find that
        '*** the initial health is too high compared to the dynamic predictions. In order to
        '*** correct for this we use an alternative imputation methodology for the older age groups.
        '*** For individuals with age AGE>75, we first impute their health at age=75 using the imputation model.
        '*** We then use the dynamic model to predict the latent health up to the age AGE. In this
        '*** process we assume that all X0 variables other than the age is unchanged.
                
        If i_health_latent1(i) = 0 Then ' Impute initial health
            If i_age(i) < 76 Then ' use static health
                i_health_latent(i) = staticHealth(i, i_age(i), median_taxinc)
            Else ' use static for age=75 and then dynamic predictions up to i_age(i)
                ' As we are in principle "back-tracking" SESIM we need to adjust the
                ' model_time to reflect this. This is needed for the DIV variable that
                ' should be non-zero for the "divorce year" only.
                Dim model_time0 As Long
                model_time0 = model_time ' stores "true" model year
                model_time = model_time - (i_age(i) - 75)
                i_health_latent(i) = staticHealth(i, 75, median_taxinc)
                Dim A As Byte
                For A = 76 To i_age(i)
                    model_time = model_time + 1
                    i_health_latent(i) = dynamicHealth(i, A, i_health_latent(i), median_taxinc)
                Next
                model_time = model_time0
            End If
        Else ' Use dynamic model to predict latent health
            i_health_latent(i) = dynamicHealth(i, i_age(i), i_health_latent1(i), median_taxinc)
        End If
        
        TAU1 = -7.82523577250703
        TAU2 = -5.82203900896874
        TAU3 = -3.17249163950687

        Select Case (i_health_latent(i))
            Case Is < TAU1
              i_health(i) = 1
            Case Is < TAU2
              i_health(i) = 2
            Case Is < TAU3
              i_health(i) = 3
            Case Else
              i_health(i) = 4
        End Select
        
    Else
      
      ' Health missing for emigrants
      i_health(i) = 0
      
    End If ' i_abroad(i) = 0
   
  Next ' Next individual
  
End Sub

Public Function staticHealth(ByVal i As Long, ByVal age As Byte, ByVal median_taxinc As Double) As Double ' Local variables Dim COLLEGE As Byte, UNIV As Byte, MARITAL As Byte, DIV As Byte, WIDOWED As Byte, CHILDREN As Byte, RELTAXINC As Double Dim SWED As Byte, KON As Byte Dim AGE0 As Byte, AGE25 As Byte, AGE30 As Byte, AGE40 As Byte, AGE50 As Byte, AGE60 As Byte, AGE65 As Byte, AGE75 As Byte Dim SPLINE_AGE0 As Integer, SPLINE_AGE25 As Integer, SPLINE_AGE30 As Integer, SPLINE_AGE40 As Integer, SPLINE_AGE50 As Integer, SPLINE_AGE60 As Integer, SPLINE_AGE65 As Integer, SPLINE_AGE75 As Integer If median_taxinc > 0 Then RELTAXINC = i_inc_taxable(i) / median_taxinc Else RELTAXINC = 0 status "ERROR: zero median of taxable income" End If ' Dummy variables for educational level If i_edlevel(i) = 1 Then COLLEGE = 1 Else COLLEGE = 0 If i_edlevel(i) = 2 Then UNIV = 1 Else UNIV = 0 ' Dummy variable for civil status If i_civ_stat(i) = 1 Then MARITAL = 1 Else MARITAL = 0 ' Dummy variable marking newly divorced individuals If i_year_sep(i) = base_year + model_time Then DIV = 1 Else DIV = 0 ' Dummy variable marking widowed individuals If i_HasBeenWidowed(i) = 1 And MARITAL = 0 Then WIDOWED = 1 Else WIDOWED = 0 ' Number of children CHILDREN = h_n_childlt7(hhnr2index(i_hhnr(i))) ' Dummy variable for men If i_sex(i) = 1 Then KON = 1 Else KON = 0 ' Dummy variable for individuals born in Sweden If i_born_abroad(i) = 0 Then SWED = 1 Else SWED = 0 If age > 0 Then SPLINE_AGE0 = age Else SPLINE_AGE0 = 0 If age > 25 Then SPLINE_AGE25 = age - 25 Else SPLINE_AGE25 = 0 If age > 30 Then SPLINE_AGE30 = age - 30 Else SPLINE_AGE30 = 0 If age > 40 Then SPLINE_AGE40 = age - 40 Else SPLINE_AGE40 = 0 If age > 50 Then SPLINE_AGE50 = age - 50 Else SPLINE_AGE50 = 0 If age > 60 Then SPLINE_AGE60 = age - 60 Else SPLINE_AGE60 = 0 If age > 65 Then SPLINE_AGE65 = age - 65 Else SPLINE_AGE65 = 0 If age > 75 Then SPLINE_AGE75 = age - 75 Else SPLINE_AGE75 = 0 ' Dummy variables for age If age > 0 Then AGE0 = 1 Else AGE0 = 0 If age > 25 Then AGE25 = 1 Else AGE25 = 0 If age > 30 Then AGE30 = 1 Else AGE30 = 0 If age > 40 Then AGE40 = 1 Else AGE40 = 0 If age > 50 Then AGE50 = 1 Else AGE50 = 0 If age > 60 Then AGE60 = 1 Else AGE60 = 0 If age > 65 Then AGE65 = 1 Else AGE65 = 0 If age > 75 Then AGE75 = 1 Else AGE75 = 0 staticHealth = _ SPLINE_AGE0 * -0.113227204112379 + _ SPLINE_AGE25 * 0.05655207408008 + _ SPLINE_AGE50 * 3.81392005988476E-03 + _ SPLINE_AGE75 * 0.665868214944526 + _ KON * 4.62412129362699E-02 + _ RELTAXINC * 0.503922003796784 + _ COLLEGE * 0.198007669548858 + _ UNIV * 0.66555797861692 + _ MARITAL * 0.187483568895784 + _ DIV * -0.408418734566758 + _ WIDOWED * -5.85548609809967E-02 + _ CHILDREN * 0.220262775244573 + _ SWED * 0.449484068347106 + _ (AGE0 * 2.53910619148707 + _ AGE25 * 0.128434743531727 + _ AGE50 * 3.55756009754367E-04 + _ AGE75 * -2.01767281171747E-02) * gauss(0, 1) End Function
Public Function dynamicHealth(ByVal i As Long, ByVal age As Byte, ByVal health_latent1 As Double, ByVal median_taxinc As Double) As Double ' Local variables Dim COLLEGE As Byte, UNIV As Byte, MARITAL As Byte, DIV As Byte, WIDOWED As Byte, CHILDREN As Byte, RELTAXINC As Double Dim SWED As Byte, KON As Byte Dim AGE0 As Byte, AGE25 As Byte, AGE30 As Byte, AGE40 As Byte, AGE50 As Byte, AGE60 As Byte, AGE65 As Byte, AGE75 As Byte Dim SPLINE_AGE0 As Integer, SPLINE_AGE25 As Integer, SPLINE_AGE30 As Integer, SPLINE_AGE40 As Integer, SPLINE_AGE50 As Integer, SPLINE_AGE60 As Integer, SPLINE_AGE65 As Integer, SPLINE_AGE75 As Integer If median_taxinc > 0 Then RELTAXINC = i_inc_taxable(i) / median_taxinc Else RELTAXINC = 0 status "ERROR: zero median of taxable income" End If ' Dummy variables for educational level If i_edlevel(i) = 1 Then COLLEGE = 1 Else COLLEGE = 0 If i_edlevel(i) = 2 Then UNIV = 1 Else UNIV = 0 ' Dummy variable for civil status If i_civ_stat(i) = 1 Then MARITAL = 1 Else MARITAL = 0 ' Dummy variable marking newly divorced individuals If i_year_sep(i) = base_year + model_time Then DIV = 1 Else DIV = 0 ' Dummy variable marking widowed individuals If i_HasBeenWidowed(i) = 1 And MARITAL = 0 Then WIDOWED = 1 Else WIDOWED = 0 ' Number of children CHILDREN = h_n_childlt7(hhnr2index(i_hhnr(i))) ' Dummy variable for men If i_sex(i) = 1 Then KON = 1 Else KON = 0 ' Dummy variable for individuals born in Sweden If i_born_abroad(i) = 0 Then SWED = 1 Else SWED = 0 If age > 0 Then SPLINE_AGE0 = age Else SPLINE_AGE0 = 0 If age > 25 Then SPLINE_AGE25 = age - 25 Else SPLINE_AGE25 = 0 If age > 30 Then SPLINE_AGE30 = age - 30 Else SPLINE_AGE30 = 0 If age > 40 Then SPLINE_AGE40 = age - 40 Else SPLINE_AGE40 = 0 If age > 50 Then SPLINE_AGE50 = age - 50 Else SPLINE_AGE50 = 0 If age > 60 Then SPLINE_AGE60 = age - 60 Else SPLINE_AGE60 = 0 If age > 65 Then SPLINE_AGE65 = age - 65 Else SPLINE_AGE65 = 0 If age > 75 Then SPLINE_AGE75 = age - 75 Else SPLINE_AGE75 = 0 ' Dummy variables for age If age > 0 Then AGE0 = 1 Else AGE0 = 0 If age > 25 Then AGE25 = 1 Else AGE25 = 0 If age > 30 Then AGE30 = 1 Else AGE30 = 0 If age > 40 Then AGE40 = 1 Else AGE40 = 0 If age > 50 Then AGE50 = 1 Else AGE50 = 0 If age > 60 Then AGE60 = 1 Else AGE60 = 0 If age > 65 Then AGE65 = 1 Else AGE65 = 0 If age > 75 Then AGE75 = 1 Else AGE75 = 0 dynamicHealth = _ SPLINE_AGE0 * -1.34664325857748E-02 + _ SPLINE_AGE25 * 1.16861579966423E-02 + _ SPLINE_AGE50 * -1.35349573784016E-03 + _ SPLINE_AGE75 * -7.56046682310413E-03 + _ KON * 1.23946429364194E-02 + _ RELTAXINC * 6.01518512935774E-02 + _ COLLEGE * 1.44112746947876E-02 + _ UNIV * 4.09707671404783E-02 + _ MARITAL * 1.67950669997164E-02 + _ DIV * -3.34639662980374E-02 + _ WIDOWED * -2.21704175271632E-02 + _ CHILDREN * 1.91850378782192E-02 + _ SWED * 3.77394480395377E-02 + _ AGE0 * health_latent1 * 0.883852796243645 + _ AGE25 * health_latent1 * 4.86507797924234E-02 + _ AGE50 * health_latent1 * 1.45852638128551E-02 + _ AGE75 * health_latent1 * 5.26201217494035E-03 + _ gauss(0, 1) End Function
'******************************** '******************************** '*** DAYS WITH INPATIENT CARE *** '******************************** '******************************** ' ' GENERAL COMMENTS: ' - The distribution of inpatient days is heavily concentrated at zero and is therefore modelled ' using a negative binomial zero inflated model. In order to generate negative binomial data ' we draw poisson data having intensities following a gamma distribution (a hierarchic model). ' - The model is dynamic and uses lagged information on days with inpatient care. When this information ' is not available, i.e. during base year and for immigrants, data are simulated from the cross ' sectional imputation model. ' - The models were estimated by Kristian Bolin using LIMDEP.
Public Sub Inpatient_Care() status "Inpatient_Care" Printdok "Inpatient_Care" ' Local variables Dim sum_income As Double, mean_income As Double, RELINK As Double, RELINK2 As Double Dim COLLEGE As Byte, UNIV As Byte, MARITAL As Byte, divorced As Byte, CHILDREN As Byte Dim SWED As Byte, KON96 As Byte, NEWBORN As Byte, CHILD As Byte Dim STOCH As Byte, GOTH As Byte, MALLU As Byte, SOUTHU As Byte, MIDTHU As Byte, NORTHU As Byte Dim SOUTHR As Byte, MIDTHR As Byte, NORTHR As Byte Dim HI962 As Byte, HI963 As Byte, HI964 As Byte, KON_RELINK As Double Dim SPLINE_AGE30 As Byte Dim i As Long, kkod As Long Dim temp_income() As Double, count_income As Long, temp_gam(1 To 2) As Double, pi As Double Dim poisson(1 To 2) As Long Dim xb As Double, u As Double, ALPHA As Double, tau As Double Dim LAMBDA As Single Dim inc_dec As Variant ' Calculate deciles of taxable income (for individuals aged 20 and older living in Sweden) ' and mean income. count_income = 0 sum_income = 0 mean_income = 0 ReDim temp_income(1 To m_icount) For i = 1 To m_icount If i_age(i) >= 20 And i_abroad(i) = 0 Then count_income = count_income + 1 ' temp_income(count_income) = i_inc_taxable(i) sum_income = sum_income + i_inc_taxable(i) End If Next ReDim Preserve temp_income(1 To count_income) ' inc_dec = arr_Percentile(temp_income, 10, 20, 30, 40, 50, 60, 70, 80, 90) If count_income > 0 Then mean_income = sum_income / count_income Else mean_income = 0 End If ' Loop across population For i = 1 To m_icount ' Simulation only for individuals living in sweden aged 16 or older If i_abroad(i) = 0 And i_age(i) >= 16 Then '*** CALCULATE COVARIATES ' Spline knot at age 30 If i_age(i) > 30 Then SPLINE_AGE30 = i_age(i) - 30 Else SPLINE_AGE30 = 0 ' Relative (to the mean) income If mean_income > 0 Then RELINK = i_inc_taxable(i) / mean_income RELINK2 = RELINK * RELINK Else RELINK = 0 RELINK2 = 0 End If ' Dummy variables for educational level If i_edlevel(i) = 1 Then COLLEGE = 1 Else COLLEGE = 0 If i_edlevel(i) = 2 Then UNIV = 1 Else UNIV = 0 ' ' Dummy variable for married/cohabiting If i_civ_stat(i) = 1 Then MARITAL = 1 Else MARITAL = 0 ' ' Dummy variables marking newly divorced individuals If i_year_sep(i) = base_year + model_time Then divorced = 1 Else divorced = 0 ' Number of children CHILDREN = h_n_childlt7(hhnr2index(i_hhnr(i))) If CHILDREN > 0 Then CHILD = 1 Else CHILD = 0 ' Existence of newborn (aged 0) NEWBORN = exist_newborn(i_hhnr(i)) ' Dummy variables for regions If h_BB_region(hhnr2index(i_hhnr(i))) = 1 Then STOCH = 1 Else STOCH = 0 If h_BB_region(hhnr2index(i_hhnr(i))) = 2 Then GOTH = 1 Else GOTH = 0 If h_BB_region(hhnr2index(i_hhnr(i))) = 3 Then MALLU = 1 Else MALLU = 0 If h_BB_region(hhnr2index(i_hhnr(i))) = 4 Then SOUTHU = 1 Else SOUTHU = 0 If h_BB_region(hhnr2index(i_hhnr(i))) = 5 Then MIDTHU = 1 Else MIDTHU = 0 If h_BB_region(hhnr2index(i_hhnr(i))) = 6 Then NORTHU = 1 Else NORTHU = 0 If h_BB_region(hhnr2index(i_hhnr(i))) = 7 Then SOUTHR = 1 Else SOUTHR = 0 If h_BB_region(hhnr2index(i_hhnr(i))) = 8 Then MIDTHR = 1 Else MIDTHR = 0 If h_BB_region(hhnr2index(i_hhnr(i))) = 9 Then NORTHR = 1 Else NORTHR = 0 ' Dummy variable for men If i_sex(i) = 1 Then KON96 = 1 Else KON96 = 0 ' Interaction between sex and relative income KON_RELINK = KON96 * RELINK ' Dummy variables individuals born in Sweden If i_born_abroad(i) = 0 Then SWED = 1 Else SWED = 0 ' Dummy variables for levels of health index If i_health(i) = 3 Then HI962 = 1 Else HI962 = 0 If i_health(i) = 2 Then HI963 = 1 Else HI963 = 0 If i_health(i) = 1 Then HI964 = 1 Else HI964 = 0 '*** During base year, for immigrants and 16-year-olds a cross sectional model is used '*** to impute the number of inpatient days If model_time = 0 Or i_new_immig(i) > 0 Or i_age(i) = 16 Then Select Case (i_age(i)) Case Is <= 49 ' Normal exit from iterations. Exit status=0. ' ' +----------------------------------------------------------------------+ ' | Zero Altered Neg.Binomial Regression Model | ' | Logistic distribution used for splitting model. | ' | ZAP term in probability is F[tau x ln LAMBDA] | ' | Comparison of estimated models | ' | Pr[0|means] Number of zeros Log-likelihood | ' | Poisson .74182 Act.= 6439 Prd.= 5145.2 -11051.05355 | ' | Neg. Bin. .75614 Act.= 6439 Prd.= 5244.6 -3018.56423 | ' | Z.I.Neg_Bin .93361 Act.= 6439 Prd.= 6475.5 -2954.96269 | ' | Note, the ZIP log-likelihood is not directly comparable. | ' | ZIP model with nonzero Q does not encompass the others. | ' | Vuong statistic for testing ZIP vs. unaltered model is 4.5702 | ' | Distributed as standard normal. A value greater than | ' | +1.96 favors the zero altered Z.I.Neg_Bin model. | ' | A value less than -1.96 rejects the ZIP model. | ' +----------------------------------------------------------------------+ ' +---------+--------------+----------------+--------+---------+----------+ ' |Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X| ' +---------+--------------+----------------+--------+---------+----------+ ' Poisson/NB/Gamma regression model ' Constant -.4921767863 .13218285 -3.723 .0002 ' HI962 .1914947281 .50520172E-01 3.790 .0002 .25951557 ' HI963 .4974410347 .12644054 3.934 .0001 .53921569E-01 ' HI964 2.343335261 .33195324 7.059 .0000 .17733564E-01 ' AGE96 .9451867978E-02 .28977697E-02 3.262 .0011 32.670127 ' SP1 -.1104980287E-01 .36737003E-02 -3.008 .0026 5.5854960 ' GOTH -.5939527583E-01 .25522302E-01 -2.327 .0200 .96453287E-01 ' SOUTHU .2796100844E-01 .15834859E-01 1.766 .0774 .20732411 ' MALLU -.9988160487E-01 .40485189E-01 -2.467 .0136 .56084198E-01 ' SWED .7904115711E-01 .27992964E-01 2.824 .0047 .89244521 ' KON96 -.2569663522 .65626373E-01 -3.916 .0001 .49783737 ' NEWBORN .7166519171 .18412731 3.892 .0001 .53344867E-01 ' Dispersion parameter ' Alpha 12.16279283 .29034191 41.891 .0000 ' Zero inflation model ' Tau -3.634764315 .93065875 -3.906 .0001 xb = 1 * -0.4921767863 + _ HI962 * 0.1914947281 + _ HI963 * 0.4974410347 + _ HI964 * 2.343335261 + _ i_age(i) * 0.009451867978 + _ SPLINE_AGE30 * -0.01104980287 + _ GOTH * -0.05939527583 + _ SOUTHU * 0.02796100844 + _ MALLU * -0.09988160487 + _ SWED * 0.07904115711 + _ KON96 * -0.2569663522 + _ NEWBORN * 0.7166519171 ALPHA = 12.16279283 tau = -3.634764315 Case Is <= 70 ' Normal exit from iterations. Exit status=0. ' ' +----------------------------------------------------------------------+ ' | Zero Altered Neg.Binomial Regression Model | ' | Logistic distribution used for splitting model. | ' | ZAP term in probability is F[tau x ln LAMBDA] | ' | Comparison of estimated models | ' | Pr[0|means] Number of zeros Log-likelihood | ' | Poisson .60355 Act.= 2923 Prd.= 1960.3 -7703.09234 | ' | Neg. Bin. .60638 Act.= 2923 Prd.= 1969.5 -1961.50716 | ' | Z.I.Neg_Bin .90238 Act.= 2923 Prd.= 2930.9 -1929.33636 | ' | Note, the ZIP log-likelihood is not directly comparable. | ' | ZIP model with nonzero Q does not encompass the others. | ' | Vuong statistic for testing ZIP vs. unaltered model is 4.5916 | ' | Distributed as standard normal. A value greater than | ' | +1.96 favors the zero altered Z.I.Neg_Bin model. | ' | A value less than -1.96 rejects the ZIP model. | ' +----------------------------------------------------------------------+ ' +---------+--------------+----------------+--------+---------+----------+ ' |Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X| ' +---------+--------------+----------------+--------+---------+----------+ ' Poisson/NB/Gamma regression model ' Constant -1.725540428 .41415505 -4.166 .0000 ' HI962 .3666224463 .84261418E-01 4.351 .0000 .31342365 ' HI963 .8273954301 .17971004 4.604 .0000 .14347291 ' HI964 1.899087487 .29173134 6.510 .0000 .83743842E-01 ' AGE96 .2122425540E-01 .51973744E-02 4.084 .0000 58.717980 ' COLLEGE -.5144218901E-01 .30099411E-01 -1.709 .0874 .41040640 ' DIVORCED .3355202639 .97279570E-01 3.449 .0006 .11576355 ' MARITAL .2139021981 .67144705E-01 3.186 .0014 .76016010 ' SOUTHU -.1447581701 .47983885E-01 -3.017 .0026 .21366995 ' MIDTHU -.7864762385E-01 .49169503E-01 -1.600 .1097 .10652709 ' MIDTHR -.9321962602E-01 .51342207E-01 -1.816 .0694 .99137931E-01 ' NORTHR -.1416569916 .49281733E-01 -2.874 .0040 .10837438 ' KON96 .4872469042E-01 .29112287E-01 1.674 .0942 .48183498 ' Dispersion parameter ' Alpha 13.35774988 .34154666 39.110 .0000 ' Zero inflation model ' Tau -2.326747219 .54594521 -4.262 .0000 xb = 1 * -1.725540428 + _ HI962 * 0.3666224463 + _ HI963 * 0.8273954301 + _ HI964 * 1.899087487 + _ i_age(i) * 0.0212242554 + _ COLLEGE * -0.05144218901 + _ divorced * 0.3355202639 + _ MARITAL * 0.2139021981 + _ SOUTHU * -0.1447581701 + _ MIDTHU * -0.07864762385 + _ MIDTHR * -0.09321962602 + _ NORTHR * -0.1416569916 + _ KON96 * 0.04872469042 ALPHA = 13.35774988 tau = -2.326747219 Case Else ' Normal exit from iterations. Exit status=0. ' ' +----------------------------------------------------------------------+ ' | Zero Altered Neg.Binomial Regression Model | ' | Logistic distribution used for splitting model. | ' | ZAP term in probability is F[tau x ln LAMBDA] | ' | Comparison of estimated models | ' | Pr[0|means] Number of zeros Log-likelihood | ' | Poisson .15562 Act.= 1108 Prd.= 221.0 -8420.74507 | ' | Neg. Bin. .17751 Act.= 1108 Prd.= 252.1 -1797.69308 | ' | Z.I.Neg_Bin .77761 Act.= 1108 Prd.= 1104.2 -1784.82923 | ' | Note, the ZIP log-likelihood is not directly comparable. | ' | ZIP model with nonzero Q does not encompass the others. | ' | Vuong statistic for testing ZIP vs. unaltered model is 3.9688 | ' | Distributed as standard normal. A value greater than | ' | +1.96 favors the zero altered Z.I.Neg_Bin model. | ' | A value less than -1.96 rejects the ZIP model. | ' +----------------------------------------------------------------------+ ' +---------+--------------+----------------+--------+---------+----------+ ' |Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X| ' +---------+--------------+----------------+--------+---------+----------+ ' Poisson/NB/Gamma regression model ' Constant -4.059309189 1.0370367 -3.914 .0001 ' HI962 .8530222358 .14593148 5.845 .0000 .35985915 ' HI963 1.459137240 .19035443 7.665 .0000 .21549296 ' HI964 2.243829082 .24623879 9.112 .0000 .17676056 ' AGE96 .5612099287E-01 .13187509E-01 4.256 .0000 76.706338 ' UNIV -.2055253298 .16963395 -1.212 .2257 .92957746E-01 ' DIVORCED -.4845178311 .16979102 -2.854 .0043 .74647887E-01 ' MARITAL -.1904241030 .10863470 -1.753 .0796 .55352113 ' RELINK -.1879357544 .58673303E-01 -3.203 .0014 1.0000000 ' GOTH .7383213920 .19715282 3.745 .0002 .80281690E-01 ' SOUTHU .1846814482 .11383729 1.622 .1047 .22535211 ' MIDTHR -.5753743811 .16844673 -3.416 .0006 .81690141E-01 ' SWED -.2619017015 .17194025 -1.523 .1277 .91760563 ' KON96 .1893221631 .13210406 1.433 .1518 .44436620 ' D4 .2958685593 .90306329E-01 3.276 .0011 .54273855 ' Dispersion parameter ' Alpha 8.734717933 .31087167 28.098 .0000 ' Zero inflation model ' Tau -1.012795956 .15578099 -6.501 .0000 ' xb = 1 * -4.059309189 + _ HI962 * 0.8530222358 + _ HI963 * 1.45913724 + _ HI964 * 2.243829082 + _ i_age(i) * 0.05612099287 + _ UNIV * -0.2055253298 + _ divorced * -0.4845178311 + _ MARITAL * -0.190424103 + _ RELINK * -0.1879357544 + _ GOTH * 0.738321392 + _ SOUTHU * 0.1846814482 + _ MIDTHR * -0.5753743811 + _ SWED * -0.2619017015 + _ KON96 * 0.1893221631 + _ KON_RELINK * 0.2958685593 ALPHA = 8.734717933 tau = -1.012795956 End Select Else '*** DYNAMIC MODELS Select Case (i_age(i)) Case Is <= 49 ' Normal exit from iterations. Exit status=0. ' ' +----------------------------------------------------------------------+ ' | Zero Altered Neg.Binomial Regression Model | ' | Logistic distribution used for splitting model. | ' | ZAP term in probability is F[tau x ln LAMBDA] | ' | Comparison of estimated models | ' | Pr[0|means] Number of zeros Log-likelihood | ' | Poisson .74574 Act.= 6440 Prd.= 5173.2 -10657.20013 | ' | Neg. Bin. .76516 Act.= 6440 Prd.= 5307.9 -3008.10605 | ' | Z.I.Neg_Bin .91580 Act.= 6440 Prd.= 6352.9 -2918.20148 | ' | Note, the ZIP log-likelihood is not directly comparable. | ' | ZIP model with nonzero Q does not encompass the others. | ' | Vuong statistic for testing ZIP vs. unaltered model is 5.7462 | ' | Distributed as standard normal. A value greater than | ' | +1.96 favors the zero altered Z.I.Neg_Bin model. | ' | A value less than -1.96 rejects the ZIP model. | ' +----------------------------------------------------------------------+ ' +---------+--------------+----------------+--------+---------+----------+ ' |Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X| ' +---------+--------------+----------------+--------+---------+----------+ ' Poisson/NB/Gamma regression model ' Constant -.1637323623 .44872255E-01 -3.649 .0003 ' HI962 .4706108660E-01 .13025965E-01 3.613 .0003 .25962232 ' HI963 .1038781308 .28972457E-01 3.585 .0003 .53913796E-01 ' HI964 1.951563096 .24981384 7.812 .0000 .17731008E-01 ' SLUTVL .4127826489E-01 .10248718E-01 4.028 .0001 .50713565 ' AGE96 .2576973274E-02 .85625335E-03 3.010 .0026 32.670319 ' SP1 -.3142815798E-02 .11298473E-02 -2.782 .0054 5.5852674 ' DIVORCED -.2525520481E-01 .12091180E-01 -2.089 .0367 .44832060E-01 ' GOTH -.1777180534E-01 .77250913E-02 -2.301 .0214 .96439383E-01 ' SOUTHU .9856699501E-02 .53399079E-02 1.846 .0649 .20743837 ' MALLU -.2042748828E-01 .11142078E-01 -1.833 .0667 .56076114E-01 ' SWED .1678939768E-01 .75160145E-02 2.234 .0255 .89246072 ' KON96 -.7154353677E-01 .19134427E-01 -3.739 .0002 .49790976 ' NEWBORN .2715037444 .73324434E-01 3.703 .0002 .53337177E-01 ' Dispersion parameter ' Alpha 10.35420120 .23558205 43.952 .0000 ' Zero inflation model ' Tau -11.83323904 3.1150083 -3.799 .0001 xb = 1 * -0.1637323623 + _ HI962 * 0.0470610866 + _ HI963 * 0.1038781308 + _ HI964 * 1.951563096 + _ i_InpatientCare(i) * 0.04127826489 + _ i_age(i) * 0.002576973274 + _ SPLINE_AGE30 * -0.003142815798 + _ divorced * -0.02525520481 + _ GOTH * -0.01777180534 + _ SOUTHU * 0.009856699501 + _ MALLU * -0.02042748828 + _ SWED * 0.01678939768 + _ KON96 * -0.07154353677 + _ NEWBORN * 0.2715037444 ALPHA = 10.3542012 tau = -11.83323904 Case Is <= 70 ' Normal exit from iterations. Exit status=0. ' ' +----------------------------------------------------------------------+ ' | Zero Altered Neg.Binomial Regression Model | ' | Logistic distribution used for splitting model. | ' | ZAP term in probability is F[tau x ln LAMBDA] | ' | Comparison of estimated models | ' | Pr[0|means] Number of zeros Log-likelihood | ' | Poisson .61534 Act.= 2923 Prd.= 1998.6 -7574.33147 | ' | Neg. Bin. .61843 Act.= 2923 Prd.= 2008.7 -1956.34955 | ' | Z.I.Neg_Bin .89793 Act.= 2923 Prd.= 2916.5 -1920.27305 | ' | Note, the ZIP log-likelihood is not directly comparable. | ' | ZIP model with nonzero Q does not encompass the others. | ' | Vuong statistic for testing ZIP vs. unaltered model is 4.5601 | ' | Distributed as standard normal. A value greater than | ' | +1.96 favors the zero altered Z.I.Neg_Bin model. | ' | A value less than -1.96 rejects the ZIP model. | ' +----------------------------------------------------------------------+ ' +---------+--------------+----------------+--------+---------+----------+ ' |Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X| ' +---------+--------------+----------------+--------+---------+----------+ ' Poisson/NB/Gamma regression model ' Constant -1.404843438 .36692036 -3.829 .0001 ' HI962 .2488735056 .65388796E-01 3.806 .0001 .31342365 ' HI963 .6665177342 .16420021 4.059 .0000 .14347291 ' HI964 1.715375562 .25263378 6.790 .0000 .83743842E-01 ' SLUTVL .5504146690E-01 .15046835E-01 3.658 .0003 .71274631 ' AGE96 .1589215546E-01 .43147541E-02 3.683 .0002 58.717980 ' COLLEGE -.6366357727E-01 .29803728E-01 -2.136 .0327 .41040640 ' UNIV -.5101838654E-01 .33365305E-01 -1.529 .1262 .21767241 ' DIVORCED .2675560877 .82906713E-01 3.227 .0013 .11576355 ' MARITAL .1815893907 .58538812E-01 3.102 .0019 .76016010 ' GOTH .4704257918E-01 .43290445E-01 1.087 .2772 .75123153E-01 ' STOCH .8866933130E-01 .37160987E-01 2.386 .0170 .16902709 ' MALLU .6120983527E-01 .47379020E-01 1.292 .1964 .51108374E-01 ' KON96 .4177844942E-01 .23420673E-01 1.784 .0745 .48183498 ' Dispersion parameter ' Alpha 12.91657860 .23262255 55.526 .0000 ' Zero inflation model ' Tau -2.980076034 .75741441 -3.935 .0001 xb = 1 * -1.404843438 + _ HI962 * 0.2488735056 + _ HI963 * 0.6665177342 + _ HI964 * 1.715375562 + _ i_InpatientCare(i) * 0.0550414669 + _ i_age(i) * 0.01589215546 + _ COLLEGE * -0.06366357727 + _ UNIV * -0.05101838654 + _ divorced * 0.2675560877 + _ MARITAL * 0.1815893907 + _ GOTH * 0.04704257918 + _ STOCH * 0.0886693313 + _ MALLU * 0.06120983527 + _ KON96 * 0.04177844942 ALPHA = 12.9165786 tau = -2.980076034 Case Else ' Normal exit from iterations. Exit status=0. ' ' +----------------------------------------------------------------------+ ' | Zero Altered Neg.Binomial Regression Model | ' | Logistic distribution used for splitting model. | ' | ZAP term in probability is F[tau x ln LAMBDA] | ' | Comparison of estimated models | ' | Pr[0|means] Number of zeros Log-likelihood | ' | Poisson .15064 Act.= 1108 Prd.= 213.9 -8364.66190 | ' | Neg. Bin. .18104 Act.= 1108 Prd.= 257.1 -1796.14496 | ' | Z.I.Neg_Bin .77362 Act.= 1108 Prd.= 1098.5 -1781.70738 | ' | Note, the ZIP log-likelihood is not directly comparable. | ' | ZIP model with nonzero Q does not encompass the others. | ' | Vuong statistic for testing ZIP vs. unaltered model is 4.0071 | ' | Distributed as standard normal. A value greater than | ' | +1.96 favors the zero altered Z.I.Neg_Bin model. | ' | A value less than -1.96 rejects the ZIP model. | ' +----------------------------------------------------------------------+ ' +---------+--------------+----------------+--------+---------+----------+ ' |Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X| ' +---------+--------------+----------------+--------+---------+----------+ ' Poisson/NB/Gamma regression model ' Constant -4.708816733 .97356213 -4.837 .0000 ' HI962 .7287025881 .12873693 5.660 .0000 .35985915 ' HI963 1.273815756 .17391577 7.324 .0000 .21549296 ' HI964 1.959084853 .23508183 8.334 .0000 .17676056 ' SLUTVL .2284860227E-01 .80974417E-02 2.822 .0048 2.8866197 ' AGE96 .5999760920E-01 .12300237E-01 4.878 .0000 76.706338 ' UNIV -.2597121920 .14323757 -1.813 .0698 .92957746E-01 ' DIVORCED -.3789241527 .15260412 -2.483 .0130 .74647887E-01 ' MARITAL -.1937412900 .10162478 -1.906 .0566 .55352113 ' RELINK -.1286187662 .43282852E-01 -2.972 .0030 1.0000000 ' GOTH .7795126220 .18201355 4.283 .0000 .80281690E-01 ' MALLU .2445169918 .19678732 1.243 .2140 .58450704E-01 ' SOUTHU .2560125246 .10122233 2.529 .0114 .22535211 ' KON96 .2626533013 .11453427 2.293 .0218 .44436620 ' D4 .2148987053 .67386308E-01 3.189 .0014 .54273855 ' Dispersion parameter ' Alpha 9.040690764 .30025283 30.110 .0000 ' Zero inflation model ' Tau -1.286706085 .20102222 -6.401 .0000 ' (Note: E+nn or E-nn means multiply by 10 to + or -nn power.) xb = 1 * -4.708816733 + _ HI962 * 0.7287025881 + _ HI963 * 1.273815756 + _ HI964 * 1.959084853 + _ i_InpatientCare(i) * 0.02284860227 + _ i_age(i) * 0.0599976092 + _ UNIV * -0.259712192 + _ divorced * -0.3789241527 + _ MARITAL * -0.19374129 + _ RELINK * -0.1286187662 + _ GOTH * 0.779512622 + _ MALLU * 0.2445169918 + _ SOUTHU * 0.2560125246 + _ KON96 * 0.2626533013 + _ KON_RELINK * 0.2148987053 ALPHA = 9.040690764 tau = -1.286706085 End Select End If ' A standard Gamma random number is drawn and rescaled to have mean value 1 and variance alpha ' NOTE: two random numbers are drawn because there seems to be some problem with the first value!!! Call RANGAM(2, temp_gam(1), base_year + model_time + i + random * Rnd, 1 / ALPHA) u = temp_gam(2) * ALPHA ' Calculate lambda (the stochastic poisson intensity) LAMBDA = Exp(xb) * u If LAMBDA = 0 Then LAMBDA = 1E-40 ' Calculate the probability of a zero value (in the splitting model) pi = 1 / (1 + Exp(-tau * Log(LAMBDA))) ' A zero outcome is generated from the splitting model --> zero outcome If Rnd < pi Then i_InpatientCare(i) = 0 Else ' A non-zero outcome is generated from the splitting model --> draw a Poisson variate ' NOTE: the outcome can be zero here to, the pdf is NOT rescaled ' NOTE2: the response variable is truncated at 365 days. Call RANPOI(2, poisson(1), base_year + model_time + i + random * Rnd, LAMBDA) If poisson(2) > 365 Then i_InpatientCare(i) = 365 Else i_InpatientCare(i) = poisson(2) End If End If Else ' No days with inpatient care for emigrants or individuals younger than 60 i_InpatientCare(i) = 0 End If Next ' Next individual End Sub
'**************************************** '**************************************** '*** ADL - Activities of Daily Living *** '**************************************** '**************************************** ' ' GENERAL COMMENTS: ' - Variable coding scheme: 0 - missing value, 1 - Non-disabled, 2 - Slightly disabled, ' 3 - Moderately disabled, 4 - Severely disabled ' - ADL is simulated using an estimated ordinal logistic regression model (proportional odds model) ' - Since a cross sectional model is used for simulation a constant individual random number is used for ' randomization in order to prevent the inter-temporal variation to be too high. ' - The model was estimated by Daniel Hallberg using STATA
Public Sub ADL() status "ADL" Printdok "ADL" Dim temp_uni(1 To 2) As Double, xb As Double, xbeta1 As Double, xbeta2 As Double, xbeta3 As Double Dim cumprob1 As Double, cumprob2 As Double, cumprob3 As Double Dim i As Long Dim ULF2 As Byte, ULF3 As Byte, ULF4 As Byte, KON As Byte Dim aldg2 As Byte, aldg3 As Byte, aldg4 As Byte, ULF1 As Byte ' added DH 20061016 ' At base year all individuals are assigned a uniform random number to use when ' randomizing health index from the cross-sectional model If model_time = 0 Then Call S_RANUNI(UBound(i_ADL_rnd), i_ADL_rnd(1), model_time + base_year + random * Rnd) ' Loop across the population For i = 1 To m_icount ' Assign random number if missing (immigrants and newborns) If i_ADL_rnd(i) = 0 Then i_ADL_rnd(i) = Rnd ' Only individuals living in Sweden aged 65 or older are "at risk" If i_abroad(i) = 0 And i_age(i) >= 65 Then '*** Calculate covariates ' Dummy variable for women If i_sex(i) = 2 Then KON = 1 Else KON = 0 ' Dummy variables for health index levels If i_health(i) = 1 Then ULF4 = 1 Else ULF4 = 0 If i_health(i) = 2 Then ULF3 = 1 Else ULF3 = 0 If i_health(i) = 3 Then ULF2 = 1 Else ULF2 = 0 'added DH 20061016 If i_age(i) >= 65 And i_age(i) <= 74 Then aldg2 = 1 Else aldg2 = 0 If i_age(i) >= 75 And i_age(i) <= 84 Then aldg3 = 1 Else aldg3 = 0 If i_age(i) >= 85 Then aldg4 = 1 Else aldg4 = 0 If i_health(i) = 4 Then ULF1 = 1 Else ULF1 = 0 '****************************************** ' 20061016 new imputatuion model by Daniel Hallberg (STATA9.0 package) '/* 'ULF SCB ohälsoindex (1=full hälsa, ...,4 =svår ohälsa) (dvs omvänt '**Kristians definition!) '** '**ADL enligt vår senaste definition; som Du kan se är det endast 5 '**obs med adl=3, de flesta har adl=0 eftersom det är en '**befolkningsstudie med en hel del yngre personer. '** '**ALDG - åldersgrupp (- 65; 65 -74, 75- 84, 85+) ' 1 2 3 4 '*/ '. '. /* reference is aldg==2 (age 65-74), ulf==1 (full health) */ '. '. ologit adl aldg_ulf_22 aldg_ulf_23 aldg_ulf_24 aldg_ulf_3* aldg_ulf_4* kon ' 'Iteration 0: Log likelihood = -2167.158 'Iteration 1: Log likelihood = -1614.3841 'Iteration 2: Log likelihood = -1496.5929 'Iteration 3: Log likelihood = -1487.2042 'Iteration 4: Log likelihood = -1486.9065 'Iteration 5: Log likelihood = -1486.904 'Iteration 6: Log likelihood = -1486.904 ' 'Ordered logistic regression Number of obs = 2421 ' LR chi2(12) = 1360.51 ' Prob > chi2 = 0.0000 'Log likelihood = -1486.904 Pseudo R2 = 0.3139 ' '------------------------------------------------------------------------------ ' adl | Coef. Std. Err. z P>|z| [95% Conf. Interval] '-------------+---------------------------------------------------------------- ' aldg_ulf_22 | .3207815 .5240976 0.61 0.540 -.7064309 1.347994 ' aldg_ulf_23 | 1.419984 .439573 3.23 0.001 .5584368 2.281531 ' aldg_ulf_24 | 3.381867 .4493978 7.53 0.000 2.501063 4.26267 ' aldg_ulf_31 | 1.196367 .5147148 2.32 0.020 .187544 2.205189 ' aldg_ulf_32 | 1.480098 .4589774 3.22 0.001 .5805192 2.379677 ' aldg_ulf_33 | 2.794293 .4003466 6.98 0.000 2.009628 3.578958 ' aldg_ulf_34 | 4.786126 .412684 11.60 0.000 3.977281 5.594972 ' aldg_ulf_41 | 2.490851 .5698053 4.37 0.000 1.374053 3.607648 ' aldg_ulf_42 | 3.030456 .4697817 6.45 0.000 2.109701 3.951211 ' aldg_ulf_43 | 4.621629 .4030794 11.47 0.000 3.831608 5.41165 ' aldg_ulf_44 | 6.146312 .4076171 15.08 0.000 5.347397 6.945227 ' kon | .3398921 .1240655 2.74 0.006 .0967281 .5830561 '-------------+---------------------------------------------------------------- ' /cut1 | 4.416326 .4334633 3.566753 5.265898 ' /cut2 | 6.355969 .4438776 5.485985 7.225953 ' /cut3 | 7.604705 .4524429 6.717933 8.491477 '------------------------------------------------------------------------------ ' Linear predictor CHANGED HERE DH 20061016 xb = aldg2 * ULF2 * 0.3207815 + _ aldg2 * ULF3 * 1.419984 + _ aldg2 * ULF4 * 3.381867 + _ aldg3 * ULF1 * 1.196367 + _ aldg3 * ULF2 * 1.480098 + _ aldg3 * ULF3 * 2.794293 + _ aldg3 * ULF4 * 4.786126 + _ aldg4 * ULF1 * 2.490851 + _ aldg4 * ULF2 * 3.030456 + _ aldg4 * ULF3 * 4.621629 + _ aldg4 * ULF4 * 6.146312 + _ KON * 0.3398921 ' Linear predictor including treshold parameters CHANGED HERE DH 20061016 xbeta1 = xb - 4.416326 xbeta2 = xb - 6.355969 xbeta3 = xb - 7.604705 ' Cumulative probabilities cumprob1 = 1 / (1 + Exp(xbeta1)) cumprob2 = 1 / (1 + Exp(xbeta2)) cumprob3 = 1 / (1 + Exp(xbeta3)) ' Randomization of ADL ' NOTE: constant random numbers i_ADL_rnd() Select Case (i_ADL_rnd(i)) Case Is < cumprob1 i_ADL(i) = 1 Case Is < cumprob2 i_ADL(i) = 2 Case Is < cumprob3 i_ADL(i) = 3 Case Else i_ADL(i) = 4 End Select Else '*** Emigrants have missing ADL-status i_ADL(i) = 0 End If Next End Sub
'************************ '************************ '*** Excess mortality *** '************************ '************************ ' ' GENERAL COMMENTS: ' - Sub ExcessMortality calculates the excess mortality (relative risks) of individuals with functional ' disorder (ADL). The relative risks are used to inflate the probabilities used by the mortality ' module (see sub Mortality in module b01_Demographics). The calculated hazards are then adjusted to ' the mean hazard rate (by age and sex) used by SCB in order to preserve the total population level of ' mortality. ' - Note that the value of i_assistance_elderly used for simulation of excess mortality was calculated ' the year before (lagged). ' - Estimation is based on an piecewise exponential model for survival times (see "Mortality and the ' transition between care forms among the very old in Sweden", Hallberg) ' - NOTE: Due to a new coding scheme for i_ADL, levels 3 and 4 will be aggregated until the new ' estimates of the model for excess mortality is available (TP040823)
Public Sub ExcessMortality(ByRef probs() As Double) status "Excess mortality" Printdok "Excess mortality" Dim i As Long Dim AGE80_84 As Byte, AGE85_89 As Byte, AGE90_94 As Byte, AGE95_ As Byte, AGE90_ As Byte Dim MAN As Byte, AGE75_79 As Byte, SAMBO As Byte, SAMBO_MAN As Byte Dim ADL1 As Byte, ADL2 As Byte, ADL3 As Byte Dim SAMBO_AGE75_79 As Byte, SAMBO_AGE80_84 As Byte, SAMBO_AGE85_89 As Byte, SAMBO_AGE90_ As Byte Dim RR As Double, h0 As Double, h1 As Double, h2 As Double Dim TIME0_365 As Byte For i = 1 To m_icount '*** The adjustment is only done for elderly with special assistance If i_assistance_elderly(i) > 0 Then ' Dummy variable for men If i_sex(i) = 1 Then MAN = 1 Else MAN = 0 ' Dummy variables for levels of ADL If i_ADL(i) = 2 Then ADL1 = 1 Else ADL1 = 0 If i_ADL(i) = 3 Then ADL2 = 1 Else ADL2 = 0 If i_ADL(i) = 4 Then ADL3 = 1 Else ADL3 = 0 ' Dummy variables for age groups If i_age(i) >= 75 And i_age(i) <= 79 Then AGE75_79 = 1 Else AGE75_79 = 0 If i_age(i) >= 80 And i_age(i) <= 84 Then AGE80_84 = 1 Else AGE80_84 = 0 If i_age(i) >= 85 And i_age(i) <= 89 Then AGE85_89 = 1 Else AGE85_89 = 0 If i_age(i) >= 90 And i_age(i) <= 94 Then AGE90_94 = 1 Else AGE90_94 = 0 If i_age(i) >= 90 Then AGE90_ = 1 Else AGE90_ = 0 If i_age(i) >= 95 Then AGE95_ = 1 Else AGE95_ = 0 ' Dummy variable for civil status If i_civ_stat(i) = 1 Then SAMBO = 1 Else SAMBO = 0 ' Interaction between civil status and sex SAMBO_MAN = SAMBO * MAN ' Dummy variables for interaction between age groups and civil status SAMBO_AGE75_79 = SAMBO * AGE75_79 SAMBO_AGE80_84 = SAMBO * AGE80_84 SAMBO_AGE85_89 = SAMBO * AGE85_89 SAMBO_AGE90_ = SAMBO * AGE90_ ' Since simulations always take place in a yearly setting the baseline of the first year of ' risk is used TIME0_365 = 1 ' -------------------------------------------------------------------------------------------- ' Variable | exp0 exp1 exp2 exp_gamma0 exp_gamma1 exp_gamma2 ' -------------+------------------------------------------------------------------------------ ' _t | ' man | 1.624704 1.472045 1.502611 1.624731 1.472055 1.906108 ' ADL1 | 0.983241 0.809372 0.655374 0.983246 0.809373 0.710921 ' ADL2 | 1.214290 1.048841 0.989511 1.214295 1.048850 0.996678 ' ADL3 | 2.901324 1.509358 1.320697 2.901383 1.509385 1.508726 ' sambo | 1.133617 0.512995 3.211793 1.133631 0.512993 4.548586 ' sambo_man | 1.004323 1.473168 0.513279 1.004325 1.473177 0.335845 ' age80_84 | 1.563147 1.133742 0.985200 1.563173 1.133750 1.758908 ' age85_89 | 2.303087 1.819745 0.871783 2.303145 1.819777 1.871325 ' age90_94 | 3.389321 2.633417 1.401773 3.389453 2.633478 3.213486 ' age95_ | 6.432405 2.535911 1.622778 6.432557 2.535943 4.418651 ' time0_365 | 0.124979 0.228688 0.438111 0.124893 0.228748 0.083063 ' time365_730 | 0.221315 0.328353 0.528714 0.221166 0.328443 0.128944 ' time730_1095 | 0.302635 0.444285 0.302435 0.444415 ' time109~1460 | 0.288160 0.692628 1.536492 0.287972 0.692841 3.4e+176 ' time146~1825 | 0.306689 0.254358 0.306497 0.254430 ' time182~2500 | 0.268059 0.365714 0.267896 0.365827 ' time250~4000 | 0.507048 0.444306 0.506799 0.444454 ' _cons | 0.001261 0.002062 0.002693 0.001262 0.002062 0.005736 ' -------------+------------------------------------------------------------------------------ ' ln_the | ' _cons | 0.000000 0.000001 0.220757 ' -------------+------------------------------------------------------------------------------ ' Statistics | ' N | 3.72e+03 1.50e+03 3.38e+02 3.72e+03 1.50e+03 3.38e+02 ' ll | -1.04e+03 -6.45e+02 -2.49e+02 -1.04e+03 -6.45e+02 -2.51e+02 ' chi2 | 2.27e+02 1.35e+02 33.022923 2.27e+02 1.35e+02 28.682978 ' theta | 0.000000 0.000001 0.220757 ' NOTE: the parameters below equals the log of the estimates in the table above '*** One-year hazard for status 0 (no special assistance) h0 = Exp(MAN * 0.210781466923365 + _ ADL1 * -7.33781169315713E-03 + _ ADL2 * 8.43242067627876E-02 + _ ADL3 * 0.462605062069638 + _ SAMBO * 5.44717135139784E-02 + _ SAMBO_MAN * 1.8742734332527E-03 + _ AGE80_84 * 0.194007045061827 + _ AGE85_89 * 0.36232128087241 + _ AGE90_94 * 0.530129616123564 + _ AGE95_ * 0.808383643257944 + _ TIME0_365 * -0.903461902270911 + _ -2.89894064509188) Select Case i_assistance_elderly(i) ' Assistance at home Case (1) h1 = Exp(MAN * 0.167924036734002 + _ ADL1 * -9.18512874000898E-02 + _ ADL2 * 2.07133825402495E-02 + _ ADL3 * 0.178800029735412 + _ SAMBO * -0.289888560974177 + _ SAMBO_MAN * 0.168254929806105 + _ AGE80_84 * 5.45173000681517E-02 + _ AGE85_89 * 0.260018171719581 + _ AGE90_94 * 0.420529694624956 + _ AGE95_ * 0.404139487749257 + _ TIME0_365 * -0.640642694388338 + _ -2.6857113390525) ' Relative risk RR = h1 / h0 ' Living in housing facility Case (2) h2 = Exp(MAN * 0.280147504106734 + _ ADL1 * -0.148178656893696 + _ ADL2 * -1.44512795763032E-03 + _ ADL3 * 0.178610374637822 + _ SAMBO * 0.657876410319157 + _ SAMBO_MAN * -0.473861113015352 + _ AGE80_84 * 0.245243124200357 + _ AGE85_89 * 0.27214921959475 + _ AGE90_94 * 0.506976412186051 + _ AGE95_ * 0.645289700869889 + _ TIME0_365 * -1.08059238745781 + _ -2.24139085734026) ' Relative risk RR = h2 / h0 '*** This should not occur... Case Else status "ERROR IN SUB: ExcessMortality" End Select '*** The original risk is multiplied by the calculated relative risk probs(i) = probs(i) * RR If probs(i) > 1 Then probs(i) = 1 End If ' i_assistance_elderly(i) > 0 Next End Sub
'************************************** '*** Special Assistance for Elderly *** '************************************** ' ' GENERAL COMMENTS: ' - Sub AssistanceElderly simulates transitions between different states ' concerning the need for special assistance (housing and care) for elderly. ' - Variable coding scheme: 0 - no assistance, 1 - assistance at home, 2 - living in housing facility ' - Individuals are assumed to have no need for assistance until age 75. At age 75, or when ' entering the population, a value of i_assistance_elderly is assigned using an imputation ' model. During every subsequent year simulation is based on the estimated transition model. The ' transition model is formulated as a series of multinomial logit models, one model for each level ' of assistance during the previous year. For further documentation see "Mortality and the ' transition between care forms among the very old in Sweden" (Hallberg & Lagergren, 2004). ' - Note: all individuals not included in the population at risk (emigrants, individuals aged ' 74 or younger) has i_assistance_elderly equal to 0.
Public Sub AssistanceElderly() status "Assistance" Printdok "Assistance" Dim pi(3) As Double, XB0 As Double, XB1 As Double, XB2 As Double, DENOM As Double Dim i As Long Dim MAN As Byte, PARTNER As Byte, IADL As Byte, PADL As Byte, AGE80_84 As Byte, AGE85_89 As Byte Dim AGE90_94 As Byte, AGE95_ As Byte, AGE75_79 As Byte, AGE90_ As Byte Dim KON As Byte, agegrp As Byte Dim ADL0 As Byte, ADL1 As Byte, ADL2 As Byte, ADL3 As Byte, SAMBO As Byte, SAMBO_MAN As Byte Dim SAMBO_AGE75_79 As Byte, SAMBO_AGE80_84 As Byte, SAMBO_AGE85_89 As Byte, SAMBO_AGE90_ As Byte Dim YTID As Byte ' Loop across population For i = 1 To m_icount ' Population at risk: individuals living in sweden aged 65 and above If i_abroad(i) = 0 And i_age(i) >= 65 Then '*** Define covariates ' Dummy variable for sex If i_sex(i) = 1 Then MAN = 1 Else MAN = 0 ' Dummy variables for age groups If i_age(i) >= 75 And i_age(i) <= 79 Then AGE75_79 = 1 Else AGE75_79 = 0 If i_age(i) >= 80 And i_age(i) <= 84 Then AGE80_84 = 1 Else AGE80_84 = 0 If i_age(i) >= 85 And i_age(i) <= 89 Then AGE85_89 = 1 Else AGE85_89 = 0 If i_age(i) >= 90 And i_age(i) <= 94 Then AGE90_94 = 1 Else AGE90_94 = 0 If i_age(i) >= 90 Then AGE90_ = 1 Else AGE90_ = 0 If i_age(i) >= 95 Then AGE95_ = 1 Else AGE95_ = 0 ' Dummy variables for levels of ADL If i_ADL(i) = 2 Then ADL1 = 1 Else ADL1 = 0 If i_ADL(i) = 3 Then ADL2 = 1 Else ADL2 = 0 If i_ADL(i) = 4 Then ADL3 = 1 Else ADL3 = 0 ' Dummy variables for civil status If i_civ_stat(i) = 1 Then SAMBO = 1 Else SAMBO = 0 ' Interaction between civil status and sex SAMBO_MAN = SAMBO * MAN ' Dummy variables for interaction between civil status and age SAMBO_AGE75_79 = SAMBO * AGE75_79 SAMBO_AGE80_84 = SAMBO * AGE80_84 SAMBO_AGE85_89 = SAMBO * AGE85_89 SAMBO_AGE90_ = SAMBO * AGE90_ YTID = 1 ' adjustment factor for time between observations in estimation, set to one in simulation '*** Individuals entering the population at risk are simulated using an '*** imputation model (multinomial logit). '*** Note that two different models are used depending on age If model_time = 0 Or i_new_immig(i) > 0 Or i_age(i) = 65 Then If i_age(i) >= 65 And i_age(i) <= 74 Then ' Linear predictor for care level 1 (comparison group) XB0 = 0 ' Linear predictor for care level 2 If i_sex(i) = 1 Then '*** Men XB1 = i_age(i) * 0.2127 + _ MAN * -1.6894 + _ ADL1 * 1.6456 + _ ADL2 * 2.7901 + _ ADL3 * 3.3229 + _ -20.3627 ' Linear predictor for care level 3 XB2 = i_age(i) * 0.161 + _ MAN * 0.0029 + _ ADL1 * -1.2447 + _ ADL2 * 1.1473 + _ ADL3 * 4.446 + _ -15.9354 Else '*** Women XB1 = i_age(i) * 0.2096 + _ ADL1 * 1.4968 + _ ADL2 * 2.6648 + _ ADL3 * 3.2562 + _ -20.1854 ' Linear predictor for care level 3 XB2 = i_age(i) * 0.1474 + _ ADL1 * -0.9949 + _ ADL2 * 1.3713 + _ ADL3 * 4.7634 + _ -14.8972 End If End If If i_age(i) >= 75 Then ' Multinomial logistic regression Number of obs = 4144 ' LR chi2(16) = 2325.1 ' Prob > chi2 = 0.0000 ' Log likelihood = -2562.4921 Pseudo R2 = 0.3121 ' ' ------------------------------------------------------------------------------ ' status1 | Coef. Std. Err. z P>|z| [95% Conf. Interval] ' -------------+---------------------------------------------------------------- ' 1 | ' age80_84 | .6233785 .1289122 4.84 0.000 .3707153 .8760417 ' age85_89 | 1.183268 .1268061 9.33 0.000 .9347331 1.431804 ' age90_94 | 1.602593 .1450857 11.05 0.000 1.31823 1.886955 ' age95_ | 2.635833 .2901941 9.08 0.000 2.067063 3.204603 ' man | -.7550017 .1049449 -7.19 0.000 -.9606898 -.5493135 ' ADL1 | 1.010446 .1083196 9.33 0.000 .7981438 1.222749 ' ADL2 | 2.124226 .1243086 17.09 0.000 1.880585 2.367866 ' ADL3 | 2.883104 .2244738 12.84 0.000 2.443144 3.323065 ' _cons | -2.683396 .1362326 -19.70 0.000 -2.950407 -2.416385 ' -------------+---------------------------------------------------------------- ' 2 | ' age80_84 | .9814142 .3142145 3.12 0.002 .3655651 1.597263 ' age85_89 | 1.904241 .3018413 6.31 0.000 1.312643 2.495839 ' age90_94 | 2.397966 .3134557 7.65 0.000 1.783605 3.012328 ' age95_ | 3.885591 .4320007 8.99 0.000 3.038886 4.732297 ' man | -.7665999 .200959 -3.81 0.000 -1.160472 -.3727275 ' ADL1 | .6918496 .3438879 2.01 0.044 .0178416 1.365858 ' ADL2 | 2.986827 .3215114 9.29 0.000 2.356676 3.616977 ' ADL3 | 6.538678 .3474283 18.82 0.000 5.857731 7.219625 ' _cons | -5.721223 .3955948 -14.46 0.000 -6.496575 -4.945871 ' ------------------------------------------------------------------------------ ' (Outcome status1==0 is the comparison group) ' Linear predictor for care level 1 (comparison group) XB0 = 0 ' Linear predictor for care level 2 XB1 = AGE80_84 * 0.6233785 + _ AGE85_89 * 1.183268 + _ AGE90_94 * 1.602593 + _ AGE95_ * 2.635833 + _ MAN * -0.7550017 + _ ADL1 * 1.010446 + _ ADL2 * 2.124226 + _ ADL3 * 2.883104 + _ -2.683396 ' Linear predictor for care level 3 XB2 = AGE80_84 * 0.9814142 + _ AGE85_89 * 1.904241 + _ AGE90_94 * 2.397966 + _ AGE95_ * 3.885591 + _ MAN * -0.7665999 + _ ADL1 * 0.6918496 + _ ADL2 * 2.986827 + _ ADL3 * 6.538678 + _ -5.721223 End If DENOM = Exp(XB0) + Exp(XB1) + Exp(XB2) pi(1) = Exp(XB0) / DENOM pi(2) = Exp(XB1) / DENOM pi(3) = Exp(XB2) / DENOM Else '*** Individuals that was included in the population at risk during the previous year '*** are simulated using the estimated transition model (a separate multinomial logit '*** model for each initial state). '*** NOTE: No transitions are assumed from the highest level of care to any other level of care. '*** Too few such transitions were observed in data. TP041005 '*** each case below represents a row in the transition matrix Select Case (i_assistance_elderly(i)) '*** No assistance last year Case 0 XB0 = 0 XB1 = i_age(i) * 0.15 + _ MAN * -0.7 + _ ADL1 * 0.114 + _ ADL2 * 0.307 + _ ADL3 * 2.2 + _ SAMBO * -0.351 + _ SAMBO_MAN * 0.618 + _ YTID * 0.354 + _ -15.1 XB2 = i_age(i) * 0.233 + _ MAN * 0.0547 + _ ADL1 * 0.135 + _ ADL2 * 0.885 + _ ADL3 * 3.51 + _ SAMBO * 0.11 + _ SAMBO_MAN * -0.334 + _ YTID * 0.94 + _ -25.1 DENOM = Exp(XB0) + Exp(XB1) + Exp(XB2) pi(1) = Exp(XB0) / DENOM pi(2) = Exp(XB1) / DENOM pi(3) = Exp(XB2) / DENOM '*** Assistance at home during last year Case 1 XB0 = i_age(i) * -0.155 + _ MAN * -0.168 + _ ADL1 * 0.1377607 + _ ADL2 * -0.881 + _ ADL3 * -1.15 + _ SAMBO * 0.347 + _ SAMBO_MAN * 0.277 + _ YTID * -0.0575 + _ 12 XB1 = 0 XB2 = i_age(i) * 0.0538 + _ MAN * -1.11 + _ ADL1 * 0.0473 + _ ADL2 * 0.386 + _ ADL3 * 0.711 + _ SAMBO * -1.36 + _ SAMBO_MAN * 1.85 + _ YTID * 0.412 + _ -6.88 DENOM = Exp(XB0) + Exp(XB1) + Exp(XB2) pi(1) = Exp(XB0) / DENOM pi(2) = Exp(XB1) / DENOM pi(3) = Exp(XB2) / DENOM '*** Living in housing facility last year '*** NOTE: No estimation is done here. These individuals are assumed to remain in '*** this level of care until death. TP 041005 Case 2 pi(1) = 0 pi(2) = 0 pi(3) = 1 '*** This should not occur... Case Else status "ERROR IN SUB ASSISTANCEELDERLY" End Select End If '*** Randomize assistance Select Case Rnd Case Is <= pi(1) i_assistance_elderly(i) = 0 Case Is <= pi(1) + pi(2) i_assistance_elderly(i) = 1 Case Else i_assistance_elderly(i) = 2 End Select Else '*** Individuals not included in the population at risk are assigned zeroes. i_assistance_elderly(i) = 0 End If Next End Sub
'*********************************** '*********************************** '*** Entry to disability pension *** '*********************************** '*********************************** ' ' GENERAL COMMENTS: ' - Sub DisabilityPension simulates the inflow into disability pension and replaces model early_retire ' in module b01_Demographics when activated. ' - The probability of entering disability pension is modelled using logit models. ' - During the first years of simulation the number of new disability pensioners is aligned to official ' statistics regarding the number of new disability pensioners.
Public Sub DisabilityPension() status "Disability pension" Printdok "Disability pension" Dim i As Long, n As Long Dim probs() As Double, rand() As Double, sortvek() As Double Dim inc_atrisk() As Double, pool_atrisk() As Long ReDim probs(1 To m_icount), pool_atrisk(1 To m_icount), rand(1 To m_icount) ReDim sortvek(1 To m_icount), inc_atrisk(1 To m_icount) Dim count_atrisk As Long, count_er As Long Dim expected As Double count_atrisk = 0 expected = 0 count_er = 0 '*** Create pool of individuals at risk and calculate quartiles of PGI For i = 1 To m_icount '*** Individuals at risk If i_age(i) >= 16 And i_age(i) <= 64 And i_status(i) <> 4 And i_abroad(i) = 0 Then count_atrisk = count_atrisk + 1 pool_atrisk(count_atrisk) = i_indnr(i) '*** add individuals at risk to pool inc_atrisk(count_atrisk) = CDbl(i_inc_taxable(i)) '*** add PGI to pool End If Next '*** Pack and/or define vectors depending on calculated count_atrisk ReDim Preserve pool_atrisk(1 To count_atrisk), inc_atrisk(1 To count_atrisk) ReDim Preserve probs(1 To count_atrisk), rand(1 To count_atrisk) ReDim Preserve sortvek(1 To count_atrisk) '*** Calculate limits for quartiles of taxable income for individuals at risk Dim inc_q() As Double inc_q = arr_Percentile(inc_atrisk, 25, 50, 75) Dim idx As Long Dim xbeta As Double Dim KVARTIL1 As Byte, KVARTIL2 As Byte, KVARTIL3 As Byte, KVARTIL4 As Byte, SWED As Byte Dim AGE96 As Byte, AGED As Byte, HI1 As Byte, HI2 As Byte, HI3 As Byte, HI4 As Byte Dim KON96 As Byte, COLLEGE As Byte, UNIV As Byte, MARITAL As Byte, INTER7 As Byte Dim PRIVAT As Byte, GOVERN As Byte, COMMUN As Byte, OWNEMPL As Byte, SICKL As Byte '*** Calculate individual probabilities for entering disability For i = 1 To count_atrisk '*** Calculate covariates idx = indnr2index(pool_atrisk(i)) ' Income quartiles KVARTIL1 = 0: KVARTIL2 = 0: KVARTIL3 = 0: KVARTIL4 = 0 Select Case i_inc_taxable(idx) Case Is < inc_q(1, 2) KVARTIL1 = 1 Case Is < inc_q(2, 2) KVARTIL2 = 1 Case Is < inc_q(3, 2) KVARTIL3 = 1 Case Else KVARTIL4 = 1 End Select ' Sex: men - 1, women - 0 If i_sex(idx) = 1 Then KON96 = 1 Else KON96 = 0 ' Dummy for born in Sweden If (i_born_abroad(idx) = 0) Then SWED = 1 Else SWED = 0 ' Age AGE96 = i_age(idx) ' Dummy for age 16 If i_age(idx) = 16 Then AGED = 1 Else AGED = 0 ' Dummies för labour market sector If (i_sector1(idx) = 1 Or i_sector1(idx) = 2) Then PRIVAT = 1 Else PRIVAT = 0 If i_sector1(idx) = 3 Then GOVERN = 1 Else GOVERN = 0 If i_sector1(idx) = 4 Then COMMUN = 1 Else COMMUN = 0 If i_sector1(idx) = 5 Then OWNEMPL = 1 Else OWNEMPL = 0 ' Dummy för sjukpenning föregående år If i_sick_ind1(idx) = 1 Then SICKL = 1 Else SICKL = 0 ' Marital status: 0 - singe, 1 - married or cohabiting MARITAL = i_civ_stat(idx) ' Health index: 1 - full health, .., 3 - some illness ' *** NOTE: opposite order compared to then SESIM-definition!!! If i_health1(idx) = 1 Then HI4 = 1 Else HI4 = 0 If i_health1(idx) = 2 Then HI3 = 1 Else HI3 = 0 If i_health1(idx) = 3 Then HI2 = 1 Else HI2 = 0 If i_health1(idx) = 4 Then HI1 = 1 Else HI1 = 0 ' Interaction: age and marital status INTER7 = AGE96 * MARITAL Select Case i_age(idx) '*** Age group 16 - 29 Case 16 To 29 ' Normal exit from iterations. Exit status=0. ' ' +---------------------------------------------+ ' | Multinomial Logit Model | ' | Maximum Likelihood Estimates | ' | Model estimated: May 17, 2005 at 10:55:03AM.| ' | Dependent variable FTP | ' | Weighting variable None | ' | Number of observations 13431 | ' | Iterations completed 8 | ' | Log likelihood function -130.0472 | ' | Restricted log likelihood -156.6603 | ' | Chi squared 53.22625 | ' | Degrees of freedom 4 | ' | Prob[ChiSqd > value] = .0000000 | ' | Hosmer-Lemeshow chi-squared = 3.28960 | ' | P-value= .91489 with deg.fr. = 8 | ' +---------------------------------------------+ ' +---------+--------------+----------------+--------+---------+----------+ ' |Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X| ' +---------+--------------+----------------+--------+---------+----------+ ' Characteristics in numerator of Prob[Y = 1] ' Constant -4.043176899 1.2750420 -3.171 .0015 ' AGE96 -.5746799675E-01 .59982909E-01 -.958 .3380 22.564738 ' HI1 -2.986380373 .74796230 -3.993 .0001 .71446653 ' SICKL 1.514236349 .49151124 3.081 .0021 .10736356 ' PRIVAT -1.873946243 .75167704 -2.493 .0127 .39245030 ' (Note: E+nn or E-nn means multiply by 10 to + or -nn power.) xbeta = -4.043176899 + _ AGE96 * -0.05746799675 + _ HI1 * -2.986380373 + _ SICKL * 1.514236349 + _ PRIVAT * -1.873946243 '*** Age group 30 - 60 Case 30 To 60 ' +---------------------------------------------+ ' | Multinomial Logit Model | ' | Maximum Likelihood Estimates | ' | Model estimated: May 17, 2005 at 11:49:16AM.| ' | Dependent variable FTP | ' | Weighting variable None | ' | Number of observations 28074 | ' | Iterations completed 10 | ' | Log likelihood function -1698.567 | ' | Restricted log likelihood -2501.492 | ' | Chi squared 1605.851 | ' | Degrees of freedom 13 | ' | Prob[ChiSqd > value] = .0000000 | ' | Hosmer-Lemeshow chi-squared = 21.93252 | ' | P-value= .00504 with deg.fr. = 8 | ' +---------------------------------------------+ ' +---------+--------------+----------------+--------+---------+----------+ ' |Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X| ' +---------+--------------+----------------+--------+---------+----------+ ' Characteristics in numerator of Prob[Y = 1] ' Constant -6.819774014 .44414986 -15.355 .0000 ' AGE96 .6207882180E-01 .62817600E-02 9.882 .0000 44.103975 ' KON -.7900835808E-01 .10711566 -.738 .4608 .49861081 ' HI1 -2.951394949 .19303575 -15.289 .0000 .61348579 ' HI2 -1.616456465 .13075425 -12.363 .0000 .24677638 ' KVARTIL1 .2781433425 .13554445 2.052 .0402 .24998219 ' KVARTIL2 .3320332890 .12759272 2.602 .0093 .25001781 ' UNIV -.3342409643 .15459690 -2.162 .0306 .26572629 ' SICKL 1.864721958 .10882312 17.135 .0000 .15665741 ' SWED -.2679968787 .11479011 -2.335 .0196 .83821329 ' PRIVAT -.4081630368 .12085245 -3.377 .0007 .42078079 ' GOVERN -.2924460070 .21825431 -1.340 .1803 .75977773E-01 ' COMMUN -.6055542721 .15385056 -3.936 .0001 .19630263 ' OWNEMPL -.8647325836E-03 .24824064E-03 -3.483 .0005 -888.54192 ' (Note: E+nn or E-nn means multiply by 10 to + or -nn power.) xbeta = -6.819774014 + _ AGE96 * 0.0620788218 + _ KON96 * -0.07900835808 + _ HI1 * -2.951394949 + _ HI2 * -1.616456465 + _ KVARTIL1 * 0.2781433425 + _ KVARTIL2 * 0.332033289 + _ UNIV * -0.3342409643 + _ SICKL * 1.864721958 + _ SWED * -0.2679968787 + _ PRIVAT * -0.4081630368 + _ GOVERN * -0.292446007 + _ COMMUN * -0.6055542721 + _ OWNEMPL * -0.0008647325836 '*** Age group 61-64 Case Is >= 61 ' +---------------------------------------------+ ' | Multinomial Logit Model | ' | Maximum Likelihood Estimates | ' | Model estimated: May 17, 2005 at 00:27:47PM.| ' | Dependent variable FTP | ' | Weighting variable None | ' | Number of observations 3246 | ' | Iterations completed 7 | ' | Log likelihood function -309.3895 | ' | Restricted log likelihood -364.1652 | ' | Chi squared 109.5512 | ' | Degrees of freedom 11 | ' | Prob[ChiSqd > value] = .0000000 | ' | Hosmer-Lemeshow chi-squared = 7.05205 | ' | P-value= .53103 with deg.fr. = 8 | ' +---------------------------------------------+ ' +---------+--------------+----------------+--------+---------+----------+ ' |Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X| ' +---------+--------------+----------------+--------+---------+----------+ ' Characteristics in numerator of Prob[Y = 1] ' Constant 22.90744270 6.1081104 3.750 .0002 ' AGE96 -.3923832241 .97867393E-01 -4.009 .0001 63.018484 ' KON -.5863395506 .26040688 -2.252 .0243 .48860136 ' HI1 -2.391690179 .40293337 -5.936 .0000 .37307455 ' HI2 -.8445878401 .27119686 -3.114 .0018 .30622304 ' UNIV -.8042096500 .49701200 -1.618 .1056 .13924831 ' KVARTIL1 -1.332620527 .48746904 -2.734 .0063 .24984596 ' KVARTIL2 -.8540250430E-02 .33896625 -.025 .9799 .25015404 ' KVARTIL3 -.8013803675E-01 .32925391 -.243 .8077 .24984596 ' PRIVAT 1.208464992 .28009026 4.315 .0000 .20764017 ' COMMUN .6376649364 .39253320 1.624 .1043 .10104744 ' OWNEMPL .1185567209E-02 .47055944E-03 2.519 .0118 -940.15835 ' (Note: E+nn or E-nn means multiply by 10 to + or -nn power.) xbeta = 22.9074427 + _ AGE96 * -0.3923832241 + _ KON96 * -0.5863395506 + _ HI1 * -2.391690179 + _ HI2 * -0.8445878401 + _ UNIV * -0.80420965 + _ KVARTIL1 * -1.332620527 + _ KVARTIL2 * -0.00854025043 + _ KVARTIL3 * -0.08013803675 + _ PRIVAT * 1.208464992 + _ COMMUN * 0.6376649364 + _ OWNEMPL * 0.001185567209 Case Else status "Error! age: " & i_age(idx) xbeta = 0 End Select ' Calculate probabilities probs(i) = 1 / (1 + Exp(-xbeta)) ' Ackumulate expected count of newly disabled expected = expected + probs(i) Next '*** Step 3: draw random numbers Call RANUNI(count_atrisk, rand(1), model_time + base_year + random * Rnd) '*** Step 4: calculate the logit transformed "sorting" variable '*** NOTE: negative sign in order to get the right selection in findlimit For i = 1 To count_atrisk sortvek(i) = -(logit(rand(i)) - logit(probs(i))) Next '*** From base_year until the current year there are real data to align the number of '*** new disability pensioneers to. (Data source: RFV, statistikinformation Is-I 2002:1, '*** tabell 1 - Nybeviljade förtidspensioner och sjukbidrag med fördelning efter '*** pensioneringsgrad och kön.) '*** 070301 ThP Kompleterad t.o.m. 2006 se; '*** S:\Dokument\Dokumentation\SESIM\Alignment\Nybeviljade SA per ålder från FK.xls Select Case (base_year + model_time) Case 2000 expected = 40845 / m_weight Case 2001 expected = 47501 / m_weight Case 2002 expected = 52648 / m_weight Case 2003 expected = 52499 / m_weight Case 2004 expected = 56916 / m_weight Case 2005 expected = 46548 / m_weight Case 2006 expected = 37550 / m_weight Case Else End Select '*** Step 5: Find the threshold value for choosing the right number of women '*** NOTE: naive simulation uses limit = 0! Dim limit As Double limit = findlimit(sortvek, CLng(expected), 0) If base_year + model_time >= 2006 Then limit = 0 '*** Naive simulation TP040527 '*** Step 6: Loop through the pool of individuals at risk and select the ones that '*** will be randomized into disability For i = 1 To count_atrisk i_new_fp(indnr2index(pool_atrisk(i))) = 0 If sortvek(i) > limit Then i_new_fp(indnr2index(pool_atrisk(i))) = 1 '*** disabled count_er = count_er + 1 '*** counts # of newly disabled i_ftp_year(indnr2index(pool_atrisk(i))) = base_year + model_time End If Next status "Disability pension: " & count_er * m_weight End Sub
'************************* '************************* '*** Closeness to relative '************************* '************************* ' ' GENERAL COMMENTS ' - Logit models are used to simulate whether the household have a closest relative that is living in ' the same LA-region. This could then affect the probability that the individual has access to ' informal care provided by the relative. ' - Separate models are estimated for single male households, single female households and ' cohabiting/married households. The variable is only simulated for households where the oldest ' individual is 65 years of age or older. ' - Imputation models are used for households that enters the population at risk during the current ' year. Dynamic models are used for all other households. '
Public Sub ClosenessToRelative() status "Closeness to relative" Printdok "Closeness to relative" Dim h As Long, count_income1 As Long, count_income2 As Long, count_income3 As Long Dim inc_dec1 As Variant, inc_dec2 As Variant, inc_dec3 As Variant, inc_dec As Variant Dim Imputation As Byte, edlev As Byte Dim SAM_LA_1 As Byte, reg1 As Byte, reg2 As Byte, reg3 As Byte, reg4 As Byte Dim reg5 As Byte, reg6 As Byte, reg7 As Byte, reg8 As Byte, REG9 As Byte Dim FAM As Byte, OWN As Byte, svenskf As Byte, AGE1 As Byte, age2 As Byte, AGE3 As Byte Dim AGE4 As Byte, AGE5 As Byte, INK1 As Byte, INK2 As Byte, INK3 As Byte, INK5 As Byte Dim INK4 As Byte, utb1 As Byte, UTB2 As Byte, UTB3 As Byte Dim kkod As Integer, STOCH As Byte, GOTH As Byte, MALLU As Byte, SOUTHU As Byte Dim MIDTHU As Byte, NORTHU As Byte, SOUTHR As Byte, MIDTHR As Byte, NORTHR As Byte Dim xbeta As Double, prob As Double Dim temp_income1() As Double, temp_income2() As Double, temp_income3() As Double ' Quintiles of disposable income for each household type (at risk) count_income1 = 0 count_income2 = 0 count_income3 = 0 ReDim temp_income1(1 To m_hcount), temp_income2(1 To m_hcount), temp_income3(1 To m_hcount) For h = 1 To m_hcount If h_abroad(h) = 0 And h_max_age(h) >= 65 Then ' Single households If h_n_adults(h) = 1 Then If h_indnr_female(h) = 0 Then ' Single male households count_income1 = count_income1 + 1 temp_income1(count_income1) = h_inc_disposable1(h) Else ' Single female households count_income2 = count_income2 + 1 temp_income2(count_income2) = h_inc_disposable1(h) End If Else ' Cohabiting/married households count_income3 = count_income3 + 1 temp_income3(count_income3) = h_inc_disposable1(h) End If End If Next ReDim Preserve temp_income1(1 To count_income1) ReDim Preserve temp_income2(1 To count_income2) ReDim Preserve temp_income3(1 To count_income3) inc_dec1 = arr_Percentile(temp_income1, 20, 40, 60, 80) inc_dec2 = arr_Percentile(temp_income2, 20, 40, 60, 80) inc_dec3 = arr_Percentile(temp_income3, 20, 40, 60, 80) ' Loop across households For h = 1 To m_hcount ' Population at risk If h_abroad(h) = 0 And h_max_age(h) >= 65 Then '*** DEFINE COVARIATES ' Closeness to relative (lagged value) SAM_LA_1 = 0 If h_close_relative1(h) = 1 Then SAM_LA_1 = 1 ' Dummy variables for regions If h_BB_region(h) = 1 Then STOCH = 1 Else STOCH = 0 If h_BB_region(h) = 2 Then GOTH = 1 Else GOTH = 0 If h_BB_region(h) = 3 Then MALLU = 1 Else MALLU = 0 If h_BB_region(h) = 4 Then SOUTHU = 1 Else SOUTHU = 0 If h_BB_region(h) = 5 Then MIDTHU = 1 Else MIDTHU = 0 If h_BB_region(h) = 6 Then NORTHU = 1 Else NORTHU = 0 If h_BB_region(h) = 7 Then SOUTHR = 1 Else SOUTHR = 0 If h_BB_region(h) = 8 Then MIDTHR = 1 Else MIDTHR = 0 If h_BB_region(h) = 9 Then NORTHR = 1 Else NORTHR = 0 ' Home ownership OWN = 0 If h_house_owner(h) = 1 Then OWN = 1 ' Age group AGE1 = 0: age2 = 0: AGE3 = 0: AGE4 = 0: AGE5 = 0 Select Case h_max_age(h) Case Is <= 74 AGE1 = 1 Case Is <= 79 age2 = 1 Case Is <= 84 AGE3 = 1 Case Is <= 89 AGE4 = 1 Case Else AGE5 = 1 End Select ' Income quintiles INK1 = 0: INK2 = 0: INK3 = 0: INK4 = 0: INK5 = 0 ' Choose household type If h_n_adults(h) = 1 Then If h_indnr_female(h) = 0 Then inc_dec = inc_dec1 Else inc_dec = inc_dec2 End If Else inc_dec = inc_dec3 End If Select Case h_inc_disposable1(h) Case Is <= inc_dec(1, 2) INK1 = 1 Case Is <= inc_dec(2, 2) INK2 = 1 Case Is <= inc_dec(3, 2) INK3 = 1 Case Is <= inc_dec(4, 2) INK4 = 1 Case Else INK5 = 1 End Select ' No lagged disposable income is available at time 0 and we assign all households ' the median value. TP 050916 If model_time = 0 Then INK1 = 0: INK2 = 0: INK3 = 1: INK4 = 0: INK5 = 0 End If ' Educational attainment of oldest individual in household If h_indnr_female(h) > 0 Then edlev = 0 If i_age(indnr2index(h_indnr_female(h))) = h_max_age(h) Then edlev = i_edlevel(indnr2index(h_indnr_female(h))) End If End If If h_indnr_male(h) > 0 Then edlev = 0 If i_age(indnr2index(h_indnr_male(h))) = h_max_age(h) Then edlev = i_edlevel(indnr2index(h_indnr_male(h))) End If End If If edlev = 0 Then utb1 = 1 Else utb1 = 0 If edlev = 1 Then UTB2 = 1 Else UTB2 = 0 If edlev = 2 Then UTB3 = 1 Else UTB3 = 0 ' Decide on imputation or dynamic simulation If h_max_age(h) = 65 Or (h_new_immig(h) = 1 And h_max_age(h) >= 65) Or model_time = 0 Then Imputation = 1 Else Imputation = 0 End If ' One or two adults in household? If h_n_adults(h) = 2 Then ' Imputation or dynamic simulation? If Imputation = 1 Then '*** COUPLES - IMPUTATION ' Output Created 29-okt-2004 15:48:10 ' ' parameter Estimates ' sam_la00(a) B Std. Error Wald df Sig. Exp(B) 95% Confidence Interval for Exp(B) ' Lower Bound Upper Bound ' 1 Intercept -0.499 0.033 233.066 1 0.000 ' [reg00=1] 0.987 0.015 4 291.633 1 0.000 2.684 2.606 2.764 ' [reg00=2] 0.830 0.017 2 317.029 1 0.000 2.292 2.216 2.371 ' [reg00=3] 0.612 0.019 1 030.569 1 0.000 1.844 1.776 1.914 ' [reg00=4] 0.230 0.013 330.994 1 0.000 1.259 1.228 1.290 ' [reg00=5] 0.441 0.015 840.186 1 0.000 1.555 1.509 1.602 ' [reg00=6] 0.413 0.020 440.346 1 0.000 1.511 1.454 1.570 ' [reg00=7] 0.071 0.014 27.632 1 0.000 1.074 1.046 1.103 ' [reg00=8] 0.043 0.015 8.397 1 0.004 1.044 1.014 1.074 ' [reg00=9] 0 . . 0 . . . . ' [age00k5e=1] 0.727 0.028 690.419 1 0.000 2.069 1.959 2.184 ' [age00k5e=2] 0.385 0.028 194.134 1 0.000 1.469 1.392 1.551 ' [age00k5e=3] 0.273 0.028 94.848 1 0.000 1.313 1.243 1.387 ' [age00k5e=4] 0.189 0.030 40.374 1 0.000 1.208 1.140 1.281 ' [age00k5e=5] 0 . . 0 . . . . ' [Ndispfb0=1] -0.082 0.012 45.786 1 0.000 0.922 0.900 0.944 ' [Ndispfb0=2] 0.040 0.012 10.934 1 0.001 1.041 1.016 1.066 ' [Ndispfb0=3] -0.062 0.012 27.529 1 0.000 0.940 0.919 0.962 ' [Ndispfb0=4] -0.081 0.011 50.105 1 0.000 0.922 0.901 0.943 ' [Ndispfb0=5] 0 . . 0 . . . . ' [utbtdsim=0] 0.635 0.014 2 144.718 1 0.000 1.887 1.837 1.938 ' [utbtdsim=1] 0.422 0.014 883.414 1 0.000 1.524 1.483 1.567 ' [utbtdsim=2] 0 . . 0 . . . . ' [own01m2=1] 0.200 0.008 589.347 1 0.000 1.221 1.202 1.241 ' [own01m2=2] 0 . . 0 . . . . ' a. The reference category is: 2. ' b. This parameter is set to zero because it is redundant. xbeta = -0.499290762115014 + _ reg1 * 0.987229367275389 + _ reg2 * 0.829620279937086 + _ reg3 * 0.611938964134331 + _ reg4 * 0.230111586415993 + _ reg5 * 0.441231047510202 + _ reg6 * 0.412821242471563 + _ reg7 * 7.14758365065545E-02 + _ reg8 * 4.28153838637315E-02 + _ AGE1 * 0.726829375215809 + _ age2 * 0.384620903026914 + _ AGE3 * 0.27263304114341 + _ AGE4 * 0.189301347597454 + _ INK1 * -8.15654388267313E-02 + _ INK2 * 4.00486808760143E-02 + _ INK3 * -6.15066820065882E-02 + _ INK4 * -8.13468547228301E-02 + _ utb1 * 0.6347271694604 + _ UTB2 * 0.421535838522456 + _ OWN * 0.199945813964228 Else '*** COUPLES - DYNAMIC MODEL ' Output Created 29-okt-2004 15:47:02 ' ' parameter Estimates ' sam_la00(a) B Std. Error Wald df Sig. Exp(B) 95% Confidence Interval for Exp(B) ' Lower Bound Upper Bound ' 1 Intercept -2.361 0.081 849.562 1 0.000 ' [sam_la99=1] 7.379 0.027 75 300.919 1 0.000 1 602.184 1 519.927 1 688.892 ' [sam_la99=2] 0 . . 0 . . . . ' [reg00=1] 0.957 0.036 719.097 1 0.000 2.603 2.427 2.791 ' [reg00=2] 0.905 0.040 513.179 1 0.000 2.471 2.285 2.672 ' [reg00=3] 0.667 0.045 219.445 1 0.000 1.949 1.784 2.129 ' [reg00=4] 0.204 0.033 37.593 1 0.000 1.226 1.149 1.309 ' [reg00=5] 0.403 0.039 109.402 1 0.000 1.497 1.388 1.615 ' [reg00=6] 0.266 0.050 28.248 1 0.000 1.305 1.183 1.440 ' [reg00=7] 0.015 0.036 0.180 1 0.671 1.016 0.946 1.091 ' [reg00=8] -0.038 0.040 0.922 1 0.337 0.963 0.890 1.041 ' [reg00=9] 0 . . 0 . . . . ' [age00k5e=1] 0.290 0.069 17.462 1 0.000 1.336 1.166 1.531 ' [age00k5e=2] 0.096 0.070 1.905 1 0.168 1.101 0.960 1.262 ' [age00k5e=3] 0.026 0.071 0.140 1 0.709 1.027 0.894 1.180 ' [age00k5e=4] 0.012 0.075 0.026 1 0.872 1.012 0.873 1.174 ' [age00k5e=5] 0 . . 0 . . . . ' [Ndispfb0=1] -0.558 0.028 386.591 1 0.000 0.572 0.541 0.605 ' [Ndispfb0=2] -0.429 0.029 223.786 1 0.000 0.651 0.616 0.689 ' [Ndispfb0=3] -0.467 0.027 288.388 1 0.000 0.627 0.594 0.662 ' [Ndispfb0=4] -0.383 0.026 212.912 1 0.000 0.682 0.648 0.718 ' [Ndispfb0=5] 0 . . 0 . . . . ' [utbtdsim=0] 0.059 0.031 3.630 1 0.057 1.061 0.998 1.128 ' [utbtdsim=1] 0.005 0.032 0.021 1 0.884 1.005 0.944 1.069 ' [utbtdsim=2] 0 . . 0 . . . . ' [own01m2=1] 0.080 0.020 15.549 1 0.000 1.083 1.041 1.127 ' [own01m2=2] 0 . . 0 . . . . ' a. The reference category is: 2. ' b. This parameter is set to zero because it is redundant. xbeta = -2.361048465 + _ SAM_LA_1 * 7.379122689 + _ reg1 * 0.956556047 + _ reg2 * 0.904585297 + _ reg3 * 0.667387319 + _ reg4 * 0.2038984 + _ reg5 * 0.403461263 + _ reg6 * 0.26617341 + _ reg7 * 0.0154 + _ reg8 * -0.0382 + _ AGE1 * 0.289901633 + _ age2 * 0.09600679 + _ AGE3 * 0.026440524 + _ AGE4 * 0.0122 + _ INK1 * -0.558 + _ INK2 * -0.429 + _ INK3 * -0.466872785 + _ INK4 * -0.382636552 + _ utb1 * 0.059341669 + _ UTB2 * 0.004632195 + _ OWN * 0.079870158 End If Else '*** SINGE ADULT HOUSEHOLD: MEN OR WOMEN? If h_indnr_female(h) > 0 Then ' Imputation or dynamic simulation? If Imputation = 1 Then '*** SINGLE WOMEN - IMPUTATION ' Output Created 29-okt-2004 16:40:02 ' ' parameter Estimates ' sam_la00(a) B Std. Error Wald df Sig. Exp(B) 95% Confidence Interval for Exp(B) ' Lower Bound Upper Bound ' 1 Intercept -0.784 0.021 1 363.040 1 0.000 ' [reg00=1] 0.203 0.012 292.730 1 0.000 1.225 1.197 1.254 ' [reg00=2] 0.240 0.014 293.284 1 0.000 1.271 1.236 1.306 ' [reg00=3] 0.124 0.015 64.659 1 0.000 1.132 1.098 1.167 ' [reg00=4] 0.044 0.011 14.828 1 0.000 1.045 1.022 1.068 ' [reg00=5] 0.152 0.013 131.374 1 0.000 1.164 1.134 1.194 ' [reg00=6] 0.251 0.017 210.805 1 0.000 1.285 1.242 1.329 ' [reg00=7] -0.031 0.012 6.425 1 0.011 0.969 0.946 0.993 ' [reg00=8] -0.022 0.013 2.782 1 0.095 0.978 0.953 1.004 ' [reg00=9] 0 . . 0 . . . . ' [age00k5e=1] 0.706 0.012 3 463.019 1 0.000 2.027 1.980 2.075 ' [age00k5e=2] 0.600 0.012 2 665.374 1 0.000 1.823 1.782 1.865 ' [age00k5e=3] 0.608 0.012 2 729.100 1 0.000 1.837 1.795 1.879 ' [age00k5e=4] 0.471 0.012 1 498.925 1 0.000 1.602 1.564 1.640 ' [age00k5e=5] 0 . . 0 . . . . ' [Nink_wom=1] -0.510 0.010 2 727.045 1 0.000 0.601 0.589 0.612 ' [Nink_wom=2] -0.176 0.010 317.347 1 0.000 0.838 0.822 0.855 ' [Nink_wom=3] 0.010 0.010 1.033 1 0.310 1.010 0.991 1.030 ' [Nink_wom=4] -0.062 0.010 41.050 1 0.000 0.940 0.922 0.958 ' [Nink_wom=5] 0 . . 0 . . . . ' [utbtdsim=0] 0.781 0.016 2 404.395 1 0.000 2.183 2.116 2.252 ' [utbtdsim=1] 0.661 0.017 1 532.145 1 0.000 1.936 1.873 2.002 ' [utbtdsim=2] 0 . . 0 . . . . ' [own01m2=1] 0.215 0.006 1 209.578 1 0.000 1.240 1.225 1.256 ' [own01m2=2] 0 . . 0 . . . . ' a. The reference category is: 2. ' b. This parameter is set to zero because it is redundant. xbeta = -0.784481421 + _ reg1 * 0.202991834 + _ reg2 * 0.239530568 + _ reg3 * 0.124221896 + _ reg4 * 0.043688156 + _ reg5 * 0.151733314 + _ reg6 * 0.250789589 + _ reg7 * -0.031229877 + _ reg8 * -0.022189023 + _ AGE1 * 0.706 + _ age2 * 0.600469363 + _ AGE3 * 0.607974519 + _ AGE4 * 0.471104557 + _ INK1 * -0.51 + _ INK2 * -0.176 + _ INK3 * 0.0101 + _ INK4 * -0.0622 + _ utb1 * 0.780610106 + _ UTB2 * 0.660832041 + _ OWN * 0.215491774 Else '*** SINGLE WOMEN - DYNAMIC MODEL ' Output Created 29-okt-2004 16:39:05 ' ' parameter Estimates ' sam_la00(a) B Std. Error Wald df Sig. Exp(B) 95% Confidence Interval for Exp(B) ' Lower Bound Upper Bound ' 1 Intercept -4.441 0.117 1 443.725 1 0.000 ' [sam_la99=1] 10.090 0.039 66 833.588 1 0.000 24 095.290 22 320.857 26 010.783 ' [sam_la99=2] 0 . . 0 . . . . ' [reg00=1] -0.275 0.067 16.683 1 0.000 0.760 0.666 0.867 ' [reg00=2] -0.126 0.079 2.552 1 0.110 0.881 0.755 1.029 ' [reg00=3] -0.201 0.088 5.179 1 0.023 0.818 0.688 0.972 ' [reg00=4] -0.022 0.063 0.119 1 0.730 0.978 0.865 1.107 ' [reg00=5] 0.243 0.071 11.583 1 0.001 1.275 1.108 1.466 ' [reg00=6] 0.161 0.094 2.953 1 0.086 1.175 0.978 1.412 ' [reg00=7] -0.032 0.069 0.214 1 0.644 0.969 0.847 1.109 ' [reg00=8] -0.060 0.075 0.654 1 0.419 0.941 0.813 1.090 ' [reg00=9] 0 . . 0 . . . . ' [age00k5e=1] 0.553 0.070 61.594 1 0.000 1.739 1.514 1.996 ' [age00k5e=2] 0.543 0.069 62.700 1 0.000 1.721 1.504 1.968 ' [age00k5e=3] 0.487 0.069 50.107 1 0.000 1.627 1.422 1.862 ' [age00k5e=4] 0.368 0.072 26.067 1 0.000 1.445 1.255 1.665 ' [age00k5e=5] 0 . . 0 . . . . ' [Nink_wom=1] -0.656 0.054 145.941 1 0.000 0.519 0.467 0.577 ' [Nink_wom=2] -0.438 0.054 65.237 1 0.000 0.645 0.580 0.718 ' [Nink_wom=3] -0.349 0.054 42.086 1 0.000 0.705 0.634 0.784 ' [Nink_wom=4] -0.257 0.052 24.461 1 0.000 0.773 0.698 0.856 ' [Nink_wom=5] 0 . . 0 . . . . ' [utbtdsim=0] 0.227 0.085 7.073 1 0.008 1.254 1.061 1.482 ' [utbtdsim=1] 0.256 0.089 8.232 1 0.004 1.292 1.085 1.540 ' [utbtdsim=2] 0 . . 0 . . . . ' [own01m2=1] -0.101 0.035 8.425 1 0.004 0.904 0.845 0.968 ' [own01m2=2] 0 . . 0 . . . . ' a. The reference category is: 2. ' b. This parameter is set to zero because it is redundant. xbeta = -4.441029702 + _ SAM_LA_1 * 10.08977165 + _ reg1 * -0.274660978 + _ reg2 * -0.126391487 + _ reg3 * -0.201249573 + _ reg4 * -0.021826759 + _ reg5 * 0.242786112 + _ reg6 * 0.161104773 + _ reg7 * -0.031798202 + _ reg8 * -0.060369521 + _ AGE1 * 0.553 + _ age2 * 0.542634235 + _ AGE3 * 0.48691372 + _ AGE4 * 0.368431112 + _ INK1 * -0.656 + _ INK2 * -0.438 + _ INK3 * -0.349 + _ INK4 * -0.257 + _ utb1 * 0.226518747 + _ UTB2 * 0.256454611 + _ OWN * -0.100571396 End If Else ' Imputation or dynamic simulation? If Imputation = 1 Then '*** SINGLE MEN - IMPUTATION ' Output Created 29-okt-2004 16:29:11 ' ' parameter Estimates ' sam_la00(a) B Std. Error Wald df Sig. Exp(B) 95% Confidence Interval for Exp(B) ' Lower Bound Upper Bound ' 1 Intercept 0.556 0.033 290.677 1 0.000 ' [reg00=1] 0.662 0.018 1 426.266 1 0.000 1.939 1.873 2.007 ' [reg00=2] 0.523 0.020 675.110 1 0.000 1.687 1.621 1.755 ' [reg00=3] 0.528 0.024 502.348 1 0.000 1.696 1.620 1.777 ' [reg00=4] 0.242 0.016 222.559 1 0.000 1.274 1.234 1.315 ' [reg00=5] 0.430 0.019 507.404 1 0.000 1.538 1.481 1.597 ' [reg00=6] 0.421 0.024 296.832 1 0.000 1.523 1.452 1.598 ' [reg00=7] -0.007 0.018 0.166 1 0.683 0.993 0.959 1.028 ' [reg00=8] 0.100 0.019 28.487 1 0.000 1.105 1.065 1.147 ' [reg00=9] 0 . . 0 . . . . ' [age00k5e=1] -0.795 0.022 1 320.663 1 0.000 0.451 0.432 0.471 ' [age00k5e=2] -0.629 0.022 796.129 1 0.000 0.533 0.511 0.557 ' [age00k5e=3] -0.429 0.023 355.900 1 0.000 0.651 0.623 0.681 ' [age00k5e=4] -0.175 0.024 52.652 1 0.000 0.840 0.801 0.880 ' [age00k5e=5] 0 . . 0 . . . . ' [Nink_men=1] -1.290 0.015 7 269.579 1 0.000 0.275 0.267 0.284 ' [Nink_men=2] -0.714 0.015 2 415.379 1 0.000 0.490 0.476 0.504 ' [Nink_men=3] -0.391 0.014 759.868 1 0.000 0.676 0.658 0.695 ' [Nink_men=4] -0.233 0.014 281.884 1 0.000 0.792 0.771 0.814 ' [Nink_men=5] 0 . . 0 . . . . ' [utbtdsim=0] 0.122 0.021 33.797 1 0.000 1.130 1.084 1.177 ' [utbtdsim=1] 0.245 0.022 123.364 1 0.000 1.278 1.224 1.335 ' [utbtdsim=2] 0 . . 0 . . . . ' [own01m2=1] 0.100 0.009 121.616 1 0.000 1.105 1.085 1.124 ' [own01m2=2] 0 . . 0 . . . . ' a. The reference category is: 2. ' b. This parameter is set to zero because it is redundant. xbeta = 0.55614348 + _ reg1 * 0.66206806 + _ reg2 * 0.522779745 + _ reg3 * 0.528476389 + _ reg4 * 0.242058587 + _ reg5 * 0.430454214 + _ reg6 * 0.420729974 + _ reg7 * -0.007190965 + _ reg8 * 0.100202494 + _ AGE1 * -0.795285025 + _ age2 * -0.629 + _ AGE3 * -0.429 + _ AGE4 * -0.174836694 + _ INK1 * -1.290062317 + _ INK2 * -0.713534287 + _ INK3 * -0.391 + _ INK4 * -0.233 + _ utb1 * 0.122 + _ UTB2 * 0.245381847 + _ OWN * 0.099595943 Else '*** SINGLE MEN - DYNAMIC MODEL ' Output Created 29-okt-2004 16:28:15 ' ' parameter Estimates ' sam_la00(a) B Std. Error Wald df Sig. Exp(B) 95% Confidence Interval for Exp(B) ' Lower Bound Upper Bound ' 1 Intercept -1.887 0.085 487.493 1 0.000 ' [sam_la99=1] 7.700 0.038 41 813.899 1 0.000 2 209.385 2 052.186 2 378.624 ' [sam_la99=2] 0 . . 0 . . . . ' [reg00=1] 0.714 0.049 213.077 1 0.000 2.042 1.855 2.248 ' [reg00=2] 0.584 0.056 108.033 1 0.000 1.793 1.606 2.002 ' [reg00=3] 0.602 0.064 87.785 1 0.000 1.827 1.610 2.072 ' [reg00=4] 0.273 0.047 33.401 1 0.000 1.314 1.198 1.441 ' [reg00=5] 0.383 0.055 48.734 1 0.000 1.467 1.317 1.634 ' [reg00=6] 0.403 0.069 33.843 1 0.000 1.496 1.306 1.714 ' [reg00=7] 0.032 0.052 0.386 1 0.535 1.033 0.933 1.143 ' [reg00=8] 0.061 0.055 1.204 1 0.273 1.063 0.953 1.185 ' [reg00=9] 0 . . 0 . . . . ' [age00k5e=1] -0.827 0.056 214.840 1 0.000 0.437 0.392 0.488 ' [age00k5e=2] -0.626 0.057 119.858 1 0.000 0.535 0.478 0.598 ' [age00k5e=3] -0.466 0.058 63.605 1 0.000 0.628 0.560 0.704 ' [age00k5e=4] -0.182 0.061 8.796 1 0.003 0.834 0.739 0.940 ' [age00k5e=5] 0 . . 0 . . . . ' [Nink_men=1] -1.067 0.041 680.204 1 0.000 0.344 0.318 0.373 ' [Nink_men=2] -0.680 0.039 300.141 1 0.000 0.506 0.469 0.547 ' [Nink_men=3] -0.481 0.038 158.661 1 0.000 0.618 0.573 0.666 ' [Nink_men=4] -0.335 0.037 82.831 1 0.000 0.715 0.665 0.769 ' [Nink_men=5] 0 . . 0 . . . . ' [utbtdsim=0] -0.220 0.055 16.325 1 0.000 0.802 0.721 0.893 ' [utbtdsim=1] -0.029 0.057 0.255 1 0.614 0.972 0.869 1.086 ' [utbtdsim=2] 0 . . 0 . . . . ' [own01m2=1] -0.015 0.025 0.346 1 0.557 0.985 0.938 1.035 ' [own01m2=2] 0 . . 0 . . . . ' a. The reference category is: 2. ' b. This parameter is set to zero because it is redundant. xbeta = -1.887298934 + _ SAM_LA_1 * 7.700469331 + _ reg1 * 0.713963252 + _ reg2 * 0.583963381 + _ reg3 * 0.602459741 + _ reg4 * 0.272985288 + _ reg5 * 0.383211836 + _ reg6 * 0.403035252 + _ reg7 * 0.032197375 + _ reg8 * 0.060845614 + _ AGE1 * -0.827138081 + _ age2 * -0.626 + _ AGE3 * -0.466 + _ AGE4 * -0.181879423 + _ INK1 * -1.067014603 + _ INK2 * -0.680265595 + _ INK3 * -0.481 + _ INK4 * -0.335 + _ utb1 * -0.22 + _ UTB2 * -0.028662256 + _ OWN * -0.014711795 End If ' Imputation / dynamic End If ' Male/female household End If ' One/two adults in household prob = 1 / (1 + Exp(-xbeta)) If Rnd <= prob Then h_close_relative(h) = 1 Else h_close_relative(h) = 0 Else ' Not included in the population at risk h_close_relative(h) = 0 End If ' In population at risk Next End Sub
'************************ '************************ '*** SICKNESS ABSENCE *** '************************ '************************ ' ' GENERAL COMMENTS: ' - The annual number of days with sickness absence is modelled using a negtive binomial model ' with correction for sample selection. For information about the technical specifications of ' the model see the LIMDEP documentation (Models for count data / Models for sample selection). ' - Incomes from previous year is used to calculate the cost variable since the simulation of ' income takes place after the current model. This does not apply to the base year where the ' actual taxable income is taken directly from from LINDA. ' - The model is estimated using health index for the current year. Due to the simulation ' sequence in SESIM this will have to be approximated using last years health index. TP041005 ' - The models were estimated by Kristian Bolin using LIMDEP ' - NOTE: Since the models were estimated using data from a period where the general level of ' sickness allowance usage was considerable lower than during the first years of simulation ' the models are aligned to observed data. This applies both to the selection and regression ' models and the alignment is achieved through an adjustment of the models intercept terms. ' The alignment constant for 2004 is carried forward to all later simulated years. ' TP 051221
Public Sub Sick_leave_Health() status "Sick leave (BabyBoom)" Printdok "Sick leave (BabyBoom)" ' Local variables Dim MARITAL As Byte, CHILDREN As Byte, Y_DUMM As Byte, STUDENT As Byte, UNEMPL As Byte Dim STOCH As Byte, GOTH As Byte, MALLU As Byte, SOUTHU As Byte, MIDTHU As Byte, NORTHU As Byte Dim SOUTHR As Byte, MIDTHR As Byte, NORTHR As Byte, KON As Byte, NEWBORN As Byte, divorced As Byte Dim HI_lag_2 As Byte, HI_lag_3 As Byte, HI_lag_4 As Byte, SJUK As Byte, D2 As Byte, PRIVAT As Byte Dim poisson(1 To 2) As Long, i As Long, counter As Long Dim xbeta_probit As Double, xbeta As Double, D7 As Double Dim dec_cost As Variant, cost As Double, tak As Double, z_star As Double Dim rho As Double, sigma As Double, u As Double, e As Double, tempvek() As Double Dim normvar(1 To 3) As Double, theta As Double, randgam(2) As Double, RCOST As Double Dim med_taxinc As Double Dim LAMBDA As Single '*** Alignment variables for 1) probability of having at least one day and '*** 2) number of days. Alignment data is given below: ' year percpos meanpos ' 1999 0.128 105.745 ' 2000 0.142 115.634 ' 2001 0.151 123.165 ' 2002 0.154 128.846 ' 2003 0.14 139.788 ' 2004 0.123 140.272 Dim align_probs() align_probs = Array(0, 0, 0.05, 0.05, -0.05, -0.1, -0.15, -0.2, -0.2) Dim align_means() align_means = Array(0, 0.75, 0.75, 0.8, 0.9, 0.9, 0.75, 0.7, 0.7) '*** First age at risk Const FirstAge = 16 ' Treshold for SGI tak = m_basbelopp_income * 7.5 ' Calculate median of cost variable counter = 0 ReDim tempvek(1 To m_icount) For i = 1 To m_icount If i_abroad(i) = 0 Then counter = counter + 1 ' Estimated cost of sickness abscense ' NOTE: since this years taxable income is not simulated yet last years is used If i_inc_taxable1(i) <= tak Then tempvek(counter) = i_inc_taxable1(i) * (1 - 0.75) Else tempvek(counter) = tak * (1 - 0.75) + (i_inc_taxable1(i) - tak) End If End If Next ReDim Preserve tempvek(1 To counter) med_taxinc = arr_Percentile(tempvek, 50)(1, 2) If med_taxinc = 0 Then status "NOTE(Sick_leave_Health): zero median of i_inc_taxable1" ' Loop across population For i = 1 To m_icount ' Selection of population at risk If i_abroad(i) = 0 And i_status(i) <> 4 And i_status(i) <> 2 And i_status(i) <> 5 And _ i_age(i) >= FirstAge Then '*** CALCULATE COVARIATES ' Estimated cost of sickness abscense ' NOTE: since this years taxable income is not simulated yet last years is used If i_inc_taxable1(i) <= tak Then cost = i_inc_taxable1(i) * (1 - 0.75) Else cost = tak * (1 - 0.75) + (i_inc_taxable1(i) - tak) End If If med_taxinc > 0 Then RCOST = cost / med_taxinc Else RCOST = 1 End If ' Dummy variable for private sector employment If i_sector(i) = 1 Or i_sector(i) = 2 Then PRIVAT = 1 Else PRIVAT = 0 ' Dummy variable for studies If i_status(i) = 3 Then STUDENT = 1 Else STUDENT = 0 ' Dummy variable for unemployment If i_status(i) = 6 Then UNEMPL = 1 Else UNEMPL = 0 ' Dummy variable for 1997, captures changes in the sickness benefit system during estimation ' but is set to zero during simulation. Y_DUMM = 0 ' Dummy variable for civil status If i_civ_stat(i) = 1 Then MARITAL = 1 Else MARITAL = 0 ' Dummy variables for regions If h_BB_region(hhnr2index(i_hhnr(i))) = 1 Then STOCH = 1 Else STOCH = 0 If h_BB_region(hhnr2index(i_hhnr(i))) = 2 Then GOTH = 1 Else GOTH = 0 If h_BB_region(hhnr2index(i_hhnr(i))) = 3 Then MALLU = 1 Else MALLU = 0 If h_BB_region(hhnr2index(i_hhnr(i))) = 4 Then SOUTHU = 1 Else SOUTHU = 0 If h_BB_region(hhnr2index(i_hhnr(i))) = 5 Then MIDTHU = 1 Else MIDTHU = 0 If h_BB_region(hhnr2index(i_hhnr(i))) = 6 Then NORTHU = 1 Else NORTHU = 0 If h_BB_region(hhnr2index(i_hhnr(i))) = 7 Then SOUTHR = 1 Else SOUTHR = 0 If h_BB_region(hhnr2index(i_hhnr(i))) = 8 Then MIDTHR = 1 Else MIDTHR = 0 If h_BB_region(hhnr2index(i_hhnr(i))) = 9 Then NORTHR = 1 Else NORTHR = 0 ' Dummy variable for men If i_sex(i) = 1 Then KON = 1 Else KON = 0 ' Dummy variable for existance of newborn If exist_newborn(i_hhnr(i)) = 1 Then NEWBORN = 1 Else NEWBORN = 0 ' Dummy variables for levels of lagged health index ' NOTE: health index from previous year If i_health1(i) = 3 Then HI_lag_2 = 1 Else HI_lag_2 = 0 If i_health1(i) = 2 Then HI_lag_3 = 1 Else HI_lag_3 = 0 If i_health1(i) = 1 Then HI_lag_4 = 1 Else HI_lag_4 = 0 ' Dummy variable indicating sickness abscense last year SJUK = 0 If i_sick_ind1(i) = 1 Then SJUK = 1 ' Number of children CHILDREN = h_n_childlt7(hhnr2index(i_hhnr(i))) ' Dummy variable marking newly divorced individuals If i_year_sep(i) = base_year + model_time Then divorced = 1 Else divorced = 0 ' Dummy variable for age If i_age(i) > 40 Then D2 = 1 Else D2 = 0 ' Interaction between cost and sex D7 = KON * RCOST If i_new_immig(i) > 0 Or i_age(i) = FirstAge Or i_status1(i) = 4 Then '*** IMPUTATION MODEL: FOR NEW IMMIGRANTS, FOR INDIVIDUALS THAT ENTERS THE AGE-AT-RISK AND '*** FOR INDIVIDUALS THAT WERE DISABLED DURING THE PREVIOUS YEAR. NOTE THAT THE DYNAMIC MODEL '*** CAN BE RUN AT BASE YEAR SINCE THE VARIABLE I_SICK_IND1() IS READ FROM BASE DATA ' +---------------------------------------------+ ' | Neg.Bin.Model with Sample Selection. | ' | Maximum Likelihood Estimates | ' | Model estimated: May 09, 2006 at 10:55:04AM.| ' | Dependent variable ANTAL | ' | Weighting variable None | ' | Number of observations 9009 | ' | Iterations completed 56 | ' | Log likelihood function -7072.959 | ' | Restricted log likelihood -36102.46 | ' | Chi squared 58059.00 | ' | Degrees of freedom 2 | ' | Prob[ChiSqd > value] = .0000000 | ' | Mean of LHS Variable = 60.15996 | ' | Restr. Log-L is Poisson+Probit (indep). | ' | Log L for initial probit = -2633.33884 | ' | Log L for initial Poisson =-33469.11869 | ' | Means for Psn/Neg.Bin. use selected data. | ' +---------------------------------------------+ ' +---------+--------------+----------------+--------+---------+----------+ ' |Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X| ' +---------+--------------+----------------+--------+---------+----------+ ' Parameters of Poisson/Neg. Binomial Probability ' Constant 1.820352909 .14785206 12.312 .0000 ' HI962 .2546720392 .66559230E-01 3.826 .0001 .36779108 ' HI963 .9563961075 .81388248E-01 11.751 .0000 .16213275 ' HI964 1.829255113 .99247106E-01 18.431 .0000 .69640914E-01 ' AGE96 .2393325149E-01 .25638611E-02 9.335 .0000 41.425462 ' CHILDREN -.5784434949E-01 .42479139E-01 -1.362 .1733 .39390642 ' NEWBORN .1453630619 .13365500 1.088 .2768 .50054407E-01 ' DIVORCED -.4541774987E-01 .99245084E-01 -.458 .6472 .77257889E-01 ' RCOST .1031946785 .56714700E-01 1.820 .0688 1.0306867 ' D7 -.5317348453E-01 .46596452E-01 -1.141 .2538 .49281546 ' Y_DUMM .3159688797 .53821217E-01 5.871 .0000 .43743199 ' STUDENT .5101861993 .17495188 2.916 .0035 .23939064E-01 ' UNEMPL -.1679829429 .58875421E-01 -2.853 .0043 .34494015 ' Parameters of Probit Selection Model ' Constant -1.185361559 .51370944E-01 -23.075 .0000 ' HI962 .4319593270 .42564697E-01 10.148 .0000 .27306027 ' HI963 .8414594841 .64882250E-01 12.969 .0000 .62271062E-01 ' HI964 1.461136665 .11379145 12.840 .0000 .13764014E-01 ' KON96 -.1671435328 .41364106E-01 -4.041 .0001 .49827950 ' NEWBORN .1834939133 .90358440E-01 2.031 .0423 .41403041E-01 ' D2 -.8677457028E-01 .73572845E-01 -1.179 .2382 .64713065E-01 ' RCOST -.9801934638E-01 .17663232E-01 -5.549 .0000 1.4019427 ' PRIVAT -.5365810155E-01 .50757279E-01 -1.057 .2904 .41525142 ' Y_DUMM -.1610837243 .38983117E-01 -4.132 .0000 .49650350 ' STUDENT -1.102073796 .89289782E-01 -12.343 .0000 .15129315 ' UNEMPL .1405697614 .51136524E-01 2.749 .0060 .32878233 ' Overdispersion Parameter for Negative Binomial ' Theta .7241934495E-01 .67364647E-02 10.750 .0000 ' Standard Deviation of Heterogeneity ' Sigma 1.288007600 .30935529E-01 41.635 .0000 ' Correlation of Heterogeneity & Selection ' Rho -.8929712838E-01 .31314722E-01 -2.852 .0043 '*** Imputation model - probit xbeta_probit = 1 * -1.185361559 + _ HI_lag_2 * 0.431959327 + _ HI_lag_3 * 0.8414594841 + _ HI_lag_4 * 1.461136665 + _ KON * -0.1671435328 + _ NEWBORN * 0.1834939133 + _ D2 * -0.08677457028 + _ RCOST * -0.09801934638 + _ PRIVAT * -0.05365810155 + _ Y_DUMM * -0.1610837243 + _ STUDENT * -1.102073796 + _ UNEMPL * 0.1405697614 '*** Imputation model - negative binomial xbeta = 1 * 1.820352909 + _ HI_lag_2 * 0.2546720392 + _ HI_lag_3 * 0.9563961075 + _ HI_lag_4 * 1.829255113 + _ i_age(i) * 0.02393325149 + _ CHILDREN * -0.05784434949 + _ NEWBORN * 0.1453630619 + _ divorced * -0.04541774987 + _ RCOST * 0.1031946785 + _ D7 * -0.05317348453 + _ Y_DUMM * 0.3159688797 + _ STUDENT * 0.5101861993 + _ UNEMPL * -0.1679829429 rho = -0.0893 sigma = 1.2880076 theta = 0.0724 Else '*** DYNAMIC MODEL ' +---------------------------------------------+ ' | Neg.Bin.Model with Sample Selection. | ' | Maximum Likelihood Estimates | ' | Model estimated: Apr 25, 2006 at 11:57:47AM.| ' | Dependent variable ANTAL | ' | Weighting variable None | ' | Number of observations 9009 | ' | Iterations completed 64 | ' | Log likelihood function -6960.570 | ' | Restricted log likelihood -35151.52 | ' | Chi squared 56381.89 | ' | Degrees of freedom 2 | ' | Prob[ChiSqd > value] = .0000000 | ' | Mean of LHS Variable = 60.15996 | ' | Restr. Log-L is Poisson+Probit (indep). | ' | Log L for initial probit = -2531.98261 | ' | Log L for initial Poisson =-32619.53432 | ' | Means for Psn/Neg.Bin. use selected data. | ' +---------------------------------------------+ ' +---------+--------------+----------------+--------+---------+----------+ ' |Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X| ' +---------+--------------+----------------+--------+---------+----------+ ' Parameters of Poisson/Neg. Binomial Probability ' Constant 1.745439561 .12038970 14.498 .0000 ' SJUK .8156901166 .67165755E-01 12.144 .0000 .19586507 ' HI962 .4574731362 .56159886E-01 8.146 .0000 .36779108 ' HI963 1.279304619 .66080567E-01 19.360 .0000 .16213275 ' HI964 1.894778374 .80018373E-01 23.679 .0000 .69640914E-01 ' AGE96 .1063509593E-01 .20555310E-02 5.174 .0000 41.425462 ' CHILDREN .4123218615E-01 .34855300E-01 1.183 .2368 .39390642 ' DIVORCED .2684843185E-01 .72469782E-01 .370 .7110 .77257889E-01 ' RCOST .3325826111 .45862649E-01 7.252 .0000 1.0306867 ' D7 -.2416475358 .39250031E-01 -6.157 .0000 .49281546 ' PRIVAT .2420809533 .53921885E-01 4.489 .0000 .35908596 ' Y_DUMM -.1250365078 .56359561E-01 -2.219 .0265 .43743199 ' STUDENT .6976191780 .16704107 4.176 .0000 .23939064E-01 ' UNEMPL -.1775190486 .57746044E-01 -3.074 .0021 .34494015 ' Parameters of Probit Selection Model ' Constant -1.159206225 .52076589E-01 -22.260 .0000 ' SJUK 1.003778198 .69365597E-01 14.471 .0000 .54057054E-01 ' HI962 .3873343824 .43617166E-01 8.880 .0000 .27306027 ' HI963 .7570019312 .65957649E-01 11.477 .0000 .62271062E-01 ' HI964 1.334160938 .11659863 11.442 .0000 .13764014E-01 ' KON96 -.1509754845 .42815218E-01 -3.526 .0004 .49827950 ' NEWBORN .1310446439 .92559475E-01 1.416 .1568 .41403041E-01 ' D2 -.7083130242E-01 .73721123E-01 -.961 .3367 .64713065E-01 ' RCOST -.9282987380E-01 .18288296E-01 -5.076 .0000 1.4019427 ' PRIVAT -.6343945233E-01 .51597068E-01 -1.230 .2189 .41525142 ' Y_DUMM -.3741757186 .43626166E-01 -8.577 .0000 .49650350 ' STUDENT -1.023372208 .91787576E-01 -11.149 .0000 .15129315 ' UNEMPL .1051345494 .52531207E-01 2.001 .0454 .32878233 ' Overdispersion Parameter for Negative Binomial ' Theta .5832333343E-01 .47458972E-02 12.289 .0000 ' Standard Deviation of Heterogeneity ' Sigma 1.282427529 .28167434E-01 45.529 .0000 ' Correlation of Heterogeneity & Selection ' Rho .4228630417E-01 .30099751E-01 1.405 .1601 ' (Note: E+nn or E-nn means multiply by 10 to + or -nn power.) ' '*** Dynamic model - probit xbeta_probit = 1 * -1.159206225 + _ SJUK * 1.003778198 + _ HI_lag_2 * 0.3873343824 + _ HI_lag_3 * 0.7570019312 + _ HI_lag_4 * 1.334160938 + _ KON * -0.1509754845 + _ NEWBORN * 0.1310446439 + _ D2 * -0.07083130242 + _ RCOST * -0.0928298738 + _ PRIVAT * -0.06343945233 + _ Y_DUMM * -0.3741757186 + _ STUDENT * -1.023372208 + _ UNEMPL * 0.1051345494 '*** Dynamic model - negative binomial xbeta = 1 * 1.745439561 + _ SJUK * 0.8156901166 + _ HI_lag_2 * 0.4574731362 + _ HI_lag_3 * 1.279304619 + _ HI_lag_4 * 1.894778374 + _ i_age(i) * 0.01063509593 + _ CHILDREN * 0.04123218615 + _ divorced * 0.02684843185 + _ RCOST * 0.3325826111 + _ D7 * -0.2416475358 + _ PRIVAT * 0.2420809533 + _ Y_DUMM * -0.1250365078 + _ STUDENT * 0.697619178 + _ UNEMPL * -0.1775190486 rho = 0.0423 sigma = 1.282427529 theta = 0.0583 End If ' Dynamic model '*** Draw bivariate normal data: ' u ~ N(0, 1), b ~ N(0, sigma^2 * (1 - rho^2)) ' e = rho * sigma * u + b ' V(u) = 1, V(e) = sigma^2, Cov(u, e) = rho * sigma, Corr(u, e) = rho ' NOTE: the first random number is not used Call RANNOR(3, normvar(1), model_time + i + random * Rnd) u = normvar(2) e = rho * sigma * u + normvar(3) * Sqr((sigma ^ 2) * (1 - rho ^ 2)) ' Probit equation ' NOTE: alignment through changes in the intercept (TP 051220) z_star = xbeta_probit + u + align_probs(mini(model_time + base_year, 2007) - 1998) '*** If z_star > 0 then i_sickleave equals zero else i_sickleave is negative '*** binomial (conditional on the random number e) If z_star > 0 Then ' A standard Gamma random number is drawn and rescaled to have mean value 1 and variance theta ' NOTE: two random numbers are drawn because there seems to be some problem with the first value!!! Call RANGAM(2, randgam(1), base_year + model_time + i + random * Rnd, 1 / theta) u = randgam(2) * theta ' Calculate lambda (the stochastic poisson intensity) ' NOTE: alignment through changes in the intercept (TP 051220) LAMBDA = Exp(xbeta + e + align_means(mini(model_time + base_year, 2007) - 1998)) * u If LAMBDA = 0 Then LAMBDA = 1E-40 Call RANPOI(2, poisson(1), base_year + model_time + i + random * Rnd, LAMBDA) 'Truncation at 365 days If poisson(2) > 365 Then i_sickleave(i) = 365 Else i_sickleave(i) = poisson(2) Else i_sickleave(i) = 0 End If Else ' No days with sickness absence outside population at risk i_sickleave(i) = 0 End If ' Update indicator for sickness absence If i_sickleave(i) > 0 Then i_sick_ind(i) = 1 Else i_sick_ind(i) = 0 Next ' Next individual End Sub