Skip to main content

4.1. Baseline Count and Trade Gravity Models

Verified Environments & Platforms:EcoDataEcoLabFincoVietLOD

Methodological Part 4.1. Baseline Count and Trade Gravity Models in 4. Count Data, Trade Gravity and Limited Dependent Variable Models provides step-by-step How-To implementation guides for 6 econometric model lessons spanning from Section 4.1.1 to 4.1.6. Full theoretical derivations are available at VietLOD Part 4.1 alongside cloud execution on EcoLab.

Video Tutorial: How-To Guide for Part 4.1: Baseline Count and Trade Gravity Models in Stata 18, R 4.x, and Python 3.11+

4.1.1. Methodological Overview and Structural Equations​

  • Methodological Focus: Provides consistent estimation and robust inference for Baseline Count and Trade Gravity Models specifications within Count Data, Trade Gravity and Limited Dependent Variable Models.
  • Mandatory Post-Estimation Diagnostics: Kiểm định quá phân tán của Cameron–Trivedi và Deviance/Pearson goodness-of-fit, sai số chuẩn vững (QMLE) và tỷ số tần suất biến cố (IRR).

Core structural specification for Part 4.1:

P(Yi=y∣Xi)=exp⁡(−μi)μiyy!,μi=exp⁡(Xi⊤β)P(Y_i = y \mid X_i) = \frac{\exp(-\mu_i)\mu_i^y}{y!}, \quad \mu_i = \exp(X_i^\top \beta)

Estimator objective and moment conditions:

θ^QMLE=arg⁡max⁡θ∈Θ∑i=1Nln⁡f(Yi∣Xi,Zi;θ),E[Yi∣Xi]=g−1(Xi⊤β)\hat{\theta}_{\text{QMLE}} = \arg\max_{\theta \in \Theta} \sum_{i=1}^N \ln f\left(Y_i \mid X_i, Z_i; \theta\right), \quad \text{E}[Y_i \mid X_i] = g^{-1}(X_i^\top \beta)
Methodological Scope Boundary:When empirical data violate the identification conditions of Part 4.1, researchers should transition to the extended methodological parts in Chapter 4 or apply appropriate instrumental-variable and cluster-robust corrections.

4.1.2. Econometric Model Lessons in Part 4.1​

4.1.1 · poisson
4.1.1. Poisson Count Regression

Estimates the Poisson Count Regression specification within the Baseline Count and Trade Gravity Models framework by optimizing the structur...

Explore Guide
4.1.2 · negative_binomial
4.1.2. Negative Binomial Count Regression

Estimates the Negative Binomial Count Regression specification within the Baseline Count and Trade Gravity Models framework by optimizing th...

Explore Guide
4.1.3 · generalized_poisson
4.1.3. Generalized Poisson Count Regression

Estimates the Generalized Poisson Count Regression specification within the Baseline Count and Trade Gravity Models framework by optimizing ...

Explore Guide
4.1.4 · ppml_hdfe
4.1.4. Poisson Pseudo-Maximum Likelihood with High-Dimensional Fixed Effects

Gold-standard bilateral trade gravity and non-negative flow estimator consistent under arbitrary heteroskedasticity and zero flows. Across e...

Explore Guide

4.1.3. Comparative Execution Syntax Across Stata 18, R 4.x, and Python 3.11+​

Section & Model TitleEstimator KeyStata 18 MP SyntaxR 4.x SyntaxPython 3.11+ SyntaxSupport
4.1.1 · Poisson Count Regressionpoissonpoisson y_count x1 x2, vce(robust) irrglm(y_count ~ x1 + x2, family = poisson(link = 'log'), data = df)smf.poisson('y_count ~ x1 + x2', data=df).fit(cov_type='HC1')Available
4.1.2 · Negative Binomial Count Regressionnegative_binomialnbreg y_count x1 x2, vce(robust) irrMASS::glm.nb(y_count ~ x1 + x2, data = df)smf.negativebinomial('y_count ~ x1 + x2', data=df).fit()Available
4.1.3 · Generalized Poisson Count Regressiongeneralized_poissongpoisson y_count x1 x2, vce(robust)glmmTMB::glmmTMB(y_count ~ x1 + x2, family = genpois, data = df)GeneralizedPoisson(endog, exog).fit()Available
4.1.4 · Poisson Pseudo-Maximum Likelihood with High-Dimensional Fixed Effectsppml_hdfeppmlhdfe trade rta x1, absorb(exp_time imp_time pair_id) cluster(pair_id)fixest::fepois(trade ~ rta + x1 | exp_time + imp_time + pair_id, cluster = ~pair_id, data = df)pyfixest.fepois('trade ~ rta + x1 | exp_time + imp_time + pair_id', data=df, vcov={'CRV1': 'pair_id'})Available

| 4.1.5 · Tweedie and Inverse Gaussian Compound Poisson Gamma GLM | inverse_gaussian_tweedie_glm | glm y x1 x2, family(gamma) link(log) vce(robust) | stats::glm(y ~ x1 + x2, family = Gamma(link = 'log')) / statmod::tweedie | statsmodels.GLM(y, X, family=sm.families.Tweedie(link=Log(), var_power=1.5)).fit(cov_type='HC1') | Available | | 4.1.6 · Zero Truncated Poisson and Negative Binomial Regression | zero_truncated_count_ztp | tpoisson y x1 x2, ll(0) vce(robust) | countreg::zerotrunc(y ~ x1 + x2, dist = 'poisson') / VGAM::pospoisson | Exact Zero-Truncated Poisson log-likelihood BFGS MLE + Huber-White sandwich SE | Available |

4.1.4. Standard Implementation Workflow for Part 4.1​

Step 1. Load Standardized Practice Datasets From VietLOD, EcoData, or Finco

Download the model-specific .csv practice dataset in Part 4.1 or extract custom empirical panels from EcoData and Finco.

Step 2. Select the Optimal Estimator for Your Error and Sample Structure

Compare the estimators from 4.1.1 to 4.1.6 in the syntax matrix above and execute the estimation in Stata 18 MP, R 4.x, or Python 3.11+.

Step 3. Run Mandatory Diagnostics and Export Publication Tables on EcoLab

Verify all required diagnostics including Kiểm định quá phân tán của Cameron–Trivedi và Deviance/Pearson goodness-of-fit, sai số chuẩn vững (QMLE) và tỷ số tần suất biến cố (IRR) and dispatch the specification to EcoLab for automated journal-grade reporting.