1. Generando la matriz X’X
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)
## Warning in print.default(matriz_xx): NAs introduced by coercion to integer range
##      [,1]    [,2]   [,3]
## [1,]   25    4586   2018
## [2,] 4586 1030398 364545
## [3,] 2018  364545 204312
## Warning in print.default(matriz_xx): NAs introduced by coercion to integer range
  1. Generando la mariz X’Y
matriz_xy<-matrix(data = c(55331,
                           12524626,
                           4374490),nrow = 3,ncol = 1, byrow = TRUE)
print(matriz_xy)
## Warning in print.default(matriz_xy): NAs introduced by coercion to integer range
##          [,1]
## [1,]    55331
## [2,] 12524626
## [3,]  4374490
## Warning in print.default(matriz_xy): NAs introduced by coercion to integer range
  1. Calculando la inversa de X’X, es decir (X’X)-1 A través de Gauss-Jordan, u otro método (usando 10 decimales para el redondeo) se obtiene:
inv_matriz_xx<-solve(matriz_xx)
print(inv_matriz_xx)
## Warning in print.default(inv_matriz_xx): NAs introduced by coercion to integer
## range
##              [,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
## Warning in print.default(inv_matriz_xx): NAs introduced by coercion to integer
## range
  1. Calculando el estimador de parametros β puede hacerse a traves del producto de “inv_matriz_xx” con “matriz_xy”,usando el operador de producto de matrices %*%
beta<-inv_matriz_xx%*%matriz_xy
print(beta)
## Warning in print.default(beta): NAs introduced by coercion to integer range
##             [,1]
## [1,] -45.8830775
## [2,]  12.5399333
## [3,]  -0.5104348
## Warning in print.default(beta): NAs introduced by coercion to integer range

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)
## Warning in print.default(beta): NAs introduced by coercion to integer range
##             [,1]
## [1,] -45.8830775
## [2,]  12.5399333
## [3,]  -0.5104348
## Warning in print.default(beta): NAs introduced by coercion to integer range

Solución de ejercicio #2

  1. Generando la matriz X’X
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)
## Warning in print.default(matriz_xx): NAs introduced by coercion to integer range
##      [,1]    [,2]  [,3]
## [1,]   26    5857   131
## [2,] 5857 1675143 28173
## [3,]  131   28173   869
## Warning in print.default(matriz_xx): NAs introduced by coercion to integer range
  1. Generando matriz X’Y
matriz_xy<-matrix(data = c(1181,
                           298629,
                           6068),nrow = 3,ncol = 1, byrow = TRUE)
print(matriz_xy)
## Warning in print.default(matriz_xy): NAs introduced by coercion to integer range
##        [,1]
## [1,]   1181
## [2,] 298629
## [3,]   6068
## Warning in print.default(matriz_xy): NAs introduced by coercion to integer range

Estimadores β

beta<-solve(matriz_xx,matriz_xy)
print(beta)
## Warning in print.default(beta): NAs introduced by coercion to integer range
##             [,1]
## [1,] 17.86018879
## [2,]  0.09602564
## [3,]  1.17719778
## Warning in print.default(beta): NAs introduced by coercion to integer range