SPB Git forge

spb/wp14_uqo

Public
3commits 1branches 1releases
1.5 MBsize
maindefault branch
35 min agolast push
Python 52.4% TeX 47.6%
17.1 KB · 313 lines latex
Raw Blame History
1% ============================================================================2\section{Methodology}3\label{sec:methodology}4% ============================================================================56Our empirical strategy has two parts: a feature-engineering pipeline that turns raw7listings into an analysis-ready design matrix (Sections~\ref{subsec:structural}--%8\ref{subsec:vision}), and a hedonic regression that maps those features to price9(Section~\ref{subsec:econometrics}).1011\subsection{Theoretical Framework}12\label{subsec:theory}1314Following \citet{rosen1974hedonic}, a house is a bundle of $K$ characteristics15$\mathbf{z}=(z_1,\dots,z_K)$, and the market clears through a hedonic price function16$P(\mathbf{z})$ that equates the marginal bid of buyers to the marginal offer of17sellers. A buyer with income $y$ and preferences $U(x,\mathbf{z})$ over a18numéraire good $x$ and housing attributes chooses $\mathbf{z}$ to solve19%20\begin{equation}21  \max_{x,\,\mathbf{z}}\; U(x,\mathbf{z})22  \quad\text{s.t.}\quad y = x + P(\mathbf{z}),23  \label{eq:consumer}24\end{equation}25%26which yields the first-order condition that, at the optimum, the implicit27(\emph{marginal}) price of each attribute equals the buyer's marginal willingness to28pay:29%30\begin{equation}31  p_k(\mathbf{z}) \;\equiv\; \frac{\partial P(\mathbf{z})}{\partial z_k}32  \;=\; \frac{\partial U/\partial z_k}{\partial U/\partial x},33  \qquad k = 1,\dots,K.34  \label{eq:implicit}35\end{equation}36%37Equation~\eqref{eq:implicit} is the object of interest: the slope of the hedonic38surface in the direction of attribute~$z_k$. The empirical task is to recover39$P(\mathbf{z})$---and hence its gradient---from observed prices and characteristics.40The linear model of Section~\ref{subsec:econometrics} imposes a parametric form on41$P(\cdot)$ and reads the implicit prices off its coefficients; the machine-learning42estimators of Section~\ref{sec:benchmark} approximate $P(\cdot)$ nonparametrically,43trading the closed-form gradient for predictive flexibility. Two caveats apply44throughout. The observed price is an asking price, so $P(\cdot)$ is the hedonic45function of sellers' offers rather than of transactions; and the machine-generated46attributes are measured with error and chosen by the seller, so their coefficients47are predictive associations rather than structural marginal prices48(Section~\ref{subsec:limits}).4950\subsection{Structural and Locational Attributes}51\label{subsec:structural}5253Structural attributes are extracted by deterministic rules. Living area and lot area54are reported in heterogeneous units (\texttt{"1535 sqft"}, \texttt{"1,333.2 ft²"},55\texttt{"11 561.52 ft²"}, \texttt{"961.6 m2"}); we parse each string and convert all56areas to square feet. For Realtor.ca listings that report room-by-room dimensions57(e.g.\ \texttt{"23 ft ,4 in x 13 ft ,8 in"}) but no aggregate living area, we sum the58parsed room areas and calibrate the total against listings where both are observed;59the median ratio of reported area to summed-room area is~0.98, so the reconstructed60value is used directly to fill missing living area. Age is computed as61$2026-\text{year built}$, entered together with its square to allow a non-monotone62depreciation profile. Bedrooms, bathrooms, parking spaces, and storeys are taken63from the attribute block. Missing values are imputed by the within-property-type64median, and each imputed field is accompanied by a ``\texttt{has\_}'' indicator so65that the regression can distinguish observed from imputed values.6667Location is captured by \textbf{municipality fixed effects}. City names are68normalized (Realtor.ca appends neighbourhood qualifiers in parentheses, which we69strip), and municipalities with fewer than 20 listings are pooled into a residual70category, leaving 195 city effects; the pooled group of small municipalities is the71omitted (reference) category, so every reported municipality effect is a premium or72discount relative to a listing in a small municipality. In robustness checks we73replace the municipality effects by \textbf{forward sortation area (RTA) effects},74the first three characters of the postal code, which are available for all but one75listing: 419 RTAs appear in the sample, of which 250 have at least 20 listings and76receive their own effect. Property-type fixed effects and a source indicator complete77the locational and platform controls.7879\subsection{Rule-Based Amenities and Room Detail}80\label{subsec:amenities}8182Fifteen amenity indicators are detected by bilingual (French/English) keyword83matching over the concatenated feature list, description, and title: swimming pool,84waterfront, garage, fireplace, central air conditioning or heat pump, finished85basement, proximity to water, cul-de-sac, proximity to a golf course, ski hill,86park, school, highway, and public transit, and the absence of rear neighbours. From87the Realtor.ca room block we additionally construct room-detail indicators---presence88of a primary bedroom, a basement, an office, a family room, a workshop, a wine89cellar, a sunroom, a mezzanine, a library, and a laundry room---together with the90room and storey counts. Two listing-quality signals, the number of photographs91(capped at~60) and the presence of a virtual tour, proxy for the marketing tier of92the listing. Finally, following the evidence of Section~\ref{subsec:text_content},93two language indicators (English, mixed; French omitted) and the description length94are available as controls.9596\subsection{Language-Model Specifications from Text}97\label{subsec:llm}9899Free-text descriptions contain valuation-relevant information that resists keyword100extraction: whether the home is turnkey or a fixer-upper, whether the kitchen or101bathroom has been renovated, the flooring and countertop materials, the heating102system, the presence of a water view, and income potential. We extract these as a103fixed set of structured specifications using a large language model104(\texttt{gpt-4o-mini}, OpenAI, called through the Chat Completions API in July 2026)105with \emph{schema-constrained decoding}: the request specifies a strict JSON schema106with closed enumerations and required fields, so the API validates the output at107generation time and the model returns exactly the expected fields in the expected108value domains (Table~\ref{tab:app_features}). Decoding temperature is set to zero,109and the system instruction, written in French, constrains the model to rely only on110the text and to code absent information as \texttt{false}, \texttt{unknown}, or an111empty list. Each call consumes roughly 600 input and 110 output tokens; the112extraction is run in parallel, is resumable through an on-disk cache keyed by the113listing identifier, and retries transient errors with exponential backoff, for a114total cost of about \$3 across the sample. Descriptions are truncated at 4{,}000115characters, which affects only the longest DuProprio property sheets.116117\subsection{Vision Attributes from the Façade Photograph}118\label{subsec:vision}119120To capture the visual quality that neither structured fields nor text convey, we121analyze one photograph per listing---the façade---with a vision--language model122(\texttt{claude-haiku-4-5}, Anthropic, Messages API, July 2026). For Realtor.ca the123first image is the exterior shot; for DuProprio, whose images are captioned, we124select the first image whose caption is not a room name. The model returns twelve125fields under a strict JSON schema: an exterior-shot flag, a visual building type, an126overall condition score (1--10), a curb-appeal score (1--10), a renovation level,127the list of exterior materials, landscaping quality, a visible-garage flag, the128visual storey count, the setting (dense urban, suburban, rural, waterfront, wooded),129a photo-quality score, and a luxury indicator. The system instruction directs the130model to ground each score in concrete criteria (surface condition, materials,131landscaping) rather than taste, and to flag non-exterior images. Images are passed132by URL without local download; each call consumes roughly 2{,}470 input and 100133output tokens, for a total cost of about \$57 across the sample. As with the text134layer, the pass is parallelized, resumable, and retried. Unlike the text layer, the135vision calls did not set a sampling temperature and therefore ran at the API default,136so repeated calls could return slightly different scores for borderline images; we137did not re-run the extraction to measure this test--retest variability (see138Section~\ref{subsec:limits}).139140\paragraph{From schema fields to regressors.}141Imposing a typed schema with enumerations, required fields, and142\texttt{additionalProperties:false} moves validation into the API layer, so the143outputs are tabulated variables that require no free-text post-processing. They are144then mapped to numeric regressors: booleans to $0/1$; the six-level text condition145scale to an ordinal score $0$--$5$ (\textit{to renovate} $=0$, \ldots, \textit{new}146$=5$, with \textit{unknown} placed at the ``good'' midpoint of~2); the five-level147visual renovation scale to $0$--$4$ and landscaping to $0$--$3$; multi-valued148fields (flooring, heating, exterior materials) and the setting to one indicator per149category. The twelve vision fields thus generate 21 regressors (two scores, the150photo-quality score, two ordinal scales, three indicators, five setting indicators,151and eight material indicators), and the text schema 18 regressors. A listing whose152photograph is not an exterior shot keeps the model's best-effort scores and is153flagged by the exterior indicator. Model identifiers are API aliases that resolve to154the provider's current snapshot; we record the alias and the extraction date, and155the raw JSON outputs are archived so that every regressor can be regenerated from156them without new API calls.157158\subsection{Econometric Specification}159\label{subsec:econometrics}160161We adopt a semi-logarithmic functional form, the standard workhorse in the hedonic162literature \citep{malpezzi2003hedonic}. Collect the attributes of listing~$i$ into163disjoint blocks,164%165\begin{equation}166  \resizebox{.94\textwidth}{!}{$\displaystyle167  \mathbf{X}_i =168  \big(\underbrace{\ln\text{Area}_i,\ \ln\text{Lot}_i}_{\text{size (logged)}},\169  \underbrace{\mathbf{s}_i}_{\text{structural}},\170  \underbrace{\mathbf{a}_i}_{\text{amenities}},\171  \underbrace{\mathbf{r}_i}_{\text{rooms}},\172  \underbrace{\mathbf{m}_i}_{\text{listing}},\173  \underbrace{\mathbf{g}_i}_{\text{LLM text}},\174  \underbrace{\mathbf{v}_i}_{\text{vision}}\big)175  $}176  \label{eq:blocks}177\end{equation}178%179and estimate, by ordinary least squares,180%181\begin{equation}182  \begin{aligned}183  \ln P_i \;=\;& \alpha184  \;+\; \beta\,\ln\text{Area}_i185  \;+\; \gamma\,\ln\text{Lot}_i186  \;+\; \mathbf{s}_i^{\!\top}\bm{\delta}_s + \mathbf{a}_i^{\!\top}\bm{\delta}_a187  + \mathbf{r}_i^{\!\top}\bm{\delta}_r + \mathbf{m}_i^{\!\top}\bm{\delta}_m \\188  &+ \underbrace{\mathbf{g}_i^{\!\top}\bm{\delta}_g}_{\text{LLM text}}189  + \underbrace{\mathbf{v}_i^{\!\top}\bm{\delta}_v}_{\text{vision}}190  \;+\; \underbrace{\mu_{c(i)}}_{\text{city FE}}191  \;+\; \underbrace{\tau_{t(i)}}_{\text{type FE}}192  \;+\; \varepsilon_i ,193  \end{aligned}194  \label{eq:hedonic}195\end{equation}196%197where $c(i)$ and $t(i)$ index the municipality and property type of listing~$i$, and198$\mu_c$, $\tau_t$ are the corresponding fixed effects that sweep out location- and199type-specific price levels. The source indicator is part of $\mathbf{m}_i$. In200matrix form $\mathbf{y}=\mathbf{Z}\bm{\theta}+\bm{\varepsilon}$ with201$\widehat{\bm{\theta}}=(\mathbf{Z}^{\!\top}\mathbf{Z})^{-1}\mathbf{Z}^{\!\top}\mathbf{y}$.202The contribution of a feature layer is measured by the change in $R^2$ when its203block is added to the specification that contains all preceding blocks; the order204is size and structural, amenities, rooms and listing signals, text, vision, so the205text layer is credited only with what the keyword amenities do not already capture,206and the vision layer only with what neither the text nor the structured fields207capture.208209\paragraph{Interpretation of the coefficients.}210Because the size variables enter in logs, $\beta$ and $\gamma$ are \emph{elasticities}:211$\partial \ln P/\partial \ln\text{Area}=\beta$. For an indicator regressor $d$ with212coefficient $b$, the percentage price effect is not $b$ but213%214\begin{equation}215  \%\Delta P \;=\; \big(e^{\,b}-1\big)\times 100,216  \label{eq:halvorsen}217\end{equation}218%219the \citet{halvorsen1980interpretation} correction we apply throughout (for small220$b$, $e^{b}-1\approx b$; the \citealp{kennedy1981estimation} adjustment221$e^{\,b-\frac12\widehat{\mathrm{Var}}(b)}-1$ moves none of our reported effects by222more than 0.1 percentage point). For an ordinal score such as curb appeal, $b$ is the223log-price difference associated with one step of the scale, holding the other224attributes fixed. Under Equation~\eqref{eq:hedonic} the implicit price of a225continuous attribute $z_k$ from \eqref{eq:implicit} is $p_k=\delta_k\,P/z_k$, so226the semi-log form lets the \emph{dollar} marginal price scale with the price level227while keeping the \emph{percentage} effect constant.228229\paragraph{Two-part coverage design.}230Because living area is reported for only about 38\% of Realtor.ca listings, we231estimate two nested versions of \eqref{eq:hedonic} and combine their predictions:232%233\begin{equation}234  \widehat{\ln P}_i =235  \begin{cases}236    \widehat{\ln P}_i^{\,A} & \text{if area is measured (Model A, rich),}\\[2pt]237    \widehat{\ln P}_i^{\,B} & \text{otherwise (Model B, broad; }\beta\equiv 0).238  \end{cases}239  \label{eq:twopart}240\end{equation}241%242Model~A includes $\ln\text{Area}$ and is fit on the 9{,}446 listings with a measured243or reconstructed area; Model~B drops it and is fit on the full cleaned sample, so244every listing can be priced.245246\paragraph{Inference.}247House-price residuals are strongly heteroskedastic, and listings within a248municipality share unobserved local shocks that induce within-cluster error249correlation. Our preferred standard errors are therefore clustered at the250municipality level (195 clusters), the same level as the fixed effects251\citep{cameron2015cluster,abadie2023when}:252%253\begin{equation}254  \widehat{\mathrm{Var}}_{\text{CL}}(\widehat{\bm{\theta}})255  = (\mathbf{Z}^{\!\top}\mathbf{Z})^{-1}256    \Bigg(\sum_{c=1}^{C}257    \mathbf{Z}_c^{\!\top}\hat{\bm{\varepsilon}}_c258    \hat{\bm{\varepsilon}}_c^{\!\top}\mathbf{Z}_c\Bigg)259    (\mathbf{Z}^{\!\top}\mathbf{Z})^{-1},260  \label{eq:cluster}261\end{equation}262%263where $\mathbf{Z}_c$ and $\hat{\bm{\varepsilon}}_c$ stack the regressors and264residuals of cluster $c$. Cluster sizes are very unequal---Montreal alone contributes265about one listing in twenty, and the pooled residual category of small municipalities,266which is treated as a single cluster, holds about one listing in four (5{,}006 listings from 999 municipalities)---a configuration in which the asymptotic cluster-robust267variance can be unreliable \citep{mackinnon2017wild}. We therefore also report a268pairs cluster bootstrap that resamples municipalities with replacement269($B=299$) and takes the 2.5th and 97.5th percentiles of the resampled coefficients270as a confidence interval. As a complement we compute heteroskedasticity-consistent271(HC3) standard errors \citep{white1980heteroskedasticity,mackinnon1985some};272Section~\ref{subsec:robust} shows that the three approaches agree on the273significance of the property-level AI attributes and differ mainly for keyword274amenities with a strong spatial component. When RTA fixed effects replace275municipality effects, standard errors are clustered by RTA.276277\paragraph{Retransformation.}278Predicting the \emph{level} of price requires undoing the log. Because279$\mathbb{E}[P\mid\mathbf{Z}]=\exp(\mathbf{Z}\bm{\theta})\,\mathbb{E}[e^{\varepsilon}]280\neq \exp(\mathbf{Z}\bm{\theta})$, naive exponentiation is biased downward. Under281$\varepsilon\sim\mathcal N(0,\sigma^2)$ we use the closed-form correction, and more282generally Duan's nonparametric smearing estimate \citep{duan1983smearing}:283%284\begin{equation}285  \widehat{P}_i286  = \exp\!\big(\widehat{\ln P}_i\big)\cdot287  \underbrace{\exp\!\big(\tfrac12\hat\sigma^{2}\big)}_{\text{normal}}288  \qquad\text{or}\qquad289  \widehat{P}_i290  = \exp\!\big(\widehat{\ln P}_i\big)\cdot291  \underbrace{\frac1n\sum_{j=1}^{n} e^{\hat\varepsilon_j}}_{\text{smearing }\hat\phi}.292  \label{eq:smearing}293\end{equation}294%295The out-of-sample accuracy metrics of Section~\ref{sec:benchmark} are computed on296$\ln P$ (for $R^2$) and on the ratio of predicted to actual price (for the median297absolute percentage error), neither of which depends on the retransformation298constant.299300\paragraph{Out-of-sample validation.}301All predictive comparisons use five-fold cross-validation with a common seed, so that302every estimator and every feature set is evaluated on identical held-out folds. Under303\emph{random} folds a held-out house typically has close neighbours in the training304folds, which flatters any model that can exploit spatial proximity305\citep{roberts2017cross}. We therefore repeat the exercise with \emph{spatially306grouped} folds, assigning entire RTAs to folds so that no held-out listing shares307its RTA with a training listing; because many small municipalities consist of a308single RTA, their municipality indicator is then unobserved in training and the309model prices them at the reference level. The spatial design is a deliberately harsh310test of how the estimators and feature layers behave for a new area; the random311design corresponds to the operational use of an AVM that prices a new listing in a312market it already covers.313