SE.XPD.PRIM.PC.ZS ( öğrenci başına düşen devlet harcamaları ) SE.XPD.TOTL.GD.ZS ( eğitime yönelik devlet harcamaları )

##dünya bankasından veri indirmek

library(WDI)
data <- WDI(indicator = c("SE.XPD.PRIM.PC.ZS", "SE.XPD.TOTL.GD.ZS" ))

##kesit veri

library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2     
## ── 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
data2003 <- data %>% filter(year == 2003)

##zaman serisi

dataTR <- data %>% filter (country == "TURKIYE")
library(ggplot2)
ggplot(dataTR, aes("year","SE.XPD.PRIM.PC.ZS")) + geom_line()
## `geom_line()`: Each group consists of only one observation.
## ℹ Do you need to adjust the group aesthetic?

ggplot(dataTR, aes(SE.XPD.TOTL.GD.ZS)) + geom_histogram()

ggplot(dataTR, aes(SE.XPD.PRIM.PC.ZS, SE.XPD.TOTL.GD.ZS)) + geom_point()

##regresyon

model <-lm (SE.XPD.PRIM.PC.ZS ~ SE.XPD.TOTL.GD.ZS , data = data)
summary(model)
## 
## Call:
## lm(formula = SE.XPD.PRIM.PC.ZS ~ SE.XPD.TOTL.GD.ZS, data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -25.166  -2.896  -0.771   2.304  46.721 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)        3.33935    0.35878   9.308   <2e-16 ***
## SE.XPD.TOTL.GD.ZS  2.75671    0.07501  36.752   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5.149 on 1795 degrees of freedom
##   (15227 observations deleted due to missingness)
## Multiple R-squared:  0.4294, Adjusted R-squared:  0.4291 
## F-statistic:  1351 on 1 and 1795 DF,  p-value: < 2.2e-16