semiparametric regression analysis via infer...later sections. each of sections 3–10 illustrates a...

36
JSS Journal of Statistical Software MMMMMM YYYY, Volume VV, Issue II. http://www.jstatsoft.org/ Semiparametric Regression Analysis via Infer.NET Jan Luts Shen S.J. Wang TheSearchParty.com Pty Ltd. University of Queensland John T. Ormerod Matt P. Wand University of Sydney University of Technology, Sydney Abstract We provide several examples of Bayesian semiparametric regression analysis via the Infer.NET package for approximate deterministic inference in graphical models. The ex- amples are chosen to encompass a wide range of semiparametric regression situations. Infer.NET is shown to produce accurate inference in comparison with Markov chain Monte Carlo via the BUGS package, but is considerably faster. Potentially, this contri- bution represents the start of a new era for semiparametric regression, where large and complex analyses are performed via fast graphical models methodology and software, mainly being developed within Machine Learning. Keywords: additive mixed models, expectation propagation, generalized additive models, measurement error models, mean field variational Bayes, missing data models, penalized splines, variational message passing . Date of this draft: 17 JAN 2014 1. Introduction Infer.NET (Minka et al. 2013) is a relatively new software package for performing approxi- mate inference in large graphical models, using fast deterministic algorithms such as expec- tation propagation (Minka 2001) and variational message passing (Winn and Bishop 2005). We demonstrate its application to Bayesian semiparametric regression. A variety of situ- ations are covered: non-Gaussian response, longitudinal data, bivariate functional effects, robustness, sparse signal penalties, missingness and measurement error. The Infer.NET project is still in its early years and, and at the time of this writing, has not pro- gressed beyond beta releases. We anticipate continual updating and enhancement for many

Upload: others

Post on 11-Mar-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

JSS Journal of Statistical SoftwareMMMMMM YYYY, Volume VV, Issue II. http://www.jstatsoft.org/

Semiparametric Regression Analysis via Infer.NET

Jan Luts Shen S.J. WangTheSearchParty.com Pty Ltd. University of Queensland

John T. Ormerod Matt P. WandUniversity of Sydney University of Technology, Sydney

Abstract

We provide several examples of Bayesian semiparametric regression analysis via theInfer.NET package for approximate deterministic inference in graphical models. The ex-amples are chosen to encompass a wide range of semiparametric regression situations.Infer.NET is shown to produce accurate inference in comparison with Markov chainMonte Carlo via the BUGS package, but is considerably faster. Potentially, this contri-bution represents the start of a new era for semiparametric regression, where large andcomplex analyses are performed via fast graphical models methodology and software,mainly being developed within Machine Learning.

Keywords: additive mixed models, expectation propagation, generalized additive models,measurement error models, mean field variational Bayes, missing data models, penalizedsplines, variational message passing .

Date of this draft: 17 JAN 2014

1. Introduction

Infer.NET (Minka et al. 2013) is a relatively new software package for performing approxi-mate inference in large graphical models, using fast deterministic algorithms such as expec-tation propagation (Minka 2001) and variational message passing (Winn and Bishop 2005).We demonstrate its application to Bayesian semiparametric regression. A variety of situ-ations are covered: non-Gaussian response, longitudinal data, bivariate functional effects,robustness, sparse signal penalties, missingness and measurement error.

The Infer.NET project is still in its early years and, and at the time of this writing, has not pro-gressed beyond beta releases. We anticipate continual updating and enhancement for many

Page 2: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

2 Regression via Infer.NET

years to come. In this article we are necessarily restricted to the capabilities of Infer.NET atthe time of preparation. All of our examples use Infer.NET 2.5, Beta 2, which was releasedin April 2013.

The graphical models viewpoint of semiparametric regression (Wand 2009), and other ad-vanced statistical techniques, has the attraction that various embellishments of the standardmodels can be accommodated by enlarging the underlying directed acyclic graph. For ex-ample, nonparametric regression with a missing predictor data model involves the additionof nodes and edges to the graph, corresponding to the missing data mechanism. Figure 4of Faes et al. (2011) provides some specific illustrations. Marley and Wand (2010) exploitedthe graphical models viewpoint of semiparametric regression to handle a wide range of non-standard models via the Markov chain Monte Carlo inference engine implemented by BUGS(Lunn et al. 2000). However, many of their examples take between several minutes and hoursto run. The inference engines provided by Infer.NET allow much faster fitting for manycommon semiparametric regression models. On the other hand, BUGS is the more versatilepackage and not all models that are treated in Marley and Wand (2010) are supported byInfer.NET.

Semiparametric regression, summarized by Ruppert et al. (2003, 2009), is a large branch ofStatistics that includes nonparametric regression, generalized additive models, generalizedadditive mixed models, curve-by-factor interaction models, wavelet regression and geoad-ditive models. Parametric models such as generalized linear mixed models are special casesof semiparametric regression. Antecedent research for special cases such as nonparametricregression was conducted in the second half of the 20th Century at a time when data setswere smaller, computing power was lower and the Internet was either non-existent or in itsinfancy. Now, as we approach the mid-2010s, semiparametric regression is continually beingchallenged by the size, complexity and, in some applications, arrival speed of data-sets re-quiring analysis. Implementation and computational speed are major limiting factors. Thiscontribution represents the potential for a new era for semiparametric regression – tappinginto 21st Century Machine Learning research on fast approximate inference on large graph-ical models (e.g. Minka 2001; Winn and Bishop 2005; Minka 2005; Minka and Winn 2008;Knowles and Minka 2011) and ensuing software development.

Section 2 lays down the definitions and notation needed to describe the models given inlater sections. Each of Sections 3–10 illustrates a different type of semiparametric regressionanalysis via Infer.NET. All code is available as web-supplement to this articles. For most ofthe examples, we also compare the Infer.NET results with those produced by BUGS. Sec-tion 11 compares BUGS with Infer.NET in terms of versatility and computational speed. Asummary of our findings on semiparametric analysis via Infer.NET is given in Section 12.An appendix gives a detailed description of using Infer.NET to fit the simple semiparametricregression model of Section 3.

2. Preparatory infrastructure

The semiparametric regression examples rely on mathematical infrastructure and notation,which we describe in this section.

Page 3: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

Journal of Statistical Software 3

2.1. Distributional notation

The density function of a random vector x is denoted by p(x). The notation for a set ofindependent random variables yi (1 ≤ i ≤ n) with distribution Di is yi

ind.∼ Di. Table 1 liststhe distributions used in the examples and the parametrization of their density functions.

distribution density function in x abbreviation

Normal (2πσ2)−1/2 exp−(x− µ)2/(2σ2); σ > 0 N(µ, σ2)

Laplace (2σ)−1 exp(−|x− µ|/σ); σ > 0 Laplace(µ, σ2)

tΓ(

ν+12

)√

πνσ2Γ(ν/2)1 + (x−µ)2

νσ2 ν+12

; σ, ν > 0 t(µ, σ2, ν)

GammaBA xA−1e−B x

Γ(A); x > 0; A,B > 0 Gamma(A,B)

Half-Cauchy2σ

π(x2 + σ2); x > 0; σ > 0 Half-Cauchy(σ)

Table 1: Distributions used in the examples. The density function argument x and parame-ters range over R unless otherwise specified.

2.2. Standardization and default priors

In real data examples, the measurements are often recorded on several different scales.Therefore, all continuous variables are standardized prior to fitting analysis using Infer.NETor Markov Chain Monte Carlo (MCMC) in BUGS. This transformation makes the analysesscale-invariant and can also lead to better behavior of the MCMC.

Since we do not have prior knowledge about the model parameters in each of the examples,non-informative priors are used. The prior distributions for a fixed effects parameter vectorβ and a standard deviation parameter σ are

β ∼ N(0, τ−1β I) and σ ∼ Half-Cauchy(A)

with default hyperparameters

τβ = 10−10 and A = 105.

This is consistent with the recommendations given in Gelman (2006) for achieving non-informativeness for variance parameters. Infer.NET and BUGS do not offer direct specifi-cation of Half-Cauchy distributions and therefore we use the result:

if x| a ∼ Gamma(12 , a) and a ∼ Gamma(1

2 , 1/A2)

then x−1/2 ∼ Half-Cauchy(A).(1)

Page 4: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

4 Regression via Infer.NET

This result allows for the imposition of a Half-Cauchy prior using only Gamma distributionspecifications. Both Infer.NET and BUGS support the Gamma distribution.

2.3. Variational message passing and expectation propagation

Infer.NET has two inference engines, variational message passing (Winn and Bishop 2005) andexpectation propagation (Minka 2001), for performing fast deterministic approximate inferencein graphical models. Succinct summaries of variational message passing and expectationpropagation are provided in Appendices A and B of Minka and Winn (2008).

Generally speaking, variational message passing is more amenable to semiparametric re-gression than expectation propagation. It is a special case of mean field variational Bayes (e.g.Wainwright and Jordan 2008). The essential idea of mean field variational Bayes is to approx-imate joint posterior density functions such as p(θ1, θ2, θ3|D), where D denotes the observeddata, by product density forms such as

qθ1(θ1) qθ2(θ2) qθ3(θ3), qθ1,θ3(θ1, θ3) qθ2(θ2) or qθ1(θ1) qθ2,θ3(θ2, θ3). (2)

The choice of the product density form is usually made by trading off tractability againstminimal imposition of product structure. Once this is choice is made, the optimal q-densityfunctions are chosen to minimize the Kullback-Liebler divergence from the exact joint pos-terior density function. For example, if the second product form in (2) is chosen then theoptimal density functions q∗θ1,θ3

(θ1, θ3) and q∗θ2(θ2) are those that minimize

∫ ∫ ∫qθ1,θ3(θ1, θ3) qθ2(θ2) log

p(θ1, θ2, θ3|D)

qθ1,θ3(θ1, θ3) qθ2(θ2)

dθ1 dθ2 dθ3, (3)

where the integrals range over the parameter spaces of θ1, θ2 and θ3. This minimizationproblem gives rise to an iterative scheme which, typically, has closed form updates and goodconvergence properties. A by-product of the iterations is a lower-bound approximation tothe marginal likelihood p(D), which we denote by p(D).

Further details on, and several examples of, mean field variational Bayes are provided bySection 2.2 of Ormerod and Wand (2010). Each of these examples can also be expressed,equivalently, in terms of variational message passing.

In typical semiparametric regression models the subscripting on the q-density functions isquite cumbersome. Hence, it is suppressed for the remainder of the article. For example,q(θ1, θ3) is taken to mean qθ1,θ3(θ1, θ3).

Expectation propagation is also based on product density restrictions such as (2), but differsin its method of obtaining the optimal density functions. It works with a different versionof the Kullback-Leibler divergence than that given in (3) and, therefore, leads to differentiterative algorithms and approximating density functions.

2.4. Mixed model-based penalized splines

Mixed model-based penalized splines are a convenient way to model nonparametric func-tional relationships in semiparametric regression models, and are amenable to the hierarchi-cal Bayesian structures supported by Infer.NET. The penalized spline of a regression function

Page 5: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

Journal of Statistical Software 5

f , with mixed model representation, takes the generic form

f(x) = β0 + β1x +K∑

k=1

ukzk(x), ukind.∼ N(0, τ−1

u ). (4)

Here z1(·), . . . , zK(·) is a set of spline basis functions and τu controls the amount of penal-ization of the spline coefficients u1, . . . , uk. Throughout this article, we use O’Sullivan splinesfor the zk(·). Wand and Ormerod (2008) provides details on their construction. O’Sullivansplines lead to (4) being a low-rank version of smoothing splines, which is also used by theR function smooth.spline().The simplest semiparametric regression model is the Gaussian response nonparametric re-gression model

yiind.∼ N(f(xi), σ2

ε), (5)

where (xi, yi), 1 ≤ i ≤ n are pairs of measurements on continuous predictor and responsevariables. Mixed model-based penalized splines give rise to hierarchical Bayesian modelsfor (5) such as

yi|β0, β1, u1, . . . , uK , τεind.∼ N

(β0 + β1 xi +

∑Kk=1 ukzk(xi), τ−1

ε

),

uk|τuind.∼ N(0, τ−1

u ), β0, β1ind.∼ N(0, τ−1

β ),

τ−1/2u ∼ Half-Cauchy(Au), τ

−1/2ε ∼ Half-Cauchy(Aε).

(6)

Such models allow nonparametric regression to be performed using Bayesian inference en-gines such as BUGS and Infer.NET. Our decision to work with precision parameters, ratherthan the variance parameters (which are common in the semiparametric regression litera-ture), is driven by the former being the standard parametrization in BUGS and Infer.NET.It is convenient to express (6) using matrix notation. This entails putting

y ≡

y1...

yn

, X ≡

1 x1...

...1 xn

, Z ≡

z1(x1) · · · zK(x1)...

. . ....

z1(xn) · · · zK(xn)

(7)

and

β ≡[

β0

β1

]and u ≡

u1...

uK

. (8)

We then re-write (6) as

y |β,u, τεind.∼ N

(Xβ + Zu, τ−1

ε

),

u|τu ∼ N(0, τ−1u I), β ∼ N(0, τ−1

β I),

τ−1/2u ∼ Half-Cauchy(Au), τ

−1/2ε ∼ Half-Cauchy(Aε).

Page 6: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

6 Regression via Infer.NET

The effective degrees of freedom (edf) corresponding to (6) is defined to be

edf(τu, τε) ≡ tr([C>C + blockdiagτ2

βI2, (τu/τε) I]−1C>C)

(9)

and is a scale-free measure of the amount of fitting being performed by the penalized splines.Further details on effective degrees of freedom for penalized splines are given in Section 3.13of Ruppert et al. (2003).

Extension to bivariate predictors

The bivariate predictor extension of (5) is

yiind.∼ N(f(xi), σ2

ε), (10)

where the predictors xi, 1 ≤ i ≤ n, are each 2× 1 vectors. In many applications, the xis cor-respond to geographical location but they could be measurements on any pair of predictorsfor which a bivariate mean function might be entertained. Mixed model-based penalizedsplines can handle this bivariate predictor case by extending (4) to

f(x) = β0 + βT1 x +

K∑k=1

ukzk(x), ukind.∼ N(0, τ−1

u ) (11)

and setting zk to be appropriate bivariate spline functions. There are several options for do-ing this (e.g. Ruppert et al. 2009, Section 2.2). A relatively simple choice is described hereand used in the examples. It is based on thin plate spline theory, and corresponds to Section13.5 of Ruppert et al. (2003). The first step is to choose the number K of bivariate knots andtheir locations. We denote these 2 × 1 vectors by κ1, . . . ,κK . Our default rule for choos-ing knot locations involves feeding the xis and K into the clustering algorithm known asCLARA (Kaufman and Rousseeuw 1990) and setting the κk to be cluster centers. Next, formthe matrices

X =

1 xT1

......

1 xTn

,

ZK =

‖x1 − κ1‖2 log ‖x1 − κ1‖ · · · ‖x1 − κK‖2 log ‖x1 − κK‖...

. . ....

‖xn − κ1‖2 log ‖xn − κ1‖ · · · ‖xn − κK‖2 log ‖xn − κK‖

,

and Ω =

‖κ1 − κ1‖2 log ‖κ1 − κ1‖ · · · ‖κ1 − κK‖2 log ‖κ1 − κK‖...

. . ....

‖κK − κ1‖2 log ‖κK − κ1‖ · · · ‖κK − κK‖2 log ‖κK − κK‖

.

Based on the singular value decomposition Ω = Udiag(d)V T , compute Ω1/2 = Udiag(√

d)V T

and then set Z = ZKΩ−1/2. Then

zk(xi) = the (i, k) entry of Z

Page 7: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

Journal of Statistical Software 7

with ukind.∼ N(0, τ−1

u ).

3. Simple semiparametric model

The first example involves the simple semiparametric regression model

yi = β0 + β1 x1i + β2 x2i +∑K

k=1 uk zk(x2i) + εi, εiind.∼ N(0, τ−1

ε ), 1 ≤ i ≤ n, (12)

where zk(·) is a set of spline basis functions as described in Section 2.4. The correspondingBayesian mixed model can then be represented by

y|β,u, τε ∼ N(Xβ + Zu, τ−1ε I), u| τu ∼ N(0, τ−1

u I),

β ∼ N(0, τ−1β I), τ

−1/2u ∼ Half-Cauchy(Au), τ

−1/2ε ∼ Half-Cauchy(Aε),

(13)

where τβ , Au and Aε are user-specified hyperparameters and

y =

y1...

yn

, β =

β0

β1

β2

, u =

u1...

uK

,

X =

1 x11 x21...

...1 x1n x2n

, Z =

z1(x21) · · · zK(x21)...

. . ....

z1(x2n) · · · zK(x2n)

.

Infer.NET 2.5, Beta 2 does not support direct fitting of model (13) under product restriction

q(β,u, τu, τε) = q(β,u) q(τu, τε). (14)

We get around this by employing the same trick as that described Section 3.2 of Wang andWand (2011). It entails the introduction of the auxiliary n × 1 data vector a. By setting theobserved data for a equal to 0 and by assuming a very small number for κ, fitting the modelin (15) provides essentially the same result as fitting the model in (13). The actual modelimplemented in Infer.NET is

y|β,u, τε ∼ N(Xβ + Zu, τ−1ε I), a|β,u, τu ∼ N

([βu

],

[τ−1β I 00 τ−1

u I

]),

[βu

]∼ N(0, κ−1I), τu| bu ∼ Gamma(1

2 , bu),

bu ∼ Gamma(12 , 1/A2

u), τε| bε ∼ Gamma(12 , bε), bε ∼ Gamma(1

2 , 1/A2ε),

(15)

with the inputted a vector containing zeroes. While the full Infer.NET code is included inthe Appendix, we will confine discussion here to the key parts of the code that specify (15).

Page 8: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

8 Regression via Infer.NET

Specification of the prior distributions for τu and τε can be achieved using the followingInfer.NET code:

Variable<double> tauu = Variable.GammaFromShapeAndRate(0.5,Variable.GammaFromShapeAndRate(0.5,Math.Pow(Au,-2))).Named("tauu");

Variable<double> tauEps = Variable.GammaFromShapeAndRate(0.5,Variable.GammaFromShapeAndRate(0.5,Math.Pow(Aeps,-2))).Named("tauEps");

(16)

while the likelihood in (15) is specified by the following line:

y[index] = Variable.GaussianFromMeanAndPrecision(Variable.InnerProduct(betauWork,cvec[index]),tauEps);

(17)

The variable index represents a range of integers from 1 to n and enables loop-type struc-tures. Finally, the inference engine is specified to be variational message passing via thecode:

InferenceEngine engine = new InferenceEngine();engine.Algorithm = new VariationalMessagePassing();engine.NumberOfIterations = nIterVB;

(18)

with nIterVB denoting the number of mean field variational Bayes iterations. Note thatthis Infer.NET code is treating the coefficient vector[

βu

]as an entity, in keeping with product restriction (14).

Figures 1 and 2 summarize the results from Infer.NET fitting of (15) to a data set on the yields(g/plant) of 84 white Spanish onions crops in two locations: Purnong Landing and Virginia,South Australia. The response variable, y is the logarithm of yield, whilst the predictors areindicator of location being Virginia (x1) and areal density of the plants (plants/m2) (x2). Thehyperparameters were set at τβ = 10−10, Aε = 105, Au = 105 and κ = 10−10, while thenumber of mean field variational Bayes iterations was fixed at 100.

As a benchmark, Bayesian inference via MCMC was performed. To this end, the followingBUGS program was used:

for(i in 1:n)

mu[i] <- (beta0 + beta1*x1[i]+ beta2*x2[i] + inprod(u[],Z[i,]))y[i] ~ dnorm(mu[i],tauEps)

for (k in 1:K)

u[k] ~ dnorm(0,tauu)

beta0 ~ dnorm(0,1.0E-10) ; beta1 ~ dnorm(0,1.0E-10)beta2 ~ dnorm(0,1.0E-10) ;bu ~ dgamma(0.5,1.0E-10) ; tauu ~ dgamma(0.5,bu)bEps ~ dgamma(0.5,1.0E-10) ; tauEps ~ dgamma(0.5,bEps)

(19)

Page 9: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

Journal of Statistical Software 9

A burn-in length of 50000 was used, while 1 million samples were obtained from the poste-rior distributions. Finally, a thinning factor of 5 was used. The posterior densities for MCMCwere produced based on kernel density estimation with plug-in bandwidth selection via theR package KernSmooth (Wand and Ripley 2010). Figure 1 displays the fitted regression linesand pointwise 95% credible intervals. The estimated regression lines and credible intervalsfrom Infer.NET and MCMC fitting are highly similar. Figure 2 visualizes the approximateposterior density functions for β1, τ−1

ε and the effective degrees of freedom of the fit. Thevariational Bayes approximations for β1 and τ−1

ε are rather accurate. The approximate pos-terior density function for the effective degrees of freedom for variational Bayesian inferencewas obtained based on Monte Carlo samples of size 1 million from the approximate posteriordistributions of τ−1

ε and τ−1u .

Figure 1: Onions data. Fitted regression line and pointwise 95% credible intervals for varia-tional Bayesian inference by Infer.NET and MCMC.

4. Generalized additive model

The next example illustrates binary response variable regression through the model

yi|β,uind.∼ Bernoulli(F (Xβ + Zui)), u| τu ∼ N(0, τ−1

u I),

β ∼ N(0, τ−1β I), τ

−1/2u ∼ Half-Cauchy(Au), 1 ≤ i ≤ n,

(20)

where F (·) denotes an inverse link function and X , Z, τβ and Au are defined as in the previ-ous section. Typical choices of F (·) correspond to logistic regression and probit regression.

Page 10: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

10 Regression via Infer.NET

Figure 2: Variational Bayes approximate posterior density functions produced by Infer.NETand MCMC posterior density functions of key model parameters for fitting a simple semi-parametric model to the onions data set.

As before, introduction of the auxiliary variables a ≡ 0 enables Infer.NET fitting of theBayesian mixed model

yi|β,uind.∼ Bernoulli(F (Xβ + Zui)),

a|β,u, τu ∼ N

([βu

],

[τ−1β I 00 τ−1

u I

]),

[βu

]∼ N(0, κ−1I), τu| bu ∼ Gamma(1

2 , bu),

bu ∼ Gamma(12 , 1/A2

u), 1 ≤ i ≤ n.

(21)

The likelihood for the logistic regression case is specified as follows

VariableArray<bool> y = Variable.Array<bool>(index).Named("y");y[index] = Variable.BernoulliFromLogOdds(

Variable.InnerProduct(betauWork, cvec[index]));

(22)

while variational message passing is used for fitting purposes. Setting up the prior for τu

and specifying the inference engine is done as in code chunk (16) and (18), respectively. Forprobit regression, the last line of (22) is replaced by

y[index] = Variable.IsPositive(Variable.GaussianFromMeanAndVariance(Variable.InnerProduct(betauWork, cvec[index]), 1));

(23)

and expectation propagation is used

engine.Algorithm = new ExpectationPropagation(); (24)

Instead of the half-Cauchy prior in (20), a gamma prior with shape and rate equal to 2 isused for τu in the probit regression model

Variable<double> tauU = Variable.GammaFromShapeAndRate(2,2); (25)

Page 11: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

Journal of Statistical Software 11

Figure 3 visualizes the results for Infer.NET and MCMC fitting of a straightforward exten-sion of model (21) with inverse-logit and probit link functions to a breast cancer data set(Haberman 1976). This data set contains 306 cases from a study that was conducted between1958 and 1970 at the University of Chicago’s Billings Hospital on the survival of patients whohad undergone surgery for breast cancer. The binary response variable represents whetherthe patient died within 5 years after operation (died), while 3 predictor variables are used:age of patient at the time of operation (age), year of operation (year) and number of posi-tive axillary nodes (nodes) detected. The actual model is

diedi|β,uind.∼ Bernoulli(F (β0 + f1(agei) + f2(yeari) + f3(nodesi))), 1 ≤ i ≤ 306.

Note that all predictor variables were standardized prior to model fitting and the followinghyperparameters were used: τβ = 10−10, Au = 105, κ = 10−10 and the number of variationalBayes iterations was 100. Figure 3 illustrates that there is good agreement between the resultsfrom Infer.NET and MCMC.

(a)

(b)

Figure 3: Breast cancer data. Fitted regression lines and pointwise 95% credible intervalsfor logit (a) and probit (b) regression via variational Bayesian inference by Infer.NET andMCMC.

Page 12: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

12 Regression via Infer.NET

5. Robust nonparametric regression based on the t-distribution

A popular model-based approach for robust regression is to model the response variableto have a t-distribution. Outliers occur with moderate probability for low values of thet-distribution’s degrees of freedom parameter (Lange et al. 1989). More recently, Stauden-mayer et al. (2009) proposed a penalized spline mixed model approach to nonparametricregression using the t-distribution.

The robust nonparametric regression model that we consider here is a Bayesian variant ofthat treated by Staudenmayer et al. (2009):

yi|β0, β1,u, τε, νind.∼ t

(β0 + β1 xi +

∑Kk=1 uk zk(xi), τ−1

ε , ν)

, 1 ≤ i ≤ n,

u| τu ∼ N(0, τ−1u I), β ∼ N(0, τ−1

β I),

τ−1/2u ∼ Half-Cauchy(Au), τ

−1/2ε ∼ Half-Cauchy(Aε),

p(ν) discrete on a finite set N.

(26)

Restricting the prior distribution of ν to be that of a discrete random variable allows In-fer.NET fitting of the model using structured mean field variational Bayes (Saul and Jordan1996). This extension of ordinary mean field variational Bayes is described in Section 3.1 ofWand et al. (2011). Since variational message passing is a special case of mean field varia-tional Bayes this extension also applies. Model (26) can be fitted through calls to Infer.NETwith ν fixed at each value in N . The results of each of these fits are combined afterwards.Details are given below.

Another challenge concerning (26) is that Infer.NET does not support t-distribution specifi-cations. We get around this by appealing to the result

if x| g ∼ N(µ, (gτ)−1

)and g ∼ Gamma(ν

2 , ν2 ) then x ∼ t(µ, τ−1, ν). (27)

As before, we use the a ≡ 0 auxiliary data trick described in Section 3 and the Half-Cauchyrepresentation (1). These lead to following suite of models, for each fixed ν ∈ N , needing tobe run in Infer.NET:

y|β,u, τε ∼ N(Xβ + Zu, τ−1ε diag(1/g)),

a|β,u, τu ∼ N

([βu

],

[τ−1β I 00 τ−1

u I

]),

[βu

]∼ N(0, κ−1I)

u| τu ∼ N(0, τ−1u I), gi| ν

ind.∼ Gamma(ν2 , ν

2 ), β ∼ N(0, τ−1β I),

τu| bu ∼ Gamma(12 , bu), bu ∼ Gamma(1

2 , 1/A2u),

τε| bε ∼ Gamma(12 , bε), bε ∼ Gamma(1

2 , 1/A2ε),

(28)

where the matrix notation of (7), (8) is being used, g ≡ [g1, . . . , gn]T and τβ , Au and Aε areuser-specified hyperparameters with default values τβ = 10−10, Au = Aε = 105. The priorfor ν was set to be a uniform distribution over the atom set N , set to be 30 equally-spacednumbers between 0.05 and 10 inclusive.

Page 13: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

Journal of Statistical Software 13

After obtaining fits of (28) for each ν ∈ N , the approximate posterior densities are obtainedfrom

q(β,u) =∑ν∈N

qν(ν)q(β,u|ν), q(τu) =∑ν∈N

qν(ν) q(τu|ν),

q(τε) =∑ν∈N

q(ν) q(τε|ν), with q(ν) = p(ν|y) =p(ν)p(y|ν)∑

ν′∈N

p(ν ′)p(y|ν ′),

and p(y|ν) denotes the variational lower bound on the conditional likelihood p(y|ν).

Specification of the prior distribution for g is achieved using the following Infer.NET code:

VariableArray<double> g = Variable.Array<double>(index);g[index] = Variable.GammaFromShapeAndRate(nu/2,2/nu).ForEach(index);

(29)

while the likelihood in (28) is specified by:

y[index] = Variable.GaussianFromMeanAndPrecision(Variable.InnerProduct(betauWork,cvec[index]),g[index]*tauEps);

(30)

The lower bound log p(y|ν) can be obtained by creating a mixture of the current model withan empty model in Infer.NET. The learned mixing weight is then equal to the marginal log-likelihood. Therefore, an auxiliary Bernoulli variable is set up:

Variable<bool> auxML = Variable.Bernoulli(0.5).Named("auxML");IfBlock model = Variable.If(auxML);

(31)

The normal code for fitting the model in (28) is then enclosed with

IfBlock model = Variable.If(auxML); (32)

and

model.CloseBlock(); (33)

Finally, the lower bound log p(y|ν) is obtained from:

double marginalLogLikelihood = engine.Infer<Bernoulli>(auxML).LogOdds; (34)

Figure 4 presents the results of the structured mean field variational Bayes analysis usingInfer.NET fitting of model (28) to a data set on a respiratory experiment conducted by Pro-fessor Russ Hauser at Harvard School of Public Health, Boston, USA. The data correspond to60 measurements on one subject during two separate respiratory experiments. The responsevariable yi represents the log of the adjusted time of exhalation for xi equal to the time inseconds since exposure to air containing particulate matter. The adjusted time of exhalationis obtained by subtracting the average time of exhalation at baseline, prior to exposure tofiltered air. Interest centers upon the mean response as a function of time. The predictor andresponse variable were both standardized prior to Infer.NET analysis. The following hyper-parameters were chosen: τβ = 10−10, Aε = 105, Au = 105 and κ = 10−10, while the numberof variational Bayes iterations equaled 100. Bayesian inference via MCMC was performedas a benchmark.

Page 14: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

14 Regression via Infer.NET

Figure 4: Structured mean field variational Bayesian, based on Infer.NET, and MCMC fittingof the robust nonparametric regression model (26) to the respiratory experiment data. Left:Posterior mean and pointwise 95% credible sets for the regression function. Right: Approxi-mate posterior function for the degrees of freedom parameter ν.

Figure 4 shows that the variational Bayes fit and pointwise 95% credible sets are close tothe ones obtained using MCMC. Finally, the approximate posterior probability function andthe posterior from MCMC for the degrees of freedom ν are compared. The Infer.NET andMCMC results coincide quite closely.

6. Semiparametric mixed model

Since semiparametric regression models based on penalized splines fit in the mixed modelframework, semiparametric longitudinal data analysis can be performed by fusion with clas-sical mixed models (Ruppert et al. 2003). In this section we illustrate the use of Infer.NET forfitting the class of semiparametric mixed models having the form:

yij |β,u, Ui, τεind.∼ N

(β0 + βT xij + Ui +

K∑k=1

uk zk(sij), τ−1ε

),

Ui| τUind.∼ N(0, τ−1

U ), 1 ≤ j ≤ ni, 1 ≤ i ≤ m,

(35)

for analysis of the longitudinal data-sets such as that described in Bachrach et al. (1999). Herexij is a vector of predictors that enter the model linearly and sij is another predictor that en-ters the model non-linearly via penalized splines. For each 1 ≤ i ≤ m, Ui denotes the random

Page 15: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

Journal of Statistical Software 15

intercept for the ith subject. The corresponding Bayesian mixed model is represented by

y|β,u, τε ∼ N(Xβ + Zu, τ−1ε I), u| τU , τu ∼ N

(0,

[τ−1U I 00 τ−1

u I

]),

β ∼ N(0, τ−1β I), τ

−1/2u ∼ Half-Cauchy(Au), τ

−1/2ε ∼ Half-Cauchy(Aε),

τ−1/2U ∼ Half-Cauchy(AU ),

(36)

where y,β and X are defined in a similar manner as in the previous sections and τβ , Au, Aε

and AU are user-specified hyperparameters. Introduction of the random intercepts resultsin

u =

U1...

Um

u1...

uK

, Z =

1 · · · 0 z1(s11) · · · zK(s11)...

. . ....

.... . .

...1 · · · 0 z1(s1n1) · · · zK(s1n1)...

......

.... . .

...0 · · · 1 z1(sm1) · · · zK(sm1)...

. . ....

.... . .

...0 · · · 1 z1(smnm) · · · zK(smnm)

.

We again use the auxiliary data vector a ≡ 0 to allow direct Infer.NET fitting of the Bayesianlongitudinal penalized spline model

y|β,u, τε ∼ N(Xβ + Zu, τ−1ε I),

[βu

]∼ N(0, κ−1I),

a|β,u, τU , τu ∼ N

[ βu

],

τ−1β I 0 00 τ−1

U I 00 0 τ−1

u I

,

τu| bu ∼ Gamma(12 , bu), bu ∼ Gamma(1

2 , 1/A2u), τε| bε ∼ Gamma(1

2 , 1/bε),

bε ∼ Gamma(12 , 1/A2

ε), τU | bU ∼ Gamma(12 , bU ), bU ∼ Gamma(1

2 , 1/A2U ).

(37)

Specification of the prior distribution for τU can be achieved in Infer.NET in a similar manneras prior specification in code chunk (16).

Figure 5 shows the Infer.NET fits of (37) to the spinal bone mineral density data (Bachrachet al. 1999). A population of 230 female subjects aged between 8 and 27 was followed overtime and each subject contributed either one, two, three, or four spinal bone mineral densitymeasurements. Age enters the model non-linearly and corresponds to sij in (35). Data onethnicity are available and the entries of xij correspond to the indicator variables for Black(x1ij), Hispanic (x2ij) and White (x3ij), with Asian ethnicity corresponding to the baseline.The following hyperparameters were chosen: τβ = 10−10, Aε = 105, Au = 105, AU = 105

and κ = 10−10, while the number of mean field variational Bayes iterations was set to 100.Figure 5 suggests that there exists a statistically significant difference in mean spinal bone

Page 16: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

16 Regression via Infer.NET

Figure 5: Spinal bone mineral density data. Fitted regression line and pointwise 95% credibleintervals based on mean field variational Bayesian inference by Infer.NET and MCMC.

mineral density between Asian and Black subjects. This difference is confirmed by the ap-proximate posterior density functions in Figure 6. No statistically significant difference isfound between Asian and Hispanic subjects and between Asian and White subjects.

Page 17: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

Journal of Statistical Software 17

Figure 6: Variational Bayes approximate posterior density functions produced by Infer.NETof ethnic group parameters for fitting a simple semiparametric mixed model to the spinalbone mineral density data set.

7. Geoadditive model

We turn our attention to geostatistical data, for which the response variable is geographicallyreferenced and the extension of generalized additive models, known as geoadditive models(Kammann and Wand 2003), applies. Such models allow for a pair of continuous predictors,typically geographical location, to have a bivariate functional impact on the mean response.An example geoadditive model is

yi ∼ N(f1(x1i) + f2(x2i) + fgeo(x3i, x4i), τ−1

ε

), 1 ≤ i ≤ n. (38)

It can be handled using the spline basis described in Section 2.4 as follows:

yi|β,u1,u2,ugeo, τε

ind.∼ N(β0 + β1 x1i + β2 x2i + β3 x3i + β4 x4i

+K1∑k=1

u1k z1k(x1i) +K2∑k=1

u2k z2k(x2i) +Kgeo∑k=1

ugeok zgeo

k (x3i, x4i), τ−1ε

), 1 ≤ i ≤ n,

(39)

where the z1k and z2k are univariate spline basis functions as used in each of this article’sprevious examples and the zgeo

k are the bivariate spline basis functions, described in Section2.4. The corresponding Bayesian mixed model is represented by

y|β,u, τε ∼ N(Xβ + Zu, τ−1ε I), β ∼ N(0, τ−1

β I),

u ≡

u1

u2

ugeo

∣∣∣∣∣ τu1, τu2, τgeo ∼ N

0,

τ−1u1 I 0 00 τ−1

u2 I 00 0 τ−1

geo I

,

τ−1/2u ∼ Half-Cauchy(Au), τ

−1/2ε ∼ Half-Cauchy(Aε),

τ−1/2geo ∼ Half-Cauchy(Ageo),

(40)

where y,β, u and X are defined in a similar manner as in the previous sections and τβ , Au,

Page 18: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

18 Regression via Infer.NET

Aε and Ageo are user-specified hyperparameters. The Z matrix is

Z =

z11(x11) · · · z1K1(x11) z21(x21) · · · z2K2(x21) zgeo1 (x31, x41) · · · zgeo

Kgeo(x31, x41)

.... . .

......

. . ....

.... . .

...z11(x1n) · · · z1K1(x1n) z21(x2n) · · · z2K2(x2n) zgeo

1 (x3n, x4n) · · · zgeoKgeo

(x3n, x4n)

.

Infer.NET can be used to fit the Bayesian geoadditive model

y|β,u, τε ∼ N(Xβ + Zu, τ−1ε I),

[βu

]∼ N(0, κ−1I),

a|β,u, τu, τgeo ∼ N

[ βu

],

τ−1β I 0 0 00 τ−1

u1 I 0 00 0 τ−1

u2 I 00 0 0 τ−1

geo I

,

τu1| bu1 ∼ Gamma(12 , bu1), bu1 ∼ Gamma(1

2 , 1/A2u1), τu2| bu2 ∼ Gamma(1

2 , bu2),

bu2 ∼ Gamma(12 , 1/A2

u2), τε| bε ∼ Gamma(12 , bε), bε ∼ Gamma(1

2 , 1/1A2ε),

τgeo| bgeo ∼ Gamma(12 , bgeo), bgeo ∼ Gamma(1

2 , 1/A2geo)

where a ≡ 0 as in all previous examples.

We illustrate geoadditive model fitting in Infer.NET using data on residential property pricesof 37,676 residential properties that were sold in Sydney, Australia, during 2001. The datawere assembled as part of of an unpublished study by A. Chernih and M. Sherris at the Uni-versity of New South Wales, Australia. The response variable is the logarithm of sale price inAustralian dollars. Apart from geographical location, several predictor variables are avail-able. For this example we selected weekly income in Australian dollars, the distance fromthe coastline in kilometres, the particulate matter 10 level and the nitrogen dioxide level. Themodel is a straightforward extension of the geoadditive model conveyed by (38)–(40). In ad-dition, all predictor variables and the dependent variable were standardized before modelfitting. The hyperparameters set to τβ = 10−10, Aε = 105 = Au1 = . . . = Au4 = Ageo = 105,while the number of variational message passing iterations was equal to 100 and κ set to10−10.

Figure 7 summarizes the housing prices for the Sydney metropolitan area based on the fittedInfer.NET model, while fixing the four predictor variables at their mean levels. This resultclearly shows that the sale price is higher for houses in Sydney’s eastern and northern sub-urbs whereas it is strongly decreased for houses in Sydney’s western suburbs.

Figure 8 visualizes the fitted regression line and pointwise 95% credible intervals for income,distance from the coastline, particulate matter 10 level and nitrogen dioxide level at a fixedgeographical location (longitude = 151.10, latitude = −33.91). As expected, a higher in-come is associated with a higher sale price and houses close to the coastline are more expen-sive. The sale price is lower for a higher particulate matter 10 level, while a lower nitrogendioxide level is generally associated with a lower sale price.

Page 19: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

Journal of Statistical Software 19

Figure 7: Sydney real estate data. Estimated housing prices for the Sydney metropolitan areafor variational Bayesian inference by Infer.NET.

8. Bayesian lasso regression

A Bayesian approach to lasso (least absolute shrinkage selection operator) regression wasproposed by Park and Casella (2008). For linear regression, the lasso approach essentiallyinvolves the replacing

βj | τβind.∼ N(0, τ−1

β ) by βj | τβind.∼ Laplace(0, τ−1

β ) (41)

where βj is the coefficient of the jth predictor variable. Replacement (41) corresponds to theform of the penalty changing from

λ

p∑j=1

β2j to λ

p∑j=1

|βj |.

Page 20: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

20 Regression via Infer.NET

Figure 8: Sydney real estate data. Fitted regression line and pointwise 95% credible intervalsfor variational Bayesian inference by Infer.NET.

For frequentist lasso regression (Tibshirani 1996) the latter penalty produces sparse regres-sion fits, in that the estimated coefficients become exactly zero. In the Bayesian case theBayes estimates do not provide exact annihilation of coefficients, but produce approximatesparseness (Park and Casella 2008).

At this point we note that, during the years following the appearance of Park and Casella(2008), several other proposals for sparse shrinkage of the βj appeared in the literature (e.g.Armagan et al. 2013; Carvalho et al. 2010; Griffin and Brown 2011). Their accommodation inInfer.NET could also be entertained. Here we restrict attention to Laplace-based shrinkage.

We commence with the goal of fitting the following model in Infer.NET:

y|β0,β, τε ∼ N(1β0 + Xβ, τ−1ε I), βj | τβ

ind.∼ Laplace(0, τ−1β )

β0 ∼ N(0, τ−1β0

), τβ ∼ Half-Cauchy(Aβ), τε ∼ Half-Cauchy(Aε).(42)

Page 21: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

Journal of Statistical Software 21

The current release of Infer.NET does not support the Laplace distribution, so we require anauxiliary variable representation in a similar vein to what was used for the t-distribution inSection 5. We first note the distributional statement

x|τ ∼ Laplace(0, τ−1) if and only if x|g ∼ N(0, g), g|τ ∼ Gamma(1, 12 τ), (43)

which is exploited by Park and Casella (2008). However, auxiliary variable representation(43) is also not supported by Infer.NET, due to violation of its conjugacy rules. We get aroundthis by working with the alternative auxiliary variable set-up:

x| c ∼ N(0, 1/c), c| d ∼ Gamma(M,M d), d|τ ∼ Gamma(1, 12 τ) (44)

which is supported by Infer.NET, and leads to good approximation to the Laplace(0, τ−1)distribution when M is large. For any given M > 0, the density function of x satisfyingauxiliary variable representation (44) is

p(x|τ ;M) =∫ ∞

0

∫ ∞

0(2π/c)−1/2 exp

(−1

2 c x) (Md)M

Γ(M)cM−1 exp(−Mdc)

× 12τ exp

(−1

2 dτ)

dc dd

=τ1/2 Γ

(M + 1

2

)2Γ(M) M1/2 1F1

(M + 1

2 ; 12 ;

τx2

4M

)− 1

2 τ1/2 |x| 1F1

(M + 1; 3/2;

τx2

4M

)where 1F1 denotes the degenerate hypergeometric function (e.g. Gradshteyn and Ryzhik

1994). Figure 9 shows p(x|τ ;M) for τ = 1 and M = 1, 10, 30. The approximation to theLaplace(0, 1) density function is excellent for M as low as 10.

Figure 9: The exact Laplace(0, 1) density function p(x) = 12 exp(−|x|) and three approxima-

tions to it based on p(x|τ ;M) for τ = 1 and M = 1, 10, 30.

The convergence in distribution of random variables having the density function p(x|τ ;M)to a Laplace(0, τ−1) random variable as M → ∞ may be established using (27) and the factthat the family of t distributions tends to a Normal distribution as the degrees of freedom

Page 22: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

22 Regression via Infer.NET

parameter increases, and then mixing this limiting distribution with a Gamma(1, 12 τ) vari-

able.

In lieu of (42), the actual model fitted in Infer.NET is:

y|β0,β, τε ∼ N(1β0 + Xβ, τ−1ε I),

a|β0,β, c1, . . . , cp ∼ N

[ β0

β

],

τ−1β0

00 diag

1≤j≤p

(1/cj)I

,

[β0

β

]∼ N(0, κ−1I), cj | dj

ind.∼ Gamma(M,M dj),

dj |τβind.∼ Gamma(1, 1

2τβ), τβ|bβ ∼ Gamma(12 , bβ), bβ ∼ Gamma(1

2 , 1/A2β),

τε| bε ∼ Gamma(12 , bε), bε ∼ Gamma(1

2 , 1/A2ε).

(45)

We use κ = 10−10,M = 100, τβ0 = 10−10, Aβ = Aε = 105.

Our illustration of (45) involves data from a diabetes study that was also used in Park andCasella (2008). The sample size is n = 442 and the number of predictor variables is p = 10.The response variable is a continuous index of disease progression one year after baseline.A description of the predictor variables is given in Efron et al. (2004). Their abbreviations,used in Park and Casella (2008), are: (1) age, (2) sex, (3), bmi, (4), map, (5), tc, (6) ldl, (7), hdl,(8), tch, (9) ltg, and (10) glu.

Figure 10 shows the fits obtained from both Infer.NET and MCMC. We see that the corre-spondence is very good, especially for the regression coefficients.

9. Measurement error model

In some situations some variables may be measured with error, i.e., the observed data arenot the true values of those variables themselves, but a contaminated version of these vari-ables. Examples of such situations include AIDS studies where CD4 counts are known tobe measured with errors (Wu 2002) or air pollution data (Bachrach et al. 1999). Carroll et al.(2006) offers a comprehensive treatment of measurement error models. As described there,failure to account for measurement error can result in biased and misleading conclusions.

Let (xi, yi), 1 ≤ i ≤ n, be a set of predictor/response pairs that are modeled according to

yi|xi, β0, β1, τεind.∼ N(β0 + β1xi, τ

−1ε ), 1 ≤ i ≤ n. (46)

However, instead of observing the xis we observe

wi|xiind.∼ N(xi, τ

−1z ), 1 ≤ i ≤ n. (47)

In other words, the predictors are measured with error with τz controlling the extent of thecontamination. In general τz can be estimated through validation data, where some of the xi

values are observed, or replication data, where replicates of the wi values are available. To

Page 23: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

Journal of Statistical Software 23

Figure 10: Approximate posterior density functions of model parameters in fitting (45) todata from a diabetes study.

simplify exposition we will assume that τz is known. Furthermore, we will assume that thexis are Normally distributed:

xi|µx, τxind.∼ N(µx, τ−1

x ), 1 ≤ i ≤ n, (48)

where µx and τx are additional parameters to be estimated.Combining (46), (47) and (48) and, including aforementioned priors for variances, a Bayesianmeasurement error model can be represented by

y|x,β, τε ∼ N(Xβ, τ−1ε I), w|x ∼ N(x, τ−1

z I), x|µx, τx ∼ N(µx1, τ−1x I),

β ∼ N(0, τ−1β I), τ

−1/2ε ∼ Half-Cauchy(Aε),

µx ∼ N(0, τ−1µx

) and τ−1/2x ∼ Half-Cauchy(Ax)

(49)

where β = [β0, β1], X = [1,x], τβ , τµ, Aε and Ax are user-specified constants and the vectorsy and w are observed. We set τβ = τµ = 10−10 and Aε = Ax = 105.

Page 24: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

24 Regression via Infer.NET

Invoking (1), we arrive at the model

y|x,β, τε ∼ N(Xβ, τ−1ε I), w|x ∼ N(x, τ−1

z I), x|µx, τx ∼ N(µx1, τ−1x I)

β ∼ N(0, τ−1β I), τε| bε ∼ Gamma(1

2 , 1/bε), bε ∼ Gamma(12 , 1/A2

ε),

µx ∼ N(0, τ−1µx

), τx| bx ∼ Gamma(12 , 1/bx) and bx ∼ Gamma(1

2 , 1/A2x).

(50)

Infer.NET 2.5, Beta 2 does not appear to be able to fit the model (50) under the productrestriction

q(β, τε, bε,x, µx, τx, bx) = q(β0, β1) q(µx) q(x) q(τε, τx) q(bε, bx).

However, Infer.NET was able to fit this model with

q(β, τε, bε,x, µx, τx, bx) = q(β0)q(β1) q(µx)q(x) q(τε, τx) q(bε, bx). (51)

Unfortunately, fitting under restriction (51) leads to poor accuracy. One possible remedyinvolves the centering transformation:

wi = wi − w.

Under this transformation, and with diffuse priors, the marginal posterior distributions ofβ0 and β1 are nearly independent.

Let q(β0), q(β1), q(µx), q(x), q(τε, τx) and q(bε, bx) be the optimal values of q(β0), q(β1), q(µx),q(x), q(τε, τx) and q(bε, bx) when the transformed wis are used in place of the wis. Thiscorresponds to the transformation on the X matrix

X = XR where R =[

1 0−w 1

].

Suppose that

q(β0) ∼ N(µq(β0), σ2q(β0)), q(β1) ∼ N(µq(β1), σ

2q(β1)),

q(µx) ∼ N(µq(µx), σ2q(µx)), and q(xi) ∼ N(µq(xi), σ

2q(xi)

), 1 ≤ i ≤ n.

Then we can back-transform approximately using

q(β0, β1) ∼ N(µq(β),Σq(β)), q(µx) ∼ N(µq(µx), σ2q(µx)),

q(xi) ∼ N(µq(xi), σ2q(xi)

), 1 ≤ i ≤ n,

where

µq(β) = R[

µq(β0)

µq(β1)

], Σq(β) = R

[σ2

q(β0) 00 σ2

q(β1)

]RT ,

µq(µx) = µq(µx) + w, σ2q(µx) = σ2

q(µx),

µq(xi) = µq(xi) + w, σ2q(xi)

= σ2q(xi)

, 1 ≤ i ≤ n,

q(τε, τx) = q(τε, τx) and q(bε, bx) = q(bε, bx).

Page 25: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

Journal of Statistical Software 25

To illustrate the use of Infer.NET we simulated data according to

xiind.∼ N(1/2, 1/36), wi|xi

ind.∼ N(xi, 1/100) and yi|xiind.∼ N(0.3 + 0.7xi, 1/16) (52)

for 1 ≤ i ≤ n with n = 50. Results from a single simulation are illustrated in Figure 11.Similar results were obtained from other simulated data sets. From Figure 11 we see rea-sonable agreement of posterior density estimates produced by Infer.NET and MCMC for allparameters. Extension to the case where the mean of the yis are modeled nonparametricallyis covered in Pham et al. (2013). However, the current version of Infer.NET does not supportmodels of this type. Such versatility limitations of Infer.NET are discussed in Section 11.1.

Figure 11: Variational Bayes approximate posterior density functions produced by Infer.NETfor simulated data (52).

Page 26: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

26 Regression via Infer.NET

10. Missing predictor model

Missing data is a commonly occurring issue in statistical problems. Naïve methods for deal-ing with this issue, such as ignoring samples containing missing values, can be shown to bedemonstrably optimistic (i.e., standard errors are deflated), biased or simply an inefficientuse of the data. Little and Rubin (2002) contains a detailed discussion of the various issuesat stake.

Consider a simple linear regression model with response yi with predictor xi:

yi|xi, β0, β1, τεind.∼ N(β0 + β1xi, τ

−1ε ), 1 ≤ i ≤ n. (53)

Suppose that some of the xis are missing and let ri be an indicator xi being observed. Specif-ically,

ri =

1 if xi is observed,0 if xi is missing

for 1 ≤ i ≤ n.

A missing data model contains at least two components:

• A model for the underlying distribution of the variable that is subject to missingnessdata. We will use

xi|µx, τxind.∼ N(µx, τ−1

x ), 1 ≤ i ≤ n. (54)

• A model for the missing data mechanism, which models the probability distributionof ri.

As detailed in Faes et al. (2011), there are several possible models, with varying degrees ofsophistication, for the missing data mechanism. Here the simplest such model, known asmissing completely at random, is used:

y|x,β, τε ∼ N(Xβ, τ−1ε I), x|µx, τx ∼ N(µx1, τ−1

x I), riind.∼ Bernoulli(p),

β ∼ N(0, τ−1β I), τε| bε ∼ Gamma(1

2 , 1/bε), bε ∼ Gamma(12 , 1/A2

ε),

µx ∼ N(0, τ−1µ ), τx | bx ∼ Gamma(1

2 , bx) and bx ∼ Gamma(12 , 1/A2

x),

(55)

where β = [β0, β1], X = [1,x], τβ , τµ, Aε and Ax are user-specified hyperparameters. Again,we will use τβ = τµ = 10−10 and Aε = Ax = 105.

The simulated data that we use in our illustration of Infer.NET involves the following samplesize and ‘true values’:

n = 50, β0 = 0.3, β1 = 0.7, µx = 0.5, τx = 36, and p = 0.75. (56)

Putting p = 0.75 implies that, on average, 25% of the predictor values are missing completelyat random.

Infer.NET 2.5, Beta 2 is not able to fit the model (50) under the product restriction

q(β, τε, bε,xmis, µx, τx, bx) = q(β0, β1) q(xmis) q(τε, τx) q(bε, bx), (57)

Page 27: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

Journal of Statistical Software 27

where xmis denotes the vector of missing predictors, but is able to handle

q(β, τε, bε,xmis, µx, τx, bx) = q(β0) q(β1) q(xmis) q(τε, τx) q(bε, bx), (58)

and was used in our illustration of Infer.NET for such models.

We also used BUGS to perform Bayesian inference via MCMC as a benchmark for compari-son of results. For similar reasons as in the previous section fitting under this restriction (58)leads to poor results. Instead we perform the centering transformation

xi = xi − xobs

where xobs is the mean of the observed x values. This transformation makes the marginalposterior distributions of β0 and β1 nearly independent.

Let q(β0), q(β1), q(µx), q(xmis), q(τε, τx) and q(bε, bx) be the optimal values of q(β0), q(β1),q(µx), q(xmis), q(τε, τx) and q(bε, bx) when the transformed xis are used in place of the xis.This corresponds to the transformation on the X matrix

X = XR where R =[

1 0−xobs 1

].

Suppose that

q(β0) ∼ N(µq(β0), σ2q(β0)), q(β1) ∼ N(µq(β1), σ

2q(β1)),

q(µx) ∼ N(µq(µx), σ2q(µx)), and q(xi) ∼ N(µq(xmis,i), σ

2q(xmis,i)

), 1 ≤ i ≤ nmis,

then we back-transform approximately using

q(β0, β1) ∼ N(µq(β),Σq(β)), q(µx) ∼ N(µq(µx), σ2q(µx)),

q(xmis,i) ∼ N(µq(xmis,i), σ2q(xmis,i)

), 1 ≤ i ≤ n,

where

µq(β) = R[

µq(β0)

µq(β1)

], Σq(β) = R

[σ2

q(β0) 00 σ2

q(β1)

]RT ,

µq(µx) = µq(µx) + xobs, σ2q(µx) = σ2

q(µx),

µq(xmis,i) = µq(xmis,i) + xobs, σ2q(xmis,i)

= σ2q(xmis,i)

, 1 ≤ i ≤ n,

q(τε, τx) = q(τε, τx) and q(bε, bx) = q(bε, bx).

Results from a single simulation are illustrated in Figure 12. Similar results were obtainedfrom other simulated data sets. From Figure 12 we see reasonable agreement of posteriordensity estimates produced by Infer.NET and MCMC for all parameters. Extension to thecase where the mean of y is modeled nonparametrically is covered in Faes et al. (2011). How-ever, the current version of Infer.NET does not support models of this type.

Page 28: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

28 Regression via Infer.NET

Figure 12: Variational Bayes approximate posterior density functions produced by Infer.NETdata simulated according to (56).

11. Comparison with BUGS

We now make some comparisons between Infer.NET and BUGS in the context of Bayesiansemiparametric regression.

11.1. Versatility comparison

These comments mainly echo those given in Section 5 of Wang and Wand (2011), so are quitebrief. BUGS is much more versatile than Infer.NET, with the latter subject to restrictions suchas standard distributional forms, conjugacy rules and not being able to handle models suchas (13) without the trick manifest in (15). The measurement error and missing data regres-sion examples given in Sections 9 and 10 are feasible in Infer.NET for parametric regression,but not for semiparametric regression such as the examples in Sections 4, 5 and 8 of Marleyand Wand (2010). Nevertheless, as demonstrated in this article, there is a wide variety of

Page 29: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

Journal of Statistical Software 29

semiparametric regression models that can be handled by Infer.NET.

11.2. Accuracy comparison

In general, BUGS can always be more accurate than Infer.NET since MCMC suffers onlyfrom Monte Carlo error, which can be made arbitrarily small via larger sample sizes. TheInfer.NET inference engines, expectation propagation and variational message passing, haveinherent approximation errors that cannot be completely eliminated. However, our exam-ples show that the accuracy of Infer.NET is quite good for a wide variety of semiparametricregression models.

11.3. Timing comparison

Table 2 gives some indication of the relative computing times for the examples in the pa-per. In this table we report the average elapsed (and standard error) of the computing timesover 100 runs with the number of variational Bayes or expectation propagation iterationsset to 100 and the MCMC sample sizes set at 10000. This was sufficient for convergence inthese particular examples. All examples were run on the third author’s laptop computer (64bit Windows 8 Intel i7-4930MX central processing unit at 3GHz with 32GB of random ac-cess memory). We concede that comparison of deterministic and Monte Carlo algorithms isfraught with difficulties. However, convergence criteria aside, these times give an indicationof the performance in terms of the implementations of each of the algorithms for particularmodels on a fast 2014 computer. Note that we did not fit the geoadditive model in Section 7via BUGS due to the excessive time required.

section semiparametric time in seconds time in secondsnumber regression model for Infer.NET for BUGS

3 Simple semiparametric regression 1.55 (0.01) 8.60 (0.01)4 Generalized additive model (logistic) 3.09 (0.01) 81.30 (0.13)4 Generalized additive model (probit) 25.80 (0.07) 79.85 (0.04)5 Robust nonparametric regression 80.38 (0.03) 22.56 (0.06)6 Semiparametric mixed model 666.73 (0.56) 477.59 (0.06)7 Geoadditive model 1231.12 (3.05) —— ——-8 Bayesian lasso regression 1.80 (0.01) 199.59 (0.30)9 Measurement error model 1.50 (0.01) 7.05 (0.02)

10 Missing predictor model 1.53 (0.01) 5.51 (0.03)

Table 2: Average run times (standard errors) in seconds over 100 runs of the methods foreach of the examples in the paper.

Table 2 reveals that Infer.NET offers considerable speed-ups compared with BUGS for mostof the examples. The exceptions are the robust nonparametric regression model of Section5 and the semiparametric mixed model of Section 6. The slowness of the robust nonpara-metric regression fit is mainly explained by the multiple calls to Infer.NET, corresponding tothe degrees of freedom grid. The semiparametric mixed model is quite slow in the currentrelease of Infer.NET due to the full sparse design matrices being carried around in the calcu-lations. Recently developed streamlined approaches to variational inference for longitudinal

Page 30: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

30 Regression via Infer.NET

and multilevel data analysis (Lee and Wand 2014) offer significant speed-ups. The geoad-ditive model of Section 7 is also slow to fit, with the large design matrices being a likelyreason.

12. Summary

Through several examples, the efficacy of Infer.NET for semiparametric regression analysishas been demonstrated. Generally speaking, the fitting and inference is shown to be quitefast and accurate. Models with very large design matrices are an exception and can takesignificant amounts of time to fit using the current release of Infer.NET.

Our survey of Infer.NET in the context of semiparametric regression will aid future analysesof this type via fast graphical models software, by building upon the examples presentedhere. It may also influence future directions for the development of fast graphical modelsmethodology and software.

Appendix: Details of Infer.NET fitting of a simple semiparametric model

This section provides an extensive description of the Infer.NET program for semiparametricregression analysis of the Onions data set based on model (15) in Section 3. The data arefirst transformed as explained in Section 3 and these transformed versions are representedby y and C = [X Z]. Thereafter, the text files K.txt, y.txt, Cmat.txt, sigsqBeta.txt,Au.txt, Aeps.txt and nIterVB.txt are generated. The first three files contain the num-ber of spline basis functions, y and C, respectively. The following three text files each con-tain a single number and represent the values for the hyperparameters: τβ = 10−10, Aε = 105

and Au = 105. The last file, nIterVB.txt, contains a single positive number (i.e., 100) thatspecifies the number of mean field variational Bayes iterations. All these files were set up inR.

The actual Infer.NET code is a C] script, which can be run from Visual Studio 2010 or DOSwithin the Microsoft Windows operating system. The following paragraphs explain the dif-ferent commands in the C] script. Firstly, all required C] and Infer.NET libraries are loaded:

using System;using System.Collections.Generic;using System.Text;using System.IO;using System.Reflection;using MicrosoftResearch.Infer;using MicrosoftResearch.Infer.Distributions;using MicrosoftResearch.Infer.Maths;using MicrosoftResearch.Infer.Models;

Next, the full path name of the directory containing the above-mentioned input files needsto be specified:

string dir = "C:\\research\\inferNet\\onions\\";

The values for the hyperparameters, number of variational Bayes iterations and number ofspline basis functions are imported using the commands:

Page 31: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

Journal of Statistical Software 31

double tauBeta = new DataTable(dir+"tauBeta.txt").DoubleNumeric;double Au = new DataTable(dir+"Au.txt").DoubleNumeric;double Aeps = new DataTable(dir+"Aeps.txt").DoubleNumeric;int nIterVB = new DataTable(dir+"nIterVB.txt").IntNumeric;int K = new DataTable(dir+"K.txt").IntNumeric;

Reading in the data y and C proceeds as follows:

DataTable yTable = new DataTable(dir+"y.txt");DataTable C = new DataTable(dir+"Cmat.txt");

These commands make use of the C] object class DataTable. This class, which was writtenby the authors, facilitates the input of general rectangular arrays of numbers when in a textfile. The following line extracts the number of observations from the data matrix C:

int n = C.numRow;

The observed values of C and y, which are stored in objects C and yTable, are assigned tothe objects cvec and y via the next set of commands:

Vector[] cvecTable = new Vector[n];for (int i = 0; i < n; i++)

cvecTable[i] = Vector.Zero(3+K);for (int j = 0; j < 3+K; j++)

cvecTable[i][j] = C.DataMatrix[i,j];

Range index = new Range(n).Named("index");VariableArray<Vector> cvec = Variable.Array<Vector>(

index).Named("cvec");cvec.ObservedValue = cvecTable;VariableArray<double> y = Variable.Array<double>(index).Named("y");y.ObservedValue = yTable.arrayForIN;

The function arrayForIN is member of the class DataTable and stores the data as anarray to match the type of y.ObservedValue. The resulting objects are now directly usedto specify the prior distributions. First, the commands in code chunk (16) in Section 3 areused to set up priors for τu and τε, while the trick involving the auxiliary variable a ≡ 0 in(15) is coded as:

Page 32: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

32 Regression via Infer.NET

Vector zeroVec = Vector.Zero(3+K);PositiveDefiniteMatrix betauPrecDummy =

new PositiveDefiniteMatrix(3+K,3+K);for (int j = 0; j < 3+K; j++)

betauPrecDummy[j,j] = kappa;Variable<Vector> betauWork =

Variable.VectorGaussianFromMeanAndPrecision(zeroVec,betauPrecDummy).Named("betauWork");

Variable<double>[] betauDummy = new Variable<double>[3+K];for (int j = 0; j < 3+K; j++)

betauDummy[j] = Variable.GetItem(betauWork,j);

Variable<double>[] a = new Variable<double>[3+K];for (int j = 0; j < 3; j++)

a[j] = Variable.GaussianFromMeanAndVariance(betauDummy[j],tauBeta);

a[j].ObservedValue = 0.0;for (int k = 0 ; k < K; k++)

a[3+k] = Variable.GaussianFromMeanAndPrecision(betauDummy[3+k],tauU);

a[3+k].ObservedValue = 0.0;

The command to specify the likelihood for model (15) is listed as code chunk (17) in Sec-tion 3. The inference engine and the number of mean field variational Bayes iterations arespecified by means of code chunk (18). Finally, the following commands write the estimatedvalues for the parameters of the approximate posteriors to files named mu.q.betau.txt,Sigma.q.betau.txt, parms.q.tauEps.txt and parms.q.tauu.txt:

SaveData.SaveTable(engine.Infer<VectorGaussian>(betauWork).GetMean(),dir+"mu.q.betau.txt");

SaveData.SaveTable(engine.Infer<VectorGaussian>(betauWork).GetVariance(),dir+"Sigma.q.betau.txt");

SaveData.SaveTable(engine.Infer<Gamma>(tauEps),dir+"parms.q.tauEps.txt");

SaveData.SaveTable(engine.Infer<Gamma>(tauu),dir+"parms.q.tauu.txt");

These commands involve the C] function named SaveTable, which is a method in theclass SaveData. We wrote SaveTable to facilitate writing the output from Infer.NET toa text file. Summary plots, such as Figure 1, can be made in R after back-transforming theapproximate posterior density parameters.

Acknowledgments

This research was partially funded by the Australian Research Council Discovery ProjectDP110100061. We are grateful to Andrew Chernih for his provision of the Sydney property

Page 33: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

Journal of Statistical Software 33

data.

References

Armagan A, Dunson D, Lee J (2013). “Generalized Double Pareto Shrinkage.” StatisticaSinica, 23, 119–143.

Bachrach LK, Hastie T, Wang MC, Narasimhan B, Marcus R (1999). “Bone Mineral Acqui-sition in Healthy Asian, Hispanic, Black, and Caucasian Youth: A Longitudinal Study.”Journal of Clinical Endocrinology & Metabolism, 84(12), 4702–4712.

Carroll RJ, Ruppert D, Stefanski LA, Crainiceanu C (2006). Measurement Error in NonlinearModels: A Modern Perspective. 2nd edition edition. Chapman and Hall, London.

Carvalho CM, Polson NG, Scott J (2010). “The Horseshoe Estimator for Sparse Signals.”Biometrika, 97, 465–480.

Efron B, Hastie T, Johnstone I, Tibshirani R (2004). “Least Angle Regression.” The Annals ofStatistics, 32, 407–451.

Faes C, Ormerod JT, Wand MP (2011). “Variational Bayesian Inference for Parametric andNonparametric Regression with Missing Data.” Journal of the American Statistical Associa-tion, 106, 959–971.

Gelman A (2006). “Prior Distributions for Variance Parameters in Hierarchical Models.”Bayesian Analysis, 1, 515–533.

Gradshteyn I, Ryzhik I (1994). Table of Integrals, Series, and Products. Academic Press, Boston.

Griffin J, Brown P (2011). “Bayesian Hyper-Lassos with Non-Convex Penalization.” Aus-tralian and New Zealand Journal of Statistics, 53, 423–442.

Haberman S (1976). “Generalized Residuals for Log-Linear Models.” In Proceedings of the 9thInternational Biometrics Conference, pp. 104–122. Boston, USA.

Kammann EE, Wand MP (2003). “Geoadditive Models.” Journal of the Royal Statistical SocietyC, 52, 1–18.

Kaufman L, Rousseeuw PJ (1990). Finding Groups in Data: An Introduction to Cluster Analysis.Wiley, New York.

Knowles DA, Minka TP (2011). “Non-Conjugate Message Passing for Multinomial and Bi-nary Regression.” Advances in Neural Information Processing Systems 24, pp. 1701– 1709.

Lange KL, Little RJA, Taylor JMG (1989). “Robust Statistical Modeling Using the t-Distribution.” The Journal of the American Statistical Association, 84, 881–896.

Lee Y, Wand M (2014). “Streamlined Mean Field Variational Bayes for Longitudinal andMultilevel Data Analysis.” In progress.

Page 34: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

34 Regression via Infer.NET

Little RJA, Rubin DB (2002). Statistical Analysis with Missing Data. 2nd edition edition. Wiley,New York.

Lunn D, Thomas A, Best NG, Spiegelhalter DJ (2000). “WinBUGS – A Bayesian ModellingFramework: Concepts, Structure, and Extensibility.” Statistics and Computing, 10, 325–337.

Marley JK, Wand MP (2010). “Non-Standard Semiparametric Regression Via BRugs.” Journalof Statistical Software, 37, 1–30.

Minka T (2001). “Expectation Propagation for Approximate Bayesian Inference.” Proceedingsof Conference on Uncertainty in Artificial Intelligence, pp. 51–76.

Minka T (2005). “Divergence Measures And Message Passing.” Microsoft Research TechnicalReport Series, MSR-TR-2008-173, 1–17.

Minka T, Winn J (2008). “Gates: A Graphical Notation for Mixture Models.” Microsoft Re-search Technical Report Series, MSR-TR-2008-185, 1–16.

Minka T, Winn J, Guiver J, Knowles D (2013). Infer.NET 2.5. URL http://research.microsoft.com/infernet.

Ormerod JT, Wand MP (2010). “Explaining Variational Approximations.” The AmericanStatistician, 64, 140–153.

Park T, Casella G (2008). “The Bayesian Lasso.” Journal of the American Statistical Association,103, 681–686.

Pham T, Ormerod JT, Wand MP (2013). “Mean Field Variational Bayesian Inference for Non-parametric Regression with Measurement Error.” Computational Statistics and Data Analy-sis, 68, 375–387.

Ruppert D, Wand MP, Carroll RJ (2003). Semiparametric Regression. Cambridge UniversityPress, New York.

Ruppert D, Wand MP, Carroll RJ (2009). “Semiparametric Regression During 2003–2007.”Bayesian Analysis, 3, 1193–1265.

Saul LK, Jordan MI (1996). “Exploiting Tractable Substructures in Intractable Networks.”In Advances in Neural Information Processing Systems, pp. 435–442. MIT Press, Cambridge,Massachusetts.

Staudenmayer J, Lake EE, Wand MP (2009). “Robustness for General Design Mixed ModelsUsing the t-Distribution.” Statistical Modelling, 9, 235–255.

Tibshirani R (1996). “Regression Shrinkage and Selection Via the Lasso.” Journal of the RoyalStatistical Society, Series B, 58, 267–288.

Wainwright M, Jordan MI (2008). “Graphical Models, Exponential Families, and VariationalInference.” Foundations and Trends in Machine Learning, 1, 1–305.

Wand MP (2009). “Semiparametric Regression and Graphical Models.” Australian and NewZealand Journal of Statistics, 51, 9–41.

Page 35: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

Journal of Statistical Software 35

Wand MP, Ormerod JT (2008). “On O’Sullivan Penalised Splines and Semiparametric Re-gression.” Australian and New Zealand Journal of Statistics, 50, 179–198.

Wand MP, Ormerod JT, Padoan SA, Frühwirth R (2011). “Mean Field Variational Bayes forElaborate Distributions.” Bayesian Analysis, 6(4), 847–900.

Wand MP, Ripley BD (2010). KernSmooth 2.23. Functions for Kernel Smoothing Correspondingto the Book: Wand, M.P. and Jones, M.C. (1995) Kernel Smoothing. URL http://cran.r-project.org.

Wang SSJ, Wand MP (2011). “Using Infer.NET for Statistical Analyses.” The American Statis-tician, 65, 115–126.

Winn J, Bishop CM (2005). “Variational Message Passing.” Journal of Machine Learning Re-search, 6, 661–694.

Wu L (2002). “A Joint Model for Nonlinear Mixed-Effects Models with Censored Responseand Covariates Measured with Error, with Application to AIDS Studies.” Journal of theAmerican Statistical Association, 97, 700–709.

Page 36: Semiparametric Regression Analysis via Infer...later sections. Each of Sections 3–10 illustrates a different type of semiparametric regression analysis via Infer.NET. All code is

36 Regression via Infer.NET

Affiliation:Jan LutsTheSearchParty.com Pty Ltd.Level 1, 79 Commonwealth Street,Surry Hills 2011, AustraliaE-mail: [email protected]

Shen S.J. WangDepartment of MathematicsThe University of QueenslandBrisbane 4072, AustraliaE-mail: [email protected]

John T. OrmerodSchool of Mathematics and StatisticsUniversity of SydneySydney 2006, AustraliaE-mail: [email protected]: http://www.maths.usyd.edu.au/u/jormerod/

Matt P. WandSchool of Mathematical SciencesUniversity of Technology, SydneyBroadway 2007, AustraliaE-mail: [email protected]: http://matt-wand.utsacademics.info

Journal of Statistical Software http://www.jstatsoft.org/published by the American Statistical Association http://www.amstat.org/

Volume VV, Issue II Submitted: yyyy-mm-ddMMMMMM YYYY Accepted: yyyy-mm-dd