I am trying to run a simulation of a probability matrix with 5 states.
N<-10 #for 10 simulations
state<-simulat(P,N,1) #P is a matrix defined earlier in my code
for(i in 1:N)
{
if (state[i]=='0')
{
time[i]<-rexp(1,Mu)
}
if (state[i]=='1' || state[i]=='2' || state[i]=='3')
{
time[i]<-rexp(1,(Mu+Lamda))
}
if (state[i]=='4')
{
time[i]<-rexp(1,Lamda)
}
}
Error in time[i] <- rexp(1, Mu) :
object of type 'closure' is not subsettable
Is this an issue with formatting or am I defining my state[i] incorrectly? I have tried switching my [] to (), but then it gives me an error that says it could not find function 'state', even though I had just defined it above. Any help is appreciated.