Did the annual flow of the Nile river change after the Aswan dam was built?
## charge the table
nile <- read.csv("C:/Users/Claudio Alvarez/Desktop/nile.csv", header = TRUE)
nile
## Annual Year Pre1905
## 1 1120 1871 1
## 2 1160 1872 1
## 3 963 1873 1
## 4 1210 1874 1
## 5 1160 1875 1
## 6 1160 1876 1
## 7 813 1877 1
## 8 1230 1878 1
## 9 1370 1879 1
## 10 1140 1880 1
## 11 995 1881 1
## 12 935 1882 1
## 13 1110 1883 1
## 14 994 1884 1
## 15 1020 1885 1
## 16 960 1886 1
## 17 1180 1887 1
## 18 799 1888 1
## 19 958 1889 1
## 20 1140 1890 1
## 21 1100 1891 1
## 22 1210 1892 1
## 23 1150 1893 1
## 24 1250 1894 1
## 25 1260 1895 1
## 26 1220 1896 1
## 27 1030 1897 1
## 28 1100 1898 1
## 29 774 1899 1
## 30 840 1900 1
## 31 874 1901 1
## 32 694 1902 0
## 33 940 1903 0
## 34 833 1904 0
## 35 701 1905 0
## 36 916 1906 0
## 37 692 1907 0
## 38 1020 1908 0
## 39 1050 1909 0
## 40 969 1910 0
## 41 831 1911 0
## 42 726 1912 0
## 43 456 1913 0
## 44 824 1914 0
## 45 702 1915 0
## 46 1120 1916 0
## 47 1100 1917 0
## 48 832 1918 0
## 49 764 1919 0
## 50 821 1920 0
## 51 768 1921 0
## 52 845 1922 0
## 53 864 1923 0
## 54 862 1924 0
## 55 698 1925 0
## 56 845 1926 0
## 57 744 1927 0
## 58 796 1928 0
## 59 1040 1929 0
## 60 759 1930 0
## 61 781 1931 0
## 62 865 1932 0
## 63 845 1933 0
## 64 944 1934 0
## 65 984 1935 0
## 66 897 1936 0
## 67 822 1937 0
## 68 1010 1938 0
## 69 771 1939 0
## 70 676 1940 0
## 71 649 1941 0
## 72 846 1942 0
## 73 812 1943 0
## 74 742 1944 0
## 75 801 1945 0
## 76 1040 1946 0
## 77 860 1947 0
## 78 874 1948 0
## 79 848 1949 0
## 80 890 1950 0
## 81 744 1951 0
## 82 749 1952 0
## 83 838 1953 0
## 84 1050 1954 0
## 85 918 1955 0
## 86 986 1956 0
## 87 797 1957 0
## 88 923 1958 0
## 89 975 1959 0
## 90 815 1960 0
## 91 1020 1961 0
## 92 906 1962 0
## 93 901 1963 0
## 94 1170 1964 0
## 95 912 1965 0
## 96 746 1966 0
## 97 919 1967 0
## 98 718 1968 0
## 99 714 1969 0
## 100 740 1970 0
## comparison of annual flow between 2 periods
aswanpre <- subset(nile, Pre1905 == 1)
aswanpost <- subset(nile, Pre1905 == 0)
summary(aswanpre)
## Annual Year Pre1905
## Min. : 774 Min. :1871 Min. :1
## 1st Qu.: 962 1st Qu.:1878 1st Qu.:1
## Median :1110 Median :1886 Median :1
## Mean :1072 Mean :1886 Mean :1
## 3rd Qu.:1170 3rd Qu.:1894 3rd Qu.:1
## Max. :1370 Max. :1901 Max. :1
summary(aswanpost)
## Annual Year Pre1905
## Min. : 456 Min. :1902 Min. :0
## 1st Qu.: 759 1st Qu.:1919 1st Qu.:0
## Median : 845 Median :1936 Median :0
## Mean : 851 Mean :1936 Mean :0
## 3rd Qu.: 919 3rd Qu.:1953 3rd Qu.:0
## Max. :1170 Max. :1970 Max. :0
## T-test
t.test(nile$Annual ~ nile$Pre1905, var.equal = T) ## mean of two subset are not equal
##
## Two Sample t-test
##
## data: nile$Annual by nile$Pre1905
## t = -7.557, df = 98, p-value = 2.211e-11
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -278.9 -162.9
## sample estimates:
## mean in group 0 mean in group 1
## 850.9 1071.8
## comparing variance
var.test(nile$Annual ~ nile$Pre1905)
##
## F test to compare two variances
##
## data: nile$Annual by nile$Pre1905
## F = 0.7001, num df = 68, denom df = 30, p-value = 0.227
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
## 0.3641 1.2501
## sample estimates:
## ratio of variances
## 0.7001
## wilcoxon test nos parametric
wilcox.test(nile$Annual ~ nile$Pre1905) ## subset are not equal
##
## Wilcoxon rank sum test with continuity correction
##
## data: nile$Annual by nile$Pre1905
## W = 304, p-value = 1.185e-08
## alternative hypothesis: true location shift is not equal to 0
the two periods compared are not equal