Getting started with BorderEffect

library(BorderEffect)
data(field_trial)
head(field_trial)
#>     x y trt blk rep response
#> 1   0 0  T3  B2  R7 2.172413
#> 2  50 0  T3  B2 R14 2.221019
#> 3 100 0  T1  B1 R15 2.159862
#> 4 150 0  T2  B1 R15 2.305717
#> 5 200 0  T2  B2  R9 2.229770
#> 6 250 0  T1  B1 R10 2.160772

Estimate kappa

be <- border_effect(response ~ trt + blk, data = field_trial, coords = field_trial)
be
#> Border-effect competition coefficient
#> Call: border_effect(formula = response ~ trt + blk, data = field_trial, 
#>     coords = field_trial)
#> kappa = -63.699317

Decide presence/absence of the edge effect

bt <- border_test(be, pattern = "outer1", nsim = 300, seed = 42)
bt
#> Edge-effect test (pattern = outer1, nsim = 300)
#> kappa (observed) = -63.699317
#> 95% CI = [-69.199418, -61.462462]
#> Decision: efecto de borde presente (presence)
plot(bt)

Spatial diagnostic

moran_border(be)
#> $observed
#> [1] 0.01395765
#> 
#> $expected
#> [1] -0.01052632
#> 
#> $sd
#> [1] 0.01178561
#> 
#> $p.value
#> [1] 0.03776051

Analyze your own trial

The bundled field_trial is simulated (via rnorm) using the exact design of the motivating dataset in the paper (a 12x8 staggered “tres bolillos” layout, 3 treatments, 2 blocks, 550 x 210 cm, border mean 2.21 vs interior 1.74). The original field-recorded values are not distributed with the paper, but any data with the same structure is analyzed the same way.

To analyze real data, provide a data frame (or CSV) with the plot coordinates x, y, the trt and blk factors, and the response. An example CSV in this exact format ships with the package:

csv <- system.file("extdata", "field_trial.csv", package = "BorderEffect")
d <- read.csv(csv)
names(d)[names(d) == "block"] <- "blk"   # the CSV names the block column `block`
be2 <- border_effect(response ~ trt + blk, data = d, coords = d)
border_test(be2, pattern = "outer1", nsim = 300, seed = 1)
#> Edge-effect test (pattern = outer1, nsim = 300)
#> kappa (observed) = -63.699317
#> 95% CI = [-69.885329, -61.892111]
#> Decision: efecto de borde presente (presence)

To reproduce the paper’s exact layout and plug in your own 96 recorded yields (in plot order), rebuild the layout and attach the response:

fl <- field_layout(nx = 12, ny = 8, ntrt = 3, nblk = 2,
                   arrangement = "triangular", width = 550, height = 210,
                   seed = 3000)
fl$response <- my_recorded_yields          # length-96 numeric vector, plot order
be <- border_effect(response ~ trt + blk, data = fl, coords = fl)
border_test(be, pattern = "outer1")