options(scipen = 9999999999)
matriz_xx<-matrix(data = c(25,4586, 2018,
4586, 1030398, 364545,
2018, 364545, 204312),nrow = 3,ncol = 3,byrow = TRUE)
print(matriz_xx)
## [,1] [,2] [,3]
## [1,] 25 4586 2018
## [2,] 4586 1030398 364545
## [3,] 2018 364545 204312
matriz_xy<-matrix(data = c(55331,
12524626,
4374490),nrow = 3,ncol = 1, byrow = TRUE)
print(matriz_xy)
## [,1]
## [1,] 55331
## [2,] 12524626
## [3,] 4374490
inv_matriz_xx<-solve(matriz_xx)
print(inv_matriz_xx)
## [,1] [,2] [,3]
## [1,] 0.397982654 -1.032120e-03 -2.089328e-03
## [2,] -0.001032120 5.308560e-06 7.224679e-07
## [3,] -0.002089328 7.224679e-07 2.424181e-05
beta<-inv_matriz_xx%*%matriz_xy
print(beta)
## [,1]
## [1,] -45.8830775
## [2,] 12.5399333
## [3,] -0.5104348
Tambien es posible a través de la solución del sistema de ecuaciones normales X’X.β=X’Y
beta<-solve(matriz_xx,matriz_xy)
print(beta)
## [,1]
## [1,] -45.8830775
## [2,] 12.5399333
## [3,] -0.5104348
options(scipen = 9999999999)
matriz_xx<-matrix(data = c(26, 5857, 131,
5857, 1675143, 28173,
131, 28173, 869),nrow = 3,ncol = 3,byrow = TRUE)
print(matriz_xx)
## [,1] [,2] [,3]
## [1,] 26 5857 131
## [2,] 5857 1675143 28173
## [3,] 131 28173 869
matriz_xy<-matrix(data = c(1181,
298629,
6068),nrow = 3,ncol = 1, byrow = TRUE)
print(matriz_xy)
## [,1]
## [1,] 1181
## [2,] 298629
## [3,] 6068
Estimadores β
beta<-solve(matriz_xx,matriz_xy)
print(beta)
## [,1]
## [1,] 17.86018879
## [2,] 0.09602564
## [3,] 1.17719778