Source: https://ec.europa.eu/eurostat/databrowser/view/sdg_01_10a__custom_9141548/default/table?lang=en The units of measure for Risk_City and Risk_Town are %. Whereby these % show the share of people at risk of poverty/social exclusion. Thus our research question is whether People in urban areas are less prone to a risk of poverty and/or social exclusion compared to those in rural areas. As the population comes from same countries, we take it as paired samples so we will conduct a t test of mean difference. H0: Mean Differences are equal H1: Mean Differences are not equal
mydata <-read.table ("C:\\Users\\Ivan Kechev\\Downloads\\rawdata.csv", header = TRUE, sep = ",", dec = ".")
head(mydata)
mydata$difference <- mydata$Risk_City - mydata$Risk_Town
hist(mydata$difference, xlab = "difference", main = "Distribution of Differences")
The histogram gives a somewhat normal distribution, however, we would also need a shapiro-wilk test of normality in order to confirm that differences are distributed normally.
shapiro.test(mydata$difference)
##
## Shapiro-Wilk normality test
##
## data: mydata$difference
## W = 0.94815, p-value = 0.1508
At a p-value of 0.15 we may confirm the null hypothesis H0: The differences are normally distributed.
library(psych)
describe(mydata[ , -1])
With meanCity = 19.52 and meanTown = 19.91, we can say that the average share of people at risk of poverty in the cities is lower than that in towns by 0.39 percentage points.
The median of the towns is lower than that of cities but the range is hihger, meaning that towns have more variety but most of it comes from the second half of the unit values (that is the 50% above the median). Although the differences are not that significant so their distributions mostly hold the same position.
By looking at the variance statistics we can see that the towns have a higher variance than the cities, so we can conclude that there is higher difference by town rather than by city.
We also have an arithmetic mean of differences equal to -0.39 which is quite close to 0 so we might expect that our t-test will fail to reject the null hypothesis.
t.test(mydata$Risk_City, mydata$Risk_Town, paired = TRUE, alternative = "two.sided")
##
## Paired t-test
##
## data: mydata$Risk_City and mydata$Risk_Town
## t = -0.34846, df = 29, p-value = 0.73
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
## -2.656159 1.882826
## sample estimates:
## mean difference
## -0.3866667
As expected, at the p-value is 0.73, way higher than the 0.05 significance level, thus, we confirm the null hypothesis saying that there is no difference in share of people at risk of poverty between towns and cities.
Although we already know the t-test is insignificant, let us still get the effect size.
library(effectsize)
##
## Attaching package: 'effectsize'
## The following object is masked from 'package:psych':
##
## phi
cohens_d(mydata$difference)
interpret_cohens_d(-0.06, rules="sawilowsky2009")
## [1] "tiny"
## (Rules: sawilowsky2009)
As expected, the effect size is “tiny”. #At a p-value of 0.15 we may confirm the null hypothesis H0: The differences are normally distributed.