  ### 4.2 Heteroskedastic linear model

Mathematical representation

$\begin{array}{lllll}\hfill & {y}_{i}={\mathbf{x}}_{i}^{\prime }\beta +{𝜀}_{i}\phantom{\rule{2em}{0ex}}\phantom{\rule{2em}{0ex}}& \hfill {𝜀}_{i}\sim \mathrm{N}\left(0,\frac{1}{{\tau }_{i}}\right)& \phantom{\rule{2em}{0ex}}& \hfill \text{(4.2)}\\ \hfill & log{\tau }_{i}={\mathbf{w}}_{i}^{\prime }\delta +{v}_{i}\phantom{\rule{2em}{0ex}}\phantom{\rule{2em}{0ex}}& \hfill {v}_{i}\sim \mathrm{N}\left(0,\frac{1}{\varphi }\right)& \phantom{\rule{2em}{0ex}}& \hfill \text{(4.3)}\end{array}$
• the model is estimated using $N$ observations
• ${y}_{i}$ is the value of the dependent variable for observation $i$
• ${\mathbf{x}}_{i}$ is a $K\phantom{\rule{0.3em}{0ex}}×\phantom{\rule{0.3em}{0ex}}1$ vector that stores the values of the $K$ independent variables for observation $i$
• $\beta$ is a $K\phantom{\rule{0.3em}{0ex}}×\phantom{\rule{0.3em}{0ex}}1$ vector of parameters
• ${\tau }_{i}$ is the precision of the error term for observation $i$: ${\sigma }_{{𝜀}_{i}}^{2}=\frac{1}{{\tau }_{i}}$
• ${\mathbf{w}}_{i}$ is an $L\phantom{\rule{0.3em}{0ex}}×\phantom{\rule{0.3em}{0ex}}1$ vector that stores the values of the $L$ variables that determine the precision of the error term for observation $i$
• $\delta$ is an $L\phantom{\rule{0.3em}{0ex}}×\phantom{\rule{0.3em}{0ex}}1$ vector of parameters
• $\varphi$ is the precision of the error term in the equation for $log{\tau }_{i}$: ${\sigma }_{v}^{2}=\frac{1}{\varphi }$

Priors

 Parameter Probability density function Default hyperparameters $\beta$ $p\left(\beta \right)=\frac{|{\mathbf{P}}_{\beta }{|}^{1∕2}}{{\left(2\pi \right)}^{K∕2}}exp\left\{-\frac{1}{2}{\left(\beta -{\mathbf{m}}_{\beta }\right)}^{\prime }{\mathbf{P}}_{\beta }\left(\beta -{\mathbf{m}}_{\beta }\right)\right\}$ ${\mathbf{m}}_{\beta }={\mathbf{0}}_{K}$, ${\mathbf{P}}_{\beta }=0.001\cdot {\mathbf{I}}_{K}$ $\delta$ $p\left(\delta \right)=\frac{|{\mathbf{P}}_{\delta }{|}^{1∕2}}{{\left(2\pi \right)}^{L∕2}}exp\left\{-\frac{1}{2}{\left(\delta -{\mathbf{m}}_{\delta }\right)}^{\prime }{\mathbf{P}}_{\delta }\left(\delta -{\mathbf{m}}_{\delta }\right)\right\}$ ${\mathbf{m}}_{\delta }={\mathbf{0}}_{L}$, ${\mathbf{P}}_{\delta }=0.01\cdot {\mathbf{I}}_{L}$ $\varphi$ $p\left(\varphi \right)=\frac{{b}_{\varphi }^{{a}_{\varphi }}}{\Gamma \left({a}_{\varphi }\right)}{\varphi }^{{a}_{\varphi }-1}{e}^{-\varphi {b}_{\varphi }}$ ${a}_{\varphi }=0.001$, ${b}_{\varphi }=0.001$

Syntax

$\left[$<model name> = $\right]$ lm( y ~ x1 x2  xK $|$ w1 w2 $\dots$ wL $\left[$,<options>$\right]$ );

where:

• y is the dependent variable name, as it appears in the dataset used for estimation
• x1 x2 $\dots$xK is a list of the $K$ independent variable names, as they appear in the dataset used for estimation; when a constant term is to be included in the model, this must be requested explicitly
• w1 w2 $\dots$wK is a list of the names of the $L$ variables which determine the precision of ${𝜀}_{i}$, as they appear in the dataset used for estimation; when a constant term is to be included in the precision equation, this must be requested explicitly

The optional arguments for the heteroskedastic linear model are:2

 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_beta" mean vector of the prior for $\beta$ ($K\phantom{\rule{0.3em}{0ex}}×\phantom{\rule{0.3em}{0ex}}1$ vector); the default value is ${\mathbf{0}}_{K}$ "P_beta" precision matrix of the prior for $\beta$ ($K\phantom{\rule{0.3em}{0ex}}×\phantom{\rule{0.3em}{0ex}}K$ symmetric and positive-deﬁnite matrix); the default value is $0.001\phantom{\rule{0.3em}{0ex}}\cdot \phantom{\rule{0.3em}{0ex}}{\mathbf{I}}_{K}$ "m_delta" mean vector of the prior for $\delta$ ($L\phantom{\rule{0.3em}{0ex}}×\phantom{\rule{0.3em}{0ex}}1$ vector); the default value is ${\mathbf{0}}_{L}$ "P_delta" precision matrix of the prior for $\delta$ ($L\phantom{\rule{0.3em}{0ex}}×\phantom{\rule{0.3em}{0ex}}L$ symmetric and positive-deﬁnite matrix); the default value is $0.01\phantom{\rule{0.3em}{0ex}}\cdot \phantom{\rule{0.3em}{0ex}}{\mathbf{I}}_{L}$ "a_phi" shape parameter of the prior for $\varphi$ (positive number); the default value is $0.001$ "b_phi" rate parameter of the prior for $\varphi$ (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 ﬁrst 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

 $\beta$ variable_name vector of parameters associated with the independent variables in the observed equation $\delta$ variable_name vector of parameters associated with the independent variables in the precision equation $\varphi$ phi precision parameter of the error term in the precision equation, ${v}_{i}$ ${\sigma }_{v}$ sigma_v standard deviation of the error term in the precision equation: ${\sigma }_{v}=1∕{\varphi }^{1∕2}$

Stored values and post-estimation analysis
If a left-hand-side id value is provided when a heteroskedastic linear 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 $\beta$, $\delta$ and $\varphi$ y$x1,$\dots$,y$xK vectors containing the draws from the posterior of the parameters associated with variables x1,$\dots$,xK (the names of these vectors are the names of the variables that were included in the right-hand side of the model, prepended by y$, where y is the name of the dependent variable; this is done so that the samples on the parameters associated with a variable that appears in both x and w lists can be distinguished) logtau$z1,$\dots$, logtau$zL vectors containing the draws from the posterior of the parameters associated with variables w1,$\dots$,wL (the names of these vectors are the names of the variables that were included in the w list, in the right-hand side of the model, prepended by logtau$; this is done so that the samples on the parameters associated with a variable that appears in both x and w lists can be distinguished) phi vector containing the draws from the posterior of $\varphi$ 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 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 $\cdot$ 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):

• diagnostics()
• test()
• pmp()

Examples

Example 1

myData = import("$BayESHOME/Datasets/dataset3.csv"); myData.constant = ones(rows(myData), 1); lm( y ~ constant x1 x2 x3 | constant z1 z2); Example 2 myData = import("$BayESHOME/Datasets/dataset3.csv");
myData.constant = ones(rows(myData), 1);

myModel = lm(y ~ constant x1 x2 x3 | constant z1 z2,
"m_beta"=ones(4,1), "P_beta" = 0.01*eye(4,4),
"m_delta"=ones(3,1), "P_delta" = 0.1*eye(3,3),
"a_phi"=0.01, "b_phi"=0.001,
"burnin"=10000, "draws"=40000, "thin"=4, "chains"=2,
"logML_CJ" = true, "dataset"=myData);

diagnostics("model"=myModel);

plotdraws(phi, "model"=myModel);
plotdraws(logtau\$z2, "model"=myModel);

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

Share this content:    © 2016–20 Grigorios Emvalomatis