data

x ve y öğrenci numara oluşkmaktadır

x<-c(2,3,4,7,9)
y<-c(5,8,9,2,4)
df<-data.frame(x,y)

data oluşturduk

ortalama

mean(x)
## [1] 5
mean(y)
## [1] 5.6

variance

var(x)
## [1] 8.5
var(y)
## [1] 8.3

covariance

cov(x,y)
## [1] -5

correlation

cor(x,y)
## [1] -0.5952803

regression

model <- lm(y ~ x, data = df)
model
## 
## Call:
## lm(formula = y ~ x, data = df)
## 
## Coefficients:
## (Intercept)            x  
##      8.5412      -0.5882

coefficients

coef(model)
## (Intercept)           x 
##   8.5411765  -0.5882353
coef(model)[1]
## (Intercept) 
##    8.541176
coef(model)[2]
##          x 
## -0.5882353

summary

summary(model)
## 
## Call:
## lm(formula = y ~ x, data = df)
## 
## Residuals:
##       1       2       3       4       5 
## -2.3647  1.2235  2.8118 -2.4235  0.7529 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)  
## (Intercept)   8.5412     2.5851   3.304   0.0456 *
## x            -0.5882     0.4584  -1.283   0.2896  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.673 on 3 degrees of freedom
## Multiple R-squared:  0.3544, Adjusted R-squared:  0.1391 
## F-statistic: 1.647 on 1 and 3 DF,  p-value: 0.2896

plot

plot(x,y)
abline(model)