将置信区间绘制到 3d 绘图平面上的困难

Difficulties plotting confidence intervals onto 3d plot plane

我有预测值和置信区间,我想使用 trans3d 添加到我的 3D 图,但我在使用 seq 的行上收到错误我已经尝试过 length(z.bin),并阅读其他可能的解决方案,但它仍然无法正常工作。

Error in seq.default(lowerCI, upperCI, length.out = 25) : 
  'from' must be of length 1 

我希望你能帮助我修复我的代码。这里是预测值(z.bin),上CI(UCI)和下CI(LCI):

z.bin= c(0.0293498087331418, 0.090245714112389, 0.184180408140189, 0.288479689911685, 
0.380290727519617, 0.447221380019439, 0.486749948207999, 0.515460732539617, 
0.524544278048373, 0.517863012982977, 0.499015552138662, 0.471040830332284, 
0.436384769878271, 0.39696995466237, 0.354295721949241, 0.309542936297033, 
0.263681366413638, 0.217589473510825, 0.172201272125033, 0.128688774135519, 
0.0886552840745102, 0.0542241604227149, 0.0277504883386967, 0.0108213094005216, 
0.00277584412160996)

UCI=c(0.0366603230533126, 0.0902131425743432, 0.190710608825939, 
0.329281535177887, 0.37359325824382, 0.49083302601992, 0.502923852215148, 
0.532414036794941, 0.542594424500199, 0.544876477822669, 0.513975201348124, 
0.500360540087923, 0.460641689148807, 0.415363280410005, 0.358399020245284, 
0.321189810843667, 0.285678220416678, 0.234306786216362, 0.185151688725085, 
0.141800528101782, 0.0848830167493455, 0.0596895934068413, 0.034797331186028, 
0.0136423698337293, 0.00416130620917585)

LCI=c(0.0203880237502624, 0.0639803379126716, 0.15252099326726, 0.279883133515488, 
0.321969495145084, 0.433138773211774, 0.445700330934391, 0.474863237969827, 
0.485779389412345, 0.489219946727086, 0.461012139808171, 0.449297954511444, 
0.412682077834953, 0.370799794091489, 0.317884618001687, 0.283779930784182, 
0.251320227770169, 0.20400383106003, 0.158982316141284, 0.119627373509671, 
0.0683623411169277, 0.0464255905587446, 0.0252020843583765, 0.00810835262770212, 
0.0014811836711362)

代码(请不要 运行 points() 和 trans3d() 行,res2 不包括在内,但它可以向您展示我想用来创建 CI 条):

    y.bin <- rep(1,25)
    x.bin <- seq(-10,10,length.out = 25)    
 #   points(trans3d(x.bin, y.bin, z.bin, pmat = res2), col = 1, pch = 16)

        for (i in 1:length(z.bin)) {
          lowerCI <- LCI
          upperCI <- UCI
          CI.bar <- seq(lowerCI,upperCI,length.out=25)
         # lines (trans3d(x.bin[i], y.bin[i], z = CI.bar, pmat = res2), col = #1, lwd=2)
        }

看起来您只需要索引 LCI 和 UCI 值,否则您将向 seq 函数提供整个列表:

for (i in 1:length(z.bin)) {
  lowerCI <- LCI[i]
  upperCI <- UCI[i]
  CI.bar <- seq(lowerCI, upperCI, length.out = 25)
  # lines (trans3d(x.bin[i], y.bin[i], z = CI.bar, pmat = res2), col = #1, lwd=2)
}