Chuyển tới nội dung chính

3. Xử lý dữ liệu

Môi trường & nền tảng hỗ trợ:Academic FreeResearcher ProInstitutional VIP

Tài liệu hướng dẫn thực hành này trình bày toàn diện cơ sở lý thuyết, hệ phương trình toán học, nội dung chi tiết của 8 bài học chuyên đề và quy trình ước lượng đa phần mềm cho 3. Xử lý dữ liệu thuộc bộ giáo trình Phân tích dữ liệu với SPSS, đối chiếu trực tiếp với nguồn học liệu gốc tại https://sachktl.tnsai.vn/vi/spss/xu-ly-du-lieu/.

Phân tích dữ liệu với SPSS3. Xử lý dữ liệuKinh tế lượng ứng dụng, mô hình hóa thống kê và kiểm định giả thuyết · 8 bài học chuyStata 18 MPR 4.xPython 3.11+TNSAI Ecosystem

1. Cơ sở phương pháp luận, biểu diễn toán học và giả thiết nhận dạng​

Part 1: Working with Variables Most of the time, you'll need to make modifications to your variables before you can analyze your data. These types of modifications can include changing a variable's type from numeric to string, merging the categories of a nominal or ordinal variable, dichotomizing a continuous variable at a cut point, or computing a new summary variable from existing variables. This section will focus on transformations applied to individual variables, particularly recoding and computing new variables.

1.1. Hệ phương trình cấu trúc và công thức ước lượng đại diện​

Yi=β0+∑k=1KβkXik+εi,E[εi∣Xi]=0[1]Y_i = \beta_0 + \sum_{k=1}^K \beta_k X_{ik} + \varepsilon_i, \quad \mathbb{E}[\varepsilon_i \mid \mathbf{X}_i] = 0 \tag*{[1]} Var^HC1(β^)=NN−K−1(X′X)−1(∑i=1Nε^i2xixi′)(X′X)−1[2]\widehat{\text{Var}}_{\text{HC1}}(\hat{\boldsymbol{\beta}}) = \frac{N}{N - K - 1}\left(\mathbf{X}'\mathbf{X}\right)^{-1}\left(\sum_{i=1}^N \hat{\varepsilon}_i^2 \mathbf{x}_i \mathbf{x}_i'\right)\left(\mathbf{X}'\mathbf{X}\right)^{-1} \tag*{[2]}

1.2. Các giả thiết nhận dạng và điều kiện áp dụng​

  1. Dạng hàm tuyến tính theo tham số được xác định đúng, không bỏ sót biến giải thích quan trọng có tương quan với các biến trong mô hình.
  2. Kỳ vọng có điều kiện của sai số bằng không E[εi∣Xi]=0\mathbb{E}[\varepsilon_i \mid \mathbf{X}_i] = 0, đảm bảo tính không chệch và vững tiệm cận của ước lượng.
  3. Ma trận thiết kế X\mathbf{X} có hạng cột đầy đủ, không xảy ra đa cộng tuyến hoàn hảo và sử dụng sai số chuẩn vững HC1/Cluster khi có phương sai thay đổi.
Giới hạn phạm vi áp dụng:Khi tồn tại biến giải thích nội sinh do đồng thời hai chiều, sai số đo lường hoặc bỏ sót biến không quan sát được, ước lượng OLS bị chệch và không vững; cần chuyển sang ước lượng biến công cụ IV/2SLS hoặc GMM.

2. Phân tích chuyên sâu từng bài học trong chương​

2.1. Tính toán các biến​

Computing Variables Sometimes you may need to compute a new variable based on existing information in your data. For example, you may want to: Convert the units of a variable from feet to meters Use a subject's height and weight to compute their BMI Compute a subscale score from items on a survey Apply a computation conditionally, so that a new variable is only computed for cases where certain conditions are met In this tutorial, we'll discuss how to compute variables in SPSS using numeric expressions, built-in functions, and conditional.

Các nội dung học thuật trọng tâm trong bài học:

  • Computing variables

  • Computing variables using syntax

  • Example: Computing a new variable using arithmetic

  • Using the compute variables dialog window

  • Using syntax

  • Example: Computing a new variable using a built-in function

  • Môi trường thực hành: IBM SPSS 29 · Tài liệu gốc: Đọc toàn văn bài học tại SachKTL

2.2. Chuẩn hóa biến​

Introduction Mean centering refers to a type of variable transformation wherein the average of a variable is subtracted from every observation of that variable. The result of this transformation is a new variable that retains its original units, but whose mean value is 0. Mean centering is often used when fitting linear regression models because of how it affects the interpretation of the intercept term. With an uncentered predictor variable, the intercept of a linear regression represents the expected value of y when the x variable is zero.

Các nội dung học thuật trọng tâm trong bài học:

  • Introduction

  • Aggregating data

  • Example: Mean-centering a variable about the grand mean

  • Problem statement

  • Running the procedure

  • Using the dialog windows

  • Môi trường thực hành: Stata 18 MP, IBM SPSS 29 · Tài liệu gốc: Đọc toàn văn bài học tại SachKTL

2.3. Chuyển hóa biến​

Recoding Variables Sometimes you will want to transform a variable by combining some of its categories or values together. For example, you may want to change a continuous variable into an ordinal categorical variable, or you may want to merge the categories of a nominal variable. In SPSS, this type of transform is called recoding.

Các nội dung học thuật trọng tâm trong bài học:

  • Recoding variables

  • Recode into different variables

  • Old and new values

  • The “if” option

  • Recode into same variables

  • DO IF - ELSE IF syntax

  • Môi trường thực hành: IBM SPSS 29 · Tài liệu gốc: Đọc toàn văn bài học tại SachKTL

2.4. Biến danh mục​

Recoding Categorical String Variables to Labeled Numeric Variables using Automatic Recode When writing down the observed values of a categorical variable, you can choose to write the data values as words or as numeric codes. Either method of recording categorical variables is valid, but it is often easier to work with numeric codes in SPSS than it is to work with strings. This is because, when referring to the content of a string during a computation, the content must match exactly.

Các nội dung học thuật trọng tâm trong bài học:

  • Recoding categorical string variables to labeled numeric variables using automatic recode

  • Running the automatic recode procedure

  • Example: Recognizing blank strings as user-missing values

  • Problem statement

  • Running the procedure

  • Using the automatic recode dialog window

  • Môi trường thực hành: IBM SPSS 29 · Tài liệu gốc: Đọc toàn văn bài học tại SachKTL

2.5. Biến thứ tự​

Introduction A rank variable represents the ordering of the values of a numeric variable from smallest to largest . Ranking is its own type of variable transformation, and is also useful when you want to convert a numeric variable into a categorical variable using percentiles. Rank Cases In SPSS, rank transforms and percentile groupings can be computed using the Rank Cases procedure. To open Rank Cases, click Transform > Rank Cases. A Variables: The variables to compute rank transforms on. The new ranks will be saved to new variables .

Các nội dung học thuật trọng tâm trong bài học:

  • Introduction

  • Rank cases

  • Example: Rank transforms for non-normal data

  • Before the procedure

  • Running the procedure

  • Syntax

  • Môi trường thực hành: IBM SPSS 29 · Tài liệu gốc: Đọc toàn văn bài học tại SachKTL

2.6. Sử dụng trọng số​

Weighting Cases In SPSS, weighting cases allows you to assign "importance" or "weight" to the cases in your dataset. Some situations where this can be useful include: Your data is in the form of counts of factors or events. The "weight" is the number of occurrences. Your data requires adjustments to correct for over- or under-representation of certain characteristics in your sample. The Pew Research Center often makes their raw survey data available online to the public.

Các nội dung học thuật trọng tâm trong bài học:

  • Weighting cases

  • Example: Reproducing an existing 3x2 table

  • Problem statement

  • Running the procedure

  • Syntax

  • Output

  • Môi trường thực hành: IBM SPSS 29 · Tài liệu gốc: Đọc toàn văn bài học tại SachKTL

2.7. Sắp xếp dữ liệu​

Sorting Data Sorting data allows us to re-organize the data in ascending or descending order with respect to a specific variable. Some procedures in SPSS require that your data be sorted in a certain way before the procedure will execute. There are two options for sorting data: Sort Cases Sort Variables We cover how to perform each sorting option below. Sort Cases Sorting cases will rearrange the rows based on a given variable.

Các nội dung học thuật trọng tâm trong bài học:

  • Sorting data

  • Sort cases

  • Sorting from the data view

  • Sorting with the sort cases procedure

  • Sorting with syntax

  • Sort variables

  • Môi trường thực hành: IBM SPSS 29 · Tài liệu gốc: Đọc toàn văn bài học tại SachKTL

2.8. Gộp tách dữ liệu​

Grouping or Splitting Data When analyzing data, it is sometimes useful to temporarily "group" or "split" your data in order to compare results across different subsets. This can be useful when you want to compare frequency distributions or descriptive statistics with respect to the categories of some variable - especially if you want separate tables of results for each group. To split your dataset, click Data > Split File. SPSS Version 25 Drop-Down Menu SPSS Version 22 Drop-Down Menu The Split File window will appear.

Các nội dung học thuật trọng tâm trong bài học:

  • Grouping or splitting data

  • Turning off split file

  • Syntax

  • Example

  • Problem statement

  • Splitting using compare groups

  • Môi trường thực hành: IBM SPSS 29 · Tài liệu gốc: Đọc toàn văn bài học tại SachKTL

3. Quy trình thực hành chuẩn từng bước trên dữ liệu thực nghiệm​

1. Xác định câu hỏi nghiên cứu và chuẩn bị dữ liệu trên EcoData & Finco

Xác định biến phụ thuộc, nhóm biến giải thích trọng tâm và biến kiểm soát phù hợp với nội dung 3. Xử lý dữ liệu. Trích xuất chuỗi dữ liệu thực nghiệm Việt Nam từ EcoData hoặc Finco, kiểm tra giá trị khuyết thiếu và ngoại lai trước khi đưa vào mô hình.

2. Thống kê mô tả, ma trận tương quan và kiểm tra tiền ước lượng

Phân tích phân phối thực nghiệm của các biến, lập bảng thống kê mô tả theo nhóm và kiểm tra hiện tượng đa cộng tuyến thông qua ma trận tương quan cặp cũng như nhân tử phóng đại phương sai VIF.

3. Ước lượng mô hình chuẩn trên Stata 18 MP, R 4.x và Python 3.11+

Thực thi kịch bản ước lượng tham số theo đúng cấu trúc phương trình toán học đã thiết lập ở Mục 1.1, đồng thời kết hợp đối chiếu với các bài học gốc tại SachKTL.

4. Kiểm định chẩn đoán sau ước lượng và hiệu chỉnh sai số chuẩn vững

Kiểm tra phương sai sai số thay đổi, tự tương quan chuỗi, dạng hàm Ramsey RESET và tính nội sinh của biến giải thích. Áp dụng sai số chuẩn vững White HC1 hoặc cụm cá thể để bảo đảm suy diễn thống kê chính xác.

5. Tổng hợp bảng kết quả chuẩn tạp chí quốc tế và đối chiếu trên EcoLab

Trình bày hệ số ước lượng, sai số chuẩn trong ngoặc đơn và ký hiệu mức ý nghĩa thống kê theo chuẩn APA 7th / AER Booktabs, hoặc tự động hóa toàn bộ quy trình báo cáo trên EcoLab và VietLOD.

4. Kịch bản mã lệnh thực hành trên Stata, R và Python​

* 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)

5. Bảng kiểm định chẩn đoán và quy tắc diễn giải kết quả​

Tiêu chí chẩn đoánGiả thuyết không H0H_0Ngưỡng đánh giá chuẩnHướng xử lý khi bác bỏ H0H_0
Phương sai sai số thay đổiPhương sai phần dư không đổi Var(εi)=σ2\text{Var}(\varepsilon_i) = \sigma^2p-value<0.05p\text{-value} < 0.05 bác bỏ H0H_0Sử dụng sai số chuẩn vững vce(robust), vcovHC(HC1) hoặc ước lượng FGLS/WLS
Đa cộng tuyến giữa các biếnKhông có phụ thuộc tuyến tính mạnh giữa các biến giải thíchVIF<10\text{VIF} < 10 là chấp nhận đượcLoại bỏ biến dư thừa, chuẩn hóa biến hoặc dùng hồi quy điều chuẩn LASSO/Ridge
Dạng hàm Ramsey RESETMô hình không bỏ sót thành phần phi tuyến bậc caop-value>0.05p\text{-value} > 0.05 chấp nhận H0H_0Bổ sung biến tương tác, đa thức bậc hai hoặc lấy logarit tự nhiên các biến dương
Tính ngoại sinh của biến giải thíchBiến giải thích không tương quan với sai số Cov(X,ε)=0\text{Cov}(X, \varepsilon)=0Kiểm định Durbin-Wu-Hausman p>0.05p > 0.05Chuyển sang ước lượng biến công cụ IV/2SLS, LIML hoặc GMM với biến công cụ hợp lệ

6. Video bài giảng hướng dẫn thực hành​

Video hướng dẫn: Hướng dẫn thực hành 3. Xử lý dữ liệu trên SachKTL

7. Danh mục toàn bộ bài học trong chương và liên kết học liệu gốc​

Mã bàiTên bài học chuyên đềPhần mềm hỗ trợLiên kết gốc tại SachKTL
3.1Tính toán các biếnIBM SPSS 29Mở bài học gốc trên SachKTL
3.2Chuẩn hóa biếnStata 18 MP, IBM SPSS 29Mở bài học gốc trên SachKTL
3.3Chuyển hóa biếnIBM SPSS 29Mở bài học gốc trên SachKTL
3.4Biến danh mụcIBM SPSS 29Mở bài học gốc trên SachKTL
3.5Biến thứ tựIBM SPSS 29Mở bài học gốc trên SachKTL
3.6Sử dụng trọng sốIBM SPSS 29Mở bài học gốc trên SachKTL
3.7Sắp xếp dữ liệuIBM SPSS 29Mở bài học gốc trên SachKTL
3.8Gộp tách dữ liệuIBM SPSS 29Mở bài học gốc trên SachKTL