En este espacio se encuentra un documento de apoyo para la aplicacion de matrices en Rstudio https://r-coder.com/operaciones-matrices-r/.
Se realiza la aplicacion multivariavle en Rstudio:
## Regresión multivariable
# Definir las matrices de datos
dates <- matrix(c(2, 2.5, 2, 3, 3, 4, 4, 5, 6, 10, 8, 9), nrow = 4, byrow = TRUE)
x <- matrix(c(1, 2.5, 2, 1, 3, 4, 1, 5, 6, 1, 8, 9), nrow = 4, byrow = TRUE)
y <- matrix(c(2, 3, 4, 10), nrow = 4, byrow = TRUE)
# Calcular la transpuesta de x
xt <- t(x)
# Calcular xt * x
xt_x <- xt %*% x
# Calcular la inversa de (xt * x)
xt_x_inv <- solve(xt_x)
# Calcular xt * y
xt_y <- xt %*% y
# Calcular los coeficientes (betas)
betas <- xt_x_inv %*% xt_y
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.