<!DOCTYPE html>
#install.packages("readxl")
#install.packages("psych")
#install.packages("car")
#install.packages("olsrr")
library(readxl)
library(psych)
library(car)
## Loading required package: carData
##
## Attaching package: 'car'
## The following object is masked from 'package:psych':
##
## logit
library(olsrr)
##
## Attaching package: 'olsrr'
## The following object is masked from 'package:datasets':
##
## rivers
podatki_pot <- "D:\\Education\\R\\Pika\\podatki.xlsx"
list <- "vpr1_tab"
tabela_podatki <- read_excel(podatki_pot, sheet = list)
## New names:
## • `` -> `...1`
## • `` -> `...2`
## • `` -> `...3`
skupina_15_24 <- as.numeric(tabela_podatki[1, 4:ncol(tabela_podatki)])
skupina_25_49 <- as.numeric(tabela_podatki[2, 4:ncol(tabela_podatki)])
describe(skupina_15_24)
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 43 30.56 4.37 30.6 30.53 4.74 21.5 39.6 18.1 0.03 -0.68 0.67
describe(skupina_25_49)
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 43 86.55 2.75 87.5 86.69 2.67 82 90.2 8.2 -0.37 -1.52 0.42
shapiro.test(skupina_15_24)
##
## Shapiro-Wilk normality test
##
## data: skupina_15_24
## W = 0.98699, p-value = 0.901
shapiro.test(skupina_25_49)
##
## Shapiro-Wilk normality test
##
## data: skupina_25_49
## W = 0.86758, p-value = 0.0001492
wilcox_rezultat <- wilcox.test(skupina_15_24, skupina_25_49, alternative = "greater")
## Warning in wilcox.test.default(skupina_15_24, skupina_25_49, alternative =
## "greater"): cannot compute exact p-value with ties
print(wilcox_rezultat)
##
## Wilcoxon rank sum test with continuity correction
##
## data: skupina_15_24 and skupina_25_49
## W = 0, p-value = 1
## alternative hypothesis: true location shift is greater than 0
list2 <- "vpr2_tab"
tabela2_podatki <- read_excel(podatki_pot, sheet = list2)
head(tabela2_podatki)
## # A tibble: 6 × 3
## `St. Brezposelnosti (v &%)` Spol Skupina
## <dbl> <chr> <chr>
## 1 21.7 moski 15-24
## 2 20.8 moski 15-24
## 3 18.9 moski 15-24
## 4 19.3 moski 15-24
## 5 24.2 moski 15-24
## 6 18.1 moski 15-24
regresijski_model <- lm(tabela2_podatki$`St. Brezposelnosti (v &%)` ~ tabela2_podatki$Spol + tabela2_podatki$Skupina)
summary(regresijski_model)
##
## Call:
## lm(formula = tabela2_podatki$`St. Brezposelnosti (v &%)` ~ tabela2_podatki$Spol +
## tabela2_podatki$Skupina)
##
## Residuals:
## Min 1Q Median 3Q Max
## -8.756 -2.491 -0.936 2.595 14.344
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 12.9744 0.5287 24.541 < 2e-16 ***
## tabela2_podatki$Spolzenske 1.6814 0.6105 2.754 0.00653 **
## tabela2_podatki$Skupina25-49 -7.4698 0.6105 -12.236 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.003 on 169 degrees of freedom
## Multiple R-squared: 0.4821, Adjusted R-squared: 0.4759
## F-statistic: 78.65 on 2 and 169 DF, p-value: < 2.2e-16
plot(regresijski_model, which = 1)
povp_napaka <- mean(residuals(regresijski_model))
print(povp_napaka)
## [1] -5.791657e-17
ols_test_breusch_pagan(regresijski_model)
##
## Breusch Pagan Test for Heteroskedasticity
## -----------------------------------------
## Ho: the variance is constant
## Ha: the variance is not constant
##
## Data
## -----------------------------------------------------------------------
## Response : tabela2_podatki$`St. Brezposelnosti (v &%)`
## Variables: fitted values of tabela2_podatki$`St. Brezposelnosti (v &%)`
##
## Test Summary
## -------------------------------
## DF = 1
## Chi2 = 34.67379
## Prob > Chi2 = 3.898446e-09
shapiro.test(residuals(regresijski_model))
##
## Shapiro-Wilk normality test
##
## data: residuals(regresijski_model)
## W = 0.97432, p-value = 0.002819
hist(residuals(regresijski_model), main = "Histogram ostankov", xlab = "Ostanki")
cook_raz <- cooks.distance(regresijski_model)
hist(cook_raz, main = "Histogram Cookovih razdalj", xlab = "Cookove razdalje")
vif(regresijski_model)
## tabela2_podatki$Spol tabela2_podatki$Skupina
## 1 1