Ошибка WinBugs: элементы вектора пропорциональности многочлена [1,1] должны суммироваться в единицу

Я пытаюсь воссоздать модель, описанную в этой статье, в WinBugs14, и у меня возникли некоторые проблемы с пониманием ошибок, поскольку я использую ее впервые.

Это версия кода с помеченными изменениями, которые я сделал. Мне удалось скомпилировать его, но когда я пытаюсь загрузить начальные значения, это дает мне такую ​​ошибку: элементы вектора пропорции многочлена [1,1] должны суммироваться в единицу.

Я смущен тем, что он имеет в виду, поскольку мне кажется, что все строки p[] складываются в 1. Я был бы очень признателен за любую помощь, спасибо!!

model {  # Define the priors for the logistic regression parameters 
    alpha1 ~ dnorm(0,0.01)
    alphaa ~ dnorm(0,0.01)  
     alphar ~ dnorm(0,0.01)
     alphal ~ dnorm(0,0.01) 
     beta1 ~ dnorm(0,0.01)
     betaa ~ dnorm(0,0.01)
     betar ~ dnorm(0,0.01)
     betal ~ dnorm(0,0.01)

# Define the observation error prior
  sigy <- 1/tauy
  tauy ~ dgamma(0.001,0.001)

# Define the logistic regression equations  
 for(t in 1:(T)) { 
     logit(phia[t]) <- alphaa + betaa*f[t] 
    log(rho[t]) <- alphar + betar*t     # We assume here that t=1  
     logit(phi1[t]) <- alpha1 + beta1*f[t]   # corresponds to the year 1963 
    logit(lambda[t]) <- alphal + betal*(t) 
 }

# Define r[t]  
 #for (t in 3:(T–1)){  r[t-2] <- (Na[t+1]+N1[t+1])/(Na[t]+N1[t])  }

# Define the initial population priors  
 for(t in 1:2){
     N1[t] ~ dnorm(200,0.000001) 
      Na[t] ~ dnorm(1000,0.000001)  }

# Define the system process for the census/index data using the Normal approximation
   for(t in 3:T){ 
    mean1[t] <- rho[t-1]*phi1[t-1]*Na[t-1]  
     meana[t] <- phia[t-1]*(N1[t-1]+Na[t-1])

    tau1[t] <- 1/(Na[t-1]*rho[t-1]*phi1[t-1])  
     taua[t] <- 1/((N1[t-1]+Na[t-1])*phia[t-1]*(1-phia[t-1]))

    N1[t] ~ dnorm(mean1[t],tau1[t])  
       Na[t] ~ dnorm(meana[t],taua[t])
  }

# Define the system process for the census/index data using the Poisson/Binomial model 
#
 #  NB. Need to change initial population priors as well to ensure N1 and Na take integer values

#  for(t in 3:T){
#   bin1[t] <- N1[t-1]+Na[t-1] 
#    bin2[t] <- phia[t-1]
#
#   po[t] <- Na[t-1]*rho[t-1]*phi1[t-1] 
#
#   N1[t] ~ dpois(po[t])
#   Na[t] ~ dbin(bin2[t],bin1[t]) 
#  }

# Define the observation process for the census/index data
   for(t in 3:T){   
y[t] ~ dnorm(Na[t],tauy)  }

# Define the recovery likelihood   
for(t in 1 : T1){   m[t, 1 : (T1 + 1)] ~ dmulti(p[t, ], rel[t])  }#change 1

# Calculate the no. of birds released each year  
for(t in 1 : T1){   rel[t] <- sum(m[t, ])  }

# Calculate the cell probabilities for the recovery table 
for(t1 in 1 : (T1-1)){
    # Calculate the diagonal 
    p[t1, t1] <- lambda[t1] * (1-phi1[t1])
    # Calculate value one above the diagonal 
    p[t1, t1+1] <- lambda[t1+1] * phi1[t1]*(1-phia[t1+1])
    # Calculate remaining terms above diagonal 
    for(t2 in (t1+2) : T2 ){     
        for(t in (t1+1):(t2-1)){    lphi[t1, t2, t] <- log(phia[t]) }
        # Probabilities in table  
        p[t1,t2]<-lambda[t2]*phi1[t1]*(1-phia[t2])*exp(sum(lphi[t1,t2,(t1+1): 
        (t2-1)]))   }  
    for(t2 in 1 : (t1 -1)){
        # Zero probabilities in lower triangle of table   
        p[t1, t2] <- 0       }
    # Probability of an animal never being seen again 
    p[t1, T2 + 1] <-1 -sum(p[t1, 1 : T2])  }
# Final row 
p[T1,T1] <- lambda[T1]*(1-phi1[T1])  
for(t in 1:(T1-1)){   p[T1,t] <- 0  } 
p[T1,T1+1] <- lambda[T1+1] * phi1[T1]*(1-phia[T1+1]) #change 2
p[T1,T2+1]<-1-(p[T1,T1]+p[T1,T2])      #change 3
}


#DATA


list(T = 36,  y=c(0,0,1092.23,1100.01,1234.32,1460.85,1570.38,1819.79,1391.27,1507.60,1541.44,1631.21,1628.60,1609.33,1801.68,1809.08,1754.74,1779.48,1699.13,1681.39,1610.46,1918.45,1717.07,1415.69,1229.02,1082.02,1096.61,1045.84,1137.03,981.1,647.67,992.65,968.62,926.83,952.96,865.64), 
f=c(0.1922,0.3082,0.3082,-0.9676,0.5401,0.3082,1.1995,0.1921,-0.8526,-1.0835,-0.6196,-1.1995,-0.5037,-0.1557,0.0762,2.628,-0.3877,-0.968,1.9318,-0.6196,-0.3877,1.700,2.2797,0.6561,-0.8516,-1.0835,-1.0835,0.1922,0.1922,-0.1557,-0.5037,-0.8516,0.8880,-0.0398,-1.1995,0),T1=35, T2=36, m=structure(.Data=c(13.,4.,1.,2.,1.,0.,0.,1.,0.,0.,0.,1.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,1124.,0.,16.,4.,3.,0.,1.,1.,0.,0.,0.,0.,0.,1.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,1259.,0.,0.,11.,1.,1.,1.,0.,2.,1.,1.,1.,1.,2.,0.,0.,1.,0.,0.,1.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,1082.,0.,0.,0.,10.,4.,2.,1.,1.,1.,0.,0.,0.,0.,0.,0.,0.,1.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,1595.,0.,0.,0.,0.,11.,1.,5.,0.,0.,0.,1.,1.,1.,1.,1.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,1596.,0.,0.,0.,0.,0.,9.,5.,4.,0.,2.,2.,2.,1.,2.,0.,1.,0.,0.,1.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,2091.,0.,0.,0.,0.,0.,0.,11.,9.,4.,3.,1.,1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0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,5.,4334),. Dim = c(35,36)) )

#STARTING VALUES


list(tauy = 1, Na = c(1000.,1000,1092.23,1100.01,1234.32,1460.85,1570.38,1819.79,  1391.27,1507.60,1541.44,1631.21, 1628.60,1609.33,1801.68,1809.08,1754.74,  1779.48,1699.13,1681.39,1610.46,1918.45,1717.07,1415.69, 1229.02,1082.02,  1096.61,1045.84,1137.03,981.1,647.67,992.65,968.62,926.83,952.96,865.64),  N1 = c(400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,  400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400), alpha1 = 1, alphaa = 2, alphar = -2, alphal = -4, beta1 =-2, betaa = 0.1, betar =-0.7, betal = -0.3 )

0 ответов

Другие вопросы по тегам