Example Analysis simple lattice 5x5 Example SAS.

    Ready for R:  Soy.txt
    In SAS the numeration of the blocks is: 1 2 3 4 5; equal within each replication
    In PBIB.test the numeration is continue, group 1: 1 2 3 4 5 and group 2: 6 7 8 9 10
    The numeration of the blocks is different in SAS and R
    
    See example in SAS. proc lattice

The Lattice Procedure
Analysis of Variance for Yield
                                      Sum of    Mean
Source                             DF Squares   Square
Replications                       1   212.18   212.18
Blocks within Replications (Adj.)  8   501.84   62.7300
Component B                        8   501.84   62.7300
Treatments (Unadj.)               24   559.28   23.3033
Intra Block Error                 16   218.48   13.6550
Randomized Complete Block Error   24   720.32   30.0133
Total                             49  1491.78   30.4445

Additional Statistics for Yield

Variance of Means in Same Block 15.7915
Variance of Means in Different Bloc 17.9280
Average of Variance 17.2159
LSD at .01 Level 12.1189
LSD at .05 Level 8.7959
Efficiency Relative to RCBD 174.34

Adjusted Treatment
Means for Yield

Treatment Mean

1 19.0681
2 16.9728
..
25 15.4048

1 vs 2, Variance of Means in Same Block 15.7915
diff = abs(19.0681 - 16.9728) = 2.0953
t.stat = 2.0953 / sqrt(15.7915) =  0.5272718
Df = 16
pvalue (two sided) = 2*(1-pt(0.5272718,16)) = 0.6052396

Proc mixed (SAS)

proc mixed data=soy method=type3;
class
Group Block Treatmnt;
model yield = Treatmnt;
random Group block(group);
lsmeans Treatmnt/pdiff;
run;
quit;

Type 3 Tests of Fixed Effects

Num Den
Effect     DF DF F Value  Pr > F
Treatmnt   24 16 1.97     0.0824

Least Squares Means
                        Standard
Effect Treatmnt Estimate Error     DF t Value Pr > |t|
Treatmnt 1      19.0681  3.5366    16 5.39     <.0001
Treatmnt 2      16.9728  3.5366    16 4.80     0.0002
Treatmnt 3      14.6463  3.5366    16 4.14     0.0008

Differences of Least Squares Means
                                  Standard
Effect Treatmnt _Treatmnt Estimate  Error   DF  t Value Pr > |t|
Treatmnt      1         2   2.0952 3.9739   16     0.53   0.6052
Treatmnt      1         3   4.4218 3.9739   16     1.11   0.2823
Treatmnt      1         4   4.2993 3.9739   16     1.08   0.2953
Treatmnt      1         5   6.2211 3.9739   16     1.57   0.1370
...
Treatmnt     23        25  -3.2007 3.9739   16    -0.81   0.4324
Treatmnt     24        25   1.9218 3.9739   16     0.48   0.6352

function PBIB.test(agricolae)

library(agricolae)
require(MASS) # method = VC in PBIB.test
require(lme4) # method = REML or LM in PBIB.test
lattice5x5 <- read.table("soy.txt",header=T)
str(lattice5x5
)
'data.frame': 50 obs. of 4 variables:
$ Group : int 1 1 1 1 1 1 1 1 1 1 ...
$ Block : int 1 1 1 1 1 2 2 2 2 2 ...
$ Treatmnt: int 1 2 3 4 5 6 7 8 9 10 ...
$ Yield : int 6 7 5 8 6 16 12 12 13 8 ...
attach(lattice5x5)
model <-PBIB.test(Block, Treatmnt, Group, Yield, k=5, method="VC", group=FALSE)


ANALYSIS PBIB: Yield
Class level information
Blocks: 10
Trts : 25
Number of observations: 50

Estimation Method: VC

Analysis of Variance Table

Response: Yield
                        Df Sum Sq Mean Sq F value Pr(>F)
replication             1 212.18  212.18  15.5386 0.001166 **
Treatmnt.unadj         24 559.28   23.303  1.7066 0.135789
replication:block.adj   8 501.84   62.730  4.5939 0.004629 **
Residuals              16 218.48   13.655
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
coefficient of variation: 27.1 %
Yield Means: 13.62

Parameters PBIB
treatmeans : 25
Block size : 5
Blocks/rep : 5
Replication: 2

Efficiency factor 0.75
Comparison between treatments means
<<< to see the objects: comparison, groups and means >>>

model$means
 Yield trt mean.adj SE       r std.err Min. Max.
1 15.0 1   19.06807 2.993997 2 9.0     6     24
2 14.0 2   16.97282 2.993997 2 7.0     7     21
3 10.5 3   14.64630 2.993997 2 5.5     5     16
4 12.5 4   14.76873 2.993997 2 4.5     8     17
5 10.5 5   12.84696 2.993997 2 4.5     6     15
6 14.5 6   13.17005 2.993997 2 1.5     13    16

model$comparison
         Difference  stderr   pvalue
1 - 2   2.095249482 3.973854 0.605248
1 - 3   4.421767894 3.973854 0.282270
1 - 4   4.299338435 3.973854 0.295332
...
25 - 23 3.200661565 3.973854 0.432380
24 - 25 1.921767894 3.973854 0.635220

############################