API reference

Signatures and public methods are generated from this checkout. Start with the method selection guide for assumptions, data shapes and inference limits. Inherited methods may be unimplemented for a particular estimator; a signature alone is not a claim of support. Edit Python docstrings or the API inventory, not these generated pages.

Regression and estimation interfaces

Least squares, likelihood and fixed-effect operations.

BaseEstimator Base class for all estimators in trex.
LinearRegression Least squares with optional additive fixed effects.
MaximumLikelihoodEstimator Base class for Maximum Likelihood Estimators using PyTorch optimizers.
LogisticRegression Logistic Regression for binary classification with MLE estimation.
PoissonRegression Poisson Regression for count data with MLE estimation.
demean_torch Return weighted within residuals and a convergence flag.
prepare_fixed_effects Encode each factor independently, including string or sparse numeric IDs.
demean.fixed_effect_rank Exact rank of additive FE incidence, without dense n-by-level dummies.

Unconditional moments

GMM backends, GEL and their criterion functions.

gmm.GMMEstimator Dispatch to a SciPy or Torch GMM implementation.
gmm.gmm.GMMEstimatorScipy
gmm.gmm.GMMEstimatorTorch
gmm.gmm.moment_covariance Uncentered long-run covariance of observation-level moment vectors.
gmm.GELEstimator Generalized empirical likelihood estimator for vector-valued moments.
gmm.rho_el Empirical Likelihood (EL): rho(v) = log(1-v)
gmm.rho_exponential Exponential tilting (ET): rho(v) = 1 - exp(v)
gmm.rho_cue Continuously Updated Estimator (CUE): rho(v) = -0.5*v^2 - v
gmm.ScalarIVCUE Scalar CUE objective (a-beta*b)' Omega(beta)^-1 (a-beta*b).
gmm.PolynomialCUEResult Candidate enumeration result; beta=inf means no selected finite fit.

Conditional moments and scores

MaximumMomentRestriction Kernel maximum moment restriction estimator.
SieveMinimumDistance Polynomial-sieve minimum distance estimator for conditional moments.
cmr.ConditionalMomentEstimator Base class for neural conditional moment estimators.
cmr.rbf_kernel RBF kernel matrix and bandwidth.
cmr.mmr_loss Maximum moment restriction loss.
cmr.hsic Biased HSIC statistic using RBF kernels.
cmr.polynomial_sieve Polynomial basis expansion for instruments.
cmr.median_bandwidth Median-heuristic bandwidth for an RBF kernel.
cmr.squared_distance Pairwise squared Euclidean distance.
AntitonicScore Piecewise-linear antitonic score estimate.
AntitonicScoreMatchingRegression Linear regression via antitonic score matching.
estimate_antitonic_score Estimate the antitonic projection of an error score from residuals.

Static and dynamic choice

choice.base.ChoiceModel Base class for structural discrete choice models.
choice.BinaryLogit Binary Logit model for discrete choice analysis.
choice.BinaryProbit Binary Probit model for discrete choice analysis.
choice.MultinomialLogit Multinomial Logit (MNL) model for discrete choice with multiple alternatives.
choice.LowRankLogit Low-Rank Logit model for matrix completion style choice problems.
choice.DynamicChoiceData Container for dynamic choice panel data.
choice.DynamicChoiceModel Base class for dynamic discrete choice models.
choice.RustNFP Rust (1987) full maximum likelihood via nested fixed point (NFP).
choice.HotzMillerCCP Hotz & Miller (1993) CCP inversion estimator.
choice.LinearFlowUtility Linear-in-features flow utility specification.
choice.ReplacementUtility Rust-style bus replacement flow utility.
choice.estimate_transition_matrix Estimate state transition probabilities P(x’|x,a) from panel data.
choice.discretize_state Discretize continuous state variable into bins.
choice.DeepValueFunction Neural network value function approximation for high-dimensional states.
choice.estimate_ccps Frequency CCPs on the input device; unobserved states use uniform rows.

Panel estimators and latent heterogeneity

NuclearNormMatrixCompletion Nuclear-norm penalized matrix completion with additive fixed effects.
panel.MatrixCompletionResult
SyntheticDID Synthetic difference-in-differences with two-way balancing weights.
panel.SyntheticDIDResult
did_estimate Classical two-way DID estimate for a block treatment design.
sc_estimate Synthetic-control special case: no time weights and no omega intercept.
matrix_completion_estimate Estimate ATT by imputing treated post cells with matrix completion.
synthdid_estimate Convenience function returning a fitted :class:SyntheticDIDResult.
panel_estimates Compute the point-estimate row from the synthdid README estimator table.
panel.matrix_completion_lambda_max Largest lambda for which the SVT update returns a zero low-rank matrix.
panel.simplex_least_squares_fw Minimize ||Ax-b||^2 + zeta^2 n ||x||^2 over simplex by Frank-Wolfe.
panel.collapsed_form Collapse treated units and post-treatment periods as in synthdid.
panel.frank_wolfe_step One exact-line-search Frank-Wolfe step over the probability simplex.
LatentFactorGLM Latent-factor GLM with factorized optimization.
KNNGroupedFixedEffects Experimental grouped fixed-effects estimator with KNN-smoothed embeddings.
grouped_fe.GroupedFEResult Container for grouped FE output.
build_panel_embeddings Build unit-level embeddings by stacking panel moments over time.
grouped_fe.chunked_knn_indices Compute exact KNN indices and squared distances in chunks.
grouped_fe.smooth_embeddings_by_knn Average each embedding with its nearest neighbors.
grouped_fe.cluster_embeddings Cluster embeddings with flash-kmeans when available, otherwise torch fallback.

Simulation, preprocessing and diagnostics

TabularTransformer Standardize continuous columns while preserving binary columns.
TabularWGAN Wasserstein GAN with gradient penalty for tabular simulation.
TabularPTGAN Parallelly tempered Wasserstein GAN for multimodal tabular data.
TabularDiffusion Small DDPM-style diffusion model for continuous tabular rows.
distribution_metrics Compute marginal and joint distribution discrepancy metrics.
sliced_wasserstein_distance Monte Carlo directional average of exact empirical 1-Wasserstein.
SafetensorsLLMInContextGenerator Generate CSV-like tabular rows from a local safetensors language model.
SafetensorsQLORAGenerator QLoRA-fine-tuned LLM row generator.