63
CHAPTER 5. LIMITED DEPENDENT VARIABLE MODELS
201
x = independent variables matrix (nobs x nvar)
W = 1st order contiguity matrix (standardized, row-sums = 1)
ndraw = # of draws
nomit = # of initial draws omitted for burn-in
prior = a structure for: B = N(c,T), sige = gamma(nu,d0)
prior.beta, prior means for beta,
c above (default 0)
prior.bcov, prior beta covariance , T above (default 1e+12)
prior.rval, r prior hyperparameter, default=4
prior.m,
informative Gamma(m,k) prior on r
prior.k,
(default: not used)
prior.nu,
a prior parameter for sige
prior.d0,
(default: diffuse prior for sige)
prior.trunc = 'left' or 'right' censoring (default = left)
prior.limit = value for censoring (default = 0)
start = (optional) structure containing starting values:
defaults: beta=1,sige=1,rho=0.5, V= ones(n,1)
start.b
= beta starting values (nvar x 1)
start.p
= rho starting value
(scalar)
start.sig = sige starting value (scalar)
start.V
= V starting values (n x 1)
---------------------------------------------------
NOTE: 1st column of x-matrix must contain iota vector (constant term)
---------------------------------------------------
RETURNS: a structure:
results.meth = 'sart_g'
results.bdraw = bhat draws (ndraw-nomit x nvar)
results.sdraw = sige draws (ndraw-nomit x 1)
results.vmean = mean of vi draws (1 x nobs)
results.rdraw = sige draws (ndraw-nomit x 1)
results.pdraw = p draws
(ndraw-nomit x 1)
results.ymean = mean of y draws (1 x nobs)
results.pmean = b prior means, prior.beta from input
results.pstd = b prior std deviations sqrt(diag(T))
results.r
= value of hyperparameter r (if input)
results.nobs = # of observations
results.nvar = # of variables in x-matrix
results.nobsc = # of censored y-values
results.ndraw = # of draws
results.nomit = # of initial draws omitted
results.y
= actual observations (nobs x 1)
results.yhat = predicted values
results.nu
= nu prior parameter
results.d0
= d0 prior parameter
results.time = time taken for sampling
results.accept= acceptance rate
results.rmax = 1/max eigenvalue of W (or rmax if input)
results.rmin = 1/min eigenvalue of W (or rmin if input)
55
CHAPTER 5. LIMITED DEPENDENT VARIABLE MODELS
202
To illustrate the case of Tobit model estimation, example 5.2 shows an
example where we generate an SAR model based on the Anselin neighbor-
hood crime spatial contiguity matrix. We censor observations that are less
than zero. Estimates based on the uncensored data using the function sar
g
are compared to those from using sar
gand sart
gon the censored data.
We would expect that ignoring censoring should produce poor estimates
from application of sar
gon the censored data whereas use of sart
gwould
produce better estimates that are closer to those from application of sar
g
to the uncensored data.
Avector y is generated based on the neighborhood crime independent
variables standardized. This standardization produces a relatively even
number of negative and positive values for y. Negative values are then
censored.
% ----- Example 5.2 SAR Tobit Model
load anselin.dat;
xt = [anselin(:,2:3)]; n = length(xt);
% center and scale the data so our y-values
% are evenly distributed around zero, the censoring point
x = [ones(n,1) studentize(xt)];
[n k] = size(x);
load wmat.dat;
W = wmat;
sige = 5.0;
evec = randn(n,1)*sqrt(sige);
rho = 0.75;
beta = ones(k,1);
B = eye(n) - rho*W;
BI = inv(B);
y = BI*x*beta + BI*evec;
yc = y;
% now censor neighborhoods with crime < 1
for i=1:n
if y(i,1) < 1
yc(i,1) = 1;
end;
end;
Vnames = strvcat('crime','constant','income','hvalue');
ndraw = 600; nomit = 100;
prior.rval = 30;
res1 = sar(y,x,W);
res2 = sar_g(yc,x,W,ndraw,nomit,prior);
prior.limit = 1;
prior.trunc = 'left';
res3 = sart_g(yc,x,W,ndraw,nomit,prior);
prt(res1,Vnames);
prt(res2,Vnames);
prt(res3,Vnames);
128
CHAPTER 5. LIMITED DEPENDENT VARIABLE MODELS
203
The printed results for an SAR model based on the uncensored data as
well as a set of estimates that ignore the sample censoring and the Tobit
version of the SAR model are presented below.
Spatial autoregressive Model Estimates
Dependent Variable =
crime
R-squared
=
0.7344
Rbar-squared
=
0.7229
sigma^2
=
5.6564
Nobs, Nvars
=
49,
3
log-likelihood =
-99.041858
# of iterations =
13
min and max rho =
-1.5362,
1.0000
***************************************************************
Variable
Coefficient
t-statistic
t-probability
constant
0.617226
1.328646
0.190519
income
1.064967
2.271643
0.027831
hvalue
0.897449
2.254232
0.028988
rho
0.724180
5.068285
0.000007
Gibbs sampling spatial autoregressive model
Dependent Variable =
crime
R-squared
=
0.7013
sigma^2
=
3.4570
r-value
=
30
Nobs, Nvars
=
49,
3
ndraws,nomit
=
600,
100
acceptance rate =
0.9662
time in secs
=
14.4129
min and max rho =
-1.5362,
1.0000
***************************************************************
Variable
Prior Mean
Std Deviation
constant
0.000000
1000000.000000
income
0.000000
1000000.000000
hvalue
0.000000
1000000.000000
***************************************************************
Posterior Estimates
Variable
Coefficient
t-statistic
t-probability
constant
1.412658
3.037593
0.003922
income
1.253225
3.479454
0.001111
hvalue
0.364549
1.267454
0.211372
rho
0.599010
6.097006
0.000000
Gibbs sampling spatial autoregressive Tobit model
Dependent Variable =
crime
R-squared
=
0.6977
sigma^2
=
6.9121
r-value
=
30
Nobs, Nvars
=
49,
3
76
CHAPTER 5. LIMITED DEPENDENT VARIABLE MODELS
204
# censored values =
16
ndraws,nomit
=
600,
100
acceptance rate
=
0.9120
time in secs
=
19.7692
min and max rho
=
-1.5362,
1.0000
***************************************************************
Variable
Prior Mean
Std Deviation
constant
0.000000
1000000.000000
income
0.000000
1000000.000000
hvalue
0.000000
1000000.000000
***************************************************************
Posterior Estimates
Variable
Coefficient
t-statistic
t-probability
constant
0.936753
1.847863
0.071058
income
1.479955
2.844135
0.006624
hvalue
0.544580
1.320079
0.193340
rho
0.629394
6.446799
0.000000
Akey to understanding how the Gibbs sampler works on these problems
is the generation of predicted values for the censored observations. These
values may also be useful for purposes of inference regarding the censored
observations. The tobit spatial autoregressive functions return a structure
variable eld `results.ymean'that represents the mean of the sampled values
for the censored observations as well as the actual values of the uncensored
observations. Figure5.2 shows aplot of this data vector against the actual y
variables. Ordinarily, we wouldn't know the values of the censored y values,
but in this case because we generated the data set and then censored the
observations we have this information.
5.5 An applied example
The Harrison and Rubinfeld Boston data set used in Chapter3 to illustrate
Gibbs sampling Bayesian spatial autoregressive models contains censored
values. Median house values greater than $50,000 were set equal to 50,000
for 16 of the 506 sample observations (see Gilley and Pace, 1995). This
provides an opportunity to see if using tobit estimation to take the sample
truncation into account produces dierent parameter estimates.
Example 5.3 reads the Boston data set and sorts by median housing
values. Note that we must also sort the explanatory variables using the
index vector `yind'returned by the sort for the y values as wellas the latitude
and longitude vectors. After carrying out Gibbs sampling estimationfor the
SAR, SEM and SAC models, we add to the prior structure variable a eld
for right-truncationand we supply the limit value which is the log of 50,000
42
CHAPTER 5. LIMITED DEPENDENT VARIABLE MODELS
205
0
5
10
15
20
25
30
35
40
45
50
-10
-5
0
5
10
15
Observations
Crime
Actual
Mean of Gibbs samples
Figure 5.2: Actual vs. simulated censored y-values
standardized. By virtue of our sorting the y vector, this transformed limit
value must equal the last 16 observations, so we use the last to dene the
limit value.
% ----- Example 5.3 Right-censored Tobit for the Boston data
load boston.raw; % Harrison-Rubinfeld data
load latitude.data; load longitude.data;
[n k] = size(boston);y = boston(:,k);
% median house values
% sort by median house values
[ys yind] = sort(y); xs = boston(yind,1:k-1);
lats = latitude(yin,1); lons = longitude(yin,1);
[W1 W W3] = xy2cont(lats,lons); % create W-matrix
vnames = strvcat('hprice','constant','crime','zoning','industry', ...
'charlesr','noxsq','rooms2','houseage','distance','access','taxrate', ...
'pupil/teacher','blackpop','lowclass');
y = studentize(log(ys)); x = [ones(n,1) studentize(xs)];
% define censoring limit
limit = y(506,1); % median values >=50,000 are censored to 50
82
CHAPTER 5. LIMITED DEPENDENT VARIABLE MODELS
206
ndraw = 1100; nomit = 100;
prior.rval = 4;
prior.rmin = 0; prior.rmax = 1;
prior.lmin = 0; prior.lmax = 1;
% ignore censoring
res1 = sar_g(y,x,W,ndraw,nomit,prior);
prt(res1,vnames);
res2 = sem_g(y,x,W,ndraw,nomit,prior);
prt(res2,vnames);
res3 = sac_g(y,x,W,W,ndraw,nomit,prior);
prt(res3,vnames);
% use Tobit for censoring
prior.trunc = 'right';
prior.limit = limit;
res4 = sart_g(y,x,W,ndraw,nomit,prior);
prt(res4,vnames);
res5 = semt_g(y,x,W,ndraw,nomit,prior);
prt(res5,vnames);
res6 = sact_g(y,x,W,W,ndraw,nomit,prior);
prt(res6,vnames);
Intuitively, we might not expect a large dierence in the parameter
estimates for this case where only 16 of the 506 sample observations are
censored. The results are presented below, where the information that is
typically printed regarding prior means and standard deviations has been
eliminated because we used a diuse prior. The order of the results has been
ordered to present both SAR and the tobit SAR, then the SEM and tobit
SEM and nally SAC and tobit SAC estimates.
Gibbs sampling spatial autoregressive model
Dependent Variable =
hprice
R-squared
=
0.8243
sigma^2
=
0.1921
r-value
=
4
Nobs, Nvars
=
506,
14
ndraws,nomit
=
1100,
100
acceptance rate =
0.8662
time in secs
= 129.8548
min and max rho =
0.0000,
1.0000
***************************************************************
Posterior Estimates
Variable
Coefficient
t-statistic
t-probability
constant
-0.025169
-1.126015
0.260708
crime
-0.152583
-3.509177
0.000491
zoning
0.050736
1.304237
0.192763
industry
0.045046
0.915162
0.360555
charlesr
0.020157
0.787959
0.431100
162
CHAPTER 5. LIMITED DEPENDENT VARIABLE MODELS
207
noxsq
-0.089610
-1.803644
0.071899
rooms2
0.267168
5.731838
0.000000
houseage
-0.036438
-0.878105
0.380315
distance
-0.178140
-5.673916
0.000000
access
0.188203
2.713291
0.006895
taxrate
-0.212748
-5.525728
0.000000
pupil/teacher
-0.117601
-3.980184
0.000079
blackpop
0.107424
3.873596
0.000122
lowclass
-0.313225
-7.068474
0.000000
rho
0.314435
3.212364
0.001403
Gibbs sampling spatial autoregressive Tobit model
Dependent Variable =
hprice
R-squared
=
0.8225
sigma^2
=
0.1595
r-value
=
4
Nobs, Nvars
=
506,
14
# censored values =
16
ndraws,nomit
=
1100,
100
acceptance rate
=
0.9206
time in secs
= 158.1523
min and max rho
=
0.0000,
1.0000
***************************************************************
Posterior Estimates
Variable
Coefficient
t-statistic
t-probability
constant
-0.034993
-1.763936
0.078363
crime
-0.159346
-3.631451
0.000311
zoning
0.051875
1.399918
0.162168
industry
0.025951
0.561893
0.574445
charlesr
0.010791
0.446021
0.655778
noxsq
-0.084991
-1.800372
0.072414
rooms2
0.240183
5.251582
0.000000
houseage
-0.048693
-1.265013
0.206465
distance
-0.176466
-5.657902
0.000000
access
0.193611
3.125944
0.001877
taxrate
-0.219662
-6.201483
0.000000
pupil/teacher
-0.115413
-4.128876
0.000043
blackpop
0.107766
4.064385
0.000056
lowclass
-0.301859
-7.543143
0.000000
rho
0.296382
2.937506
0.003464
Gibbs sampling spatial error model
Dependent Variable =
hprice
R-squared
=
0.7304
sigma^2
=
0.1445
r-value
=
4
Nobs, Nvars
=
506,
14
ndraws,nomit
=
1100,
100
acceptance rate
=
0.4870
165
CHAPTER 5. LIMITED DEPENDENT VARIABLE MODELS
208
time in secs
= 114.7631
min and max lambda =
0.0000,
1.0000
***************************************************************
Posterior Estimates
Variable
Coefficient
t-statistic
t-probability
constant
-0.039799
-0.420595
0.674234
crime
-0.165742
-4.010247
0.000070
zoning
0.049197
1.177168
0.239698
industry
-0.005192
-0.087059
0.930660
charlesr
-0.015074
-0.579339
0.562625
noxsq
-0.147566
-1.925225
0.054777
rooms2
0.338988
8.416259
0.000000
houseage
-0.127886
-2.885708
0.004077
distance
-0.175342
-2.494614
0.012936
access
0.276185
3.014877
0.002704
taxrate
-0.237284
-4.804194
0.000002
pupil/teacher
-0.084627
-2.720154
0.006756
blackpop
0.144584
4.584164
0.000006
lowclass
-0.243651
-5.941416
0.000000
lambda
0.786425
19.084355
0.000000
Gibbs sampling spatial error Tobit model
Dependent Variable =
hprice
R-squared
=
0.7313
sigma^2
=
0.1493
r-value
=
4
Nobs, Nvars
=
506,
14
# censored values =
16
ndraws,nomit
=
1100,
100
acceptance rate
=
0.4808
time in secs
= 142.1482
min and max lambda =
0.0000,
1.0000
***************************************************************
Posterior Estimates
Variable
Coefficient
t-statistic
t-probability
constant
-0.039910
-0.544675
0.586224
crime
-0.155688
-4.035574
0.000063
zoning
0.049964
1.139609
0.255004
industry
-0.013470
-0.220422
0.825634
charlesr
-0.019834
-0.649249
0.516481
noxsq
-0.108960
-1.401207
0.161783
rooms2
0.277678
5.450260
0.000000
houseage
-0.116271
-2.463411
0.014103
distance
-0.161768
-2.319974
0.020751
access
0.255551
2.665245
0.007946
taxrate
-0.241885
-4.658895
0.000004
pupil/teacher
-0.088207
-2.694077
0.007300
blackpop
0.134053
4.262707
0.000024
lowclass
-0.259032
-5.544375
0.000000
150
CHAPTER 5. LIMITED DEPENDENT VARIABLE MODELS
209
lambda
0.728140
12.943930
0.000000
Gibbs sampling general spatial model
Dependent Variable =
hprice
R-squared
=
0.8601
sigma^2
=
0.1468
r-value
=
4
Nobs, Nvars
=
506,
14
ndraws,nomit
=
1100,
100
accept rho rate
=
0.9857
accept lam rate
=
0.5040
time in secs
= 214.1628
min and max rho
=
0.0000,
1.0000
min and max lambda =
0.0000,
1.0000
***************************************************************
Posterior Estimates
Variable
Coefficient
t-statistic
t-probability
constant
-0.026721
-0.556941
0.577821
crime
-0.167938
-4.414590
0.000012
zoning
0.047543
1.179076
0.238938
industry
0.016986
0.299507
0.764680
charlesr
0.009328
0.343660
0.731249
noxsq
-0.128901
-1.944391
0.052418
rooms2
0.330110
7.369387
0.000000
houseage
-0.099118
-2.108214
0.035518
distance
-0.191117
-3.638851
0.000303
access
0.235348
2.793913
0.005411
taxrate
-0.232871
-4.977616
0.000001
pupil/teacher
-0.108696
-3.825547
0.000147
blackpop
0.133964
4.398670
0.000013
lowclass
-0.297188
-7.347890
0.000000
rho
0.717992
13.037376
0.000000
lambda
0.083388
1.815698
0.070025
Gibbs sampling general spatial Tobit model
Dependent Variable =
hprice
R-squared
=
0.8602
sigma^2
=
0.1333
r-value
=
4
Nobs, Nvars
=
506,
14
# censored values =
16
ndraws,nomit
=
1100,
100
accept rho rate
=
0.9839
accept lam rate
=
0.7113
time in secs
= 249.0965
min and max rho
=
0.0000,
1.0000
min and max lambda =
0.0000,
1.0000
***************************************************************
Posterior Estimates
Documents you may be interested
Documents you may be interested