Attribute VB_Name = "b03_Labour"
Option Explicit
Option Base 1
'*************************************************************************
'*** Function unemployed(indexnr) returns the unemployment status of
'*** the individual indexed by indexnr. Vector randnr() is used for the
'*** randomization. If debuginfo equals one debugging information is
'*** written to file.
'*************************************************************************
Public Function unemployed(indexnr As Long, randnr() As Double, debuginfo As Long) _
As Long
Dim lag As Byte, ed1 As Byte, ed2 As Byte, age16_19 As Byte, age55_ As Byte
Dim xbeta As Double, prob As Double
lag = 0
If i_status1(indexnr) = 6 Then lag = 1
ed1 = 0
If i_edlevel(indexnr) = 1 Then ed1 = 1
ed2 = 0
If i_edlevel(indexnr) = 2 Then ed2 = 1
age16_19 = 0
If i_age(indexnr) >= 16 And i_age(indexnr) <= 19 Then age16_19 = 1
age55_ = 0
If i_age(indexnr) >= 55 Then age55_ = 1
If i_sex(indexnr) = 1 Then
'*** Men
xbeta = -1.508117159 + _
lag * 0.705455697 + _
ed1 * -0.388771963 + _
ed2 * -0.917106809 + _
i_age(indexnr) * -0.043398264 + _
age16_19 * 12.23315076 + _
age55_ * -7.29774975 + _
i_age(indexnr) * age16_19 * -0.653933459 + _
i_age(indexnr) * age55_ * 0.133689794 + _
lag * ed1 * 0.310025609 + _
lag * ed2 * 0.79081017 + _
lag * i_age(indexnr) * 0.073198747
Else
'*** Women
xbeta = -0.97510581 + _
lag * 0.342606728 + _
ed1 * -0.324050062 + _
ed2 * -1.064068408 + _
i_age(indexnr) * -0.048922683 + _
age16_19 * 13.50319428 + _
age55_ * -8.623367249 + _
i_age(indexnr) * age16_19 * -0.733277594 + _
i_age(indexnr) * age55_ * 0.155404223 + _
lag * ed1 * 0.248329048 + _
lag * ed2 * 0.690020389 + _
lag * i_age(indexnr) * 0.076254805
End If
prob = 1 / (1 + Exp(-xbeta))
i_prob_unemployed(indexnr) = logit(randnr(indexnr)) - logit(prob)
unemployed = 0
If randnr(indexnr) < prob Then unemployed = 1
'*** Debug information is written to file optionally
If debuginfo = 1 Then
Call Print_to_file("\tempdata\debug_unemp.txt", "N", _
base_year + model_time, lag, i_age(indexnr), i_edlevel(indexnr), _
i_status1(indexnr), i_sex(indexnr), randnr(indexnr), unemployed, prob)
End If
End Function
'*************************************************************************
'*** Function f_working(indexnr) returns the work status of
'*** the individual indexed by indexnr. Vector randnr() is used for the
'*** randomization. If debuginfo equals one debugging information is
'*** written to file.
'*************************************************************************
Public Function f_working(indexnr As Long, randnr() As Double, debuginfo As Long) As Long
Dim lag As Byte, ed As Byte, studlag As Byte
Dim xbeta As Double, prob As Double
lag = 0
If i_status1(indexnr) = 8 Then lag = 1
studlag = 0
If i_status1(indexnr) = 3 Then studlag = 1
ed = 0
If i_edlevel(indexnr) > 0 Then ed = 1
If i_sex(indexnr) = 1 Then
'*** Men
xbeta = -0.917696703 + _
lag * -3.087010757 + _
i_age(indexnr) * 0.066816947 + _
(i_age(indexnr) ^ 2) * -0.001087459 + _
ed * 1.548055416 + _
i_age(indexnr) * ed * -0.026167978 + _
studlag * 1.025556837 + _
lag * i_age(indexnr) * 0.332829026 + _
lag * (i_age(indexnr) ^ 2) * -0.003487943
Else
'*** Women
xbeta = -2.196158508 + _
lag * -2.349071234 + _
i_age(indexnr) * 0.169718608 + _
(i_age(indexnr) ^ 2) * -0.002661252 + _
ed * 2.196326777 + _
i_age(indexnr) * ed * -0.031514388 + _
studlag * 1.441618639 + _
lag * i_age(indexnr) * 0.240113658 + _
lag * (i_age(indexnr) ^ 2) * -0.002001953
End If
'AW mallar in LU-scenariet. Ska tas bort!
' If model_time + base_year < 2003 Then
' prob = 1 / (1 + Exp(-xbeta + 0.449))
' ElseIf model_time + base_year > 2003 And model_time + base_year < 2009 Then
' prob = 1 / (1 + Exp(-xbeta + 0.45))
' ElseIf model_time + base_year > 2009 And model_time + base_year < 2028 Then
' prob = 1 / (1 + Exp(-xbeta + 0.56))
' ElseIf model_time + base_year > 2042 Then
' prob = 1 / (1 + Exp(-xbeta + 0.67))
' Else
' prob = 1 / (1 + Exp(-xbeta + 0.61))
' End If
prob = 1 / (1 + Exp(-xbeta))
i_prob_working(indexnr) = logit(randnr(indexnr)) - logit(prob)
f_working = 0
If randnr(indexnr) < prob Then f_working = 1
'*** Debug information is written to file optionally
If debuginfo = 1 Then
Call Print_to_file("\tempdata\debug_working.txt", "N", _
base_year + model_time, lag, i_age(indexnr), i_edlevel(indexnr), _
i_status1(indexnr), i_sex(indexnr), randnr(indexnr), f_working, prob)
End If
End Function
Public Function misc_status(indexnr)
Static prob_misc(1 To 9, 0 To 2) As Double
Static init_flag As Integer
Dim risk As Double
misc_status = 0
If init_flag = 0 Then
init_flag = 1
prob_misc(1, 0) = 0.3615359075
prob_misc(1, 1) = 0.1431901179
prob_misc(1, 2) = 0.0977958242
prob_misc(2, 0) = 0.1798583537
prob_misc(2, 1) = 0.0814819619
prob_misc(2, 2) = 0.0628057706
prob_misc(3, 0) = 0.1292071797
prob_misc(3, 1) = 0.0720701241
prob_misc(3, 2) = 0.0585771111
prob_misc(4, 0) = 0.1354658348
prob_misc(4, 1) = 0.02208423
prob_misc(4, 2) = 0.0546739535
prob_misc(5, 0) = 0.1153769047
prob_misc(5, 1) = 0.0326264454
prob_misc(5, 2) = 0.0386936984
prob_misc(6, 0) = 0.0808602572
prob_misc(6, 1) = 0.043919096
prob_misc(6, 2) = 0.015951432
prob_misc(7, 0) = 0.0766413919
prob_misc(7, 1) = 0.033500284
prob_misc(7, 2) = 0.0124435728
prob_misc(8, 0) = 0.0871398635
prob_misc(8, 1) = 0.0349510522
prob_misc(8, 2) = 0.0299131195
prob_misc(9, 0) = 0.2486815134
prob_misc(9, 1) = 0.311511226
prob_misc(9, 2) = 0.1561582531
End If
If i_age(indexnr) <= 19 Then
risk = prob_misc(1, i_edlevel(indexnr))
Else
risk = prob_misc(Int(i_age(indexnr) / 5) - 3, i_edlevel(indexnr))
End If
If Rnd < risk Then misc_status = 1
End Function
'***********************************************************************
'*** Sub Sick_leave() randomizes number of days of absence due to
'*** sickness for each individual.
'*** NOTE: No alignment of variance reduction is implemented in the
'*** first version of the model. TP021016
'*** NOTE2: Alignment of general level of take-up, see code. TP030214
'***********************************************************************
Public Sub Sick_leave()
status "Sick leave"
Printdok " -- Sick_leave"
Dim lag As Integer, age30 As Integer, age50 As Integer, ed1 As Integer
Dim ed2 As Integer, female As Integer, bigcity As Integer, noncohab As Integer
Dim swedish As Integer, kommun As Integer, fem_ed1 As Integer, male As Integer
Dim fem_ed2 As Integer, havechildren As Integer, workexp As Integer
Dim sec_state As Integer, sec_municip As Integer, self_empl As Integer
Dim student As Integer, unempl As Integer
Dim unemprate As Double, ystar As Double, age2 As Double, gdp As Double
Dim xbeta As Double, rand() As Double, temp As Double, mse As Double
Dim i As Long, randcount As Long, stat5 As Long, stat6 As Long, stat8 As Long
Dim DENOM As Long, sick_add As Double
'*** Calculate the total unemployment rate. Labor market programs outside of
'*** the workforce are assumed to be a constant share (50%) of the total number
'*** of unemployed and are not included.
'*** TP030211
unemprate = 0
stat5 = 0
stat6 = 0
stat8 = 0
For i = 1 To m_icount
If i_age(i) >= 16 And i_age(i) <= 64 Then
If i_status(i) = 5 Then stat5 = stat5 + 1
If i_status(i) = 6 Then stat6 = stat6 + 1
If i_status(i) = 8 Then stat8 = stat8 + 1
End If
Next
DENOM = stat5 + 0.5 * stat6 + stat8
If DENOM > 0 Then
unemprate = ((0.5 * stat6) / DENOM) * 100
End If
'*** Draw random numbers
'*** NOTE: too many numbers are generally drawn -> waste of CPU time -> figure out
'*** a more efficient way
ReDim rand(1 To 2 * m_icount)
Call RANNOR(2 * m_icount, rand(1), model_time + base_year + random * Rnd)
For i = 1 To m_icount
'*** At risk: Individuals living in sweden at ages 16 to 64 that
'*** does not have disability pension or old age pension
If i_abroad(i) = 0 And i_status(i) <> 4 And i_status(i) <> 2 And i_status(i) <> 5 And _
i_age(i) >= 16 Then
'*** Code covariates
If i_sick_ind1(i) = 1 Then lag = 1 Else lag = 0
If i_age(i) < 30 Then age30 = 1 Else age30 = 0
If i_age(i) >= 30 And i_age(i) < 50 Then age50 = 1 Else age50 = 0
age2 = (i_age(i) ^ 2) / 40
If i_edlevel(i) = 1 Then ed1 = 1 Else ed1 = 0
If i_edlevel(i) = 2 Then ed2 = 1 Else ed2 = 0
If i_sex(i) = 2 Then female = 1 Else female = 0
If i_sex(i) = 1 Then male = 1 Else male = 0
fem_ed1 = female * ed1
fem_ed2 = female * ed2
kommun = kommundata(h_kommunindex(hhnr2index(i_hhnr(i)))).kod
If kommun = 180 Or kommun = 1480 Or kommun = 1280 Then bigcity = 1 Else bigcity = 0
If i_civ_stat(i) = 0 Then noncohab = 1 Else noncohab = 0
If i_born_abroad(i) = 0 Then swedish = 1 Else swedish = 0
If h_n_child(hhnr2index(i_hhnr(i))) > 0 Then havechildren = 1 Else havechildren = 0
'*** Check this truncation at 2!
'*** TP030218
If i_workexperience(i) >= 2 Then workexp = i_workexperience(i) Else workexp = 0
If i_sector(i) = 3 Then sec_state = 1 Else sec_state = 0
If i_sector(i) = 4 Then sec_municip = 1 Else sec_municip = 0
If i_status(i) = 3 Then student = 1 Else student = 0
If i_status(i) = 6 Then unempl = 1 Else unempl = 0
gdp = m_realwage
mse = 1.37367 ^ 2
'*** Model 1) Determine if individuals have sickleave during the
'*** current year.
'*** Calculate the latent normal variate
ystar = -0.5898 + _
lag * 0.7463 + _
age30 * -0.0444 + _
age50 * -0.0891 + _
ed1 * -0.1079 + _
ed2 * -0.3386 + _
female * 0.3025 + _
unemprate * -0.1137 + _
bigcity * -0.0639 + _
noncohab * 0.1288 + _
swedish * -0.234 + _
i_sickleave_ivariance(i) + _
rand(i)
'*** Alignment: the take-up of sickness benefits is
'*** lowered in order to reproduce the observed levels
'*** (and projected) until 2003.
'*** TP030214
'ystar = ystar - 0.2
'*** ThP 060207 Aligment to reprodude outcome until 2005
'*** and predictions according to KI until 2008
Select Case (base_year + model_time)
Case 2000
sick_add = -0.2
Case 2001
sick_add = 0#
Case 2002
sick_add = -0.1
Case 2003
sick_add = -0.1
Case 2004
sick_add = -0.4
Case 2005
sick_add = -0.4
Case 2006
sick_add = -0.5
Case 2007
sick_add = -0.5
Case 2008
sick_add = -0.5
Case Else
sick_add = -0.4
End Select
ystar = ystar + sick_add
'*** Model 2: randomize number of days of sickleave for selected
'*** individuals using an OLS regression model.
'*** NOTE: At base year we know the paid sickness allowance but not the number of days. In order
'*** to avoid zero days for individuals having positive allowances we always randomize
'*** days for these individuals. TP040930
If ystar > 0 Or (model_time = 0 And i_sick_ind(i) = 1) Then
xbeta = 3.81252 + _
age30 * -0.31242 + _
age50 * -0.28102 + _
workexp * 0.05597 + _
((workexp ^ 2) / 100) * -0.09157 + _
male * -0.05931 + _
sec_state * -0.02956 + _
sec_municip * 0.02845 + _
self_empl * -0.655 + _
bigcity * 0.01893 + _
unempl * -0.93576 + _
student * -0.24275 + _
ed1 * -0.12958 + _
ed2 * -0.16573 + _
havechildren * -0.00978 + _
noncohab * 0.15565 + _
swedish * -0.21332 + _
gdp * 0.05572 + _
Sqr(mse) * rand(i + m_icount)
'*** Truncation to avoid overflow in i_sickleave.
'*** Exp(6) = 403...
If xbeta > 6 Then xbeta = 6
i_sickleave(i) = Exp(xbeta)
'*** Do not allow more than 365 days
If i_sickleave(i) > 365 Then i_sickleave(i) = 365
Else
i_sickleave(i) = 0
End If
Else
'*** Individuals not at risk for sickness absence
i_sickleave(i) = 0
End If
'*** Indicator for positive number of days
If i_sickleave(i) > 0 Then i_sick_ind(i) = 1 Else i_sick_ind(i) = 0
Next
End Sub
'**********************************************************************
'*** Public Sub Update_Sector(iidx) is used to randomize labor market
'*** sector for individual having index iidx.
'***
'*** The categories of labor market sector are:
'*** 1 - Private blue collar
'*** 2 - Private white collar
'*** 3 - Public State
'*** 4 - Public local government
'*** 5 - Self employed
'***
'*** NOTE: The parameterization of PROC CATMOD uses effect coding of all
'*** categorical covariates (i.e. 1, -1 instead of dummy coding 1, 0).
'*** Also, the parameter vector for the last response level is set to
'*** zero. The parameter arrays given below corresponds to the FULL
'*** RANK design matrix (redundant parameters have been calculated
'*** manually).
'***
'*** NOTE2: The compound index used for searching the parameter arrays
'*** below is constructed as follows. For an interaction term such as e.g.
'*** BKON_EDLEVEL there are 5*2*3 = 30 parameters. The array orders the
'*** parameters in the response-bkon-edlevel order. The index is
'*** obtained as:
'*** idx = (response - 1) * F(bkon) * F(edlevel) +
'*** (bkon - 1) * F(edlevel) + (edlevel + 1)
'*** , where F(X) denotes the levelse of factor X.
'***
'*** TP030404
'**********************************************************************
Public Sub Update_Sector(ByVal iidx As Long)
Dim probs As Variant
ReDim probs(1 To 5)
Dim cumprobs(5) As Double, xbeta(5) As Double, rand As Double
Dim DENOM As Double
Dim swe As Long, i As Long
Dim icp_, bkon_, bald_, bald2_, edlevel_, swe_, bkon_edlevel_, bald_edlevel_
'*** Individuals that are included in the labor force for the
'*** first time
If i_sector(iidx) = 0 Then
' Analysis of Maximum Likelihood Estimates
'
' Function Standard Chi-
'Parameter Number Estimate Error Square Pr > ChiSq
'ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
'Intercept 1 3.9186 0.0541 5243.15 <.0001
' 2 3.0291 0.0493 3780.28 <.0001
' 3 2.2388 0.0527 1802.07 <.0001
' 4 3.7495 0.0470 6367.34 <.0001
'BALD 1 -0.0478 0.00106 2013.14 <.0001
' 2 -0.0384 0.000973 1562.09 <.0001
' 3 -0.0312 0.00105 883.42 <.0001
' 4 -0.0379 0.000920 1695.62 <.0001
'BKON 1 1 -0.0452 0.00938 23.28 <.0001
' 1 2 -0.0157 0.00860 3.32 0.0686
' 1 3 -0.2401 0.00945 646.20 <.0001
' 1 4 -0.6570 0.00805 6659.74 <.0001
'edlevel 0 1 0.5183 0.0544 90.70 <.0001
' 0 2 -0.9746 0.0497 384.87 <.0001
' 0 3 -0.9555 0.0531 323.37 <.0001
' 0 4 -1.1982 0.0474 639.83 <.0001
' 1 1 1.5767 0.0549 824.06 <.0001
' 1 2 -0.2519 0.0502 25.20 <.0001
' 1 3 -0.0863 0.0536 2.59 0.1075
' 1 4 -0.7730 0.0479 260.11 <.0001
'swe 0 1 0.0372 0.00537 47.86 <.0001
' 0 2 -0.0945 0.00601 247.09 <.0001
' 0 3 -0.1690 0.00642 694.13 <.0001
' 0 4 -0.1473 0.00571 666.55 <.0001
'BKON*edlevel 1 0 1 -0.1763 0.00954 341.38 <.0001
' 1 0 2 -0.0732 0.00884 68.60 <.0001
' 1 0 3 -0.1856 0.00966 368.90 <.0001
' 1 0 4 -0.5180 0.00827 3924.44 <.0001
' 1 1 1 0.0629 0.00980 41.15 <.0001
' 1 1 2 0.1186 0.00909 170.22 <.0001
' 1 1 3 0.1991 0.00993 402.15 <.0001
' 1 1 4 -0.0674 0.00855 61.99 <.0001
'BALD*edlevel 0 1 0.00120 0.00107 1.24 0.2656
' 0 2 0.00920 0.000987 86.91 <.0001
' 0 3 0.0161 0.00106 229.38 <.0001
' 0 4 0.0135 0.000933 210.56 <.0001
' 1 1 -0.0270 0.00109 616.68 <.0001
' 1 2 0.0119 0.001000 141.37 <.0001
' 1 3 0.00886 0.00108 67.74 <.0001
' 1 4 0.0151 0.000948 252.49 <.0001
' icp_ = Array(3.918617546, 3.029141055, 2.238825738, 3.749518629, 0)
'*** ALIGNMENT: The probability of private blue collar is increased
icp_ = Array(4.5, 3.029141055, 2.238825738, 3.749518629, 0)
bald_ = Array(-0.047768934, -0.038443212, -0.031210912, -0.037899091, 0)
bkon_ = Array(-0.045241429, 0.045241429, -0.015660363, 0.015660363, -0.240123164, 0.240123164, -0.65698379, 0.65698379, 0, 0)
edlevel_ = Array(0.518260393, 1.57666273, -2.094923124, -0.974570322, -0.251858035, 1.226428358, -0.955460403, -0.086309836, 1.041770239, -1.198199164, -0.773020564, 1.971219728, 0, 0, 0)
swe_ = Array(0.03718202, -0.03718202, -0.094524937, 0.094524937, -0.169045408, 0.169045408, -0.1473489, 0.1473489, 0, 0)
bkon_edlevel_ = Array(-0.176336733, 0.06287154, 0.113465193, 0.176336733, -0.06287154, -0.113465193, -0.07318472, 0.118643297, -0.045458577, 0.07318472, -0.118643297, 0.045458577, -0.185563954, 0.199050237, -0.013486283, 0.185563954, -0.199050237, 0.013486283, -0.517978173, -0.067352673, 0.585330846, 0.517978173, 0.067352673, -0.585330846, 0, 0, 0, 0, 0, 0)
bald_edlevel_ = Array(0.00119638, -0.027027885, 0.025831505, 0.009197627, 0.011887007, -0.021084634, 0.016111599, 0.008864184, -0.024975782, 0.013540732, 0.015062901, -0.028603633, 0, 0, 0)
swe = 1
If i_born_abroad(iidx) = 1 Then swe = 0
DENOM = 0
For i = 1 To 5
xbeta(i) = icp_(i) + _
i_age(iidx) * bald_(i) + _
bkon_((i - 1) * 2 + i_sex(iidx)) + _
edlevel_((i - 1) * 3 + (i_edlevel(iidx) + 1)) + _
swe_((i - 1) * 2 + (swe + 1)) + _
bkon_edlevel_((i - 1) * 6 + (i_sex(iidx) - 1) * 3 + (i_edlevel(iidx) + 1)) + _
i_age(iidx) * bald_edlevel_((i - 1) * 3 + (i_edlevel(iidx) + 1))
DENOM = DENOM + Exp(xbeta(i))
Next
probs(1) = Exp(xbeta(1)) / DENOM
cumprobs(1) = CDbl(probs(1))
For i = 2 To 4
probs(i) = Exp(xbeta(i)) / DENOM
cumprobs(i) = cumprobs(i - 1) + CDbl(probs(i))
Next
cumprobs(5) = 1#
End If
'*** Individuals that already have a sector code - i.e. have
'*** been included in the labor force before
If i_sector(iidx) > 0 Then
Select Case (i_sector(iidx))
Case (1)
' Analysis of Maximum Likelihood Estimates
'
' Function Standard Chi-
'Parameter Number Estimate Error Square Pr > ChiSq
'ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
'Intercept 1 5.9876 0.3351 319.19 <.0001
' 2 0.3986 0.3537 1.27 0.2597
' 3 5.2687 0.3823 189.97 <.0001
' 4 6.0518 0.3539 292.40 <.0001
'BALD 1 -0.0751 0.0168 19.94 <.0001
' 2 0.0564 0.0178 10.09 0.0015
' 3 -0.2251 0.0194 134.66 <.0001
' 4 -0.1960 0.0179 120.06 <.0001
'BALD*BALD 1 0.00110 0.000205 29.02 <.0001
' 2 -0.00075 0.000217 12.00 0.0005
' 3 0.00233 0.000239 94.55 <.0001
' 4 0.00196 0.000219 80.53 <.0001
'BKON 1 1 -0.0807 0.0260 9.63 0.0019
' 1 2 -0.3251 0.0272 142.56 <.0001
' 1 3 -0.3907 0.0296 174.41 <.0001
' 1 4 -0.8399 0.0278 915.26 <.0001
'edlevel 1 0.3540 0.0651 29.62 <.0001
' 2 1.1084 0.0675 269.41 <.0001
' 3 0.6442 0.0728 78.39 <.0001
' 4 0.4561 0.0682 44.66 <.0001
'swe 0 1 -0.0390 0.0505 0.60 0.4396
' 0 2 -0.5073 0.0574 78.05 <.0001
' 0 3 -0.3685 0.0682 29.20 <.0001
' 0 4 0.0749 0.0539 1.93 0.1647
' icp_ = Array(5.98763, 0.39862, 5.26865, 6.05185, 0)
'*** ALIGNMENT: The probability of remaining in private blue collar is increased
icp_ = Array(7, 0.39862, 5.26865, 6.05185, 0)
bald_ = Array(-0.0751, 0.05641, -0.22513, -0.19598, 0)
bald2_ = Array(0.0011, -0.00075, 0.00233, 0.00196, 0)
bkon_ = Array(-0.08068, 0.08068, -0.32506, 0.32506, -0.39071, 0.39071, -0.83993, 0.83993, 0, 0)
edlevel_ = Array(0.35404, 1.10837, 0.6442, 0.45608, 0)
swe_ = Array(-0.039, 0.039, -0.50728, 0.50728, -0.36851, 0.36851, 0.07488, -0.07488, 0, 0)
Case (2)
' Analysis of Maximum Likelihood Estimates
'
' Function Standard Chi-
'Parameter Number Estimate Error Square Pr > ChiSq
'ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
'Intercept 1 9.9116 0.5548 319.17 <.0001
' 2 5.7285 0.5360 114.22 <.0001
' 3 4.5531 0.5700 63.80 <.0001
' 4 5.6270 0.5754 95.62 <.0001
'BALD 1 -0.3400 0.0265 164.49 <.0001
' 2 -0.0253 0.0255 0.99 0.3208
' 3 -0.1149 0.0272 17.78 <.0001
' 4 -0.1724 0.0276 39.00 <.0001
'BALD*BALD 1 0.00377 0.000315 142.76 <.0001
' 2 0.000548 0.000303 3.27 0.0707
' 3 0.00141 0.000324 19.12 <.0001
' 4 0.00191 0.000329 33.56 <.0001
'BKON 1 1 -0.5198 0.0398 170.78 <.0001
' 1 2 -0.3251 0.0385 71.41 <.0001
' 1 3 -0.1454 0.0410 12.55 0.0004
' 1 4 -0.8641 0.0410 443.66 <.0001
'edlevel 1 -0.3431 0.0671 26.15 <.0001
' 2 0.2735 0.0638 18.40 <.0001
' 3 0.2253 0.0686 10.80 0.0010
' 4 0.5386 0.0698 59.50 <.0001
'swe 0 1 0.3273 0.1561 4.40 0.0360
' 0 2 0.5902 0.1521 15.05 0.0001
' 0 3 0.6716 0.1554 18.67 <.0001
' 0 4 0.5732 0.1566 13.40 0.0003
icp_ = Array(9.91163, 5.72851, 4.55309, 5.62698, 0)
bald_ = Array(-0.34003, -0.02533, -0.11486, -0.17236, 0)
bald2_ = Array(0.00377, 0.00055, 0.00141, 0.00191, 0)
bkon_ = Array(-0.5198, 0.5198, -0.32512, 0.32512, -0.14537, 0.14537, -0.86407, 0.86407, 0, 0)
edlevel_ = Array(-0.34307, 0.2735, 0.22534, 0.53862, 0)
swe_ = Array(0.32727, -0.32727, 0.59015, -0.59015, 0.67157, -0.67157, 0.57316, -0.57316, 0, 0)
Case (3)
' Analysis of Maximum Likelihood Estimates
'
' Function Standard Chi-
'Parameter Number Estimate Error Square Pr > ChiSq
'ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
'Intercept 1 4.9354 0.3460 203.51 <.0001
' 2 0.2042 0.3645 0.31 0.5752
' 3 2.9863 0.3137 90.64 <.0001
' 4 4.6957 0.3349 196.54 <.0001
'BALD 1 -0.0960 0.0167 33.04 <.0001
' 2 0.0934 0.0176 28.03 <.0001
' 3 0.1232 0.0148 69.60 <.0001
' 4 -0.0962 0.0160 36.25 <.0001
'BALD*BALD 1 0.000177 0.000195 0.82 0.3652
' 2 -0.00199 0.000208 91.52 <.0001
' 3 -0.00158 0.000168 88.90 <.0001
' 4 0.000331 0.000185 3.21 0.0734
'BKON 1 1 -0.1011 0.0264 14.65 0.0001
' 1 2 -0.1078 0.0272 15.65 <.0001
' 1 3 -0.1166 0.0230 25.70 <.0001
' 1 4 -0.4495 0.0253 315.22 <.0001
'edlevel 1 -0.5677 0.0498 129.77 <.0001
' 2 0.5724 0.0509 126.31 <.0001
' 3 -0.3012 0.0425 50.32 <.0001
' 4 -0.1249 0.0470 7.05 0.0079
'swe 0 1 -0.0285 0.0553 0.27 0.6057
' 0 2 -0.1617 0.0589 7.53 0.0061
' 0 3 -0.3035 0.0484 39.27 <.0001
' 0 4 -0.2957 0.0558 28.11 <.0001
icp_ = Array(4.93536, 0.20424, 2.98632, 4.69572, 0)
bald_ = Array(-0.096, 0.09344, 0.12322, -0.09623, 0)
bald2_ = Array(0.00018, -0.00199, -0.00158, 0.00033, 0)
bkon_ = Array(-0.10106, 0.10106, -0.10779, 0.10779, -0.11664, 0.11664, -0.44948, 0.44948, 0, 0)
edlevel_ = Array(-0.56771, 0.57237, -0.30121, -0.12489, 0)
swe_ = Array(-0.02853, 0.02853, -0.1617, 0.1617, -0.30349, 0.30349, -0.29574, 0.29574, 0, 0)
Case (4)
' Analysis of Maximum Likelihood Estimates
'
' Function Standard Chi-
'Parameter Number Estimate Error Square Pr > ChiSq
'ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
'Intercept 1 6.9732 0.2549 748.35 <.0001
' 2 -1.0407 0.2707 14.78 0.0001
' 3 3.5433 0.2566 190.74 <.0001
' 4 6.2573 0.2446 654.61 <.0001
'BALD 1 -0.1664 0.0120 192.50 <.0001
' 2 0.1460 0.0128 131.14 <.0001
' 3 -0.0583 0.0120 23.62 <.0001
' 4 -0.0112 0.0114 0.96 0.3263
'BALD*BALD 1 0.00122 0.000138 78.81 <.0001
' 2 -0.00219 0.000147 221.83 <.0001
' 3 0.000378 0.000137 7.60 0.0058
' 4 -0.00010 0.000130 0.57 0.4502
'BKON 1 1 -0.0824 0.0185 19.93 <.0001
' 1 2 -0.3481 0.0194 322.50 <.0001
' 1 3 -0.3481 0.0185 353.30 <.0001
' 1 4 -0.4848 0.0172 794.44 <.0001
'edlevel 1 -0.7030 0.0324 471.46 <.0001
' 2 0.7257 0.0322 507.41 <.0001
' 3 -0.1209 0.0316 14.68 0.0001
' 4 -0.2172 0.0295 54.26 <.0001
'swe 0 1 0.1696 0.0414 16.75 <.0001
' 0 2 -0.0314 0.0435 0.52 0.4701
' 0 3 -0.2340 0.0432 29.38 <.0001
' 0 4 -0.1469 0.0394 13.89 0.0002
icp_ = Array(6.97322, -1.04068, 3.54333, 6.25727, 0)
bald_ = Array(-0.16644, 0.14603, -0.05827, -0.01118, 0)
bald2_ = Array(0.00122, -0.00219, 0.00038, -0.0001, 0)
bkon_ = Array(-0.08242, 0.08242, -0.3481, 0.3481, -0.34813, 0.34813, -0.48478, 0.48478, 0, 0)
edlevel_ = Array(-0.70305, 0.72573, -0.12089, -0.21719, 0)
swe_ = Array(0.16955, -0.16955, -0.03143, 0.03143, -0.23402, 0.23402, -0.14692, 0.14692, 0, 0)
Case (5)
' Analysis of Maximum Likelihood Estimates
'
' Function Standard Chi-
'Parameter Number Estimate Error Square Pr > ChiSq
'ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
'Intercept 1 -0.5142 0.4313 1.42 0.2331
' 2 -0.3394 0.4545 0.56 0.4552
' 3 -1.5727 0.3942 15.91 <.0001
' 4 -4.1625 0.3301 159.05 <.0001
'BALD 1 -0.1261 0.0215 34.53 <.0001
' 2 -0.1790 0.0226 62.72 <.0001
' 3 -0.1004 0.0193 27.15 <.0001
' 4 0.0286 0.0151 3.59 0.0582
'BALD*BALD 1 0.000551 0.000259 4.51 0.0338
' 2 0.00125 0.000275 20.48 <.0001
' 3 0.000542 0.000229 5.64 0.0176
' 4 -0.00055 0.000170 10.70 0.0011
'BKON 1 1 -0.0729 0.0328 4.94 0.0262
' 1 2 -0.0786 0.0366 4.61 0.0318
' 1 3 0.3346 0.0351 90.84 <.0001
' 1 4 -0.5905 0.0193 939.76 <.0001
'edlevel 1 -0.2259 0.0700 10.41 0.0013
' 2 0.7915 0.0652 147.37 <.0001
' 3 0.9481 0.0506 351.47 <.0001
' 4 0.3367 0.0364 85.55 <.0001
'swe 0 1 0.00826 0.0673 0.02 0.9023
' 0 2 -0.1065 0.0858 1.54 0.2148
' 0 3 0.5198 0.0415 157.07 <.0001
' 0 4 -0.0593 0.0461 1.65 0.1985
icp_ = Array(-0.51424, -0.33939, -1.57273, -4.16251, 0)
bald_ = Array(-0.12608, -0.17902, -0.10043, 0.02863, 0)
bald2_ = Array(0.00055, 0.00125, 0.00054, -0.00055, 0)
bkon_ = Array(-0.07287, 0.07287, -0.07856, 0.07856, 0.33464, -0.33464, -0.59053, 0.59053, 0, 0)
edlevel_ = Array(-0.22593, 0.79149, 0.94806, 0.3367, 0)
swe_ = Array(0.00826, -0.00826, -0.10649, 0.10649, 0.51982, -0.51982, -0.05931, 0.05931, 0, 0)
End Select
swe = 1
If i_born_abroad(iidx) = 1 Then swe = 0
DENOM = 0
For i = 1 To 5
xbeta(i) = icp_(i) + _
i_age(iidx) * bald_(i) + _
(i_age(iidx) ^ 2) * bald2_(i) + _
bkon_((i - 1) * 2 + i_sex(iidx)) + _
edlevel_(i) + _
swe_((i - 1) * 2 + (swe + 1))
DENOM = DENOM + Exp(xbeta(i))
Next
probs(1) = Exp(xbeta(1)) / DENOM
cumprobs(1) = CDbl(probs(1))
For i = 2 To 4
probs(i) = Exp(xbeta(i)) / DENOM
cumprobs(i) = cumprobs(i - 1) + CDbl(probs(i))
Next
cumprobs(5) = 1#
End If
'*** Draw from a multinomial distribution defined using the
'*** above calculated probabilities
rand = Rnd
For i = 1 To 5
If rand < cumprobs(i) Then
i_sector(iidx) = i
Exit For
End If
Next
End Sub