Sie sind auf Seite 1von 21

Electronic copy available at: http://ssrn.

com/abstract=1433709
Bayesian Estimation of Structural Equation Models
with R
A User Manual
J. B uschken

Catholic University of Eichstatt-Ingolstadt


G. Allenby

The Ohio State University


Working Paper
Please do not cite without the authors permission
Draft as of 2009-07-07

Joachim B uschken, Catholic University of Eichstatt-Ingolstadt, Ingolstadt School of Management, Mar-


keting Department, Auf der Schanz 49, D-85049 Ingolstadt, Germany, phone: +49 841 937 1976, fax: +49
841 937 2976, email: jb@w.edu.

Greg M. Allenby, The Ohio State University, Fisher College of Business, 540A Fisher Hall, Helen C.
Kurtz Chair in Marketing, 2100 Neil Avenue, OH-43210 Columbus, USA, phone: +1 614 292 9452, fax: +49
841 937 2976, email: allenby.1@osu.edu.
1
Electronic copy available at: http://ssrn.com/abstract=1433709
How to estimate structural equation models with R?
In the social sciences it is often useful to introduce latent variables and use structural
equation modeling to quantify relations among observable and latent variables. This paper
presents a manual, describing how to estimate structural equation models in a Bayesian
approach with R. Parameter estimation follows a Gibbs sampling procedure, generating
draws from the full conditionals of the unknown parameters. The manual is divided into
two main parts. The rst part presents an introduction to the estimation of structural
equation models with R. The second part describes a method for simulating data of a
structural equation model and the appendix contains the derivation of the full conditional
distributions.
1 Estimation of SEMs
To illustrate the Bayesian estimation of SEMs with R, we present an application in the
context of a simple SEM. The estimation procedure covers three parts. Firstly the model
has to be specied, secondly the data have to be attached to the model and nally these
values have to be passed to the estimation function.
Specifying the model and attaching data
In order to enable the user to become familiar with the notation and to transfer his model
specications to the model framework used in this paper, this subsection gives a short
overview of the model framework.
1
An example for the specication of a simple SEM
illustrates how the specication procedure is done. This is followed by showing how to
attach data to the model.
1
for more details to the model framework see appendix.
1
A SEM is composed of a measurement equation (1) and a structural equation (2):
y
i
=
i
+
i
(1)

i
=
i
+
i
+
i
(2)

i
=
_

_

i
+
i
= M
i
+
i
where i {1, ..., n}.
Observations of reective measures y
i
are assumed to be generated by underlying
latent variables
i
, possibly with measurement error
i
. The measurement equation is
dened by a conrmatory factor analysis model, where is the associated (p q) loading
matrix. The structural equation species relationships among the latent variables, where
i
can be divided into
i
=
i
, an endogenous (q
1
1) vector of latent variables, and
i
=
i
,
an exogenous (q
2
1) vector of latent variables. Let q = q
1
+q
2
, M is the unknown (q
1
q)
matrix of regression coecients that represent the proposed causal eects among and ,
and (q
1
1) is a random vector of residuals. It is assumed that measurement errors are
uncorrelated with and , residuals are uncorrelated with and the variables are
distributed as follows:

i
N (0,

) (3)

i
N (0,

) (4)

i
N (0,

) (5)
i {1, ..., n}where

and

are diagonal matrices. This model is not identied, but it


can be identied by restricting appropriate elements in and/or M at xed known values
(0 or 1). This is done with the help of the following Pick matrices:

Pick
(p q): matrix, containing xed known elements (0 or 1) in
M
Pick
(q
1
q): matrix, containing xed known elements (0 or 1) in M
For example, if is a (2 2) matrix and you want to x element [1, 1] to 1 and element
2
[2, 2] to 0,
Pick
is:

Pick
=
_
_
_
1 4
4 0
_
_
_
The non-xed elements of
Pick
can be set to any value except for 0 and 1. Non-xed
elements represent starting values for the MCMC chain (in this case: 4).
In order to enable Gibbs sampling from posterior distributions, we set natural
conjugate prior distributions for the unknown parameters: Let
k
be the kth diagonal
element of

,
l
be the lth diagonal element of

,
T
k
be the kth row of and M
T
l
be
the lth row of M, we get:

1
k
Gamma (
0k
,
0k
) (6)
_

k
|
1
k

N (
0k
,
k
H
0k
) (7)

1
l
Gamma (
0l
,
0l
) (8)
_
M
l
|
1
l

N (M
0l
,
l
H
0Ml
) (9)
IW [v
0
, V
0
] (10)
with k {1, ..., p} and l {1, ..., q
1
}.
It follows that the following parameters have to be specied:

0k
: shape parameter of the prior distribution of
1
k

0k
: inverse scale parameter of the prior distribution of
1
k

0l
: shape parameter of the prior distribution of
1
l

0l
: inverse scale parameter of the prior distribution of
1
l
v
0
, V
0
: parameters of the prior distribution of
Note that we assume that those values are the same for all k {1, ..., p} and l {1, ..., q1}.
Prior parameters of the distributions of regression matrices are set as follows:

0k
: prior mean of
k
is assumed to be zero
H
0k
: variance-covariance matrix of the prior distribution of
k
3
is assumed to be a diagonal matrix with 0,01 on the diagonal
M
0l
: prior mean of M
l
is assumed to be zero
H
0Ml
: variance-covariance matrix of the prior distribution of M
l
is assumed to be a
diagonal matrix with 0,01 on the diagonal
Furthermore it is necessary to set starting values for the unknown parameters:

(p p): diagonal variance-covariance matrix of the measurement errors

(q
1
q
1
): diagonal variance-covariance matrix of the structural residuals
(q
2
q
2
): variance-covariance matrix of the latent exogenous variables
and to determine the number of iterations of the MCMC Chain: R.
Starting values for the regression coecients in the matrices and M have been
already set in the corresponding Pick matrices.
4
We use the following simple structural equation model with a single exogenous
variable and three endogenous variables to exemplify our approach:

3
Q
Q
Q
Q
Q
Q
Q
Q
Q
Qs
Q
Q
Q
Q
Q
Q
Q
Q
Q
Qs

3
Figure 1: SEM example
_

1i

2i

3i
_

_
=
_

_
0 0 0
0 0 0

1

2
0
_

_
_

1i

2i

3i
_

_
+
_

2
0
_

1i
+
_

1i

2i

3i
_

_
(11)

1i
,
2i
and
3i
are the endogenous variables in this model,
1i
is an exogenous variable. In
matrix notation and using the usual notation for vectors of latent variables in the SEM
literature, this structural model can be written as:
i
=
i
+
1i
+
i
for observations
i = 1, ..., n.
By continuing the two matrices and this equation becomes:
_

1i

2i

3i
_

_
=
_

_
0 0 0
1
0 0 0
2

1

2
0 0
_

_
_

1i

2i

3i

1i
_

_
+
_

1i

2i

3i
_

_
(12)
In matrix notation we write this as:
i
= M
i
+
i
. In our example, we assume that each
5
latent variable is measured by two reective measurement indicators, as shown by the
following measurement equations:
y
i
=
_

11
0 0 0

21
0 0 0
0
32
0 0
0
42
0 0
0 0
53
0
0 0
63
0
0 0 0
74
0 0 0
84
_

_
_

1i

2i

3i

1i
_

_
+
_

1i

2i

3i

4i

5i

6i

7i

8i
_

_
(13)
which is the same as y
i
=
i
+
i
, where
i
comprises the values of all latent variables for
observation i and y
i
comprises the vector of observed measurement indicators for i. Since
this modell is not identied, we have to x elements in to 1. Thus we get:
y
i
=
_

11
0 0 0
1 0 0 0
0
32
0 0
0 1 0 0
0 0
53
0
0 0 1 0
0 0 0
74
0 0 0 1
_

_
_

1i

2i

3i

1i
_

_
+
_

1i

2i

3i

4i

5i

6i

7i

8i
_

_
(14)
6
The matrices and M contain xed known elements, either 0 or 1. On this basis we
can determine the corresponding Pick matrices:

Pick
=
_

_
0 0 0
1 0 0 0
0 0 0
0 1 0 0
0 0 0
0 0 1 0
0 0 0
0 0 0 1
_

_
(15)
M
Pick
=
_

_
0 0 0
0 0 0
0 0
_

_
(16)
stands for the unknown elements of the matrices. For the MCMC chain we have to set
starting values for these elements. In this case we set all unknown parameters to 4. The
resulting Pick matrices are:

Pick
=
_

_
4 0 0 0
1 0 0 0
0 4 0 0
0 1 0 0
0 0 4 0
0 0 1 0
0 0 0 4
0 0 0 1
_

_
(17)
7
M
Pick
=
_

_
0 0 0 4
0 0 0 4
4 4 0 0
_

_
(18)
The second step is attaching the data to the model. While the input of text-based data is
possible, R supports of several common data formats. For the manual, we will present how
to attach a .txt le. The data have to be arranged as (n p) matrix and saved as a .txt le.
You can read data from this le using the read.table function, creating a dataframe from it:
Data = read.table(le=C:/your folder/data.txt,header=TRUE, sep=\t, dec=,)
Passing data to the estimating function
Having set all necessary parameters and having attached the data, these objects can be
passed to a function, called semest, drawing the parameters of the model from the full
conditionals and thus yielding estimates for the unknown parameters. In order to pass data
and parameter values to the function semest, you have to rearrange the objects in the
following order:
L = (Data,
0k
,
0k
,
0l
,
0l
,
Pick
, M
Pick
,

, , v
0
, V
0
, R),
where
0
and M
0
are the corresponding matrices, including all rows
0k
respectively M
0l
.
Now these values have to be passed to the function semest:
semest(L)
This function yields all draws of the posterior distributions of the unknown parameters as
well as the estimated values of the latent variables.
2
2 Data Simulation
In order to check whether the algorithm yields the true parameters values, you can test the
Gibbs Sampler by simulating data and subsequently estimating the corresponding
2
for more details to the derivation of the posterior distributions see appendix.
8
parameter values. Firstly you have to determine a structural equation model, thus the
following parameters have to be spedied:
(p q): matrix of regression coecients of the measurement model
M(q
1
q): matrix of regression coecients of the structural model

(p p): diagonal variance-covariance matrix of the measurement errors

(q
1
q
1
): diagonal variance-covariance matrix of the structural residuals
(q
2
q
2
): variance-covariance matrix of the latent exogenous variables
n: number of observations
Then you can pass those values to the function sim, yielding the simulated observations
and latent variables:
sim(, M,

, , n)
9
Appendix: Bayesian Estimation of standard SEMs
This section develops a Gibbs sampler to estimate structural equation models (SEM) with
reective measurement indicators. We illustrate the Bayesian estimation by considering a
standard SEM that is equivalent to the most commonly used LISREL model.
A Model Framework
A SEM is composed of a measurement equation (19) and a structural equation (20):
y
i
=
i
+
i
(19)

i
=
i
+
i
+
i
(20)

i
=
_

_

i
+
i
= M
i
+
i
(21)
where i {1, ..., n}.
Observations of reective measures y
i
are assumed to be generated by underlying
latent variables
i
, possibly with measurement error
i
. The corresponding matrices
including all observations are Y (n p), (n q) and E(n p). The measurement
equation is dened by a conrmatory factor analysis model, where (p q) is the
associated loading matrix. The structural equation species relationships among the
identied latent variables, where can be divided into

= (q
1
1), an endogenous
random vector of latent variables, and

= (q
2
1), an exogenous random vector of
latent variables. M(q
1
q) is the unknown matrix of regression coecients that represent
the causal eects among and , and (q
1
1) is a random vector of residuals. It is
assumed that measruement errors are uncorrelated with and , residuals are uncorrelated
with and the variables are distributed as follows:

i
N (0,

) (22)
10

i
N (0,

) (23)

i
N (0,

) (24)
i {1, ..., n}, where

and

are diagonal matrices. The covariance matrix of is


derived on the basis of the SEM:

=
_

_
E
_

T
_
E
_

T
_
E
_

T
_
E
_

T
_
_

_
(25)

=
_

1
0
_

T
+

T
0

1
0

T
0

_

_
(26)

T
=
_

1
0
+
1
0

_ _

1
0
+
1
0

_
T
=
1
0
_

T
+
T
_

T
0
+
1
0
_

T
+
T

T
_

T
0
E
_

T
_
=
1
0
_

T
+

T
0

T
=
_

1
0
+
1
0

_

T
E
_

T
_
=
1
0

(27)
This model is not identied, but it can be identied by restricting appropriate elements in
and/or M at xed known values (0 or 1).
B Prior Distributions
In order to enable Gibbs sampling from posterior distributions, we set natural conjugate
prior distributions for the unknown parameters: Let
k
be the kth diagonal element of

l
be the lth diagonal element of

,
T
k
be the kth row of and M
T
l
be the lth row of M,
we get:

1
k
Gamma (
0k
,
0k
) (28)
_

k
|
1
k

N (
0k
,
k
H
0k
) (29)
11

1
l
Gamma (
0l
,
0l
) (30)
_
M
l
|
1
l

N (M
0l
,
l
H
0Ml
) (31)
IW [v
0
, V
0
] (32)
with k {1, ..., p} and l {1, ..., q
1
}.
C Derivations of conditional distributions
According to Bayes Theorem, the joint posterior of all unknown parameters is
proportional to the likelihood times the prior, or:
p (,

, , M,

, |Y ) p (Y |,

, , M,

, ) p (,

, , M,

, ) (33)
Given Y and , and

are independent from

. Once we have obtained draws of ,


we can treat the estimation of and

as a simple regression model. Thus we can sample


from the posterior distribution of and

without having to refer to

. The same holds


for inference with regard to M, and

, which are independent from Y given . This


suggests:
p (,

, M,

, |Y, ) [p (Y |,

, ) p (,

)] [p (|M,

, ) p (M,

, )] (34)
and we can treat the conditional posterior distributions of ,

and M, and

separately. in the above expression refers to the the n observations of the values of the
latent variables
i
which are conditionally independant given

. The parameters of

can be understood as the parameters of the distribution of heterogeneity of the latent


variables.
12
C.1 Obtaining draws of the latent variables ()
We can obtain draws of through the posterior of , which, according to Bayes Theorem,
is given by:
p (|Y, ,

)
n

i=1
p (y
i
|
i
, ,

) p (
i
|

) (35)
Given our assumption that the y
i
are distributed N (
i
,

) and the
i
are distributed
N (0,

), we see that the posterior involves the kernel of two normals, whose quadratic
form in the exponent can easily be combined. Because of the IID assumtion, we treat the
inference for the
i
separately for each observation i. The exponent of the resulting
distribution has the following expression:
(
i
0)
T

1
(
i
0) + (y
i

i
)
T

(y
i

i
)
=
T
i

1

i
+ y
T
i

1

y
i
2
T
i

T

y
i
+
T
i

T


i
=
T
i
_

1
+
T

i
2
T
i

T

y
i
+ y
T
i

1

y
i
=
_

i

_

1
+
T


_
1

y
i
_
T _

1
+
T


_
_

i

_

1
+
T


_
1

y
i
_

y
i
_
T
_

1
+
T


_
1
_

y
i
_
+ y
T
i

1

y
i
(36)
where the last two terms are constants wrt
i
. As a result, the conditional posterior
distribution of
i
is:
p (
i
|y
i
, ,

) N
_
_

1
+
T


_
1
_

y
i
_
,
_

1
+
T


_
1
_
(37)
To obtain , we simply cycle in this manner through the i loop. We can then treat as
data in subsequent steps of the Gibbs sampler.
13
C.2 Obtaining draws of
The rst step in developing the conditional distribution for is to recognize that only
those elements of , which refer to , are relevant for . Since
i
=
_
_
_

i
_
_
_
, we can simply
separate the draws of from and use this for inference regarding . refers to the
variance of the vector of exogenous variables only. The likelihood of observing

is:
p (

|)
n

i=1
||
0,5
exp
_

1
2

T
i

i
_
= ||

n
2
etr
_

1
2

1
_
(38)
Combining equation (38) with the prior distribution of in equation (32) yields:
[|

] IW
_
v
0
+ n, V
0
+
T

_
(39)
C.3 Obtaining draws of and

Given , obtaining draws of and

becomes a regression problem. We assume that

is a diagonal matrix, i.e. the measurement errors are uncorrelated. The likelihood of
observing the data is given by:
p (Y |,

, ) |

n
2
exp
_

1
2
n

i=1
(y
i

i
)
T

(y
i

i
)
_
(40)
in which y
i
and
i
are column vectors. Because of the property of

, we write this as:


p (Y |,

, ) |

n
2
exp
_

1
2
n

i=1
p

k=1

1
k
_
y
ik

T
k

i
_
2
_
(41)
We can change the order of summation and move
k
out of the summation over i. The
kernel of this distribution can then be written as:

1
2
p

k=1
_

1
k
_
n

i=1
_
y
ik

T
k

i
_
2
__
(42)
14
The summation over i is:
n

i=1
_
y
ik

T
k

i
_
2
=
n

i=1
_
y
2
ik
2y
ik

T
k

i
+ tr
_

T
k

T
i

k
__
=
n

i=1
y
2
ik
2
T
k
n

i=1
y
ik

i
+
T
k

k
= Y
T
k
Y
k
2
T
k

T
Y
k
+
T
k

k
=
_

k

_
_

_
1
_

T
Y
k
_
__
T _

_
_

k

_
_

_
1
_

T
Y
k
_
__
(43)
In the above expression, Y
k
refers to the column vector of all observations with regard to
the kth measurement variable. This yields the following likelihood:
p
_
Y |,
1
k
,
_
|

n
2
p

k=1
exp
_

1
2

1
k
_

k

_
_

_
1
_

T
Y
k
_
__
T _

_
_

k

_
_

_
1
_

T
Y
k
_
___
=
p

k=1

n
2
k
exp
_

1
2

1
k
_

k

_
_

_
1
_

T
Y
k
_
__
T _

_
_

k

_
_

_
1
_

T
Y
k
_
___
(44)
Notice that the determinant of

involves only the product of the diagonal elements. We


can therefore move these elements into the exponential expression. The above expression
for the likelihood implies:
independence of the draws of
k
,
1
k
of
h
,
1
h
for all h = k
conditional independence of p
_

1
k
|Y,
_
and p
_

k
|Y, ,
1
k
_
Also notice that the p distributions for
k
|
1
k
and
1
k
are independent. This implies that
we can draw
k
and
1
k
independently. Thus the likelihood of observing Y
k
is given by:
p
_
Y
k
|
k
,
1
k
,
_

n
2
k
exp
_

1
2

1
k
_

k

_
_

_
1
_

T
Y
k
_
__
T _

_
_

k

_
_

_
1
_

T
Y
k
_
__
_
(45)
As mentioned above, this model is not identied. We can handle this problem by xing
some of the parameters in , see (Lee 2007) for the following section. We suggest to x
15
some elements in to 1 and/or 0. Consider
T
k
, the kth row of , with certain xed
parameters. Let c
k
be the corresponding (1 q) row vector such that c
kj
= 0 if
kj
is a
xed parameter; and c
kj
= 1 if
kj
is an unknown parameter, for k = 1, ..., p, j = 1, ..., q
and r
k
= c
k1
+ ... + c
kq
. Moreover, let
T
k
be the (1 r
k
) row vector that contains the
unknown parameters in
k
; and let

k
be the (n r
k
) submatrix of such that for
j = 1, ..., r
k
, all the rows corresponding to c
kj
= 0 are deleted. Let Y
T
k
= (y

1k
, ..., y

nk
) with
y

ik
= y
ik

q

j=1
(
ki

ij
(1 c
kj
)) (46)
This yields the following likelihood of observing Y

k
:
p
_
Y

k
|

k
,
1
k
,

n
2
k
exp
_

1
2

1
k
_

k

_
_

_
1
_

T
Y

k
_
__
T _

_
_

k

_
_

_
1
_

T
Y

k
_
___
(47)
which can also be written as:
_
Y

k
|

k
,
1
k
,

N
__
_

_
1
_

T
Y

k
_
_
,
k
_

_
1
_
(48)
The conjugate prior distribution dened in equation (29) about the loading matrix is
[

k
|
k
] N (

0k
,
k
H

0k
) (49)
16
To derive the posterior for

k
and
1
k
, we multiply equation (48) with (49) and (28):
p
_

k
,
1
k
|Y

k
,

n
2
k
exp
_

1
2

1
k
_

k

_
_

_
1
_

T
Y

k
_
__
T _

_
_

k

_
_

_
1
_

T
Y

k
_
___

q
2
k
exp
_

1
2

1
k
(

0k
)
T
(H

0k
)
1
(

0k
)
_

1
k
_

0k
1
exp
_

0k

1
k
_
(50)
Combining the two quadratic forms yields:
p
_

k
,
1
k
|Y

k
,

n
2
k

q
2
k
exp
_

1
2

1
k
_
(

k
c

)
T
C

k
c

) + d

__

1
k
_

0k
1
exp
_

0k

1
k
_
(51)
with
C

=
_

+ (H

0k
)
1
_
c

=
_

+ (H

0k
)
1
_
1
_
_

_
_
_

_
1
_

T
Y

k
_
_
+ (H

0k
)
1

0k
_
d

=
_
_

_
1
_

T
Y

k
_
_
T _

_
_
_

_
1
_

T
Y

k
_
_
+(

0k
)
T
(H

0k
)
1
(

0k
) (c

)
T
_

+ (H

0k
)
1
_
(c

)
(52)
Thus the posterior distributions of
_

k
,
1
k
_
are respectively given by:
p
_

k
|Y

k
,
1
k
,

q
2
k
exp
_

1
2

1
k
(

k
c

)
T
C

k
c

)
_ (53)
and
p
_

1
k
|Y

k
,

1
k
_n
2
+
0k
1
exp
_

1
2

1
k
[2
0k
+ d

]
_
(54)
17
which can also be written as:
_

k
|Y

k
,
1
k
,

N
_
c

,
k
C
1

_
(55)
and
_

1
k
|Y

k
,

Gamma
_
n
2
+
0k
,
0k
+
1
2
d

_
(56)
C.4 Obtaining draws of M and

Given , obtaining draws of M and

becomes a regression problem. We assume that

is a diagonal matrix, i.e. the measurement errors are uncorrelated. Thus estimating the
parameters of the structural equation follows the same procedure as obtaining draws of the
parameters of the measurement equation. Analogous to the likelihood of observing Y

k
, see
equation (48), we get the likelihood of observing

l
:
_

l
|M

l
,
1
l
,

N
__
_

_
1
_

l
_
_
,
l
_

_
1
_
(57)
with l {1, ..., q
1
}. The conjugate prior distribution dened in equation (31) about the
loading matrix is
[M

l
|
l
] N (M

0k
,
l
H

0Ml
) (58)
To derive the posterior distributions of M

l
and
1
l
, we multiply equation (57) with (58)
and (30):
p
_
M

l
,
1
l
|

l
,

n
2
l
exp
_

1
2

1
l
_
M

l

_
_

_
1
_

l
_
__
T _

_
_
M

l

_
_

_
1
_

l
_
___

q
2
l
exp
_

1
2

1
l
(M

l
M

0l
)
T
(H

0Ml
)
1
(M

l
M

0l
)
_

1
l
_

0l
1
exp
_

0l

1
l
_
(59)
18
Combining the two quadratic forms yields:
p
_
M

l
,
1
l
|

l
,

n
2
l

q
2
l
exp
_

1
2

1
l
_
(M

l
c
M
)
T
C
M
(M

l
c
M
) + d
M
__

1
l
_

0l
1
exp
_

0l

1
l
_
(60)
with
C
M
=
_

+ (H

0Ml
)
1
_
c
M
=
_

+ (H

0Ml
)
1
_
1
_
_

_
_
_

_
1
_

l
_
_
+ (H

0Ml
)
1
M

0l
_
d
M
=
_
_

_
1
_

l
_
_
T _

_
_
_

_
1
_

l
_
_
+(M

0l
)
T
(H

0Ml
)
1
(M

0l
) (c
M
)
T
_

+ (H

0Ml
)
1
_
(c
M
)
(61)
Thus the posterior distributions of
_
M

l
,
1
l
_
are respectively given by:
p
_
M

l
|

l
,
1
l
,

q
2
l
exp
_

1
2

1
l
(M

l
c
M
)
T
C
M
(M

l
c
M
)
_ (62)
and
p
_

1
l
|

l
,

1
l
_n
2
+
0l
1
exp
_

1
2

1
l
[2
0l
+ d
M
]
_
(63)
which can also be written as:
_
M

l
|

l
,
1
l
,

N
_
c
M
,
l
C
1
M
_
(64)
and
_

1
l
|

l
,

Gamma
_
n
2
+
0l
,
0l
+
1
2
d
M
_
(65)
19
D Setting values for hyperprior parameters
In order to enable sampling from posterior distributions of the unknown elements, we have
to set values for the hyperparameters
0k
and
0k
, as well as
0l
and
0l
of the prior
distributions in equation (28) and (30). Since the results of the sampler are very sensitive
to these values, they have to be set thoughtfully. We suggest to run the Gibbs sampler
initially without sampling the parameters in

and

, but calculate them using the


following formulas:

k
=
1
n q
(Y
k

k
)
T
(Y
k

k
) (66)

l
=
1
n q
(
l
M
l
)
T
(
l
M
l
) (67)
In a second run we set the parameters
0k
and
0k
as follows:

0k
= 100

0k
=

k
100
(68)
and

0l
= 100

0l
=

l
100
(69)
and include the sampling of the parameters in

and

.
20

Das könnte Ihnen auch gefallen