我对R(以及统计学)是新手,因此对于可能是非常基础的问题提前道歉,但我将非常感激任何帮助!
我正在尝试评估在给定车道上开始赛车与其他车道相比是否存在统计优势。
我拥有的样本量很小,不一定符合正态分布,因此我选择使用卡方检验来检查预期胜利与观察到的胜利之间的显着差异。
#create lanes var
lane_num <- c(1:10)
#num wins per lane
num_wins <- c(8, 7, 10, 7, 6, 3, 6, 4, 1, 0)
#create df
df <- as.data.frame(cbind(lane_num, num_wins))
#convert lanes_num factor
df$lane_num <- as.factor(df$lane_num)
#check str
str(df)
#run chisq
chi_res <- chisq.test(df$num_wins)
#check results
chi_res
#check for sig diff between lanes
chisq.post.hoc(df) #this is where i'm having issues
chisq.test的结果表明,预期值与观察值之间存在显著差异;
Chi-squared test for given probabilities
data: df$num_wins
X-squared = 17.231, df = 9, p-value = 0.04522
我遇到困难的地方是在运行事后检验时,需要比较各个车道之间的差异,以确定哪些车道更有优势。
仅仅运行以下命令:
chisq.post.hoc(df)
返回以下错误:
Error in test(tbl[prs[, i], ], ...) :
all entries of 'x' must be nonnegative and finite
正如我所说,我对R和统计学都很陌生,因此提供的关于chisq.post.hoc的文档对我来说并不是很清晰易懂 - 而且似乎该软件包已经不再得到支持了,因此我必须下载存档版本。我尝试了各种方法,但都出现了错误。例如:
chisq.post.hoc(df$num_wins, control = "bonferroni")
> Error in 1:nrow(tbl) : argument of length 0
我真的很希望你能给我指点一下,或者提供任何关于我可以使用的替代事后检验以及如何在运行前结构化数据的建议。
先谢谢了!