我收到此错误:
> dMMSE(c(2,1))
Show Traceback
Rerun with Debug
Error in abs(t) <= k : 'k' is missing
这是我的代码:
rho.prime<-function(t,k) ifelse (abs(t)<=k,2*t,(2*k*sign(t)))
dMMSE <- function(b, y=farmland$farm, x=farmland$land){
n = length(y)
a=0
d=0
for (i in 1:n) {
a = a + rho.prime(y[i]-b[1]-b[2]*x[i])
d = d + x[i]*rho.prime(y[i]-b[1]-b[2]*x[i])
}
a <- (-a/n)
d <- (-d/n)
return(c(a,d))
}
知道我错过了什么或做错了吗?