Foundations  ·  The Valuation Engineer

Latent Variable — Prolog companion

Machine-readable Prolog representation of this entry's facts, rules, and worked example.

Download 006-latent-variable.pl
%% 006-latent-variable.pl
%%
%% Prolog companion to Foundations Vol. 1, Issue 1, Article 006
%%   Title:    Latent Variable
%%   Author:   Bert Craytor
%%   Concept:  latent_variable
%%   Version:  0.1.0-draft

% =====================================================================
% DICTIONARY IMPORT
% =====================================================================

:- use_module('../../../../tools/dictionary/dictionary').
:- dictionary_release('dictionary-2026.1').

% --- From the dictionary (loaded via :- use_module above) -----------
% term(latent_variable, "Latent Variable", measurement_theory,
%      "A latent variable is an unobserved attribute that influences
%       observed outcomes, whose value must be inferred from its
%       effects on observable variables rather than measured directly.",
%      published, 'dictionary-2026.1').
%
% term(residual, ...).
% term(omitted_variable_bias, ...).
% term(proxy_variable, ...).
% term(residual_constraint_approach, ...).  % synonym: rca
%
% introduced_by(latent_variable, spearman_1904).
% formalized_by(latent_variable, bollen_2002).
% introduced_by(residual_constraint_approach, craytor_2025).
% depends_on(latent_variable, characteristics_space).
% ---------------------------------------------------------------------

:- use_terms([ latent_variable, residual, omitted_variable_bias,
               proxy_variable, residual_constraint_approach,
               characteristics_space, hedonic_price_function,
               implicit_price, hedonic_regression ]).
:- use_relations([related/2, depends_on/2,
                  introduced_by/2, formalized_by/2]).

% =====================================================================
% ARTICLE SUBJECT
% =====================================================================

article_concept(latent_variable).
article_issue(volume(1), number(1), year(2026)).
article_id('foundations.2026.006').

% =====================================================================
% LOCAL VOCABULARY
% =====================================================================

local_term(unobserved).
local_term(noise).
local_term(signal).
local_term(structured_signal).
local_term(uad_3_6).
local_term(c3_condition_rating).
local_term(mls).
local_term(permit_records).
local_term(neighborhood_micro_effect).

% =====================================================================
% THE CENTRAL CLAIM
% =====================================================================

claim(latent_variables_accumulate_in_residuals,
    "Unobserved-but-relevant attributes do not vanish when omitted from the model; their effects accumulate in the residual, appearing as noise from the model's perspective but as structured signal from the data-generating process's perspective.").

claim(residuals_are_mixture,
    "Standard regression theory treats residuals as iid Gaussian noise; the latent-variable view treats them as a mixture of sampling noise AND signal from unobserved attributes.").

% =====================================================================
% THREE CONTEXTS WHERE APPRAISERS ENCOUNTER LATENT VARIABLES
% =====================================================================

appraiser_encounter(quality_and_condition_proxies,
    "UAD 3.6 'C3 condition' is a single ordinal scale collapsing a multi-dimensional construct (deferred maintenance, finish wear, mechanical-systems age, presentation). The rating is a proxy_variable for a latent construct.").

appraiser_encounter(unexplained_grid_disagreement,
    "When three adjusted comps disagree by more than expected, the disagreement is rarely all sampling noise; usually reflects an attribute not yet identified or adjusted for.").

appraiser_encounter(unobserved_recent_improvement,
    "A recent remodel, roof replacement, or permitted ADU buildout may be observable in person but not in MLS/assessor data — observable to the appraiser but latent to the regression.").

% =====================================================================
% DEFENSIBILITY ISSUES
% =====================================================================

defensibility_issue(omitted_variable_bias,
    "If a latent variable is correlated with an observed variable, its effect leaks into the observed variable's coefficient. Observed-variable coefficients are conditional on what is missing from the model.").

defensibility_issue(residual_interpretation,
    "Treat residuals as a mixture, not pure noise. A residual that correlates with location, sale date, appraiser identity, or any other observable suggests the latent variable can be partially recovered.").

defensibility_issue(model_selection_limits,
    "The latent variables that matter most are often hardest to add (condition fine-grain, quality, micro-locational effects). Sometimes the defensible response is to allocate the unexplained variance to the residual rather than force-fit additional variables.").

% =====================================================================
% WORKED EXAMPLE: COMP H'S ANOMALOUS RESIDUAL
% =====================================================================

:- consult('../../kb/pacifica_comps').

% Comp H's regression residual from entry 005.
comp_h_residual_dollars(46455).

% The latent attribute revealed by investigation.
comp_h_latent_attribute(kitchen_remodel).
comp_h_latent_attribute_value_estimate(60000).

% Why the estimated residual is smaller than the latent attribute's
% true contribution: regression spreads small portions of the latent
% effect across correlated coefficients, biasing them upward.
residual_smaller_than_truth_explanation(
    "Regression spreads small portions of the latent effect across the other coefficients via correlations, biasing them slightly upward in correlated dimensions.").

% =====================================================================
% THREE OPERATIONAL CONSEQUENCES
% =====================================================================

operational_consequence(outlier_residual_is_evidence,
    "The first response to Comp H's residual is to investigate, not to drop. An in-person inspection or permit search reveals the remodel; the model's failure has diagnostic value.").

operational_consequence(other_coefficients_slightly_biased,
    "View, condition, and lot coefficients absorbed small fractions of the remodel effect via correlations with Comp H's observed characteristics. Bias is small at n=8 but not zero.").

operational_consequence(residuals_carry_recoverable_structure,
    "Residuals in residential appraisal data are systematically not iid Gaussian. They reflect structured contributions of unobserved attributes that can be partially recovered: this is the Residual Constraint Approach intuition.").

% =====================================================================
% CONNECTION TO RESIDUAL CONSTRAINT APPROACH (RCA)
% =====================================================================
%
% The single-comp illustration here is the simplest case of the RCA
% intuition. With richer modeling, residual structure is partitioned
% into recognizable latent factors.

framework_reference(residual_constraint_approach, craytor_2025).

rca_intuition(
    "Treat the residual itself as a latent-variable signal to be modeled rather than discarded. Latent variables are not a nuisance to be controlled away; they are the next frontier of defensible valuation modeling.").

rca_factor_examples(
    [condition_fine_grain, quality_fine_grain, functional_utility]).

% Two-level condition/quality structure (RCA protocol; mirrors the prose).
rating_levels(condition, condition_coarse_grain, condition_fine_grain).
rating_levels(quality,   quality_coarse_grain,   quality_fine_grain).

coarse_to_fine_grain_protocol(
    "Regress on the appraiser's coarse-grain C1-C6/Q1-Q6 ratings to obtain approximate value contributions; move those contributions out of the measured attributes back into the residual; reassign them to the fine-grain latent variables and refine against MLS public remarks. In the end, the fine-grain value contribution replaces the coarse-grain value contribution.").

% =====================================================================
% INFERENCE RULE: anomalous-residual detection
% =====================================================================
%
% A property's residual is "anomalous" if its magnitude exceeds the
% typical residual band reported in entry 005 (+/-$18,000 for the other
% seven comps). Useful for flagging properties whose hedonic prediction
% suggests a latent attribute warrants investigation.

typical_residual_band(18000).

anomalous_residual(P, R) :-
    comp_h_residual_dollars(R0),  % stand-in: this entry references the
                                  % residual computed in entry 005; future
                                  % integration would pull from there.
    P == comp_h,
    R = R0.

% =====================================================================
% CROSS-REFERENCES
% =====================================================================

cross_reference(characteristics_space).
cross_reference(hedonic_price_function).
cross_reference(implicit_price).
cross_reference(hedonic_regression).

The source above is the canonical Prolog form of this entry. It imports the journal-wide dictionary (Issues/tools/dictionary/) and can be queried using SWI-Prolog. See the article's prose form (PDF / HTML galleys) for the human-readable exposition.