Integrate the latent variable out to obtain the hospital's marginal likelihood:
For this becomes . It is a geometric distribution on the nonnegative integers, with success probability . The transformation concerns the likelihood, so no Jacobian is inserted here.
The observed-data likelihood function integrates out the latent variable:
Choose an initial parameter with positive likelihood. At iteration , the E-step of the EM algorithm forms the entire expected complete-data log-likelihood
The expectation is under the conditional missing-data law at the old parameter, while the argument remains free. The M-step then chooses
The observed data stay fixed throughout. This is not obtained merely by substituting the conditional mean of into a nonlinear log-likelihood: the expectation of all required complete-data terms must be taken. A generalized EM step only requires , which suffices for the monotonicity proved next. Exact maximization assumes that an admissible maximizer exists.
Model 2 is an errors-in-variables model: the follow-up regression depends on a latent true baseline rather than substituting its noisy observation. A common normal distribution for the true baselines provides partial pooling and allows uncertainty about each baseline to propagate to the regression coefficients and predictions. Conditional on the shared parameters, the child-specific factorization is
The Directed acyclic graph below includes the shared parameters, the two local latent variables, both observed measurements, and the deterministic regression mean. The outer plate repeats over children and the inner plate over follow-up visits. Filled nodes are observed; rectangular mean nodes are deterministic.
Figure 1.
Directed graph of the latent-baseline random-intercept model, including shared priors, baseline measurement error and repeated follow-up visits
. Details.
One complete adapted BUGS specification uses the non-centered form of the random intercept, retaining the original priors and adding proper broad priors for and :
for (i in 1:N) {
  z[i] ~ dnorm(0, 1)
  alpha[i] <- delta + tau*z[i]
  truebase[i] ~ dnorm(theta, baseprec)
  baseline[i] ~ dnorm(truebase[i], noiseprec)
  for (j in 1:3) {
    followmean[i,j] <- alpha[i] + beta*log(time[i,j]) + gamma*truebase[i]
    followup[i,j] ~ dnorm(followmean[i,j], noiseprec)
  }
}
noiseprec ~ dgamma(0.001, 0.001)
beta ~ dunif(-100, 100)
gamma ~ dunif(-100, 100)
delta ~ dunif(-100, 100)
tau ~ dunif(0, 100)
theta ~ dunif(-100, 100)
psi ~ dunif(0, 100)
baseprec <- 1/(psi*psi)
Here is the number of children, baseline and followup contain the observed data, and dnorm uses precision rather than variance. The priors on the newly introduced population baseline mean and standard deviation are explicit choices, not consequences of the likelihood; sensible alternatives can be checked for sensitivity. The code uses the noisy baseline only in its own measurement likelihood, and uses truebase in every follow-up mean.
Unobserved heterogeneity is persistent variation between subjects arising from unmeasured characteristics. A subject-specific latent variable or random intercept can represent it. Subjects with high latent success propensities tend to succeed repeatedly, so their observed outcomes can have positive serial correlation even when outcomes are conditionally independent given that propensity. Apparent persistence therefore need not imply true state dependence.
Conditional on , the auxiliary binomial distribution gives and . Thus large makes close to . The law of total variance also gives
The latent variable encodes the first draw increasingly accurately.
Multiply the beta distribution density of , the conditional binomial distribution mass of , and the conditional beta distribution density of . With the beta function, the full joint density, relative to counting measure in and Lebesgue measure in the two probabilities, is
Here and both probabilities lie in . The printed joint expression omits the factor . It is a constant when is fixed and only the two probabilities vary, but is not a constant for the full joint probability distribution. Keeping it is essential when summing over the latent variable.
Put and . Dropping factors independent of , the multinomial likelihood and uniform prior give the posterior density
Multiplying this by the stipulated binomial distribution for the latent variable cancels the factor :
Consequently the two full conditional distributions are
Start with , sample from its binomial distribution, then sample a new from its Beta distribution, and repeat. The binomial distribution can be sampled by adding independent Bernoulli random variables. For the Beta distribution, take independent and and return ; integer-shape gamma distributions are sums of independent unit-rate exponential distributions. Both shapes are positive even when some observed counts vanish.
Each Gibbs sampler update preserves the augmented posterior distribution, so its marginal distribution is the required posterior distribution. The positive full conditional distributions on the interior allow exploration of the entire support. These iterates are generally dependent; they are not the independent exact draws constructed in the later parts.
Write for the directed edges from parent to child and for the state at site . The global Markov property for an undirected graph on this tree, together with the specified parent transitions, gives the complete-data likelihood function
One can obtain the factorization by successively removing terminal subtrees: after conditioning on their parent, each subtree is independent of the rest. The root factor and transition products also show that different sites are independent. Only ancestral states are latent variables.
At the current Markov kernel , define expected transition counts
The E-step of the expectation-maximization algorithm is
Maximize separately for each row under and . For , the Lagrange multiplier equation is , with zero-count entries set to zero at a boundary maximum. Thus the EM transition-count update on a tree is
If , that row does not occur in ; any row probability distribution, including its previous value, maximizes the objective.
The expected counts can be computed exactly by the Felsenstein pruning algorithm and an outward belief propagation pass. For one site, let be the conditional probability of observations in the subtree below , given state . For a leaf with observed state , . For an internal vertex,
Define as the joint mass of state at and all observations outside its subtree. The root has . For a child of , put
The edge posterior probability required above is
Multiply the inside and outside factors to obtain the joint mass of the observations and endpoint states; division by the site likelihood function proves this expression. Sum over edges and sites to form . The two passes take operations on a binary tree. Scaling messages or computing them logarithmically avoids underflow.
A strictly positive initial Markov kernel ensures for every observed leaf pattern, so every E-step is defined. At a later boundary iterate, require positive likelihood for the actual data and restrict the conditional distribution to its support. EM likelihood monotonicity proves that the update cannot decrease observed-data likelihood function. It is a maximum-likelihood iteration, not a guarantee of finding the global maximum-likelihood estimate; different initial kernels may lead to different stationary points.
The most plausible cause is strong dependence between the latent variables and covariance hyperparameters in their joint posterior distribution. In the usual conditionally independent Gaussian process classification model, put , , and . The probit regression likelihood is , while has a multivariate normal distribution with covariance matrix .
For distinct inputs and positive length scales, is positive definite. Its Gaussian probability density function contributes
The unit-rate exponential prior distribution on therefore gives
Its scale is tightly tied to the current magnitude and shape of . Changing changes the eigenvectors and eigenvalues of its covariance matrix; a latent vector typical under the old covariance may be very atypical under a substantially different one. Holding fixed can thus restrict the range of a hyperparameter update, and holding the hyperparameters fixed restricts the next latent-function update. Even exact sampling of each full conditional distribution can move slowly along a narrow ridge of the joint posterior distribution.
Binary observations provide limited information about the absolute size of large correctly signed latent values. This can leave substantial scale uncertainty and strengthen the dependence. Long correlation lengths can also make the covariance matrix nearly singular and the latent coordinates highly dependent. These are plausible explanations for a large mixing time, not proofs that every data set causes slow convergence. A blocked Gibbs sampler removes dependence within its chosen blocks, but not dependence between them. Repeated identical inputs should be represented by one shared latent value; otherwise the nominal Gaussian matrix is singular and the displayed inverse formula must be replaced by a representation on its support.
Let and regard as the latent variable. At iteration , the E-step forms
The M-step updates
This is the expectation-maximization algorithm for the posterior objective: including in the complete-data log density makes the maximizer a maximum a posteriori estimate rather than a maximum-likelihood estimate.
For one object, the probabilistic graphical model factorization is
Each factor is the normal distribution density specified by the model. This factorization displays the conditional independences of the latent variables and the noisy observations .
Let be independent standard logistic random variables and define the latent variable
Set exactly when . If is the logistic cumulative distribution function, its symmetry and the identity give
which is precisely the fitted logistic regression.
Let and . With the stated improper hyperpriors, the unnormalized posterior density is
Its Directed acyclic graph has, for each star, the arrows
followed by the deterministic observation arrows
The latent variables are repeated inside a plate indexed by ; all hyperparameters lie outside that plate.
Phylogenetic tree Created 2026-10-06 Updated 2026-10-13
A phylogenetic tree describes ancestral relationships. In a probabilistic graphical model on a rooted tree, latent variables at ancestral vertices are inferred from observations at leaves using belief propagation.
Random effect 2026-10-05
A random effect is a latent variable used to describe variation between observational units or dependence among related observations. Its distribution supplements the fixed effects used in statistical modelling. Independent random effects produce extra variability; correlated random effects can produce serial dependence.
Imagine an instrument measuring the same fixed quantity twice on each unit. Across units the persistent signal is a latent variable; the two measurement errors are fresh, mutually independent random variables, also independent of . Assume they have mean zero and common finite variance , while has mean and variance . Then
Thus the Pearson correlation coefficient is when . Both measurements retain the same marginal mean and variance. Repetition does not make the entire population collapse toward ; it changes what we expect after selecting on .
For , further assuming normal distributions for and both measurement errors gives the conditional expectation
Since , this predicted reading is closer to than is. Independence and zero mean errors alone do not justify this linear conditional expectation: without the normal distribution assumption the same expression is the linear least-squares projection, and the actual conditional expectation can be nonlinear. Correlated errors, a changing signal, or different error variances require their own model; a noisy reading by itself supplies no universal shrinkage factor.
Select units with first reading , keep that membership fixed, and measure the same units again. The first reading now has a truncated normal distribution. For a general finite threshold , write for the standard normal density and for the standard normal distribution function. Since ,
The tower property of conditional expectation lets us average the line over the selected group.[ref] At this gives
The average second reading is below the selection threshold even though every selected first reading exceeded it. This is a group expectation; any finite generated group's sample mean fluctuates around it. Selecting again on would define a different group and answer a different question.
The latent variable decomposition makes the apparent drop especially clear. Gaussian conditioning gives and . Thus
The first measurement error has zero unconditional mean, but positive selected mean. The second measurement error stays centered because it is independent of selection on . The persistent signal never changed.
Figure 1.
Selection captures an extreme first error while the persistent signal stays fixed
. Original synthetic repeated measurements, not actual measurements. Left: 40 generated units selected by ; orange trajectories move farther from zero. Right: analytic selected-group expectations decompose the first and second readings into persistent latent variable and measurement error. Black dots give generated group sample means after selecting from 60,000 synthetic units; their small departures from the bar totals reflect sampling variation. All selections use the first reading only. Details.
Unobserved heterogeneity 2026-10-07
Persistent unmeasured differences between individuals can generate outcome dependence after adjusting for observed covariates. A random intercept is one representation. Conditional independence given that latent variable need not persist after it is integrated out; apparent history dependence can therefore occur without true state dependence.
WinBUGS 2026-10-14
Software for Bayesian inference through Markov chain Monte Carlo in directed statistical models. Its model language uses dnorm(mean, precision), so the second argument is inverse variance; dcat indexes a supplied probability vector, and dbern introduces a binary latent variable. The model is declarative, so the order of deterministic node definitions does not impose procedural evaluation order.