Phân tích hồi qui

Bách khoa toàn thư mở Wikipedia


Phân tích hồi qui là phương pháp thống kê mà giá trị trung bình (mean) của một hay nhiều biến ngẫu nhiên là được dự đoán dựa vào điều kiện của các biến ngẫu nhiên (đã tính toán) khác. Cụ thể, có hồi qui tuyến tình, hồi qui lôgic, hồi qui Poisson và học có giám sát. Phân tích hồi qui không chỉ là trùng khớp đường cong (lựa chọn một đường cong mà vừa khớp nhất với một tập điểm dữ liệu); nó còn phải trùng khớp với một mô hình với các thành phần ngẫu nhiên và xác định (deterministic and stochastic components). Thành phần xác định được gọi là bộ dự đoán (predictor) và thành phần ngẫu nhiên được gọi là phần sai số (error term).

Dạng đơn giản nhất của một mô hình hồi qui chứa một biến phụ thuộc (còn gọi là "biến đầu ra," "biến nội sinh," hay "biến-Y") và một biến độc lập đơn (còn gọi là "hệ số," "biến ngoại sinh," hay "biến-X").

Ví dụ thường dùng là sự phụ thuộc của huyết áp (blood pressure) Y theo tuổi tác X của một người, hay sự phụ thuộc của trọng lượng Y của một con thú nào đó theo khẩu phần thức ăn hằng ngày X. Sự phụ thuộc này được gọi là hồi qui của Y lên X.

Xem thêm: phân phối chuẩn đa biến (multivariate normal distribution), các ẩn bản quan trọng trong phân tích hồi qui.

Hồi qui thường được xếp vào loại bài toán tối ưu vì chúng ta nỗ lực để tìm kiếm một giải pháp để cho sai số là tối thiểu. Phương pháp sai số chung nhất được sử dụng là phương pháp bình phương cực tiểu: phương pháp này tương ứng với một Gaussian likelihood của việc tạo ra các dữ liệu quan sát khi biết biến ngẫu nhiên (ẩn). Về một mặt nào đó, bình phương cực tiểu là một phương pháp ước lượng tối ưu: xem định lý Gauss-Markov.

Để giải quyết bài toán tối ưu trong hồi qui thường dùng các giải thuật như giải thuật gradient descent, giải thuật Gauss-Newton, và giải thuật Levenberg-Marquardt. Các giải thuật xác suất như RANSAC có thể được dùng để tìm một phù hợp tốt cho tập mẫu, khi cho trước một mô hình tham số hóa của hàm đường cong.

Hồi qui có thể được biểu diễn bằng phương pháp maximum likelihood ước lượng các tham số của một mô hình nào đó. Tuy nhiên, với một lượng nhỏ dữ liệu, ước lượng này có thể có sai sót cao (high variance). Các phương pháp Bayesian có thể được sử dụng để ước lượng các mô hình hồi qui. Các tham số có một điều kiện trước, nó bao gồm mọi thứ đã biết trước về các biến. (Ví dụ, nếu một tham số được biết là không âm thì một phân phối không âm sẽ được gán cho nó.) A posterior distribution is then obtained for the parameter vector. Bayesian methods have the advantages that they use all the information that is available and they are exact, not asymptotic, and thus work well for small data sets. Some practitioners use maximum a posteriori (MAP) methods, a simpler method than full Bayesian analysis, in which the parameters are chosen that maximize the posterior. Các phương pháp MAP có liên hệ với Occam's Razor: ở chỗ có sự ưu tiên cho sự đơn giản, khi có nhiều mô hình hồi qui (đường cong) cũng như khi có nhiều lí thuyết thì chọn cái đơn giản.

Mục lục

[sửa] Công thức tổng quát

We want to predict the values of a random variable Y conditioned on other random variables called factors. Let p\in\mathbb{N}^* be the number of factors used for this prediction.

(\Omega,\mathcal{A}, P) will denote a probability space and (Γ,S) will be a measure space where (Γ, + ,.) may be \Gamma = \mathbb{R}^n and S=\mathcal{B}_n with n\in\mathbb{N}^*). We can now define the dependent variable Y:(\Omega,\mathcal{A})\rightarrow(\Gamma, S) and \forall i\in \{1,\cdots,p\}, X_i:(\Omega,\mathcal{A})\rightarrow(\Gamma, S). Now, let F be a set of functions defined on Ω with values in Γ such that Y,X_1,\cdots,X_p\in F and d be a metric such that (F,d) is a complete metric space.

We are looking for a measurable function f:(\Gamma^p,S^p)\rightarrow(\Gamma,S) such that d(\omega\mapsto Y(\omega),\omega\mapsto f(X_1(\omega),\cdots,X_p(\omega)) is minimal.

[sửa] Hồi qui tuyến tính

Linear regression is the most common case in practice. We suppose that the function f depends linearly on the covariates X_1,\cdots,X_p so we are really just looking for the right coefficients.

Let Θ be a set of coefficients. The hypothesis of the linear regression is:

\exists (\beta^0,\cdots,\beta^p)\in\theta^{p+1}:
\mathbb{E}(Y|X_1,\cdots,X_p)=\beta^0 + \sum_{j=1}^p \beta^j X_j

and the metric used is:

\forall f,g\in F, d(f,g) = \mathbb{E}[(f-g)^2]

We therefore want to minimize \mathbb{E}[(Y-f(X_1,\cdots,X_p))^2], which means that

f(X_1,\cdots,X_p)=\mathbb{E}(Y|X_1,\cdots,X_p) = \beta^0 + \sum_{j=1}^p \beta^j X_j.

Hence, we only need to find \beta^0,\cdots,\beta^p.

In order to solve this problem efficiently, several methods exist. The most common one is the Gauss-Markov method, but it requires extra hypotheses.

[sửa] Mô hình tuyến tính Gauss-Markov

Under assumptions which are met relatively often, there exists an optimal solution to the linear regression problem. These assumptions (called Gauss-Markov hypothesis) are:

We use the linear regression model, n\in\mathbb{N}^*, n\ge p Y=(Y_1,\cdots,Y_n) and \forall j\in\{1,\cdots,p\},X_j=(X_{1j},\cdots,X_{nj}) \Gamma = \mathbb{R}^n, S=\mathcal{B}_n We then define the error \varepsilon := Y - \mathbb{E}(Y|(X_1,\cdots,X_p))\sim\mathcal{N}(0,\sigma^2 I) independent where \sigma^2<+\infty and I is the n\times n identity matrix. (\beta^0,\cdots,\beta^p)\in\Theta^{p+1}

[sửa] Ước lượng bình phương cực tiểu của các hệ số

Xem thêm bình phương cực tiểu

We want an estimate of \beta=(\beta^0,\cdots,\beta^p). Under the Gauss-Markov assumptions, there exists an optimal solution. We can see the unknown function f = \mathbb{E}(Y|(X_1,\cdots,X_p)) as the projection of Y on the subspace of F generated by (X_1,\cdots,X_p). Let \widehat{Y}:= X\beta, where X is the matrix whose columns are (X_1,\cdots,X_p).

If we define the scalar product \langle\bullet,\bullet\rangle by \langle u,v\rangle:=u^t v and write \|\bullet\| for the induced norm, the metric d can be written d(f,g) = \mathbb{E}[\|f-g\|^2]. Minimizing this norm is equivalent to projecting orthogonally Y on the subspace induced by (X_1,\cdots,X_p).

X^t (Y-\widehat{Y}) = 0 because the projection is orthogonal, therefore, an estimate of the unknown coefficients \beta=(\beta^0,\cdots,\beta^p) is

\widehat{\beta}:=(X^t X)^{-1} X^t Y. This is called the least-squares estimate of the linear regression coefficients.

How good is this estimate? Under the Gauss-Markov assumptions, the Gauss-Markov theorem states that the least-square estimation of the linear regression coefficients are the best we can do. More precisely, under the Gauss-Markov assumptions, of all unbiased estimators of the linear regression coefficients, the least-square ones are the most efficient ones.

Things look great, but no matter how attractive, this method lacks robustness: departure from the normality assumptions will corrupt the results. However, this method is the most widely used in practice, and because of the central limit theorem, for large values of n, the Gauss-Markov assumptions are often met.

If the Gauss-Markov hypotheses are not met, a variety of techniques are available.

  • If the error term is not normal but forms an exponential family one can use generalized linear models. Other techniques include the use of weighted least squares or transforming the dependent variable using the Box-Cox transformation.
  • If outliers are present the normal distribution can be replaced by a t-distribution or, alternatively, robust regression methods may be used.
  • If the predictor is not linear a nonparametric regression or semiparametric regression or nonlinear regression may be used.

[sửa] Ví dụ

Ví dụ đơn giản nhất của hồi qui là trong trường hợp 1 chiều. Chúng ta được cấp một vec-tơ của các giá trị x và một vec-tơ khác của các giá trị y và chúng ta đang cố gắng tìm kiếm một hàm mà f(xi) = yi.

giả sử \vec{x} = \begin{pmatrix} -2 \\ -1 \\ 0 \\ 1 \\ 2 \\ \end{pmatrix},  \vec{y} = \begin{pmatrix} 5 \\ 2 \\ 1 \\ 2 \\ 5 \\ \end{pmatrix}

Giả thiết rằng giải pháp (hàm) của chúng ta là thuộc họ các hàm được định bởi chuỗi Fourier mở rộng cấp 3 (3rd degree Fourier expansion) được viết dưới dạng:

f(x) = a0 / 2 + a1cos(x) + b1sin(x) + a2cos(2x) + b2sin(2x) + a3cos(3x) + b3sin(3x)

với ai,bi là các số thực. Bài toán này có thể được biểu diễn theo dạng ma trận như sau:

\begin{pmatrix} 1/2, & \cos(x), & \sin(x), & \cos(2x), & \sin(2x), & \cos(3x), & \sin(3x), \\  \end{pmatrix} \begin{pmatrix} a_{0} \\ a_{1} \\ b_{1} \\ a_{2} \\ b_{2} \\ a_{3} \\ b_{3} \\ \end{pmatrix} = \vec{y}

điền vào dạng này các giá trị của chúng ta sẽ cho ta bài toán với dạng Xw = y

\begin{pmatrix} 1/2 & \cos(-2) & \sin(-2) & \cos(-4) & \sin(-4) & \cos(-6) & \sin(-6)\\  1/2 & \cos(-1) & \sin(-1) & \cos(-2) & \sin(-2) & \cos(-3) & \sin(-3)\\  1/2 & 1 & 0 & 1 & 0 & 1 & 0\\  1/2 & \cos(1) & \sin(1) & \cos(2) & \sin(2) & \cos(3) & \sin(3)\\  1/2 & \cos(2) & \sin(2) & \cos(4) & \sin(4) & \cos(6) & \sin(6)\\  \end{pmatrix} . \begin{pmatrix} a_{0} \\ a_{1} \\ b_{1} \\ a_{2} \\ b_{2} \\ a_{3} \\ b_{3} \\ \end{pmatrix} = \begin{pmatrix} 5 \\ 2 \\ 1 \\ 2 \\ 5 \\ \end{pmatrix}

Bài toán này bây giờ có thể chuyển thành bài toán tối ưu để tìm ra tổng cực tiểu của bình phương sai số.

hàm Fourier bậc 3
Phóng lớn
hàm Fourier bậc 3
\min_{\vec{w}} \sum_{i=1}^{n} (\vec{x_{i}}\vec{w} - y_{i})^2
\min_{\vec{w}} \|X\vec{w} - \vec{y}\|^2.

giải bằng phương pháp bình phương cực tiểu cho ra:

\vec{w} =  \begin{pmatrix} 0 \\ 4.25 \\ 0 \\ -6.13 \\ 0 \\ 2.88 \\ 0 \\ \end{pmatrix}

vì thế hàm Fourier bậc 3 mà trùng khớp nhất với dữ liệu có công thức cụ thể:

f(x) = 4.25cos(x) − 6.13cos(2x) + 2.88cos(3x).

[sửa] Xem thêm

[sửa] Tham khảo

  • Audi, R., Ed. (1996) The Cambridge Dictionary of Philosophy. Cambridge, Cambridge University Press. curve fitting problem p.172-173.
  • David Birkes and Yadolah Dodge, Alternative Methods of Regression (1993), ISBN 0-471-56881-3
  • W. Hardle, Applied Nonparametric Regression (1990), ISBN 0-521-42950-1
  • J. Fox, Applied Regression Analysis, Linear Models and Related Methods. (1997), Sage

[sửa] Liên kết ngoài