Regresion Lineal Multiple Ejercicios Resueltos A Mano

La regresión lineal múltiple es una técnica estadística fundamental que nos permite modelar la relación entre una variable dependiente (Y) y dos o más variables independientes (X1, X2, ..., Xk). Aunque hoy en día el software estadístico hace los cálculos en milisegundos, resolver un ejercicio a mano es crucial para entender la lógica subyacente: matrices, derivadas parciales y el significado de cada coeficiente.

En este artículo, resolveremos dos ejercicios completos usando el método de Mínimos Cuadrados Ordinarios (MCO). Trabajaremos con:


Problema: Se tienen datos de 5 empresas. Se quiere explicar las ventas anuales ((Y), en miles de euros) en función del gasto en publicidad en TV ((X_1), en cientos de euros) y el gasto en publicidad en redes sociales ((X_2), en decenas de euros).

| Empresa | (Y) (Ventas) | (X_1) (TV) | (X_2) (RRSS) | |---------|----------------|---------------|----------------| | 1 | 23 | 2 | 3 | | 2 | 26 | 3 | 4 | | 3 | 30 | 5 | 5 | | 4 | 34 | 6 | 6 | | 5 | 37 | 8 | 7 |

Objetivo: Encontrar (\hatY = \hat\beta_0 + \hat\beta_1 X_1 + \hat\beta_2 X_2) regresion lineal multiple ejercicios resueltos a mano

In the world of statistics and data science, Multiple Linear Regression (MLR) is a fundamental tool for predicting a dependent variable based on two or more independent variables. While modern software like R, Python, or SPSS can compute regression coefficients instantly, doing it by hand builds a deep, intuitive understanding of the math behind the curtain.

In this article, we will break down the matrix algebra and normal equations needed to solve MLR problems manually. We will work through a complete, solved exercise step by step.

Given data:

| (X_1) | (X_2) | (Y) | |---------|---------|-------| | 2 | 3 | 10 | | 4 | 1 | 12 | | 6 | 2 | 16 | La regresión lineal múltiple es una técnica estadística

Find (\hatY = b_0 + b_1X_1 + b_2X_2).

Answer (after solving): (\hatY = 6 + 1.5X_1 - 1X_2) (approximately).


[ \hatY = 55 + 5X_1 + 0X_2 ]

Interesting result: Sleep hours ((X_2)) has no effect in this sample. The model simplifies to simple linear regression. Problema : Se tienen datos de 5 empresas

[ \mathbfX'\mathbfX = \beginbmatrix 1 & 1 & 1 & 1 \ 1 & 2 & 3 & 4 \ 2 & 1 & 3 & 2 \ 1 & 2 & 3 & 4 \endbmatrix \beginbmatrix 1 & 1 & 2 & 1 \ 1 & 2 & 1 & 2 \ 1 & 3 & 3 & 3 \ 1 & 4 & 2 & 4 \endbmatrix ]

Calculamos elemento a elemento:

Entonces: [ \mathbfX'\mathbfX = \beginbmatrix 4 & 10 & 7 & 10 \ 10 & 30 & 21 & 30 \ 7 & 21 & 18 & 21 \ 10 & 30 & 21 & 30 \endbmatrix ]

(Observación: las columnas 2 y 4 son iguales, lo que indica multicolinealidad perfecta – un problema real. Para el ejercicio didáctico, seguiremos, pero en la práctica debe corregirse.)

| Week | (X_1) | (X_2) | (Y) | (X_1Y) | (X_2Y) | (X_1^2) | (X_2^2) | (X_1X_2) | |------|---------|---------|-------|----------|----------|----------|----------|------------| | 1 | 1 | 2 | 5 | 5 | 10 | 1 | 4 | 2 | | 2 | 2 | 3 | 8 | 16 | 24 | 4 | 9 | 6 | | 3 | 3 | 4 | 11 | 33 | 44 | 9 | 16 | 12 | | 4 | 4 | 5 | 14 | 56 | 70 | 16 | 25 | 20 | | Sum | 10 | 14 | 38 | 110 | 148 | 30 | 54 | 40 |

Predict exam score for (X_1=4, X_2=7): [ \hatY = 55 + 5(4) = 75 ]