Processing math: 100%

40 votos

¿Existe una manera de utilizar la matriz de covarianza para encontrar coeficientes para la regresión múltiple?

Para la regresión lineal simple, el coeficiente de regresión es calculable directamente de la varianza-covarianza de la matriz C, por Cd,eCe,e donde d es la variable dependiente es el índice, y e es la variable explicativa del índice.

Si sólo se dispone de la matriz de covarianza, es posible calcular los coeficientes de un modelo con múltiples variables explicativas?

ETA: Para dos variables explicativas, parece que β1=Cov(y,x1)var(x2)Cov(y,x2)Cov(x1,x2)var(x1)var(x2)Cov(x1,x2)2 y de forma análoga para β2. No estoy de inmediato al ver cómo extender a tres o más variables.

59voto

jldugger Puntos 7490

Sí, la matriz de covarianza de todas las variables--explicativo y respuesta-contiene la información necesaria para encontrar todos los coeficientes, siempre y una intercepción (constante) plazo se incluye en el modelo. (Aunque las covarianzas no proporciona ninguna información sobre el término constante, se puede encontrar desde los medios de la información).


Análisis

Deje que los datos para las variables explicativas, se pueden organizar como n-dimensiones vectores columna x1,x2,,xp y la variable de respuesta sea el vector columna y, que se considera ser una realización de una variable aleatoria Y. Los cálculos por mínimos cuadrados ordinarios ˆβ de los coeficientes en el modelo de

E(Y)=α+Xβ

are obtained by assembling the p+1 column vectors X0=(1,1,,1),X1,,Xp into an n×p+1 array X and solving the system of linear equations

XXˆβ=Xy.

It is equivalent to the system

1nXXˆβ=1nXy.

Gaussian elimination will solve this system. It proceeds by adjoining the p+1×p+1 matrix 1nXX and the p+1-vector 1nXy into a p+1×p+2 array $$ and row-reducing it.

The first step will inspect 1n(XX)11=1nX0X0=1. Finding this to be nonzero, it proceeds to subtract appropriate multiples of the first row of A from the remaining rows in order to zero out the remaining entries in its first column. These multiples will be 1nX0Xi=¯Xi and the number subtracted from the entry Ai+1,j+1=XiXj will equal ¯Xi¯Xj. This is just the formula for the covariance of Xi and Xj. Moreover, the number left in the i+1,p+2 position equals 1nXiy¯Xi¯y, the covariance of Xi with y.

Thus, after the first step of Gaussian elimination the system is reduced to solving

Cˆβ=(Cov(Xi,y))

and obviously--since all the coefficients are covariances--that solution can be found from the covariance matrix of all the variables.

(When C is invertible the solution can be written C1(Cov(Xi,y)). The formulas given in the question are special cases of this when p=1 and p=2. Writing out such formulas explicitly will become more and more complex as p grows. Moreover, they are inferior for numerical computation, which is best carried out by solving the system of equations rather than by inverting the matrix C.)

The constant term will be the difference between the mean of s and the mean values predicted from the estimates, Xˆβ.


Ejemplo

Para ilustrar, los siguientes R código crea algunos datos, calcula sus covarianzas, y obtiene los mínimos cuadrados de los coeficientes estimados únicamente a partir de esa información. Se compara con las estimaciones obtenidas a partir de los mínimos cuadrados estimador lm.

#
# 1. Generate some data.
#
set.seed(17)
n <- 10; p <- 2
z <- matrix(rnorm(n*(p+1)), nrow=n)
y <- z[, p+1]; x <- z[, -(p+1)]
#
# 2. Find the OLS coefficients from the covariances only.
#
a <- cov(x)
b <- cov(x,y)
t(beta.hat <- solve(a, b)) # Coefficients from the covariance matrix
mean(y - x %*% beta.hat)   # Intercept from the covariance matrix and means
coef(lm(y ~ x))            # OLS solution

La salida muestra el acuerdo entre los dos métodos:

> t(beta.hat <- solve(a, b)) # Coefficients from the covariance matrix
          [,1]      [,2]
[1,] -0.424551 -1.006675
> mean(y - x %*% beta.hat)   # Intercept from the covariance matrix and means
[1] 0.946155
> coef(lm(y ~ x))
(Intercept)          x1          x2 
   0.946155   -0.424551   -1.006675 

i-Ciencias.com

I-Ciencias es una comunidad de estudiantes y amantes de la ciencia en la que puedes resolver tus problemas y dudas.
Puedes consultar las preguntas de otros usuarios, hacer tus propias preguntas o resolver las de los demás.

Powered by:

X