An error object of the closure type is not a subset of

I have a problem with program R. I programmed this code, and when I want to continue it, I get an error message:

Error in daten.asset [[s]]: an object of type "closure" is not a subset.

I am completely unfamiliar with programming and sometimes quite complicated. Can anybody help me?

Thanks for any attempt.

My code is:

rMZR <- arima.sim(model=list(ar=0.6), n = 1100) ; rM <-as.vector(rMZR,mode="numeric" ); tilde.rM <- rM - mean(rM) M <- matrix(c(tilde.rM, tilde.rM),2,1100) A=matrix(c(0.5,0,0,0.5),2,2) X <- c(0,rnorm(1400, 0, 0.5)) Y <- c(0,rnorm(1400, 0, 0.5)) Zeta=matrix(0,2,1401) Zeta[1,]=X Zeta[2,]=Y epsilon=matrix(0,2,1401) epsilon[,1]=0 for (i in 2:1401){ epsilon[,i]=A%*%epsilon[,i-1] + Zeta[,i] } epsilon=epsilon[,302:1401] alpha <- vector(mode="numeric", length= 1100) beta <- rep(1, 1100) daten.asset<-function(){ da<-vector(mode="list",length=s); for (s in 1:2500) { r.i1.ZR <- alpha + beta %*% r.iM[,1] + epsilon; r.i1 <-as.vector(r.i1.ZR,mode="numeric" ); r.i2.ZR<- alpha + beta %*% r.iM[,2] + epsilon; r.i2 <-as.vector(r.i2.ZR,mode="numeric" ); A[s] <- matrix(c(r.i1, r.i2),2,1100) print(i) }; #for return(da) } for(s in 1:2500){ mu.1 <- hubers(daten.asset[[s]][1,1:100], k=1.5, s=1)$mu mu.2 <- hubers(daten.asset[[s]][2,1:100], k=1.5, s=1)$mu epsilon.dach.1 <- daten.asset[[s]][1,1:100] - mu.1 epsilon.dach.2 <- daten.asset[[s]][2,1:100] - mu.2 epsilon.dach <- matrix(c(epsilon.dach.1,epsilon.dach.2),2,100)} huber.psi <- function(x, k=1.345) ifelse(abs(x) < k, 2*x, 2*k*sign(x)) psi.epsilon1 <- huber.psi(epsilon1) psi.epsilon2 <- huber.psi(epsilon2) psi.epsilon <- matrix(c(psi.epsilon1,psi.epsilon2),2,100) 
+6
source share
1 answer

Error:

 Error in daten.asset[[s]] : object of type 'closure' is not subsettable. 

means that you call the daten.asset function ( closure ) as a data file or matrix ( subset ). The change

 daten.asset[[s]] 

to

 daten.asset()[[s]] 

should solve the problem.

+14
source

Source: https://habr.com/ru/post/975218/


All Articles