title: “Untitled” author: “Jorge Diaz” date: “17/4/2020” output: html_document

Ejercicio 1

1.Creando matriz XX

options(scipen=999999999)
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

2.Creando matriz X´y


```r
matriz_xy<-matrix(data=c(55331,
                         12524626,
                         4374490),nrow = 3,ncol = 1,byrow = TRUE)
print(matriz_xy)
##          [,1]
## [1,]    55331
## [2,] 12524626
## [3,]  4374490

3.Inversa matriz XX

inv_matriz_xx<-solve(matriz_xx)
print(inv_matriz_xx)
##              [,1]             [,2]             [,3]
## [1,]  0.397982654 -0.0010321198463 -0.0020893284104
## [2,] -0.001032120  0.0000053085599  0.0000007224679
## [3,] -0.002089328  0.0000007224679  0.0000242418099

4.Calculo de B

beta<-inv_matriz_xx%*%matriz_xy
print(beta)
##             [,1]
## [1,] -45.8830775
## [2,]  12.5399333
## [3,]  -0.5104348

Calculo Varianza residual

matriz_Yy<-c(152288873)
print(matriz_Yy)
## [1] 152288873
trans_Beta<-t(beta)
print(trans_Beta)
##           [,1]     [,2]       [,3]
## [1,] -45.88308 12.53993 -0.5104348
Sol<-trans_Beta%*%matriz_xy
solucion<-matriz_Yy-Sol
print(solucion)
##          [,1]
## [1,] 2546.173
n<-25
k<-3
solucion_final_VarianzaR<-solucion/(n-k)
print(solucion_final_VarianzaR)
##          [,1]
## [1,] 115.7351

Coeficiente de Determinacion

Y2<-(53331/25)^2
ny2<-n*Y2
print(ny2)
## [1] 113767822
Coeficiente_numerador<-Sol-ny2
print(Coeficiente_numerador)
##          [,1]
## [1,] 38518504
Coeficiente_denominador<-matriz_Yy-ny2
print(Coeficiente_denominador)
## [1] 38521051
R<-Coeficiente_numerador/Coeficiente_denominador
print(R)
##           [,1]
## [1,] 0.9999339

R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.