attach(Geyser)
n=length(y)
n
Y=matrix(1,n,2)
X=matrix(1,n,2)
X[,2]=x
Y[,2]=y
X
b.int=(0:20)*10/20+30
b.slope=(0:20)*4/20+10
b.int
b.slope
ss=matrix(0,length(b.int),length(b.slope))
ss
for (i in 1:(length(b.int))){
for (j in 1:(length(b.slope))){
b=rbind(b.int[i],b.slope[j])
ss[i,j]=sum((Y-X %*% b)^2)
}
}
persp(b.int,b.slope,ss)
ss[i,j]=sum((Y-X %*% b)^2)#此段代码提示:非整合陈列错误,如何改写才能正确,谢谢