【问题标题】:Error code: insufficient values in manual scale错误代码:手动刻度值不足
【发布时间】:2021-08-19 02:26:25
【问题描述】:

我正在尝试使用以下代码运行假设检验:

library(statsr)
inference(x= sex, y = natheal, data = dataset, 
    statistic = "proportion", type = "ht", 
    method = "theoretical", alternative = "greater", 
    success = "Too Much")

但我不断收到此错误:

Error: Insufficient values in manual scale. 3 needed but only 2 provided.

这是什么意思?我该如何解决?

【问题讨论】:

    标签: r statistics inference manual hypothesis-test


    【解决方案1】:

    该函数在绘制输出图形时引起错误;期望为两种结果使用两种颜色,但结果不止两种。可以通过将参数show_eda_plotshow_inf_plot 设置为FALSE 来抑制图形。

    但是错误是因为您选择的方法只期望响应变量中有两个结果,但有两个以上。

    library(statsr)
    dataset <- data.frame(
        sex = c(0, 0, 1, 1), 
        natheal = c("Not Enough", "Just Right", "Too Much", "Not Enough"))
    inference(x = sex, y = natheal, 
        data = dataset, 
        statistic = "proportion", 
        type = "ht", 
        method = "theoretical", 
        alternative = "greater", 
        success = "Too Much")
    # Error: Insufficient values in manual scale. 3 needed but only 2 provided.
    
    unique(dataset$natheal)
    # [1] Not Enough Just Right Too Much  
    # Levels: Just Right Not Enough Too Much
    

    如果您重新编码响应变量,以便只有两个唯一值,则函数将按预期运行。或者,选择其他方法来分析您的数据。

    dataset2 <- data.frame(
        sex = c(0, 0, 1, 1), 
        natheal = c("Not Enough", "Not Enough", "Too Much", "Not Enough"))
    inference(x = sex, y = natheal, 
        data = dataset2, 
        statistic = "proportion", 
        type = "ht", 
        method = "theoretical", 
        alternative = "greater", 
        success = "Too Much")
    

    【讨论】:

      猜你喜欢
      • 2013-09-30
      • 2018-09-10
      • 2012-03-04
      • 1970-01-01
      • 1970-01-01
      • 2020-06-12
      • 2018-09-02
      • 1970-01-01
      相关资源
      最近更新 更多