简体   繁体   English

使用Agricolae包装的R中LSD没有给出值

[英]No value given for LSD in R using Agricolae package

Hi: I am trying to calculate the LSD for some data in using the agricolae package in R. It seems straightforward enough from the documentation, but a part of the LSD is missing from the results. 嗨:我正在尝试使用R中的agricolae软件包计算一些数据的LSD。从文档中看起来很简单,但结果中缺少一部分LSD。

I found that some others have had this problem, but was not able to find an answer to their questions. 我发现其他一些人有这个问题,但无法找到问题的答案。 https://stat.ethz.ch/pipermail/r-help/2013-December/364391.html https://stat.ethz.ch/pipermail/r-help/2013-December/364391.html

Here is the code I am using, and some data I generated which replicates the results I am getting on my real data. 这是我正在使用的代码,以及我生成的一些数据,它复制了我在实际数据上获得的结果。

library(agricolae)

## Create Data Frame 

factor <- c(1,1,1,1,2,2,2,2,3,3,3)
var <- c(22,23,24,27,13,17,18,10,31,29,33)

df <- data.frame(factor,var)

## Run LSD test 

model <- aov(var ~ factor, df)
out <- LSD.test(model, "factor")

## Results 

out$statistics$LSD
NULL

No LSD value is given in the output because it appears that this output is only included when you have perfectly balanced data, and the data you have provided are unbalanced (ie 4 group "1" replications, 4 group "2" replications, but only 3 group "3" replications). 输出中没有给出LSD值,因为看起来只有当您拥有完美平衡的数据时才会包含此输出,并且您提供的数据是不平衡的(即4组“1”复制,4组“2”复制,但仅限3组“3”重复)。 When the data are balanced, the LSD value is given, for example: 当数据平衡时,给出LSD值,例如:

library(agricolae)

## Create Data Frame 

factor <- c(1,1,1,1,2,2,2,2,3,3,3,3)
var <- c(22,23,24,27,13,17,18,10,31,29,33,27)

df <- data.frame(factor,var)

## Run LSD test 

model <- aov(var ~ factor, df)
out <- LSD.test(model, "factor")

## Results 

out$statistics$LSD
11.04747

Try to make the factor vector as factor after you make the data frame and before build the model. 在创建数据框之后和构建模型之前,尝试将因子向量作为因子。 Here is the full code: 这是完整的代码:

library(agricolae)
factor <- c(1,1,1,1,2,2,2,2,3,3,3)
var <- c(22,23,24,27,13,17,18,10,31,29,33)
df <- data.frame(factor, var) 
df$factor<-as.factor(df$factor) #make the factor "factor"
model<-aov(var~factor, data=df)
(LSD.test(model, "factor"))$groups

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM