0
中运行width.SJ()时出现错误今天,我使用下面的代码来检查非参数密度估计的数据正态性。然而,我得到错误说:在R
width.SJ(bc.mdat[, 2]) :
no solution in the specified range of bandwidths
所以,我不知道为什么会发生这个错误。因为我用另一个数据做得很好。感谢您的帮助
library(car)
library(MASS)
library(graphics)
Q=read.table(text='
12.5 13.7
14.5 16.5
8.0 17.4
9.0 11.0
19.5 23.6
8.0 13.2
9.0 32.1
7.0 12.3
7.0 11.8
9.0 24.4
6.5 18.2
10.5 22.0
10.0 32.5
4.5 18.7
7.0 15.8
8.5 15.6
6.5 12.0
8.0 12.8
3.5 26.1
8.0 14.5
17.5 42.3
10.5 17.5
12.0 21.8
6.0 10.4
13.0 25.6
')
bc=powerTransform(as.matrix(Q)~1)
summary(bc)
bc.mdat<-bcPower(Q,bc$lambda)
f2=kde2d(bc.mdat[,1],bc.mdat[,2],h=c(width.SJ(bc.mdat[,1]),width.SJ(bc.mdat[,2])))
persp(f2,phi=30,theta=20,d=5)