library(readxl)
Caso_Regresion_Lineal_R2_Alto <- read_excel("~/Downloads/Caso_Regresion_Lineal_R2_Alto.xlsx", 
    col_types = c("text", "numeric", "numeric"))
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.2.1     ✔ readr     2.2.0
## ✔ forcats   1.0.1     ✔ stringr   1.6.0
## ✔ ggplot2   4.0.2     ✔ tibble    3.3.1
## ✔ lubridate 1.9.5     ✔ tidyr     1.3.2
## ✔ purrr     1.2.1     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
ggplot(Caso_Regresion_Lineal_R2_Alto, aes(x= GastoEducacion, y= PuntajeEstudiantes))+
  geom_point()+
  geom_smooth(method = "lm")+
  labs( title = "Regresión lineal simple", x = "Gasto en Educación", y = "Puntaje")
## `geom_smooth()` using formula = 'y ~ x'

cor.test(Caso_Regresion_Lineal_R2_Alto$GastoEducacion, Caso_Regresion_Lineal_R2_Alto$PuntajeEstudiantes)
## 
##  Pearson's product-moment correlation
## 
## data:  Caso_Regresion_Lineal_R2_Alto$GastoEducacion and Caso_Regresion_Lineal_R2_Alto$PuntajeEstudiantes
## t = 11.437, df = 28, p-value = 4.591e-12
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.8131826 0.9554380
## sample estimates:
##       cor 
## 0.9075668
modelo<- lm(PuntajeEstudiantes~ GastoEducacion, data = Caso_Regresion_Lineal_R2_Alto)
summary(modelo)
## 
## Call:
## lm(formula = PuntajeEstudiantes ~ GastoEducacion, data = Caso_Regresion_Lineal_R2_Alto)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.6900 -2.2494  0.1452  1.4368  5.0131 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    41.79686    3.25046   12.86 2.87e-13 ***
## GastoEducacion  0.73644    0.06439   11.44 4.59e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.522 on 28 degrees of freedom
## Multiple R-squared:  0.8237, Adjusted R-squared:  0.8174 
## F-statistic: 130.8 on 1 and 28 DF,  p-value: 4.591e-12