进行PBIB.test

时间:2018-01-23 22:20:00

标签: r lattice

我有一个不完整的格子设计研究的数据集,我已经从excel导入到R中,并希望进行PBIB.test。但是,在运行如下所示的功能后,即使重复多次,输出也会显示找不到对象区域。

library("agricolae", lib.loc = "~/R/win-library/3.3")
Rdata2 <- PBIB.test("BlockNo", "AccNo", "Rep", Area, k = 9, c("REML"), console = TRUE)

  Error in data.frame(v1 = 1, y) : object 'Area' not found

有什么问题?

1 个答案:

答案 0 :(得分:0)

根据PBIB.test tutorial,查看以下agricolae的示例应用。

  1. 首先,创建一些样本数据。

    # Construct the alpha design with 30 treatments, 2 repetitions, and block size = 3
    Genotype <- c(paste("gen0", 1:9, sep= ""), paste("gen", 10:30, sep= ""));
    r <- 2;
    k <- 3;
    s <- 10;
    b <- s * r;
    book <- design.alpha(Genotype, k, r,seed = 5);
    
    # Source dataframe
    df <- book$book;
    
  2. 创建响应值向量。

    # Response variable
    response <- c(
        5,2,7,6,4,9,7,6,7,9,6,2,1,1,3,2,4,6,7,9,8,7,6,4,3,2,2,1,1,2,
        1,1,2,4,5,6,7,8,6,5,4,3,1,1,2,5,4,2,7,6,6,5,6,4,5,7,6,5,5,4);
    
  3. 运行PBIB.test

    model <- with(df, PBIB.test(block, Genotype, replication, response, k = 3, method="REML"))
    head(model);
    #$ANOVA
    #Analysis of Variance Table
    #
    #Response: yield
    #          Df Sum Sq Mean Sq F value Pr(>F)
    #Genotype  29 72.006  2.4830  1.2396 0.3668
    #Residuals 11 22.034  2.0031
    #
    #$method
    #[1] "Residual (restricted) maximum likelihood"
    #
    #$parameters
    #      test   name.t treatments blockSize blocks r alpha
    #  PBIB-lsd Genotype         30         3     10 2  0.05
    #
    #$statistics
    #  Efficiency     Mean       CV
    #   0.6170213 4.533333 31.22004
    #
    #$model
    #Linear mixed-effects model fit by REML
    #  Data: NULL
    #  Log-restricted-likelihood: -73.82968
    #  Fixed: y ~ trt.adj
    # (Intercept) trt.adjgen02 trt.adjgen03 trt.adjgen04 trt.adjgen05 trt.adjgen06
    #   6.5047533   -3.6252940   -0.7701618   -2.5264354   -3.1633495   -1.9413054
    #trt.adjgen07 trt.adjgen08 trt.adjgen09 trt.adjgen10 trt.adjgen11 trt.adjgen12
    #  -3.0096514   -4.0648738   -3.5051139   -2.8765561   -1.7111335   -1.6308755
    #trt.adjgen13 trt.adjgen14 trt.adjgen15 trt.adjgen16 trt.adjgen17 trt.adjgen18
    #  -2.2187974   -2.3393290   -2.0807215   -0.3122845   -3.4526453   -1.0320169
    #trt.adjgen19 trt.adjgen20 trt.adjgen21 trt.adjgen22 trt.adjgen23 trt.adjgen24
    #  -3.1257616    0.2101325   -1.7632411   -1.9177848   -1.0500345   -2.5612960
    #trt.adjgen25 trt.adjgen26 trt.adjgen27 trt.adjgen28 trt.adjgen29 trt.adjgen30
    #  -4.3184716   -2.3071359    1.2239927   -1.3643068   -1.4354599   -0.4726870
    #
    #Random effects:
    # Formula: ~1 | replication
    #         (Intercept)
    #StdDev: 8.969587e-05
    #
    # Formula: ~1 | block.adj %in% replication
    #        (Intercept) Residual
    #StdDev:    1.683459 1.415308
    #
    #Number of Observations: 60
    #Number of Groups:
    #               replication block.adj %in% replication
    #                         2                         20
    #
    #$Fstat
    #                      Fit Statistics
    #AIC                        213.65937
    #BIC                        259.89888
    #-2 Res Log Likelihood      -73.82968