BayES BayES

6.4 Random-effects binary Logit

Mathematical representation

Prob yit = 1 = Λ αi + xitβ,α i N 0, 1 ω (6.7)

An equivalent representation uses the latent variable yit:

yit = α i + xitβ + 𝜀 it,𝜀it Logistic 0,1,αi N 0, 1 ω , yit = 1 if yit > 0 0 if yit 0 (6.8)

PIC The mean of the distribution of the αis is restricted to zero and, therefore, these are simply group-specific errors terms. However, including a constant term in the set of independent variables is valid and leads to a specification equivalent to one where the group effects are draws from a normal distribution with mean equal to the parameter associated with the constant term and precision ω.

Priors




Parameter Probability density function Default hyperparameters



β p β = |P|12 2πK2 exp 1 2 β mP β m m = 0 K, P = 0.001 IK
ω p ω = bωaω Γaω ωaω1eωbω aω = 0.01, bω = 0.001



Syntax

[<model name> = ] logit_re( y ~ x1 x2  xK [, <options> ] );

where:

PIC The dependent variable, y, in the dataset used for estimation must contain only two values: 0 and 1 (with 1 indicating “success"). Observations with missing values in y are dropped during estimation, but if a numerical value other than 0 and 1 is encountered, then an error is produced.

PIC BayES automatically drops from the sample used for estimation groups which are observed only once. This is because for these groups the group effect (αi) cannot be distinguished from the error term (𝜀it).

The optional arguments for the random-effects binary Logit model are:4

Gibbs parameters


"chains"

number of chains to run in parallel (positive integer); the default value is 1

"burnin"

number of burn-in draws per chain (positive integer); the default value is 10000

"draws"

number of retained draws per chain (positive integer); the default value is 20000

"thin"

value of the thinning parameter (positive integer); the default value is 1

"seed"

value of the seed for the random-number generator (positive integer); the default value is 42

Hyperparameters


"m"

mean vector of the prior for β (K ×1 vector); the default value is 0K

"P"

precision matrix of the prior for β (K ×K symmetric and positive-definite matrix); the default value is 0.001 IK

"a_omega"

shape parameter of the prior for ω (positive number); the default value is 0.01

"b_omega"

rate parameter of the prior for ω (positive number); the default value is 0.001

Dataset and log-marginal likelihood


"dataset"

the id value of the dataset that will be used for estimation; the default value is the first dataset in memory (in alphabetical order)

"logML_CJ"

boolean indicating whether the Chib (1995)/Chib & Jeliazkov (2001) approximation to the log-marginal likelihood should be calculated (true|false); the default value is false

Reported Parameters




β

variable_name

vector of parameters associated with the independent variables




ω

omega

precision parameter of the group-specific error term, αi




σα

sigma_alpha

standard deviation of the group-specific error term: σα = 1ω12




Stored values and post-estimation analysis
If a left-hand-side id value is provided when a random-effects binary Logit model is created, then the following results are saved in the model item and are accessible via the ‘.’ operator:

Samples

a matrix containing the draws from the posterior of β and ω

x1,,xK

vectors containing the draws from the posterior of the parameters associated with variables x1,,xK (the names of these vectors are the names of the variables that were included in the right-hand side of the model)

omega

vector containing the draws from the posterior of ω

logML

the Lewis & Raftery (1997) approximation of the log-marginal likelihood

logML_CJ

the Chib (1995)/Chib & Jeliazkov (2001) approximation to the log-marginal likelihood; this is available only if the model was estimated with the "logML_CJ"=true option

alpha_i

N ×1 vector that stores the group-specific errors; the values in this vector are not guaranteed to be in the same order as the order in which the groups appear in the dataset used for estimation; use the store() function to associate the values in alpha_i with the observations in the dataset

nchains

the number of chains that were used to estimate the model

nburnin

the number of burn-in draws per chain that were used when estimating the model

ndraws

the total number of retained draws from the posterior ( =chains draws)

nthin

value of the thinning parameter that was used when estimating the model

nseed

value of the seed for the random-number generator that was used when estimating the model

Additionally, the following functions are available for post-estimation analysis (see section B.14):

The random-effects binary Logit model uses the store() function to associate the group effects (alpha_i) with specific observations and store their values in the dataset used for estimation. The generic syntax for a statement involving the store() function after estimation of a random-effects binary Logit model is:

store( alpha_i, <new variable name>, ["model"=<model name>] );

The random-effects binary Logit model uses the mfx() function to calculate and report the marginal effects of the independent variables on the probability of success. There are two types of marginal effects which can be requested by setting the "type" argument of the mfx() function equal to 1 or 2:

  1. when "type"=1 the marginal effects are calculated marginally with respect to the group effects.

  2. when "type"=2 the marginal effects are calculated conditionally on the group-effects being equal to zero (the expected value of the group effects, when treated as group-specific errors).

The generic syntax for a statement involving the mfx() function after estimation of a random-effects binary Logit model is:

mfx( ["type"=1] [, "point"=<point of calculation>] [, "model"=<model name>] );

and:

mfx( "type"=2 [, "point"=<point of calculation>] [, "model"=<model name>] );

for calculating these two types of marginal effects. The default value of the "type" option is 1. See the general documentation of the mfx() function (section B.14) for details on the other optional arguments.

The random-effects binary Logit model uses the predict() function to generate predictions of the probability of success. There are two types of predictions which can be requested by setting the "type" argument of the mfx() function equal to 1 or 2:

  1. when "type"=1 the predictions are generated marginally with respect to the group effects.

  2. when "type"=2 the predictions are generated conditionally on the group-effects being equal to zero (the expected value of the group effects, when treated as group-specific errors).

The generic syntax for a statement involving the predict() function after estimation of a random-effects binary Logit model is:

[<id value>] = predict( ["type"=1] [, "point"=<point of calculation>] [,"model"=<model name>] [, "stats"=true|false] [, "prefix"=<prefix for new variable name>] );

and:

[<id value>] = predict( "type"=2 [, "point"=<point of calculation>] [,"model"=<model name>] [, "stats"=true|false] [, "prefix"=<prefix for new variable name>] );

for generating these two types of predictions effects. The default value of the "type" option is 1. See the general documentation of the predict() function (section B.14) for details on the other optional arguments.

Examples

Example 1

myData = import("$BayESHOME/Datasets/dataset4.csv"); 
myData.constant = ones(rows(myData), 1); 
set_pd( year, id, "dataset" = myData); 
 
logit_re( y ~ constant x1 x2 x3 x4 );

Example 2

myData = import("$BayESHOME/Datasets/dataset4.csv"); 
myData.constant = ones(rows(myData), 1); 
set_pd( year, id, "dataset" = myData); 
 
myModel = logit_re( y ~ constant x1 x2 x3 x4, 
    "m"=ones(5,1), "P"=0.1*eye(5,5), "a_omega"=0.1, "b_omega"=0.01, 
    "burnin"=10000, "draws"=40000, "thin"=4, "chains"=2, 
    "logML_CJ" = true ); 
 
diagnostics("model"=myModel); 
 
kden(myModel.x3, "title" = "beta3 from the Logit model"); 
 
margeff_mean = mfx("point"="mean","model"=myModel,"type"=1); 
margeff_mean = mfx("point"="mean","model"=myModel,"type"=2); 
 
predict("type"=1, "prefix"=marg_); 
predict("type"=2, "prefix"=cond_);

4Optional arguments are always given in option-value pairs (eg. "chains"=3).

Share this content:
Facebook Twitter LinkedIn Email
© 2016–20 Grigorios Emvalomatis