Significance of differences among slopes

# VER TB http://r-eco-evo.blogspot.com.es/2011/08/comparing-two-regression-slopes-by.html
# http://stackoverflow.com/questions/33192618/looking-for-differences-btw-linear-regression-lines-in-r
# http://www.ats.ucla.edu/stat/r/faq/testing_contrasts.htm
# https://cran.r-project.org/web/packages/multcomp/vignettes/multcomp-examples.pdf

require(lmPerm)

#setwd("C:/Users/peibol/R/NDVI Masters Tesis") #Pablo
setwd("/Users/agustinlobo/Dropbox/Public/pablo/PABLO2016") #ALOBO
## Error in setwd("/Users/agustinlobo/Dropbox/Public/pablo/PABLO2016"): cannot change working directory
Dtndvilong <- read.csv("Dtndvilong.csv", header=TRUE,stringsAsFactors=TRUE)
facets <- c("CenKal_ShWoodl", "HlShl_ShDens", "NKal_ShWoodl", "ThShl_ShDens")

1. CKSW (“CenKal_ShWoodl”) Central Kalahari Shrubland-Woodland Mosaic

1.1 Private vs. Illegal Fencing

f <- "CenKal_ShWoodl"
sel <- Dtndvilong[Dtndvilong$VEG==f,]
sel$year <- as.numeric(as.character(sel$year))
priv<- "PRIV"
selpriv <- sel[sel$TenureZone==priv,]
illegfenc<- "ILLEGFENC"
selillegfenc <- sel[sel$TenureZone==illegfenc,]
selcombi <- sel[sel$TenureZone==priv | sel$TenureZone==illegfenc,]
selcombi$TenureZone <- droplevels(selcombi$TenureZone)

1.1.1 t-test

aCenkal_interact_lm <- lm(DNDVIan ~ year*TenureZone, data=selcombi)
levels(selcombi$TenureZone)
## [1] "ILLEGFENC" "PRIV"
aCenkal_interact_lm
## 
## Call:
## lm(formula = DNDVIan ~ year * TenureZone, data = selcombi)
## 
## Coefficients:
##         (Intercept)                 year       TenureZonePRIV  
##          -317038.51               159.77             21801.77  
## year:TenureZonePRIV  
##              -11.19
summary(aCenkal_interact_lm)
## 
## Call:
## lm(formula = DNDVIan ~ year * TenureZone, data = selcombi)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -22979.9  -5543.0   -450.6   6204.9  20359.2 
## 
## Coefficients:
##                       Estimate Std. Error t value Pr(>|t|)    
## (Intercept)         -317038.51   69310.61  -4.574 5.01e-06 ***
## year                    159.77      34.81   4.590 4.66e-06 ***
## TenureZonePRIV        21801.77  118737.44   0.184    0.854    
## year:TenureZonePRIV     -11.19      59.64  -0.188    0.851    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 7841 on 2561 degrees of freedom
## Multiple R-squared:  0.01255,    Adjusted R-squared:  0.01139 
## F-statistic: 10.85 on 3 and 2561 DF,  p-value: 4.437e-07

1.1.2 Permutation test

#NOTE: repeat untill summary(aCenkal_interact) indicates 5000 Iter
#the p*Ca criterion sometimes make it stop at too short Iter nb.
aCenkal_interact <- lmp(DNDVIan ~ year*TenureZone, data=selcombi,center=FALSE,
                        contrasts=list(TenureZone="contr.treatment"),
                        perm="Prob",maxiter=5000,Ca=0.000000001)
levels(selcombi$TenureZone)
## [1] "ILLEGFENC" "PRIV"
aCenkal_interact
## 
## Call:
## lmp(formula = DNDVIan ~ year * TenureZone, data = selcombi, perm = "Prob", 
##     center = FALSE, contrasts = list(TenureZone = "contr.treatment"), 
##     maxiter = 5000, Ca = 1e-09)
## 
## Coefficients:
##         (Intercept)       TenureZonePRIV                 year  
##          -317038.51             21801.77               159.77  
## year:TenureZonePRIV  
##              -11.19
summary(aCenkal_interact)
## 
## Call:
## lmp(formula = DNDVIan ~ year * TenureZone, data = selcombi, perm = "Prob", 
##     center = FALSE, contrasts = list(TenureZone = "contr.treatment"), 
##     maxiter = 5000, Ca = 1e-09)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -22979.9  -5543.0   -450.6   6204.9  20359.2 
## 
## Coefficients:
##                     Estimate Iter Pr(Prob)    
## TenureZonePRIV      21801.77 5000    0.169    
## year                  159.77 5000   <2e-16 ***
## year:TenureZonePRIV   -11.19 5000    0.819    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 7841 on 2561 degrees of freedom
## Multiple R-Squared: 0.01255, Adjusted R-squared: 0.01139 
## F-statistic: 10.85 on 3 and 2561 DF,  p-value: 4.437e-07

2. HSSD (“HlShl_ShDens”) Highland Dense Shrubland

2.1 Private vs. Open Communal

f <- "HlShl_ShDens"
sel <- Dtndvilong[Dtndvilong$VEG==f,]
sel$year <- as.numeric(as.character(sel$year))
priv<- "PRIV"
selpriv <- sel[sel$TenureZone==priv,]
comm<- "OPENCOMM"
selcomm <- sel[sel$TenureZone==comm,]
selcombi <- sel[sel$TenureZone==priv | sel$TenureZone==comm,]
selcombi <- droplevels(selcombi)

2.1.1 t-test

aHlsh_interact_lm <- lm(DNDVIan ~ year*TenureZone, data=selcombi)
levels(selcombi$TenureZone)
## [1] "OPENCOMM" "PRIV"
aHlsh_interact_lm
## 
## Call:
## lm(formula = DNDVIan ~ year * TenureZone, data = selcombi)
## 
## Coefficients:
##         (Intercept)                 year       TenureZonePRIV  
##          -575614.57               289.45            -27176.71  
## year:TenureZonePRIV  
##               13.67
summary(aHlsh_interact_lm)
## 
## Call:
## lm(formula = DNDVIan ~ year * TenureZone, data = selcombi)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -22548  -3663   -140   3476  15081 
## 
## Coefficients:
##                       Estimate Std. Error t value Pr(>|t|)    
## (Intercept)         -575614.57  147116.02  -3.913 9.84e-05 ***
## year                    289.45      73.89   3.917 9.66e-05 ***
## TenureZonePRIV       -27176.71  166298.23  -0.163     0.87    
## year:TenureZonePRIV      13.67      83.52   0.164     0.87    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5579 on 870 degrees of freedom
## Multiple R-squared:  0.08028,    Adjusted R-squared:  0.0771 
## F-statistic: 25.31 on 3 and 870 DF,  p-value: 1.05e-15

2.1.2 Permutation lm

#NOTE: repeat untill summary(aCenkal_interact) indicates 5000 Iter
#the p*Ca criterion sometimes make it stop at too short Iter nb.
aHlsh_interact <- lmp(DNDVIan ~ year*TenureZone, data=selcombi,
                      center=FALSE,contrasts=list(TenureZone="contr.treatment"),
                      perm="Prob",maxiter=5000,Ca=0.000000001)
levels(selcombi$TenureZone)
## [1] "OPENCOMM" "PRIV"
aHlsh_interact
## 
## Call:
## lmp(formula = DNDVIan ~ year * TenureZone, data = selcombi, perm = "Prob", 
##     center = FALSE, contrasts = list(TenureZone = "contr.treatment"), 
##     maxiter = 5000, Ca = 1e-09)
## 
## Coefficients:
##         (Intercept)       TenureZonePRIV                 year  
##          -575614.57            -27176.71               289.45  
## year:TenureZonePRIV  
##               13.67
summary(aHlsh_interact)
## 
## Call:
## lmp(formula = DNDVIan ~ year * TenureZone, data = selcombi, perm = "Prob", 
##     center = FALSE, contrasts = list(TenureZone = "contr.treatment"), 
##     maxiter = 5000, Ca = 1e-09)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -22548  -3663   -140   3476  15081 
## 
## Coefficients:
##                      Estimate Iter Pr(Prob)    
## TenureZonePRIV      -27176.71   51    1.000    
## year                   289.45 5000   <2e-16 ***
## year:TenureZonePRIV     13.67 5000    0.831    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5579 on 870 degrees of freedom
## Multiple R-Squared: 0.08028, Adjusted R-squared: 0.0771 
## F-statistic: 25.31 on 3 and 870 DF,  p-value: 1.05e-15

3. “NKal_ShWoodl” (NKSW) Northern Kalahari Shrubland-Woodland Mosaic

f <- "NKal_ShWoodl"
sel <- Dtndvilong[Dtndvilong$VEG==f,]
sel$year <- as.numeric(as.character(sel$year))
priv<- "PRIV"
selpriv <- sel[sel$TenureZone==priv,]
comm<- "OPENCOMM"
selcomm <- sel[sel$TenureZone==comm,]
illegfenc<- "ILLEGFENC"
selillegfenc <- sel[sel$TenureZone==illegfenc,]
allocs<- "ALLOCSPREINDEP"
selallocs<- sel[sel$TenureZone==allocs,]
selcombi_all <- sel[sel$TenureZone==priv | sel$TenureZone==comm | sel$TenureZone==illegfenc | sel$TenureZone==allocs,]
selcombi_all <- droplevels(selcombi_all)
selcombi_privcomm <- sel[sel$TenureZone==priv | sel$TenureZone==comm,]
selcombi_privcomm <- droplevels(selcombi_privcomm)
selcombi_privilleg <- sel[sel$TenureZone==priv | sel$TenureZone==illegfenc,]
selcombi_privilleg <- droplevels(selcombi_privilleg)
selcombi_privallocs <- sel[sel$TenureZone==priv | sel$TenureZone==allocs,]
selcombi_privallocs <- droplevels(selcombi_privallocs)
selcombi_commilleg <- sel[sel$TenureZone==comm | sel$TenureZone==illegfenc,]
selcombi_commilleg <- droplevels(selcombi_commilleg)
selcombi_commallocs <- sel[sel$TenureZone==comm | sel$TenureZone==allocs,]
selcombi_commallocs <- droplevels(selcombi_commallocs)
selcombi_illegallocs <- sel[sel$TenureZone==illegfenc | sel$TenureZone==allocs,]
selcombi_illegallocs <- droplevels(selcombi_illegallocs)

3.1 Private vs. Illegal fencing

3.1.1 t-test

Nkal_int_privilleg_lm <- lm(DNDVIan ~ year*TenureZone, data=selcombi_privilleg)
levels(selcombi_privilleg$TenureZone)
## [1] "ILLEGFENC" "PRIV"
Nkal_int_privilleg_lm
## 
## Call:
## lm(formula = DNDVIan ~ year * TenureZone, data = selcombi_privilleg)
## 
## Coefficients:
##         (Intercept)                 year       TenureZonePRIV  
##           -691853.8                347.9             576621.0  
## year:TenureZonePRIV  
##              -290.1
summary(Nkal_int_privilleg_lm) #private against illegal fencing
## 
## Call:
## lm(formula = DNDVIan ~ year * TenureZone, data = selcombi_privilleg)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -21659.9  -4852.8     58.4   4948.9  20247.9 
## 
## Coefficients:
##                       Estimate Std. Error t value Pr(>|t|)    
## (Intercept)         -691853.81   60562.53 -11.424  < 2e-16 ***
## year                    347.91      30.42  11.438  < 2e-16 ***
## TenureZonePRIV       576621.03   83479.69   6.907 5.81e-12 ***
## year:TenureZonePRIV    -290.12      41.93  -6.920 5.34e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 6890 on 3606 degrees of freedom
## Multiple R-squared:  0.04106,    Adjusted R-squared:  0.04027 
## F-statistic: 51.47 on 3 and 3606 DF,  p-value: < 2.2e-16

3.1.2 Permutation test

Nkal_int_privilleg <- lmp(DNDVIan ~ year*TenureZone, data=selcombi_privilleg,
                          center=FALSE,contrasts=list(TenureZone="contr.treatment"),
                          perm="Prob",maxiter=5000,Ca=0.000000001)
levels(selcombi_privilleg$TenureZone)
## [1] "ILLEGFENC" "PRIV"
Nkal_int_privilleg
## 
## Call:
## lmp(formula = DNDVIan ~ year * TenureZone, data = selcombi_privilleg, 
##     perm = "Prob", center = FALSE, contrasts = list(TenureZone = "contr.treatment"), 
##     maxiter = 5000, Ca = 1e-09)
## 
## Coefficients:
##         (Intercept)       TenureZonePRIV                 year  
##           -691853.8             576621.0                347.9  
## year:TenureZonePRIV  
##              -290.1
summary(Nkal_int_privilleg) #private against illegal fencing
## 
## Call:
## lmp(formula = DNDVIan ~ year * TenureZone, data = selcombi_privilleg, 
##     perm = "Prob", center = FALSE, contrasts = list(TenureZone = "contr.treatment"), 
##     maxiter = 5000, Ca = 1e-09)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -21659.87  -4852.81     58.39   4948.89  20247.87 
## 
## Coefficients:
##                     Estimate Iter Pr(Prob)    
## TenureZonePRIV      576621.0 5000   <2e-16 ***
## year                   347.9 5000   <2e-16 ***
## year:TenureZonePRIV   -290.1 5000   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 6890 on 3606 degrees of freedom
## Multiple R-Squared: 0.04106, Adjusted R-squared: 0.04027 
## F-statistic: 51.47 on 3 and 3606 DF,  p-value: < 2.2e-16

3.2 Private vs. Open Communal

3.2.1 t-test

Nkal_int_privcomm_lm <- lm(DNDVIan ~ year*TenureZone, data=selcombi_privcomm)
levels(selcombi_privcomm$TenureZone)
## [1] "OPENCOMM" "PRIV"
Nkal_int_privcomm_lm
## 
## Call:
## lm(formula = DNDVIan ~ year * TenureZone, data = selcombi_privcomm)
## 
## Coefficients:
##         (Intercept)                 year       TenureZonePRIV  
##           -739673.5                371.4             624440.7  
## year:TenureZonePRIV  
##              -313.6
summary(Nkal_int_privcomm_lm) # private against opencomm
## 
## Call:
## lm(formula = DNDVIan ~ year * TenureZone, data = selcombi_privcomm)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -34578  -5624    394   5873  27586 
## 
## Coefficients:
##                       Estimate Std. Error t value Pr(>|t|)    
## (Intercept)         -739673.47   36037.02 -20.525  < 2e-16 ***
## year                    371.37      18.10  20.518  < 2e-16 ***
## TenureZonePRIV       624440.69   77876.67   8.018 1.21e-15 ***
## year:TenureZonePRIV    -313.58      39.11  -8.017 1.22e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 8278 on 8869 degrees of freedom
## Multiple R-squared:  0.04562,    Adjusted R-squared:  0.0453 
## F-statistic: 141.3 on 3 and 8869 DF,  p-value: < 2.2e-16

3.2.2 Permutation test

Nkal_int_privcomm <- lmp(DNDVIan ~ year*TenureZone, data=selcombi_privcomm,
                         center=FALSE,contrasts=list(TenureZone="contr.treatment"),
                         perm="Prob",maxiter=5000,Ca=0.000000001)
levels(selcombi_privcomm$TenureZone)
## [1] "OPENCOMM" "PRIV"
Nkal_int_privcomm
## 
## Call:
## lmp(formula = DNDVIan ~ year * TenureZone, data = selcombi_privcomm, 
##     perm = "Prob", center = FALSE, contrasts = list(TenureZone = "contr.treatment"), 
##     maxiter = 5000, Ca = 1e-09)
## 
## Coefficients:
##         (Intercept)       TenureZonePRIV                 year  
##           -739673.5             624440.7                371.4  
## year:TenureZonePRIV  
##              -313.6
summary(Nkal_int_privcomm) # private against opencomm
## 
## Call:
## lmp(formula = DNDVIan ~ year * TenureZone, data = selcombi_privcomm, 
##     perm = "Prob", center = FALSE, contrasts = list(TenureZone = "contr.treatment"), 
##     maxiter = 5000, Ca = 1e-09)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -34578.3  -5623.8    394.3   5873.4  27586.2 
## 
## Coefficients:
##                     Estimate Iter Pr(Prob)    
## TenureZonePRIV      624440.7 5000    0.796    
## year                   371.4 5000   <2e-16 ***
## year:TenureZonePRIV   -313.6 5000   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 8278 on 8869 degrees of freedom
## Multiple R-Squared: 0.04562, Adjusted R-squared: 0.0453 
## F-statistic: 141.3 on 3 and 8869 DF,  p-value: < 2.2e-16

3.3 Private vs. Pre-independence allocations

3.3.1 t-test

Nkal_int_privallocs_lm <- lm(DNDVIan ~ year*TenureZone, data=selcombi_privallocs)
levels(selcombi_privallocs$TenureZone)
## [1] "ALLOCSPREINDEP" "PRIV"
Nkal_int_privallocs_lm
## 
## Call:
## lm(formula = DNDVIan ~ year * TenureZone, data = selcombi_privallocs)
## 
## Coefficients:
##         (Intercept)                 year       TenureZonePRIV  
##           -643404.9                323.5             528172.1  
## year:TenureZonePRIV  
##              -265.7
summary(Nkal_int_privallocs_lm) #private against allocspreindep
## 
## Call:
## lm(formula = DNDVIan ~ year * TenureZone, data = selcombi_privallocs)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -21659.9  -4609.7    184.7   4633.4  20247.9 
## 
## Coefficients:
##                       Estimate Std. Error t value Pr(>|t|)    
## (Intercept)         -643404.92   81180.16  -7.926 3.28e-15 ***
## year                    323.54      40.77   7.935 3.04e-15 ***
## TenureZonePRIV       528172.14   97416.19   5.422 6.42e-08 ***
## year:TenureZonePRIV    -265.75      48.93  -5.431 6.08e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 6457 on 2732 degrees of freedom
## Multiple R-squared:  0.02832,    Adjusted R-squared:  0.02725 
## F-statistic: 26.54 on 3 and 2732 DF,  p-value: < 2.2e-16

3.3.2 Permutation test

Nkal_int_privallocs <- lmp(DNDVIan ~ year*TenureZone, data=selcombi_privallocs,
                           center=FALSE,contrasts=list(TenureZone="contr.treatment"),
                           perm="Prob",maxiter=5000,Ca=0.000000001)
levels(selcombi_privallocs$TenureZone)
## [1] "ALLOCSPREINDEP" "PRIV"
Nkal_int_privallocs
## 
## Call:
## lmp(formula = DNDVIan ~ year * TenureZone, data = selcombi_privallocs, 
##     perm = "Prob", center = FALSE, contrasts = list(TenureZone = "contr.treatment"), 
##     maxiter = 5000, Ca = 1e-09)
## 
## Coefficients:
##         (Intercept)       TenureZonePRIV                 year  
##           -643404.9             528172.1                323.5  
## year:TenureZonePRIV  
##              -265.7
summary(Nkal_int_privallocs) #private against allocspreindep
## 
## Call:
## lmp(formula = DNDVIan ~ year * TenureZone, data = selcombi_privallocs, 
##     perm = "Prob", center = FALSE, contrasts = list(TenureZone = "contr.treatment"), 
##     maxiter = 5000, Ca = 1e-09)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -21659.9  -4609.7    184.7   4633.4  20247.9 
## 
## Coefficients:
##                     Estimate Iter Pr(Prob)    
## TenureZonePRIV      528172.1 5000   <2e-16 ***
## year                   323.5 5000   <2e-16 ***
## year:TenureZonePRIV   -265.7 5000   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 6457 on 2732 degrees of freedom
## Multiple R-Squared: 0.02832, Adjusted R-squared: 0.02725 
## F-statistic: 26.54 on 3 and 2732 DF,  p-value: < 2.2e-16

3.4 Open Communal vs. Illegal fencing

3.4.1 t-test

Nkal_int_commilleg_lm <- lm(DNDVIan ~ year*TenureZone, data=selcombi_commilleg)
levels(selcombi_commilleg$TenureZone)
## [1] "ILLEGFENC" "OPENCOMM"
Nkal_int_commilleg_lm
## 
## Call:
## lm(formula = DNDVIan ~ year * TenureZone, data = selcombi_commilleg)
## 
## Coefficients:
##             (Intercept)                     year       TenureZoneOPENCOMM  
##              -691853.81                   347.91                -47819.66  
## year:TenureZoneOPENCOMM  
##                   23.46
summary(Nkal_int_commilleg_lm) #opencomm against illegal fencing
## 
## Call:
## lm(formula = DNDVIan ~ year * TenureZone, data = selcombi_commilleg)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -34578  -5899    315   6255  27586 
## 
## Coefficients:
##                           Estimate Std. Error t value Pr(>|t|)    
## (Intercept)             -691853.81   74476.65  -9.290   <2e-16 ***
## year                        347.91      37.41   9.301   <2e-16 ***
## TenureZoneOPENCOMM       -47819.66   83108.46  -0.575    0.565    
## year:TenureZoneOPENCOMM      23.46      41.74   0.562    0.574    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 8472 on 8679 degrees of freedom
## Multiple R-squared:  0.05571,    Adjusted R-squared:  0.05539 
## F-statistic: 170.7 on 3 and 8679 DF,  p-value: < 2.2e-16

3.4.2 Permutation test

Nkal_int_commilleg <- lmp(DNDVIan ~ year*TenureZone, data=selcombi_commilleg,
                          center=FALSE,contrasts=list(TenureZone="contr.treatment"),
                          perm="Prob",maxiter=5000,Ca=0.000000001)
levels(selcombi_commilleg$TenureZone)
## [1] "ILLEGFENC" "OPENCOMM"
Nkal_int_commilleg
## 
## Call:
## lmp(formula = DNDVIan ~ year * TenureZone, data = selcombi_commilleg, 
##     perm = "Prob", center = FALSE, contrasts = list(TenureZone = "contr.treatment"), 
##     maxiter = 5000, Ca = 1e-09)
## 
## Coefficients:
##             (Intercept)       TenureZoneOPENCOMM                     year  
##              -691853.81                -47819.66                   347.91  
## year:TenureZoneOPENCOMM  
##                   23.46
summary(Nkal_int_commilleg) #opencomm against illegal fencing
## 
## Call:
## lmp(formula = DNDVIan ~ year * TenureZone, data = selcombi_commilleg, 
##     perm = "Prob", center = FALSE, contrasts = list(TenureZone = "contr.treatment"), 
##     maxiter = 5000, Ca = 1e-09)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -34578.3  -5899.1    315.4   6255.1  27586.2 
## 
## Coefficients:
##                          Estimate Iter Pr(Prob)    
## TenureZoneOPENCOMM      -47819.66 5000   <2e-16 ***
## year                       347.91 5000   <2e-16 ***
## year:TenureZoneOPENCOMM     23.46 5000    0.583    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 8472 on 8679 degrees of freedom
## Multiple R-Squared: 0.05571, Adjusted R-squared: 0.05539 
## F-statistic: 170.7 on 3 and 8679 DF,  p-value: < 2.2e-16

3.5 Open Communal vs. Pre-independence allocations

3.5.1 t-test

Nkal_int_commallocs_lm <- lm(DNDVIan ~ year*TenureZone, data=selcombi_commallocs)
levels(selcombi_commallocs$TenureZone)
## [1] "ALLOCSPREINDEP" "OPENCOMM"
Nkal_int_commallocs_lm
## 
## Call:
## lm(formula = DNDVIan ~ year * TenureZone, data = selcombi_commallocs)
## 
## Coefficients:
##             (Intercept)                     year       TenureZoneOPENCOMM  
##              -643404.92                   323.54                -96268.55  
## year:TenureZoneOPENCOMM  
##                   47.84
summary(Nkal_int_commallocs_lm)
## 
## Call:
## lm(formula = DNDVIan ~ year * TenureZone, data = selcombi_commallocs)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -34578  -5887    471   6214  27586 
## 
## Coefficients:
##                           Estimate Std. Error t value Pr(>|t|)    
## (Intercept)             -643404.92  107036.27  -6.011 1.93e-09 ***
## year                        323.54      53.76   6.018 1.84e-09 ***
## TenureZoneOPENCOMM       -96268.55  113271.03  -0.850    0.395    
## year:TenureZoneOPENCOMM      47.84      56.89   0.841    0.400    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 8514 on 7805 degrees of freedom
## Multiple R-squared:  0.05395,    Adjusted R-squared:  0.05359 
## F-statistic: 148.4 on 3 and 7805 DF,  p-value: < 2.2e-16

3.5.2 Permutation test

Nkal_int_commallocs <- lmp(DNDVIan ~ year*TenureZone, data=selcombi_commallocs,
                           center=FALSE,contrasts=list(TenureZone="contr.treatment"),
                           perm="Prob",maxiter=5000,Ca=0.000000001)
levels(selcombi_commallocs$TenureZone)
## [1] "ALLOCSPREINDEP" "OPENCOMM"
Nkal_int_commallocs
## 
## Call:
## lmp(formula = DNDVIan ~ year * TenureZone, data = selcombi_commallocs, 
##     perm = "Prob", center = FALSE, contrasts = list(TenureZone = "contr.treatment"), 
##     maxiter = 5000, Ca = 1e-09)
## 
## Coefficients:
##             (Intercept)       TenureZoneOPENCOMM                     year  
##              -643404.92                -96268.55                   323.54  
## year:TenureZoneOPENCOMM  
##                   47.84
summary(Nkal_int_commallocs) #opencomm against allocspreindep
## 
## Call:
## lmp(formula = DNDVIan ~ year * TenureZone, data = selcombi_commallocs, 
##     perm = "Prob", center = FALSE, contrasts = list(TenureZone = "contr.treatment"), 
##     maxiter = 5000, Ca = 1e-09)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -34578.3  -5887.4    471.1   6214.1  27586.2 
## 
## Coefficients:
##                          Estimate Iter Pr(Prob)    
## TenureZoneOPENCOMM      -96268.55 5000   <2e-16 ***
## year                       323.54 5000   <2e-16 ***
## year:TenureZoneOPENCOMM     47.84 5000    0.349    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 8514 on 7805 degrees of freedom
## Multiple R-Squared: 0.05395, Adjusted R-squared: 0.05359 
## F-statistic: 148.4 on 3 and 7805 DF,  p-value: < 2.2e-16

3.5 Illegal fencing vs. Pre-independence allocations

3.5.1 t-test

Nkal_int_illegallocs_lm <- lm(DNDVIan ~ year*TenureZone, data=selcombi_illegallocs)
levels(selcombi_illegallocs$TenureZone)
## [1] "ALLOCSPREINDEP" "ILLEGFENC"
Nkal_int_illegallocs_lm
## 
## Call:
## lm(formula = DNDVIan ~ year * TenureZone, data = selcombi_illegallocs)
## 
## Coefficients:
##              (Intercept)                      year  
##               -643404.92                    323.54  
##      TenureZoneILLEGFENC  year:TenureZoneILLEGFENC  
##                -48448.89                     24.38
summary(Nkal_int_illegallocs_lm)
## 
## Call:
## lm(formula = DNDVIan ~ year * TenureZone, data = selcombi_illegallocs)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -21342.0  -5157.7   -326.9   5699.8  18411.1 
## 
## Coefficients:
##                            Estimate Std. Error t value Pr(>|t|)    
## (Intercept)              -643404.92   89592.05  -7.181 9.02e-13 ***
## year                         323.54      45.00   7.190 8.48e-13 ***
## TenureZoneILLEGFENC       -48448.89  109320.26  -0.443    0.658    
## year:TenureZoneILLEGFENC      24.38      54.91   0.444    0.657    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 7126 on 2542 degrees of freedom
## Multiple R-squared:  0.06408,    Adjusted R-squared:  0.06298 
## F-statistic: 58.02 on 3 and 2542 DF,  p-value: < 2.2e-16

3.5.2 Permutation test

Nkal_int_illegallocs <- lmp(DNDVIan ~ year*TenureZone, data=selcombi_illegallocs,
                            center=FALSE,contrasts=list(TenureZone="contr.treatment"),
                            perm="Prob",maxiter=5000,Ca=0.000000001)
levels(selcombi_illegallocs$TenureZone)
## [1] "ALLOCSPREINDEP" "ILLEGFENC"
Nkal_int_illegallocs
## 
## Call:
## lmp(formula = DNDVIan ~ year * TenureZone, data = selcombi_illegallocs, 
##     perm = "Prob", center = FALSE, contrasts = list(TenureZone = "contr.treatment"), 
##     maxiter = 5000, Ca = 1e-09)
## 
## Coefficients:
##              (Intercept)       TenureZoneILLEGFENC  
##               -643404.92                 -48448.89  
##                     year  year:TenureZoneILLEGFENC  
##                   323.54                     24.38
summary(Nkal_int_illegallocs) #illegal fencing against allocspreindep
## 
## Call:
## lmp(formula = DNDVIan ~ year * TenureZone, data = selcombi_illegallocs, 
##     perm = "Prob", center = FALSE, contrasts = list(TenureZone = "contr.treatment"), 
##     maxiter = 5000, Ca = 1e-09)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -21342.0  -5157.7   -326.9   5699.8  18411.1 
## 
## Coefficients:
##                           Estimate Iter Pr(Prob)    
## TenureZoneILLEGFENC      -48448.89   51    1.000    
## year                        323.54 5000   <2e-16 ***
## year:TenureZoneILLEGFENC     24.38 5000    0.373    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 7126 on 2542 degrees of freedom
## Multiple R-Squared: 0.06408, Adjusted R-squared: 0.06298 
## F-statistic: 58.02 on 3 and 2542 DF,  p-value: < 2.2e-16

4. “ThShl_ShDens” (TSSD) Thornbush dense shrubland

f <- "ThShl_ShDens"
sel <- Dtndvilong[Dtndvilong$VEG==f,]
sel$year <- as.numeric(as.character(sel$year))
priv<- "PRIV"
selpriv <- sel[sel$TenureZone==priv,]
illegfenc<- "ILLEGFENC"
selillegfenc <- sel[sel$TenureZone==illegfenc,]
selcombi <- sel[sel$TenureZone==priv | sel$TenureZone==illegfenc,]
selcombi$TenureZone <- droplevels(selcombi$TenureZone)

4.1 Private vs. Illegal fencing

4.1.1 t-test

aThsh_interact_lm <- lm(DNDVIan ~ year*TenureZone, data=selcombi)
levels(selcombi$TenureZone)
## [1] "ILLEGFENC" "PRIV"
aThsh_interact_lm
## 
## Call:
## lm(formula = DNDVIan ~ year * TenureZone, data = selcombi)
## 
## Coefficients:
##         (Intercept)                 year       TenureZonePRIV  
##           -636294.9                320.2             481371.1  
## year:TenureZonePRIV  
##              -242.3
summary(aThsh_interact_lm)
## 
## Call:
## lm(formula = DNDVIan ~ year * TenureZone, data = selcombi)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -21575.5  -4505.2     40.5   4254.9  21685.3 
## 
## Coefficients:
##                       Estimate Std. Error t value Pr(>|t|)    
## (Intercept)         -636294.92  165220.11  -3.851 0.000118 ***
## year                    320.25      82.98   3.859 0.000114 ***
## TenureZonePRIV       481371.09  167024.05   2.882 0.003960 ** 
## year:TenureZonePRIV    -242.34      83.89  -2.889 0.003876 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 6571 on 9724 degrees of freedom
## Multiple R-squared:  0.00624,    Adjusted R-squared:  0.005933 
## F-statistic: 20.35 on 3 and 9724 DF,  p-value: 3.838e-13

4.1.2 Permutation test

aThsh_interact <- lmp(DNDVIan ~ year*TenureZone, data=selcombi,center=FALSE,
                      contrasts=list(TenureZone="contr.treatment"),
                      perm="Prob",maxiter=5000,Ca=0.000000001)
levels(selcombi)
## NULL
aThsh_interact
## 
## Call:
## lmp(formula = DNDVIan ~ year * TenureZone, data = selcombi, perm = "Prob", 
##     center = FALSE, contrasts = list(TenureZone = "contr.treatment"), 
##     maxiter = 5000, Ca = 1e-09)
## 
## Coefficients:
##         (Intercept)       TenureZonePRIV                 year  
##           -636294.9             481371.1                320.2  
## year:TenureZonePRIV  
##              -242.3
summary(aThsh_interact)
## 
## Call:
## lmp(formula = DNDVIan ~ year * TenureZone, data = selcombi, perm = "Prob", 
##     center = FALSE, contrasts = list(TenureZone = "contr.treatment"), 
##     maxiter = 5000, Ca = 1e-09)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -21575.5  -4505.2     40.5   4254.9  21685.3 
## 
## Coefficients:
##                     Estimate Iter Pr(Prob)    
## TenureZonePRIV      481371.1 5000   <2e-16 ***
## year                   320.2 5000   <2e-16 ***
## year:TenureZonePRIV   -242.3 5000   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 6571 on 9724 degrees of freedom
## Multiple R-Squared: 0.00624, Adjusted R-squared: 0.005933 
## F-statistic: 20.35 on 3 and 9724 DF,  p-value: 3.838e-13