Error en min(y):'type'(list)无效参数

时间:2014-04-07 23:00:15

标签: r

我编写了这段代码来训练不同“nhs”值的模型。需要使用RHmm包

nhs <- c(2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)
s<-c(-0.0838896339,  0.0735056762,  0.0794009862, -0.0004037037,  0.0429916064,   
0.0144869164, -0.0587177735, -0.0274224634, -0.0040271534, -0.0595318433,-0.0006365332,   
0.0357587768,  0.0326540869, -0.0875506031, -0.0257552930,  0.0650400171, -0.0647646729,  
-0.0236693628, 0.0182259473,  0.0521212573)

S<-runif(length (s))<= .6
while(S[length(S)] [!FALSE]) {S<-runif(nrow (s))<= .6}
train<-print(S)

for(i in 1:length(nhs)){
pred <- vector("list", length(s))
    for(fold in 1:s){
    fit <- HMMFit(s[which(train==TRUE)], dis="NORMAL",nStates= nhs[i],asymptCov=FALSE)
    pred[[fold]] <- predict(fit, s[which(train==FALSE)])
}
error[i] <- perf(pred)
}


Error en min(y) : 'type' (list) de argumento no válido
Además: Mensajes de aviso perdidos
1: In 1:s :
expresión numérica tiene 20 elementos: solo el primero es utilizado

[edit - error message in English]
Error in UseMethod("predict") : 
  no applicable method for 'predict' applied to an object of class "HMMFitClass"
In addition: Warning message:
In 1:s : numerical expression has 20 elements: only the first used

不确定错误消息的含义或其语法是否正确。我相信trainig模型不采用我传递的格式。任何帮助都会受到欢迎。

0 个答案:

没有答案