Skip to main content

1.1. Classical Least Squares

Verified Environments & Platforms:EcoDataEcoLabFincoVietLOD

Methodological Part 1.1. Classical Least Squares in 1. Classical Linear and Instrumental Variables Regression provides step-by-step How-To implementation guides for 7 econometric model lessons spanning from Section 1.1.1 to 1.1.7. Full theoretical derivations are available at VietLOD Part 1.1 alongside cloud execution on EcoLab.

Video Tutorial: How-To Guide for Part 1.1: Classical Least Squares in Stata 18, R 4.x, and Python 3.11+

1.1.1. Methodological Overview and Structural Equations​

  • Methodological Focus: Provides consistent estimation and robust inference for Classical Least Squares specifications within Classical Linear and Instrumental Variables Regression.
  • Mandatory Post-Estimation Diagnostics: Kiểm định phương sai thay đổi Breusch–Pagan và White, hệ số phóng đại phương sai đa cộng tuyến (VIF), kiểm định dạng hàm Ramsey RESET, kiểm định phân phối chuẩn phần dư Jarque–Bera.

Core structural specification for Part 1.1:

Yi=β0+∑k=1KβkXik+εi,E[εi∣Xi]=0Y_i = \beta_0 + \sum_{k=1}^K \beta_k X_{ik} + \varepsilon_i, \quad \text{E}[\varepsilon_i \mid X_i] = 0

Estimator objective and moment conditions:

β^N=arg⁡min⁡β∈RK∑i=1Nwi(Yi−Xi⊤β)2,E[Xiεi]=0\hat{\beta}_N = \arg\min_{\beta \in \mathbb{R}^K} \sum_{i=1}^N w_i \left(Y_i - X_i^\top \beta\right)^2, \quad \text{E}\left[X_i \varepsilon_i\right] = 0
Methodological Scope Boundary:When empirical data violate the identification conditions of Part 1.1, researchers should transition to the extended methodological parts in Chapter 1 or apply appropriate instrumental-variable and cluster-robust corrections.

1.1.2. Econometric Model Lessons in Part 1.1​

1.1.1 · ols
1.1.1. Ordinary Least Squares — OLS

Estimates the Ordinary Least Squares — OLS specification within the Classical Least Squares framework by optimizing the structural objective...

Explore Guide
1.1.2 · wls
1.1.2. Weighted Least Squares — WLS

Estimates the Weighted Least Squares — WLS specification within the Classical Least Squares framework by optimizing the structural objective...

Explore Guide
1.1.3 · gls
1.1.3. Generalized Least Squares — GLS

Estimates the Generalized Least Squares — GLS specification within the Classical Least Squares framework by optimizing the structural object...

Explore Guide
1.1.4 · fgls
1.1.4. Feasible Generalized Least Squares — FGLS

Estimates the Feasible Generalized Least Squares — FGLS specification within the Classical Least Squares framework by optimizing the structu...

Explore Guide

1.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
1.1.1 · Ordinary Least Squares — OLSolsregress y x1 x2, vce(robust)lm(y ~ x1 + x2, data = df)smf.ols('y ~ x1 + x2', data=df).fit(cov_type='HC1')Available
1.1.2 · Weighted Least Squares — WLSwlsregress y x1 x2 [aweight = w], vce(robust)lm(y ~ x1 + x2, data = df, weights = w)smf.wls('y ~ x1 + x2', data=df, weights=df['w']).fit()Available
1.1.3 · Generalized Least Squares — GLSglsgls / vwls y x1 x2, sd(sigma_i)nlme::gls(y ~ x1 + x2, data = df)sm.GLS(y, X, sigma=Omega).fit()Available
1.1.4 · Feasible Generalized Least Squares — FGLSfglsregress y x1 x2 -> gen ln_e2 = ln(e^2) -> regress y x1 x2 [aw=1/exp(xb)]nlme::gls(y ~ x1 + x2, weights = varExp(), data = df)smf.glsar('y ~ x1 + x2', data=df, rho=1).iterative_fit()Available

| 1.1.5 · Constrained and Restricted Least Squares | constrained_least_squares | cnsreg y x1 x2, constraints(1) vce(robust) | car::linearHypothesis + quadprog::solve.QP | scipy.optimize.lsq_linear + statsmodels.OLS Lagrangian projection | Available | | 1.1.6 · Nonlinear Least Squares Gauss Newton | nonlinear_least_squares | nl (y = {b0} + {b1}*x1), vce(robust) | stats::nls + sandwich::vcovHC | scipy.optimize.least_squares(method='trf') | Available | | 1.1.7 · Errors in Variables Reliability Adjusted and Deming Regression | errors_in_variables_eiv | eivreg y x1 x2, r(x1 0.90) | deming::deming / reliability-corrected moment matrix | Fuller (1987) reliability-corrected moment estimator + Deming SVD total least squares | Available |

1.1.4. Standard Implementation Workflow for Part 1.1​

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

Download the model-specific .csv practice dataset in Part 1.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 1.1.1 to 1.1.7 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 phương sai thay đổi Breusch–Pagan và White, hệ số phóng đại phương sai đa cộng tuyến (VIF), kiểm định dạng hàm Ramsey RESET, kiểm định phân phối chuẩn phần dư Jarque–Bera and dispatch the specification to EcoLab for automated journal-grade reporting.