liveBook · Manning

Latent variable

As explained in Causal AI

A latent variable is an unobserved variable in a statistical model, here represented as a lower-dimensional continuous encoding of image causes.

A latent variable is included in a statistical model but is not directly observed in the data. Suppose records show who threw rocks and whether a window broke, but not the strength of each impact. Impact strength can still appear in a model of how the window broke; its values remain latent in the records. section 2.3.2

Observed variables have an observational joint distribution. A model that also includes latent variables has a full joint distribution; marginalizing over the latent variables recovers the observational distribution. The observed data alone need not determine which data-generating process—or which latent structure—produced them. section 2.3.2

Figure 2.25 Marginalizing the full joint distribution over the latent variables produces the observational joint distribution.
figure

Shows how marginalizing unseen variables connects a model’s full joint distribution to the distribution of observed variables. section 2.3.2

In a causal DAG, an unobserved node should not be dropped merely because it is absent from the dataset. Its parameters may be difficult or impossible to identify, even with unlimited data. That does not automatically make the causal quantity of interest unidentifiable. Latency also narrows DAG testing: if genetic factors affecting both smoking and lung cancer are unobserved, conditional-independence tests involving genetics cannot be run, though other model constraints may still be testable. section 3.1.10 section 4.5

Estimating an unrecorded survey variable

If education is missing from a transportation survey, retain it as a latent node in the causal graph. In pgmpy, structural expectation maximization can estimate parameters with that node declared latent. Its estimated categories are numbered; assigning those numbers meanings such as “high school” and “university” requires further assumptions. section 3.1.10

An image model gives latent variables another role. A variational autoencoder uses a continuous Z with fewer dimensions than a 28 × 28 image to encode image information. An encoder maps an image and its labels toward Z; a decoder uses Z and the labels to generate an image. Z can stand in for otherwise unmodeled influences such as stroke thickness or font variation. A learned encoding is not, however, the same as discovering those actual causes: a classical VAE does not itself define Z as causal. section 5.2.2

Reconstructing images through the encoder and decoder, generating random images, and tracking loss provide checks during training. In a causal inference workflow, variational inference with a VAE can handle latent variables before a trained graphical model is transformed by an intervention and used to estimate an average treatment effect. In a partially observable decision problem, a latent state instead represents an environment state inferred from incomplete observations; depending on the causal graph, unobserved state can also confound conclusions about actions and utility. section 5.2.4 section 11.6 section 12.5.3

How Causal AI covers it

How deep it goes
Defines latent variables, explains marginalization and identification limits, and implements estimation and image encoding; learned encodings are not established as actual causes.
Examples
Uses unseen rock-impact strength, unrecorded survey education, unobserved smoking-related genetics, and lower-dimensional digit-image encodings.
What it assumes
Builds the definition from observed data and joint distributions, then assumes familiarity with causal DAGs for identification and testing applications.
What you can do after
Apply it via pgmpy to estimate parameters with a latent survey node, while checking whether category labels and causal quantities are identifiable.
How it connects
Connects latent variables to joint distributions, causal DAGs, identifiability, conditional independence, variational autoencoders, and partially observable Markov decision processes.

Also explained in

Compare how 3 books explain latent variable →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Causal AI. The section links point to the parts of the book it draws on.