Objective 1: EXPLORATORY DATA ANALYSIS

FIGURE 1

#Line graph: Figure 1
par(mfrow=c(1,2))
#par(mar = c(0.3))        # Reduce space around plots

#Cassava
Cassava <- c(10.5,7.2, 7.46, 15.76, 35.8)
P1 = plot(Cassava,type="o", col="blue", x = c(2018, 2019, 2020, 2021, 2022), ylim=c(0,40),  pch=20, ylab = "percentage", xlab = "years")+title(main="Cassava Production", col.main="black", font.main=1)

# Swine Fattening
SwineF <- c(2.54,4.72,12.14,15.12,20.5)
P2 = plot(SwineF,type="o", col="red", x = c(2018, 2019, 2020, 2021, 2022), ylim=c(0,30),  pch=20, ylab = "percentage", xlab = "years")
title(main="Swine Fattening", col.main="black", font.main=1)

# Rice Production
Rice <- c(11.52,26.28,31.13,37.66,43.3)
P3 = plot(Rice,type="o", col="black", x = c(2018, 2019, 2020, 2021, 2022), ylim=c(0,50),  pch=20, ylab = "percentage", xlab = "years")
title(main="Rice Production", col.main="black", font.main=1)

# Corn Production
Corn <- c(18.8,17.24,8.12,5.20,15.77)
P4 = plot(Corn,type="o", col="brown", x = c(2018, 2019, 2020, 2021, 2022), ylim=c(0,20),  pch=20, ylab = "percentage", xlab = "years")
title(main="Corn Production", col.main="black", font.main=1)

# Swine Production
P5= SwineP <- c(2.54,5.26,6.93,11.50,18.85)
plot(SwineP,type="o", col="orange", x = c(2018, 2019, 2020, 2021, 2022), ylim=c(0,20),  pch=20, ylab = "percentage", xlab = "years")
title(main="Swine Production", col.main="black", font.main=1)


# Vegetable Production
Vegetable <- c(12.93,34.29,67.75)
P6 = plot(Vegetable,type="o", col="darkgreen", x = c(2020, 2021, 2022), ylim=c(0,80),  pch=20, ylab = "percentage", xlab = "years")+title(main="Vegetable Production", col.main="black", font.main=1)

#GENERAL: LINE GRAPH AGRICULTURAL :  FINAL
library(ggplot2)
library(tidyverse)
L = read.csv("LINE_GENERAL.csv")
head(L)
##   Year     Intervention Percentage
## 1 2018          Cassava      10.50
## 2 2018  Swine Fattening       2.54
## 3 2018             Rice      11.52
## 4 2018             Corn      18.80
## 5 2018 Swine Production       2.54
## 6 2019          Cassava       7.20
ggplot(L, aes(x=Year, y=Percentage, col= Intervention)) + geom_line() +geom_point()+ theme_gray()+
  ggtitle("Figure 1:Percentage of Beneficiaries per Intervention(2018-2022)")+
  theme(plot.title = element_text(hjust = 0.5))

#FOLLOW UP:

library(ggplot2)
library(tidyverse)

M1= read.csv("Agri_By_Municipality_Beneficiaries.csv")


M = cbind(M1$Cassava,M1$Corn, M1$Rice, M1$Swine.P, M1$Swine.F, M1$Vegetable)

barplot(M,xlab="Intervention",ylab="Count",ylim = c(0,200),
        main="Figure 2: Agricultural Beneficiaries per Municipalities",
        col=c("gray","red","yellow","pink","brown","orange","pink","green","blue"),
        beside=TRUE, cex.names = .8,
        names.arg=c("Cassava","Corn","Rice", "Swine P","Swine F",
                    "Vegetable"))
legend("topright",c("Bontoc","Malitbog","Sogod", "TO","Liloan",
                    "Pintuyan","San Francisco","St. Bernard","Libagon"),fill=c("gray","red","yellow","pink","brown","orange","pink","green","blue"),cex = .6)

#Figure 3

#GENERAL: LINE GRAPH FISHERY:  FINAL
library(ggplot2)
library(tidyverse)
LF = read.csv("LINE_GRAPH_FISHERY.csv")
head(LF)
##   Year       Intervention Percentage
## 1 2018     Motorized Boat      62.65
## 2 2019     Motorized Boat      61.47
## 3 2022  Bangus Production      44.84
## 4 2020     Motorized Boat      40.00
## 5 2021     Motorized Boat      34.55
## 6 2020 Lobster Production      34.42
ggplot(LF, aes(x=Year, y=Percentage, col= Intervention)) + geom_line()+geom_point() + theme_gray()+
  ggtitle("Figure 3: Percentage of Fishery Beneficiaries (2018-2022) ")+
  theme(plot.title = element_text(hjust = 0.5))

Figure 4

f4 = read.csv("Fishery_By_Municipality_Beneficiaries.csv")

f = cbind(f4$Motorized.Boat,f4$Bangus.P,f4$Lobster.P)

barplot(f,xlab="Intervention",ylab="Count",ylim = c(0,30),
        main="Figure 4: Fishery Beneficiaries per Municipalities",
        col=c("gray","blue","brown","red","yellow","pink","yellowgreen","orange","lightblue","violet","green"),
        beside=TRUE, cex.names = .8,
        names.arg=c("Motorized Boat","Bangus P.","Lobster P."))
legend("topright",c("Anahawan","Malitbog","Limasawa", "Bontoc","Libagon",
                    "Sogod","Hinunangan","Hinundayan","St. Bernard"),fill=c("gray","blue","brown","red","yellow","pink","yellowgreen","orange","lightblue","violet","green"),cex = .6)

#Data
Fig2 = data.frame(read.csv("Figure2.csv"))
head(Fig2)
##   Year Motorized.Boat Bangus.Production Lobster.Production
## 1 2018          62.65             19.62              17.72
## 2 2019          61.47             11.47              27.06
## 3 2020          40.00             25.58              34.42
## 4 2021          34.55             33.09              32.36
## 5 2022          31.61             44.84              23.55
par(mfrow=c(2,3))
#2018
Fig2.slices <- as.numeric(Fig2[1,2:4])
Fig2.labels <- paste(Fig2.slices," %",sep="")

pie(Fig2.slices,Fig2.labels,
    col= c("lightblue","yellowgreen","lightpink"),
    main="2018")
legend("bottomleft", c("lightblue","yellowgreen","lightpink"),cex=0.6, fill=  rainbow(length(Fig2.slices)))

#2019
Fig2.slicesb <- as.numeric(Fig2[2,2:4])
Fig2.labels <- paste(Fig2.slicesb," %",sep="")
pie(Fig2.slicesb,Fig2.labels,
    col= c("lightblue","yellowgreen","lightpink"),
    main="2019")
legend("bottomleft", c("lightblue","yellowgreen","lightpink"),cex=0.6, fill=  rainbow(length(Fig2.slicesb)))

#2020

Fig2.slicesc <- as.numeric(Fig2[3,2:4])
Fig2.labels <- paste(Fig2.slicesc," %",sep="")
pie(Fig2.slicesc,Fig2.labels,
    col= c("lightblue","yellowgreen","lightpink"),
    main="2020")
legend("bottomleft", c("lightblue","yellowgreen","lightpink"),cex=0.6, fill=  rainbow(length(Fig2.slicesc)))

#2021

Fig2.slicesd <- as.numeric(Fig2[4,2:4])
Fig2.labels <- paste(Fig2.slicesd," %",sep="")
pie(Fig2.slicesd,Fig2.labels,
    col= c("lightblue","yellowgreen","lightpink"),
    main="2021")
legend("bottomleft", c("lightblue","yellowgreen","lightpink"),cex=0.6, fill=  rainbow(length(Fig2.slicesd)))

#2022

Fig2.slicese <- as.numeric(Fig2[4,2:4])
Fig2.labels <- paste(Fig2.slicese," %",sep="")
pie(Fig2.slicese,Fig2.labels,
    col= c("lightblue","yellowgreen","lightpink"),
    main="2022")
legend("bottomleft", c("lightblue","yellowgreen","lightpink"),cex=0.6, fill=  rainbow(length(Fig2.slicese)))

#Figure 5

F3 = data.frame(read.csv("Figure3.csv"))
head(F3)
##                 X Y2018 Y2019 Y2020 Y2021 Y2022
## 1 Swine Fattening  16.8  1.70  6.80  1.70  2.10
## 2         Swine P   5.6  2.10  6.80  7.40  0.55
## 3        Cassava    2.7  0.95  0.56  3.20  3.10
## 4            Rice   2.4  2.30  0.41  3.10  3.20
## 5            Corn   2.3  2.40  1.00  0.53  2.00
F = cbind(F3$Y2018,F3$Y2019,F3$Y2020,F3$Y2021,F3$Y2022)

barplot(F,xlab="Years",ylab="Amount (in millions)",ylim = c(0,20),
        main="Figure 5: Project Cost per Agricultural Intervention (2018-2022)",
        col=c("gray","lightblue","yellowgreen","lightpink","brown"),
        beside=TRUE, cex.names = .8,
        names.arg=c("2018","2019","2020", "2021",
                    "2022"))

legend("topright",c("Swine Fattening","Swine Prduction","Cassava Production", "Rice Production",
                    "Corn Prduction"), fill=c("gray","lightblue","yellowgreen","lightpink","brown"),
       cex = 0.8)

#Figure 6

F4 = data.frame(read.csv("Figure4.csv"))

Ff = cbind(F4$Y2018,F4$Y2019,F4$Y2020,F4$Y2021,F4$Y2022)

barplot(Ff,xlab="Years",ylab="Amount (in millions)",ylim = c(0,5),
        main="Figure 6: Project Cost per Fishery Intervention (2018-2022)",
        col=c("gray","lightblue","yellowgreen"),
        beside=TRUE, cex.names = 0.8,
        names.arg=c("2018","2019","2020", "2021",
                    "2022"))

legend("topright",c("Motorized boat","Bangus Production","Lobster Production"), fill=c("gray","lightblue","yellowgreen"),
       cex = 0.6)

Objective 2:

#PRE-POST:

P1 = read.csv("PDATA.csv")
head(P1)
##   Beneficiaries Before After Intervention Difference  X X.1          X.2
## 1             4   2000  4900           T1       2900 NA  NA     X = 1052
## 2           128   2000  4900           T2       2900 NA  NA      Mean = 
## 3           130   2000  4900           T2       2900 NA  NA             
## 4           132   2000  4900           T2       2900 NA  NA            0
## 5           134   2000  4900           T2       2900 NA  NA             
## 6           136   2000  4900           T2       2900 NA  NA Intervention
##               X.3 X.4 X.5 X.6 X.7 X.8 X.9 X.10 X.11 X.12 X.13 X.14
## 1                                  NA  NA        NA               
## 2     6600.570885                  NA  NA        NA               
## 3                                  NA  NA        NA               
## 4                                  NA  NA        NA               
## 5                                  NA  NA        NA               
## 6 Mean Difference                  NA  NA        NA
shapiro.test(P1$Before)
## 
##  Shapiro-Wilk normality test
## 
## data:  P1$Before
## W = 0.8565, p-value < 2.2e-16
shapiro.test(P1$After)
## 
##  Shapiro-Wilk normality test
## 
## data:  P1$After
## W = 0.96532, p-value = 3.988e-15
t.test(P1$After)
## 
##  One Sample t-test
## 
## data:  P1$After
## t = 113.53, df = 1050, p-value < 2.2e-16
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
##   9706.718 10048.144
## sample estimates:
## mean of x 
##  9877.431
t.test(P1$Difference)
## 
##  One Sample t-test
## 
## data:  P1$Difference
## t = 95.224, df = 1050, p-value < 2.2e-16
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
##  6464.557 6736.585
## sample estimates:
## mean of x 
##  6600.571
library(tidyverse)
library(ggplot2)
P1 = read.csv("PDATA.csv")
head(P1)
##   Beneficiaries Before After Intervention Difference  X X.1          X.2
## 1             4   2000  4900           T1       2900 NA  NA     X = 1052
## 2           128   2000  4900           T2       2900 NA  NA      Mean = 
## 3           130   2000  4900           T2       2900 NA  NA             
## 4           132   2000  4900           T2       2900 NA  NA            0
## 5           134   2000  4900           T2       2900 NA  NA             
## 6           136   2000  4900           T2       2900 NA  NA Intervention
##               X.3 X.4 X.5 X.6 X.7 X.8 X.9 X.10 X.11 X.12 X.13 X.14
## 1                                  NA  NA        NA               
## 2     6600.570885                  NA  NA        NA               
## 3                                  NA  NA        NA               
## 4                                  NA  NA        NA               
## 5                                  NA  NA        NA               
## 6 Mean Difference                  NA  NA        NA
#as.factor(P1$Beneficiaries)

par(mfrow=c(2,1))

T1 = P1 %>% select(c(Beneficiaries,Before, After, Intervention)) %>% filter(Intervention == "T1")

theme_set(theme_minimal())

Ta =T1 %>% ggplot(aes(Beneficiaries, Before)) + 
  geom_ribbon(aes(ymin = 500 , ymax = 16000),fill = "white") + 
  geom_line(aes(Beneficiaries, Before ), color = "black", size = 0.5) +
  geom_line(aes(Beneficiaries, After ), color = "blue", size = 0.5)+
  ggtitle("Cassava Income Before and After")
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
T2 = P1 %>% select(c(Beneficiaries,Before, After, Intervention)) %>% filter(Intervention == "T2")

theme_set(theme_minimal())

Tb =T2 %>% ggplot(aes(Beneficiaries, Before)) + 
  geom_ribbon(aes(ymin = 500 , ymax = 16000),fill = "white") + 
  geom_line(aes(Beneficiaries, Before ), color = "black", size = 0.5) +
  geom_line(aes(Beneficiaries, After ), color = "blue", size = 0.5)+
  ggtitle("Corn Income Before and After")


T3 = P1 %>% select(c(Beneficiaries,Before, After, Intervention)) %>% filter(Intervention == "T3")

theme_set(theme_minimal())

Tc =T3 %>% ggplot(aes(Beneficiaries, Before)) + 
  geom_ribbon(aes(ymin = 500 , ymax = 16000),fill = "white") + 
  geom_line(aes(Beneficiaries, Before ), color = "black", size = 0.5) +
  geom_line(aes(Beneficiaries, After ), color = "blue", size = 0.5)+
  ggtitle("Rice Income Before and After")



T4 = P1 %>% select(c(Beneficiaries,Before, After, Intervention)) %>% filter(Intervention == "T4")

theme_set(theme_minimal())

Td =T4 %>% ggplot(aes(Beneficiaries, Before)) + 
  geom_ribbon(aes(ymin = 500 , ymax = 16000),fill = "white") + 
  geom_line(aes(Beneficiaries, Before ), color = "black", size = 0.5) +
  geom_line(aes(Beneficiaries, After ), color = "blue", size = 0.5)+
  ggtitle("Swine Production Income Before and After")
Td

T5 = P1 %>% select(c(Beneficiaries,Before, After, Intervention)) %>% filter(Intervention == "T5")

theme_set(theme_minimal())

Te =T5 %>% ggplot(aes(Beneficiaries, Before)) + 
  geom_ribbon(aes(ymin = 500 , ymax = 16000),fill = "white") + 
  geom_line(aes(Beneficiaries, Before ), color = "black", size = 0.5) +
  geom_line(aes(Beneficiaries, After ), color = "blue", size = 0.5)+
  ggtitle("Swine Fattening Income Before and After")

library(ggplot2)
library(gridExtra)
## 
## Attaching package: 'gridExtra'
## The following object is masked from 'package:dplyr':
## 
##     combine
# Combine the plots with gridExtra
grid.arrange(Ta, Tb) 

grid.arrange(Tc, Td) 

grid.arrange(Te,Td)

#ANOVA and Multiple Comparison Test

P1 = read.csv("PDATA.csv")
head(P1)
##   Beneficiaries Before After Intervention Difference  X X.1          X.2
## 1             4   2000  4900           T1       2900 NA  NA     X = 1052
## 2           128   2000  4900           T2       2900 NA  NA      Mean = 
## 3           130   2000  4900           T2       2900 NA  NA             
## 4           132   2000  4900           T2       2900 NA  NA            0
## 5           134   2000  4900           T2       2900 NA  NA             
## 6           136   2000  4900           T2       2900 NA  NA Intervention
##               X.3 X.4 X.5 X.6 X.7 X.8 X.9 X.10 X.11 X.12 X.13 X.14
## 1                                  NA  NA        NA               
## 2     6600.570885                  NA  NA        NA               
## 3                                  NA  NA        NA               
## 4                                  NA  NA        NA               
## 5                                  NA  NA        NA               
## 6 Mean Difference                  NA  NA        NA
#ANOVA TABLE
Intervention_aov <- anova(lm(Difference ~ Intervention, data = P1))
Intervention_aov
## Analysis of Variance Table
## 
## Response: Difference
##                Df     Sum Sq   Mean Sq F value    Pr(>F)    
## Intervention    4 2582936238 645734059  248.38 < 2.2e-16 ***
## Residuals    1046 2719323420   2599736                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
aov1 <- with(P1, aov(Difference ~ Intervention)) 
anova(aov1)
## Analysis of Variance Table
## 
## Response: Difference
##                Df     Sum Sq   Mean Sq F value    Pr(>F)    
## Intervention    4 2582936238 645734059  248.38 < 2.2e-16 ***
## Residuals    1046 2719323420   2599736                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
library(agricolae)
LSD.test(y = aov1,
         trt = "Intervention",
         group = TRUE,
         console = TRUE)
## 
## Study: aov1 ~ "Intervention"
## 
## LSD t Test for Difference 
## 
## Mean Square Error:  2599736 
## 
## Intervention,  means and individual ( 95 %) CI
## 
##    Difference       std   r      LCL      UCL  Min   Max
## T1   3507.937  593.3772 126 3226.079 3789.794 2900  5200
## T2   3531.034  950.3844  58 3115.601 3946.468 2900  5200
## T3   6673.438 1861.2399 320 6496.573 6850.302 2900  9400
## T4   7265.342 1549.2832 453 7116.692 7413.993 2900  9600
## T5   9188.298 2159.7917  94 8861.972 9514.624 4900 10500
## 
## Alpha: 0.05 ; DF Error: 1046
## Critical Value of t: 1.962235 
## 
## Groups according to probability of means differences and alpha level( 0.05 )
## 
## Treatments with the same letter are not significantly different.
## 
##    Difference groups
## T5   9188.298      a
## T4   7265.342      b
## T3   6673.438      c
## T2   3531.034      d
## T1   3507.937      d
W = read.csv("PDATA.csv")

wilcox.test(W$Difference)
## 
##  Wilcoxon signed rank test with continuity correction
## 
## data:  W$Difference
## V = 552826, p-value < 2.2e-16
## alternative hypothesis: true location is not equal to 0
plot(W$Difference)

#DATA TRANSFORMATION
data_log <- log(W$Difference)
data_log
##    [1] 7.972466 7.972466 7.972466 7.972466 7.972466 7.972466 7.972466 7.972466
##    [9] 7.972466 7.972466 7.972466 7.972466 7.972466 7.972466 7.972466 7.972466
##   [17] 7.972466 7.972466 7.972466 7.972466 7.972466 7.972466 7.972466 7.972466
##   [25] 7.972466 7.972466 7.972466 7.972466 7.972466 7.972466 7.972466 7.972466
##   [33] 7.972466 7.972466 7.972466 7.972466 7.972466 7.972466 8.101678 7.972466
##   [41] 8.496990 8.101678 8.101678 8.496990 8.496990 8.496990 8.496990 8.496990
##   [49] 8.101678 8.496990 8.101678 8.496990 8.496990 8.496990 8.496990 8.101678
##   [57] 8.496990 8.101678 8.496990 8.101678 7.972466 8.101678 7.972466 8.101678
##   [65] 8.101678 8.101678 7.972466 7.972466 7.972466 7.972466 7.972466 7.972466
##   [73] 8.496990 8.101678 8.101678 8.496990 8.496990 8.101678 8.496990 8.496990
##   [81] 8.101678 8.101678 8.101678 8.101678 8.496990 8.496990 8.496990 8.496990
##   [89] 8.496990 8.496990 8.101678 8.496990 8.496990 8.101678 8.496990 8.496990
##   [97] 8.101678 8.496990 8.496990 8.496990 8.496990 8.101678 8.496990 8.101678
##  [105] 8.101678 8.496990 8.496990 8.496990 8.101678 8.496990 7.972466 7.972466
##  [113] 8.101678 8.556414 8.648221 8.556414 8.496990 7.972466 7.972466 8.101678
##  [121] 8.101678 8.101678 8.101678 7.972466 7.972466 7.972466 7.972466 8.496990
##  [129] 8.101678 8.496990 8.496990 8.101678 8.101678 8.101678 8.101678 8.101678
##  [137] 8.101678 8.496990 8.496990 8.496990 8.496990 8.496990 8.496990 8.496990
##  [145] 8.101678 8.101678 8.101678 8.496990 8.496990 8.496990 8.101678 8.101678
##  [153] 8.101678 8.101678 8.101678 8.101678 8.101678 8.101678 8.101678 8.496990
##  [161] 8.496990 8.496990 8.496990 8.496990 8.496990 8.496990 8.496990 8.496990
##  [169] 8.496990 8.496990 8.101678 8.496990 8.101678 8.101678 8.496990 8.496990
##  [177] 8.101678 8.101678 8.101678 8.101678 8.101678 8.101678 8.101678 8.496990
##  [185] 8.496990 8.496990 8.496990 8.496990 8.496990 8.496990 8.496990 8.101678
##  [193] 8.496990 8.101678 8.496990 8.101678 8.496990 8.101678 8.496990 8.496990
##  [201] 8.101678 8.101678 8.496990 8.496990 8.496990 8.496990 8.101678 8.496990
##  [209] 8.496990 8.496990 8.101678 8.101678 8.101678 8.101678 8.101678 8.101678
##  [217] 8.101678 8.101678 8.496990 8.496990 8.496990 8.496990 8.496990 8.496990
##  [225] 8.496990 8.496990 8.101678 8.101678 8.101678 8.101678 8.556414 8.101678
##  [233] 8.101678 8.101678 8.496990 8.594154 8.496990 8.496990 8.496990 8.496990
##  [241] 8.496990 8.612503 8.612503 8.101678 8.101678 8.101678 8.648221 8.496990
##  [249] 8.556414 7.972466 7.972466 7.972466 7.972466 8.496990 8.496990 8.496990
##  [257] 8.496990 8.496990 7.972466 7.972466 7.972466 7.972466 7.972466 7.972466
##  [265] 8.496990 8.496990 8.496990 8.496990 8.496990 8.496990 8.496990 8.496990
##  [273] 8.496990 8.496990 8.496990 8.648221 8.648221 8.648221 8.648221 8.648221
##  [281] 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221
##  [289] 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221
##  [297] 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221
##  [305] 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221
##  [313] 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221
##  [321] 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221
##  [329] 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221
##  [337] 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221
##  [345] 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221
##  [353] 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221
##  [361] 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221
##  [369] 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221
##  [377] 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221
##  [385] 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221
##  [393] 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221
##  [401] 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221
##  [409] 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221
##  [417] 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221 8.648221
##  [425] 8.648221 8.594154 8.612503 8.496990 8.496990 8.665613 8.665613 8.665613
##  [433] 8.665613 8.496990 8.496990 8.682708 8.682708 8.682708 8.682708 7.972466
##  [441] 7.972466 7.972466 7.972466 8.496990 8.496990 7.972466 8.496990 7.972466
##  [449] 7.972466 8.496990 7.972466 8.101678 8.556414 8.556414 8.556414 8.556414
##  [457] 8.556414 8.556414 8.496990 8.496990 8.496990 8.101678 8.101678 8.101678
##  [465] 8.496990 8.496990 8.101678 8.101678 8.496990 7.972466 8.612503 8.496990
##  [473] 8.732305 8.732305 8.732305 8.732305 8.732305 8.732305 8.732305 8.732305
##  [481] 8.732305 8.732305 8.732305 8.732305 8.732305 8.732305 8.732305 8.732305
##  [489] 8.732305 8.732305 8.732305 8.732305 8.496990 8.496990 8.496990 8.496990
##  [497] 8.101678 8.101678 8.101678 8.496990 8.496990 8.496990 8.101678 8.496990
##  [505] 8.496990 8.496990 8.496990 8.496990 8.101678 8.101678 8.496990 8.496990
##  [513] 8.496990 8.101678 8.101678 8.101678 8.648221 8.648221 8.496990 8.895630
##  [521] 8.895630 8.895630 8.895630 8.895630 8.895630 8.895630 8.895630 7.972466
##  [529] 8.496990 8.496990 8.909235 8.909235 8.909235 8.909235 8.909235 8.909235
##  [537] 8.909235 8.909235 8.909235 8.909235 8.909235 8.909235 8.909235 8.909235
##  [545] 8.909235 8.909235 8.935904 8.935904 8.935904 8.935904 8.935904 8.935904
##  [553] 8.935904 8.935904 8.935904 8.935904 8.935904 8.935904 8.935904 8.935904
##  [561] 8.935904 8.935904 8.948976 8.948976 8.948976 8.948976 8.948976 8.948976
##  [569] 8.948976 8.948976 8.948976 8.948976 8.948976 8.948976 8.948976 8.948976
##  [577] 8.948976 8.948976 8.496990 8.961879 8.961879 8.961879 8.961879 8.961879
##  [585] 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879
##  [593] 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879
##  [601] 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879
##  [609] 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879
##  [617] 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879
##  [625] 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879
##  [633] 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879
##  [641] 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879
##  [649] 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879
##  [657] 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879
##  [665] 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879 8.961879
##  [673] 8.974618 8.974618 8.974618 8.974618 8.974618 8.974618 8.974618 8.974618
##  [681] 8.974618 8.974618 8.974618 8.974618 8.974618 8.974618 8.974618 9.011889
##  [689] 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889
##  [697] 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889
##  [705] 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889
##  [713] 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889
##  [721] 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889
##  [729] 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889
##  [737] 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889
##  [745] 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889
##  [753] 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889
##  [761] 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889
##  [769] 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889 9.011889
##  [777] 9.011889 9.011889 9.011889 8.575462 8.575462 8.809863 8.809863 8.809863
##  [785] 8.809863 8.809863 8.809863 8.809863 8.809863 8.809863 8.809863 8.809863
##  [793] 8.809863 8.809863 8.809863 8.809863 8.809863 8.809863 8.809863 8.809863
##  [801] 8.809863 8.809863 9.071078 9.071078 9.071078 9.071078 9.071078 9.071078
##  [809] 9.071078 9.071078 9.071078 9.071078 9.071078 9.071078 9.071078 9.071078
##  [817] 9.071078 9.071078 9.071078 9.071078 9.071078 9.047821 9.047821 9.047821
##  [825] 9.047821 9.047821 9.047821 9.047821 9.047821 9.047821 9.047821 9.047821
##  [833] 9.047821 9.047821 9.047821 9.047821 9.047821 9.047821 9.047821 9.047821
##  [841] 9.047821 8.948976 8.948976 8.948976 8.948976 8.948976 8.948976 8.948976
##  [849] 8.948976 8.948976 8.948976 8.948976 8.948976 8.948976 8.948976 8.948976
##  [857] 8.948976 9.082507 9.082507 9.082507 9.082507 9.082507 9.082507 9.082507
##  [865] 9.082507 9.082507 9.082507 9.082507 9.082507 9.082507 9.082507 9.082507
##  [873] 9.082507 9.082507 9.082507 9.082507 9.148465 9.148465 9.148465 9.148465
##  [881] 9.148465 9.148465 9.148465 9.148465 9.148465 9.148465 9.148465 9.148465
##  [889] 9.148465 9.148465 9.169518 9.169518 9.169518 9.169518 9.169518 9.169518
##  [897] 9.169518 9.169518 9.169518 9.169518 9.169518 9.169518 9.169518 9.169518
##  [905] 9.169518 9.169518 9.169518 9.169518 9.169518 9.169518 9.169518 9.169518
##  [913] 9.169518 9.169518 9.169518 9.169518 9.169518 9.169518 9.169518 9.169518
##  [921] 9.169518 9.169518 9.169518 9.169518 9.169518 9.169518 9.169518 9.169518
##  [929] 9.169518 9.169518 9.169518 9.169518 9.169518 9.169518 9.169518 9.169518
##  [937] 9.169518 9.169518 9.169518 9.169518 9.169518 9.169518 9.169518 9.169518
##  [945] 9.169518 9.169518 9.169518 9.169518 9.169518 9.169518 9.169518 9.169518
##  [953] 9.169518 9.169518 9.169518 9.169518 9.169518 9.169518 9.169518 9.169518
##  [961] 9.169518 9.169518 9.148465 9.148465 9.148465 9.148465 9.148465 9.148465
##  [969] 9.148465 9.148465 9.148465 9.148465 9.148465 9.148465 9.148465 9.148465
##  [977] 9.230143 9.230143 9.230143 9.230143 9.230143 9.230143 9.230143 9.230143
##  [985] 9.230143 9.230143 9.230143 9.230143 9.230143 9.230143 9.230143 9.230143
##  [993] 9.230143 9.230143 9.230143 9.230143 9.230143 9.230143 9.230143 9.230143
## [1001] 9.230143 9.259131 9.259131 9.259131 9.259131 9.259131 9.259131 9.259131
## [1009] 9.259131 9.259131 9.259131 9.259131 9.259131 9.259131 9.259131 9.259131
## [1017] 9.259131 9.259131 9.259131 9.259131 9.259131 9.259131 9.259131 9.259131
## [1025] 9.259131 9.259131 9.220291 9.220291 9.220291 9.220291 9.220291 9.220291
## [1033] 9.220291 9.220291 9.220291 9.220291 9.220291 9.220291 9.220291 9.220291
## [1041] 9.220291 9.220291 9.220291 9.220291 9.220291 9.220291 9.220291 9.220291
## [1049] 9.220291 9.220291 9.220291
par(mfrow=c(1,2))

hist(W$Difference)
hist(data_log)

shapiro.test(data_log)
## 
##  Shapiro-Wilk normality test
## 
## data:  data_log
## W = 0.90775, p-value < 2.2e-16
P = read.csv("PDATA.csv")

#DATA TRANSFORMATION
#data_log1 <- log(P$Diffrence)
#data_log1

#par(mfrow=c(1,2))

#plot(P$Difference, col="blue")
#hist(P$Difference)
#hist(data_log1)

#shapiro.test(data_log1)
#shapiro.test(P$Difference)

TRIAL AND ERROR 1

library(MASS)
## 
## Attaching package: 'MASS'
## The following object is masked from 'package:dplyr':
## 
##     select
library(boot)
library(rcompanion)

#Code sa Morag Time Series

# figure 11
#library(nutshell) 
#data(turkey.price.ts)
#plot(turkey.price.ts)

#MAP CREATING

library(ggplot2)
library(maps)
## 
## Attaching package: 'maps'
## The following object is masked from 'package:purrr':
## 
##     map
library(mapdata)
library(dplyr)

#install.packages("devtools")
#install.packages("stringr")
#install.packages(c("maps", "mapdata"))