4. Khai phá dữ liệu
This practical how-to guide presents the theoretical foundations, structural mathematical equations, detailed breakdown of 7 specialized lessons, and multi-platform replication workflows for 4. Khai phá dữ liệu from the textbook Applied Quantitative Data Analysis with IBM SPSS, with direct cross-references to the authoritative source material at https://sachktl.tnsai.vn/vi/spss/khai-pha-du-lieu/.
1. Methodological Foundations, Mathematical Specification, and Identification
Introduction Before doing any kind of statistical testing or model building, you should always examine your data using summary statistics and graphs. This process is called exploratory data analysis, and it's a crucial part of every research project. Exploratory data analysis is about "getting to know" your data: which values are typical, which values are unusual; where is it centered, how spread out is it; what are its extremes. More importantly, it's an opportunity to identify and correct any problems in your data that would affect the conclusions you draw from your analysis.
1.1. Structural Equations and Representative Estimator
1.2. Core Identification Assumptions and Applicability Conditions
- Correct functional form specification in parameters without omitting relevant covariates correlated with included regressors.
- Zero conditional mean of disturbances , ensuring unbiasedness and asymptotic consistency.
- Full column rank of the design matrix without exact multicollinearity, paired with HC1 or cluster-robust standard errors under heteroskedasticity.
Read the complete theoretical derivations, mathematical proofs, and worked examples for this chapter on SachKTL.
Extract standardized Vietnamese macroeconomic, corporate financial, and household survey data for hands-on replication.
Execute econometric specifications, run diagnostic battery tests, and export APA 7th / AER publication-grade tables automatically.
2. Lesson-by-Lesson Academic Breakdown
2.1. Thống kê đơn biến
Explore The Explore procedure produces detailed univariate statistics and graphs for numeric scale variables for an entire sample, or for subsets of a sample. It can also be used to assess the normality of a numeric scale variable with special inferential statistics and detailed diagnostic plots. To run the Explore procedure, click Analyze > Descriptive Statistics > Explore. A Dependent List: The continuous numeric variables you wish to analyze. B Factor List: Categorical variables to subset the analysis by.
Key Methodological Sub-Topics Covered in This Lesson:
-
Explore
-
About the Normality plots with tests option
-
About boxplot types in the Explore procedure
-
Two numeric variables, no factors
-
Factor levels together
-
Dependents together
-
Analytical Environments:
IBM SPSS 29· Authoritative Source: Read Full Original Lesson on SachKTL
2.2. Tần suất đơn biến
When applied to scale variables, the Frequencies procedure in SPSS can compute quartiles, percentiles, and other summary statistics. It can also create histograms with an estimated normal distribution overlaid on the graph. Introduction When summarizing quantitative variables, we are typically interested in questions like: What is the "center" of the data? How spread out is the data? What are the extremes of the data? What is the "shape" of the distribution? Is it symmetric or asymmetric?
Key Methodological Sub-Topics Covered in This Lesson:
-
Introduction
-
Using the Frequencies Procedure with Scale Variables
-
Example: Comparing Percentiles for More Than Two Variables
-
Problem Statement
-
Running the Procedure
-
Using the Frequencies Dialog Window
-
Analytical Environments:
IBM SPSS 29· Authoritative Source: Read Full Original Lesson on SachKTL
2.3. Thống kê đa biến
Descriptives is best to obtain quick summaries of numeric variables, or to compare several numeric variables side-by-side. Introduction When summarizing quantitative variables, we are typically interested in questions like: What is the "center" of the data? How spread out is the data? What are the extremes of the data? What is the "shape" of the distribution? Is it symmetric or asymmetric? Are the values mostly clustered about the mean, or are there many values in the "tails" of the distribution?
Key Methodological Sub-Topics Covered in This Lesson:
-
Introduction
-
Descriptives
-
Example: Comparing average test scores side-by-side
-
Problem Statement
-
Running the Procedure
-
Using the Descriptives Dialog Window
-
Analytical Environments:
IBM SPSS 29· Authoritative Source: Read Full Original Lesson on SachKTL
2.4. Thống kê theo nhóm
Compare Means is best used when you want to compare several numeric variables with respect to one or more categorical variables. It is especially useful for summarizing numeric variables simultaneously across categories. Compare Means The Compare Means procedure is useful when you want to summarize and compare differences in descriptive statistics across one or more factors, or categorical variables. To open the Compare Means procedure, click Analyze > Compare Means > Means. A Dependent List: The continuous numeric variables to be analyzed.
Key Methodological Sub-Topics Covered in This Lesson:
-
Compare Means
-
Example: Comparing averages across related demographic variables
-
Problem Statement
-
Compare Means: Basic Report, No Layers
-
Running the Procedure
-
Output
-
Analytical Environments:
IBM SPSS 29, R 4.x· Authoritative Source: Read Full Original Lesson on SachKTL
2.5. Tạo bảng tần suất
In SPSS, the Frequencies procedure is primarily used to create frequency tables, bar charts, and pie charts for categorical variables. Introduction When summarizing a categorical or qualitative variable , we are typically interested in questions like: How many unique categories were there? How many observations fell into each category? Were there any categories with zero observations? Were there any observations with missing responses? What proportion of the observations fell into each category?
Key Methodological Sub-Topics Covered in This Lesson:
-
Introduction
-
Data Requirements
-
Data Set-Up
-
Create a Frequency Table in SPSS
-
Example: Summarizing a Categorical Variable
-
Running the Procedure
-
Analytical Environments:
IBM SPSS 29· Authoritative Source: Read Full Original Lesson on SachKTL
2.6. Tạo bảng chéo
The Crosstabs procedure is used to create contingency tables, which describe the interaction between two categorical variables. Crosstabs To describe a single categorical variable, we use frequency tables. To describe the relationship between two categorical variables, we use a special type of table called a cross-tabulation . In a cross-tabulation, the categories of one variable determine the rows of the table, and the categories of the other variable determine the columns.
Key Methodological Sub-Topics Covered in This Lesson:
-
Crosstabs
-
Describing a Crosstab
-
Example 1: A "square" table
-
Example 2: A "long" table
-
Example 3: A "wide" table
-
Understanding Row, Column, and Total Percents
-
Analytical Environments:
IBM SPSS 29, R 4.x· Authoritative Source: Read Full Original Lesson on SachKTL
2.7. Dữ liệu đa lựa chọn
This tutorial shows how to work with the data from "check-all-that-apply" multiple choice survey questions in SPSS Statistics using multiple response sets. Introduction This tutorial is a primer on how to work with data from multiple choice, multiple-response questions in SPSS Statistics.
Key Methodological Sub-Topics Covered in This Lesson:
-
Introduction
-
Data Set-Up
-
Numeric code if present, blank if absent
-
Numeric codes to indicate present/not present
-
Sample Data for This Tutorial
-
Counting Selected Choices and Identifying Non-respondents
-
Analytical Environments:
IBM SPSS 29· Authoritative Source: Read Full Original Lesson on SachKTL
3. Step-by-Step Empirical Implementation Workflow
1. Formulate the Research Question and Prepare Data on EcoData & Finco
Define the dependent variable, core explanatory variables, and control covariates aligned with 4. Khai phá dữ liệu. Extract standardized Vietnamese empirical series from EcoData or Finco, and screen for missing observations and extreme outliers.
2. Conduct Descriptive Profiling, Correlation Analysis, and Pre-Estimation Checks
Examine empirical distributions, construct summary statistics tables, and evaluate collinearity using pairwise correlation matrices and Variance Inflation Factors (VIF).
3. Estimate the Model Across Stata 18 MP, R 4.x, and Python 3.11+
Execute the parameter estimation scripts matching the structural equations in Section 1.1 while cross-checking theoretical derivations at SachKTL.
4. Perform Post-Estimation Diagnostics and Robust Variance Correction
Test for heteroskedasticity, serial correlation, Ramsey RESET functional form misspecification, and regressor endogeneity. Apply White HC1 or cluster-robust standard errors for valid inference.
4. Multi-Platform Implementation Scripts in Stata, R, and Python
- Stata 18 MP
- R 4.x
- Python 3.11+
* Thiết lập môi trường, ước lượng mô hình và kiểm định chẩn đoán toàn diện
version 18.0
clear all
set more off
import delimited "sachktl_empirical_ecodata.csv", clear encoding("utf-8")
describe
summarize y x1 x2 x3, detail
* 1. Ước lượng mô hình cơ sở và kiểm định phương sai thay đổi / đa cộng tuyến / dạng hàm
regress y x1 x2 x3
estat hettest
estat imtest, white
estat vif
estat ovtest
* 2. Ước lượng với sai số chuẩn vững White HC1 và xuất tác động biên
regress y c.x1##c.x2 x3, vce(robust)
margins, dydx(x1 x2 x3)
# Nạp thư viện phân tích kinh tế lượng và thực thi kiểm định chẩn đoán
library(tidyverse)
library(lmtest)
library(sandwich)
library(car)
df <- read.csv("sachktl_empirical_ecodata.csv")
summary(df)
# 1. Ước lượng mô hình tuyến tính và kiểm định Breusch-Pagan, RESET, VIF
fit <- lm(y ~ x1 + x2 + x3, data = df)
bptest(fit)
resettest(fit, power = 2:3, type = "fitted")
vif(fit)
# 2. Xuất bảng hệ số ước lượng với sai số chuẩn vững HC1
coeftest(fit, vcov = vcovHC(fit, type = "HC1"))
# Nạp thư viện statsmodels và thực thi ước lượng kèm chẩn đoán phần dư
import pandas as pd
import statsmodels.api as sm
import statsmodels.formula.api as smf
from statsmodels.stats.diagnostic import het_breuschpagan, linear_reset
from statsmodels.stats.outliers_influence import variance_inflation_factor
df = pd.read_csv("sachktl_empirical_ecodata.csv")
# 1. Ước lượng mô hình với sai số chuẩn vững HC1
model = smf.ols("y ~ x1 + x2 + x3", data=df).fit(cov_type="HC1")
print(model.summary())
# 2. Kiểm định phương sai thay đổi Breusch-Pagan, Ramsey RESET và hệ số VIF
bp_lm, bp_pval, _, _ = het_breuschpagan(model.resid, model.model.exog)
reset_res = linear_reset(model, power=2, use_f=True)
X = sm.add_constant(df[["x1", "x2", "x3"]].dropna())
vifs = {col: variance_inflation_factor(X.values, i) for i, col in enumerate(X.columns)}
print(f"Breusch-Pagan p={bp_pval:.4f} | RESET p={reset_res.pvalue:.4f} | VIF={vifs}")
5. Post-Estimation Diagnostic and Interpretation Guide
| Diagnostic Criterion | Null Hypothesis | Benchmark Threshold | Corrective Action When Is Rejected |
|---|---|---|---|
| Heteroskedasticity | Constant error variance | rejects | Apply vce(robust), vcovHC(HC1), or FGLS/WLS weighted estimation |
| Multicollinearity | No severe linear dependence among regressors | acceptable | Drop redundant covariates, center interactions, or apply LASSO/Ridge regularization |
| Ramsey RESET Functional Form | No omitted nonlinear or higher-order terms | retains | Add interaction terms, quadratic polynomials, or log-transform skewed positive variables |
| Regressor Exogeneity | Orthogonality | Durbin-Wu-Hausman | Transition to IV/2SLS, LIML, or GMM estimation with validated instruments |
6. Video Tutorial Walkthrough
Video Tutorial: Practical Walkthrough for 4. Khai phá dữ liệu on SachKTL
7. Complete Lesson Directory and Backlinks to Original SachKTL Articles
| Lesson Code | Lesson Title | Supported Software | Original Source Link on SachKTL |
|---|---|---|---|
| 4.1 | Thống kê đơn biến | IBM SPSS 29 | Open Original Lesson on SachKTL |
| 4.2 | Tần suất đơn biến | IBM SPSS 29 | Open Original Lesson on SachKTL |
| 4.3 | Thống kê đa biến | IBM SPSS 29 | Open Original Lesson on SachKTL |
| 4.4 | Thống kê theo nhóm | IBM SPSS 29, R 4.x | Open Original Lesson on SachKTL |
| 4.5 | Tạo bảng tần suất | IBM SPSS 29 | Open Original Lesson on SachKTL |
| 4.6 | Tạo bảng chéo | IBM SPSS 29, R 4.x | Open Original Lesson on SachKTL |
| 4.7 | Dữ liệu đa lựa chọn | IBM SPSS 29 | Open Original Lesson on SachKTL |