Laboratorio 7 Stephanie Banquez 2026-09-17 utput: html_document: toc: true toc_float: true toc_depth: 3 number_sections: true theme: cosmo highlight: tango code_folding: show df_print: paged css: styles.css pdf_document: toc: true number_sections: true highlight: tango word_document: toc: true number_sections: true 📊📊📊📊📊📊📊📊📊📊📊 MI CURSO DE ESTADÍSTICA Y PROBABILIDAD - 2026 🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯 🎯🎯🎯🎯🎯 SEMANA 7. Mi página Web en Estadistica 📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊 📊📊📊📊📊 Clase N° 28. LABORATORIO 7 ANALISIS DE DATOS EN R 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 🚀🚀🚀🚀🚀

library(readxl)
DATOS2026 <- read_excel("00. DATOS202460ULTIMOS25 (1).xlsx")
DATOS2026
## # A tibble: 74 × 16
##    CURSO    ASISTENCIA2 ASISTENCIA1 `PARCIAL 1` `PARCIAL 2`   NRC PROGRAMA  EDAD
##    <chr>          <dbl>       <dbl> <chr>       <chr>       <dbl> <chr>    <dbl>
##  1 PROBABI…         100          90 3.6         4.3          2314 F_NEGOC…    20
##  2 ESTADIS…          70          75 0.9         2.5          1136 DERECHO     18
##  3 PROBABI…          85          95 3.9         3.8          2314 F_NEGOC…    19
##  4 PROBABI…           5           5 2.9         0.5          2314 MECANICA    18
##  5 ESTADIS…          20          70 3.7         0.55         1009 PSICOLO…    19
##  6 ESTADIS…         100         100 0.9         2.95         2313 PSICOLO…    20
##  7 PROBABI…          50          75 3.7         1.7          1010 C_DATOS     18
##  8 PROBABI…         100          95 3           3.3          2314 F_NEGOC…    19
##  9 ESTADIS…         100         100 3.8         3.3          1009 PSICOLO…    18
## 10 PROBABI…          95          85 3           2.9          2314 SISTEMAS    22
## # ℹ 64 more rows
## # ℹ 8 more variables: PESO <dbl>, ESTATURA <dbl>, SEXO <chr>,
## #   ESTADO_CIVIL <chr>, ESTRATO <chr>, URBANO <chr>, TRANSPORTE <chr>,
## #   GR_SANGUINEO <chr>

#####<-========== PASO 4. =========->

table_sexo<-table(DATOS2026$SEXO)
table_sexo
## 
##  Femenino Masculino 
##        42        32

#####<-========== PASO 5.=========->

pie_1<-pie(table_sexo, col=c("lightblue","pink"),
main="Estudio de Pastel. Stephanie Banquez \n Distribución por
sexos.", labels = table_sexo)

#####<-========== PASO 6. =========->

barp<-barplot(table_sexo, col = rainbow(5), border = "darkred",main =
"Gráfico de Barras STEPHANIE BANQUEZ ",sub = "UTB",xlab = "SEXO", ylab =
"Conteo")
text(barp, table_sexo-30, labels = table_sexo)

#####<-========== PASO 7. =========->

table_sexo2<-round(table(DATOS2026$SEXO)/74*100)
table_sexo2
## 
##  Femenino Masculino 
##        57        43

#####<-========== PASO 8. =========->

barp2<-barplot(table_sexo2, col = rainbow(5), border = "darkred",main =
"Gráfico de Barras STEPHANIE BANQUEZ ",sub = "UTB",xlab = "SEXO", ylab =
"Porcentaje")
text(barp2, table_sexo2-30, labels = table_sexo2)

###<-========== PASO 9. =========-> ###

pie_1<-pie(table_sexo2, col=c("lightblue","pink"),
main="Estudio de Pastel.\n Distribución por sexos.", labels =
table_sexo2)

#####<-========== PASO 10. =========->

table_3<-table(DATOS2026$SEXO, DATOS2026$CURSO)
table_3
##            
##             ESTADISTICAI PROBABILIDAD
##   Femenino            16           26
##   Masculino           10           22

#####<-========== PASO 11. =========->

barp3<-barplot(table_3,
main = "Gráfico de barras CURSO vs SEXO",
xlab = "CURSO", ylab = "Frecuencia",
col = c("pink", "blue"),
legend.text = rownames(table_3),
beside = TRUE) # Barras agrupadas
text(barp3, table_3-5, labels = table_3)

#####<-========== PASO 12. =========->

table_4<-round(table(DATOS2026$SEXO, DATOS2026$CURSO)/74*100)
table_4
##            
##             ESTADISTICAI PROBABILIDAD
##   Femenino            22           35
##   Masculino           14           30

#####<-========== PASO 13. =========->

barp4<-barplot(table_4,
main = "Gráfico de barras CURSO vs SEXO en porcentajes",
xlab = "CURSO", ylab = "Frecuencia",
col = c("pink", "blue"),
legend.text = rownames(table_4),
beside = TRUE) # Barras agrupadas
text(barp4, table_4-5, labels = table_4)

#####<-========== PASO 14. =========->

table_5<-table(DATOS2026$ESTRATO, DATOS2026$CURSO)
table_5
##      
##       ESTADISTICAI PROBABILIDAD
##   I              5           10
##   II             7           18
##   III            9            9
##   IV             5            5
##   V              0            5

#####<-========== PASO 15. =========->

barp3<-barplot(table_5,
main = "Gráfico de barras CURSO vs ESTRATO",
xlab = "CURSO", ylab = "Frecuencia",
col = rainbow(5),
legend.text = rownames(table_5),
beside = TRUE) # Barras agrupadas
text(barp3, table_5-1, labels = table_3)

#####<-========== PASO 16. =========->

table_6<-table(DATOS2026$ESTRATO, DATOS2026$SEXO)
table_6
##      
##       Femenino Masculino
##   I          8         7
##   II        17         8
##   III       10         8
##   IV         4         6
##   V          3         2

#####<-========== PASO 17. =========->

barp3<-barplot(table_6,
main = "Gráfico de barras CURSO vs ESTRATO",
xlab = "CURSO", ylab = "Frecuencia",
col = rainbow(5),
legend.text = rownames(table_6),
beside = TRUE) # Barras agrupadas
text(barp3, table_6-1, labels = table_6)

<-========== PASO 18. ==========->
library(summarytools) 
## Warning in fun(libname, pkgname): couldn't connect to display ":0"
## system might not have X11 capabilities; in case of errors when using dfSummary(), set st_options(use.x11 = FALSE)
if (!requireNamespace("summarytools", quietly = TRUE)) {
install.packages("summarytools", repos = "https://cloud.r-project.org")
} 
tabla_8 <- freq(DATOS2026$EDAD)
tabla_8
## Frequencies  
## DATOS2026$EDAD  
## Type: Numeric  
## 
##               Freq   % Valid   % Valid Cum.   % Total   % Total Cum.
## ----------- ------ --------- -------------- --------- --------------
##          17      7      9.46           9.46      9.46           9.46
##          18     32     43.24          52.70     43.24          52.70
##          19     21     28.38          81.08     28.38          81.08
##          20      7      9.46          90.54      9.46          90.54
##          21      4      5.41          95.95      5.41          95.95
##          22      3      4.05         100.00      4.05         100.00
##        <NA>      0                               0.00         100.00
##       Total     74    100.00         100.00    100.00         100.00

#####<-========== PASO 19. =========->

library(summarytools)
summary(DATOS2026$EDAD)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    17.0    18.0    18.0    18.7    19.0    22.0

#####<-========== PASO 20. =========->

boxplot(DATOS2026$EDAD, horizontal = TRUE, col = rainbow(3))

#####<-========== PASO 21. =========->

x = DATOS2026$EDAD
boxplot(x, notch = FALSE, horizontal = FALSE, col = rainbow(3))

#####<-========== PASO 22. =========->

x = DATOS2026$EDAD
y = DATOS2026$SEXO
boxplot(x~y, horizontal = TRUE, col = rainbow(3))

#####<-========== PASO 23. =========->

library(summarytools)
x = DATOS2026$EDAD
z = DATOS2026$ESTRATO
boxplot(x~z, horizontal = TRUE, col = rainbow(3))

####<-========== PASO 24. =========->

library(ggplot2)

if (!requireNamespace("ggplot2", quietly = TRUE)) {
install.packages("ggplot2", repos = "https://cloud.r-project.org")
}

ggplot(data = DATOS2026, aes(y = EDAD, x = ESTRATO, fill = SEXO)) +
geom_boxplot() +
scale_y_continuous(name = "EDAD") +
scale_x_discrete(labels = abbreviate, name = "ESTRATO")

####<-========== PASO 25. =========->

summary(DATOS2026$ESTATURA)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   153.0   163.0   168.0   168.4   174.0   192.0

####<-========== PASO 26. =========->

boxplot(DATOS2026$ESTATURA, horizontal = TRUE, col = rainbow(3))

####<-========== PASO 27. =========->

x = DATOS2026$ESTATURA
boxplot(x, notch = TRUE, horizontal = TRUE, col = rainbow(3))

####<-========== PASO 28. =========->

x = DATOS2026$ESTATURA
y = DATOS2026$SEXO
boxplot(x~y, horizontal = TRUE, col = rainbow(3))

####<-========== PASO 29. =========->

library(ggplot2)
x = DATOS2026$ESTATURA
z = DATOS2026$ESTRATO
boxplot(x~z, horizontal = TRUE, col = rainbow(3))

###<-========== PASO 30. =========->

(28i)ESTATURA vs ESTRATO vs SEXO

library(ggplot2)
ggplot(data= DATOS2026,mapping= aes(y=ESTATURA,x = ESTRATO, fill=SEXO))+geom_boxplot()+
  scale_y_continuous(name = "ESTATURA") +
  scale_x_discrete(labels = abbreviate, name = "ESTRATO")

##<-========== PASO 31. =========->

(29i)Histograma y tabla de frecuencias usando Regla de Sturges

# Instalar la librería
install.packages("agricolae", repos = "https://cloud.r-project.org")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.6'
## (as 'lib' is unspecified)
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.6'
## (as 'lib' is unspecified)
# Cargar la librería
library(agricolae)
# Crear el histograma
h2 <- graph.freq(DATOS2026$EDAD, col = colors()[75])

####<-========== PASO 32. =========->

summary(h2)
##   Lower Upper  Main Frequency Percentage CF   CPF
## 1  17.0  17.7 17.35         7        9.5  7   9.5
## 2  17.7  18.4 18.05        32       43.2 39  52.7
## 3  18.4  19.1 18.75        21       28.4 60  81.1
## 4  19.1  19.8 19.45         0        0.0 60  81.1
## 5  19.8  20.5 20.15         7        9.5 67  90.5
## 6  20.5  21.2 20.85         4        5.4 71  95.9
## 7  21.2  21.9 21.55         0        0.0 71  95.9
## 8  21.9  22.6 22.25         3        4.1 74 100.0

####<-========== PASO 33. =========->

plot(h2, col=colors()[70], frequency = 1)
polygon.freq(h2, col = "red", frequency = 1, lwd = 2)

####<-========== PASO 34. =========->

plot(h2, col=colors()[70], frequency = 2)
polygon.freq(h2, col = "red", frequency = 2, lwd = 2)

####<-========== PASO 35. =========->

fr_por_clase2<-h2$counts
fr_por_clase2
## [1]  7 32 21  0  7  4  0  3
## [1] 7 32 21 0 7 4 0 3
total_n2<-sum(h2$counts)
total_n2
## [1] 74
## [1] 74
fr_relativos2<-fr_por_clase2/total_n2
fr_porcentuales2<-100*fr_relativos2
fr_porcentuales2
## [1]  9.459459 43.243243 28.378378  0.000000  9.459459  5.405405  0.000000
## [8]  4.054054
cumsum(fr_relativos2)
## [1] 0.09459459 0.52702703 0.81081081 0.81081081 0.90540541 0.95945946 0.95945946
## [8] 1.00000000
cumsum(fr_porcentuales2)
## [1]   9.459459  52.702703  81.081081  81.081081  90.540541  95.945946  95.945946
## [8] 100.000000

####<-========== PASO 36. =========->

p4<-cumsum(fr_porcentuales2)
plot(p4, col = "red")
lines(p4, col = "red")

####<-========== AQUI INICIA EL LABORATORIO 8. VARIABLES RELACIONADAS=========->

MI CURSO DE ESTADÍSTICA Y PROBABILIDAD - 2026

🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯🎯

SEMANA 8. Mi página Web en Estadistica

POR STEPHANIE GABRIELA BANQUEZ SERPA

📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊📊

Clase N° 32. AQUI COMIENZA EL LABORATORIO 8 Regresión lineal

🌈🧪🌟💻✨🧠📈🔬⚗️📚💻🌈🧪🌟💻✨🧠📈🌈🧪🌟💻✨🧠📈🔬⚗️📚💻🌈🧪🌟💻✨🧠📈

####<-========== PASO 37. =========->

table_bv1<-table(DATOS2026$SEXO, DATOS2026$CURSO)
table_bv1
##            
##             ESTADISTICAI PROBABILIDAD
##   Femenino            16           26
##   Masculino           10           22

####<-========== PASO 38. =========->

barp_bv1<-barplot(table_bv1,
        main = "Gráfico de barras CURSO vs SEXO",
        xlab = "CURSO", ylab = "Frecuencia",
        col = c("pink", "blue"),
        legend.text = rownames(table_bv1),
        beside = TRUE) # Barras agrupadas
text(barp_bv1, table_bv1-5, labels = table_bv1)

####<-========== PASO 39. =========->

table_bv2<-table(DATOS2026$ESTRATO, DATOS2026$CURSO)
table_bv2
##      
##       ESTADISTICAI PROBABILIDAD
##   I              5           10
##   II             7           18
##   III            9            9
##   IV             5            5
##   V              0            5

####<-========== PASO 40. =========->

barp_bv2<-barplot(table_bv2,
        main = "Gráfico de barras CURSO vs ESTRATO",
        xlab = "CURSO", ylab = "Frecuencia",
        col = rainbow(5),
        legend.text = rownames(table_bv2),
        beside = TRUE) # Barras agrupadas
text(barp_bv2, table_bv2-1, labels = table_bv2)

##<-========== PASO 41. =========-> ### (38i)Una variable cualitativa y la otra cuantitativa: es necesario un boxplot

x = DATOS2026$EDAD
y = DATOS2026$SEXO
boxplot(x~y, horizontal = TRUE, col = rainbow(3))

####<-========== PASO 42. =========->

(39i)Una variable cualitativa y la otra cuantitativa: es necesario un boxplot

library(ggplot2)
x = DATOS2026$EDAD
z = DATOS2026$ESTRATO
boxplot(x~z, horizontal = TRUE, xlab = "EDAD", ylab = "ESTRATOS", col = rainbow(3))

#<-========== PASO 43. =========-> ## (40i)Una variable cualitativa y la otra cuantitativa: es necesario un boxplot

library(ggplot2)
x = DATOS2026$ESTATURA
z = DATOS2026$SEXO
boxplot(x~z, horizontal = TRUE, xlab = "ESTATURA", ylab = "SEXO", col = rainbow(3))

##<-========== PASO 44. =========->

(41i)Dos variables cuantitativas: es necesario un diagrama de dispersión

library(ggplot2)
x = DATOS2026$ESTATURA
y = DATOS2026$PESO
plot(x,y,  xlab = "ESTATURA", ylab = "PESO", col = rainbow(3))
#dibujar una línea punteada vertical en el valor medio
mean(x)
## [1] 168.3919
mean(y)
## [1] 63.32432
abline (v = mean (x), lwd = 3, lty = 2)
 #dibujar una línea punteada horizontal en el valor medio
abline (h = mean (y), lwd = 3, lty = 2)

##<-========== PASO 45. =========->

mean(x)
## [1] 168.3919
mean(y)
## [1] 63.32432

##<-========== PASO 46. =========->

(42i)Recta de regresión lineal Simple

regresion1 = lm(y~x, data=DATOS2026)
regresion1
## 
## Call:
## lm(formula = y ~ x, data = DATOS2026)
## 
## Coefficients:
## (Intercept)            x  
##    -84.1267       0.8756

##<-========== PASO 47. =========->

(43i)Recta de regresión lineal Simple2

regresion2 = lm(x~y, data=DATOS2026)
regresion2
## 
## Call:
## lm(formula = x ~ y, data = DATOS2026)
## 
## Coefficients:
## (Intercept)            y  
##    137.0763       0.4945

##<-========== PASO 48. =========->

(45i)Recta de regresión lineal Simple

Haciendo uso de RStudio con la función summary.

summary(regresion2)
## 
## Call:
## lm(formula = x ~ y, data = DATOS2026)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -13.7479  -4.6462  -0.2041   4.1066  16.1973 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 137.07631    4.28941  31.957  < 2e-16 ***
## y             0.49453    0.06669   7.416 1.88e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 6.47 on 72 degrees of freedom
## Multiple R-squared:  0.433,  Adjusted R-squared:  0.4252 
## F-statistic: 54.99 on 1 and 72 DF,  p-value: 1.881e-10

##<-========== PASO 49. =========->

46i Diagrama de Dispersión y lineal de regresión

library(ggplot2)
x = DATOS2026$ESTATURA
y = DATOS2026$PESO
plot(x,y,  xlab = "ESTATURA", ylab = "PESO", col = rainbow(3), main = "y_ajus= a + bx = -13.2018+0.4552x, r= 0.4352732")
#dibujar una línea punteada vertical en el valor medio
abline (v = mean (x), lwd = 3, lty = 2)
 #dibujar una línea punteada horizontal en el valor medio
abline (h = mean (y), lwd = 3, lty = 2)

#ajustar un modelo de regresión lineal a los datos
 regresion1 <- lm (y ~ x, data = DATOS2026)

#definir los valores de intersección y pendiente
 a <- -13.20178 #Intercepto 
b <- 0.4552 # pendiente

#agregue la línea de regresión ajustada al diagrama de dispersión
 abline (a = a, b = b, col = "steelblue")

##<-========== PASO 50. =========-> ### Problema de aplicación:En la siguiente base de datos se encuentran consignados los pesos y estaturas de 50 estudiantes seleccionados al azar de un grupo de Estudiantes de Estadística I de la UTB.Complete el siguiente formulario de preguntas:

(a)Datos

taller_rl <- data.frame (x = c (88, 77, 68, 80, 68, 55, 89, 61, 72, 72, 79, 75, 68, 65, 70, 52, 78, 55, 96, 75, 44, 57, 60, 50, 93), y = c (175, 183, 158, 165, 175, 160, 160, 156, 174, 171, 160, 184, 163, 176, 167, 172, 168, 167, 181, 175, 153, 154, 169, 168, 187))

##<-========== PASO 51. =========->

(b)Diagrama de dispersión

plot(taller_rl$x,taller_rl$y,  xlab = "PESO", ylab = "ESTATURA", col = rainbow(3))
#dibujar una línea punteada vertical en el valor medio
mean(taller_rl$x)
## [1] 69.88
mean(taller_rl$y)
## [1] 168.84
abline (v = mean (taller_rl$x), lwd = 3, lty = 2)
 #dibujar una línea punteada horizontal en el valor medio
abline (h = mean (taller_rl$y), lwd = 3, lty = 2)

##<-========== PASO 52. =========->

(51i)Coeficiente de Correlación de Pearson

cor(taller_rl$x,taller_rl$y)
## [1] 0.5133798

###<-========== PASO 52. =========-> ## (d)Recta de regresión lineal Simple

regresion3 = lm(taller_rl$y~taller_rl$x, data=taller_rl)
regresion3
## 
## Call:
## lm(formula = taller_rl$y ~ taller_rl$x, data = taller_rl)
## 
## Coefficients:
## (Intercept)  taller_rl$x  
##    143.9296       0.3565

##<-========== PASO 54. =========-> ### (e)Recta de regresión lineal Simple

Haciendo uso de RStudio con la función summary.

summary(regresion3)
## 
## Call:
## lm(formula = taller_rl$y ~ taller_rl$x, data = taller_rl)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -15.656  -6.614   1.404   6.247  13.335 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 143.9296     8.8404  16.281 4.06e-14 ***
## taller_rl$x   0.3565     0.1242   2.869  0.00867 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 8.315 on 23 degrees of freedom
## Multiple R-squared:  0.2636, Adjusted R-squared:  0.2315 
## F-statistic: 8.231 on 1 and 23 DF,  p-value: 0.008673
plot(taller_rl$x,taller_rl$y,  xlab = "PESO", ylab = "ESTATURA", col = rainbow(3))
#dibujar una línea punteada vertical en el valor medio
mean(taller_rl$x)
## [1] 69.88
mean(taller_rl$y)
## [1] 168.84
abline (v = mean (taller_rl$x), lwd = 3, lty = 2)
 #dibujar una línea punteada horizontal en el valor medio

abline (h = mean (taller_rl$y), lwd = 3, lty = 2)

#ajustar un modelo de regresión lineal a los datos
 regresion3 = lm(taller_rl$y~taller_rl$x, data=taller_rl)

#definir los valores de intersección y pendiente
 a <- 143.9296 #Intercepto 
b <- 0.3565 # pendiente

#agregue la línea de regresión ajustada al diagrama de dispersión
 abline (a = a, b = b, col = "steelblue")

##<-========== PASO 55. =========->

(52i)Los datos del fichero EdadPesoGrasas.txt corresponden a tres variables medidas en 25 individuos: edad, peso y cantidad de grasas en sangre. Para leer el fichero de datos y saber los nombres de las variables:

grasas <- read.table('http://verso.mat.uam.es/~joser.berrendero/datos/EdadPesoGrasas.txt', header = TRUE)
names(grasas)
## [1] "peso"   "edad"   "grasas"

##<-========== PASO 56. =========->

(53i)una matriz de diagramas de dispersión

pairs(grasas)

#<-========== PASO 57. =========->

(54i)una matriz de correlacion

cor(grasas)
##             peso      edad    grasas
## peso   1.0000000 0.2400133 0.2652935
## edad   0.2400133 1.0000000 0.8373534
## grasas 0.2652935 0.8373534 1.0000000

#<-========== PASO 58. =========->

(55i)Cálculo y representacion de la recta de mínimos cuadrados

regresion <- lm(grasas ~ edad, data = grasas)
summary(regresion)
## 
## Call:
## lm(formula = grasas ~ edad, data = grasas)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -63.478 -26.816  -3.854  28.315  90.881 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 102.5751    29.6376   3.461  0.00212 ** 
## edad          5.3207     0.7243   7.346 1.79e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 43.46 on 23 degrees of freedom
## Multiple R-squared:  0.7012, Adjusted R-squared:  0.6882 
## F-statistic: 53.96 on 1 and 23 DF,  p-value: 1.794e-07

##<-========== PASO 59. =========->

(56i)representación gráfica de la recta de mínimos cuadrados

plot(grasas$edad, grasas$grasas, xlab='Edad', ylab='Grasas')
abline(regresion)

##<-========== PASO 60. =========->

(57i)Supongamos que queremos utilizar la recta de mínimos cuadrados para predecir la cantidad de grasas para individuos de edades 31,31,32,…,50

nuevas.edades <- data.frame(edad = seq(30, 50))
predict(regresion, nuevas.edades)
##        1        2        3        4        5        6        7        8 
## 262.1954 267.5161 272.8368 278.1575 283.4781 288.7988 294.1195 299.4402 
##        9       10       11       12       13       14       15       16 
## 304.7608 310.0815 315.4022 320.7229 326.0435 331.3642 336.6849 342.0056 
##       17       18       19       20       21 
## 347.3263 352.6469 357.9676 363.2883 368.6090

###<-==========AQUI FINALIZA EL LABORATORIO 8 =========->