Dear All, I need help implementing a logistic model for dynamic network formation. This is how I am passing the data from R.
#### DATA
dat.stan <-list(
## Indixes
N=m, # Index of individuals.
G=G, # Index of networks.
P=P, # Index of time periods.
W=W, # Array of binary elements (adjacency matrices NxN) for each network (G) and time period (P) W[N,N,G,P]
C=C, # Array of binary elements (adjacency matrices NxN) for each network (G) and time period (P) that describe simmilarity between two individuals If c(i=j)=1, or else c(i diff j)=0 C[N,N,G,P]
CC=CC # Array of characteristics of each individual in each network in each time period CC[N,G,P]
)
#### STAN
rstan_options(auto_write = T)
options(mc.cores = 3L)
# model options
file <- "network_formation.stan"
inter <- 100L
chains <- 3L
model_name <- "network_formation.stan"
init <- 0
fit <-
stan(
file = file,
data = dat.stan,
iter = inter,
chains = chains,
model_name = model_name,
cores = 3L,
init = init
)
data {
//// Indixes ////
int<lower=0> N; // Index of units.
int<lower=0> G; // Index of networks.
int<lower=0> P; // Index of time periods.
//// Data ////
int<lower=0> W[N, N, G, P]; // array of G adjacency matrices dimension NxN for each P period
real<lower=1> C=[N,N,G,P]; // space for dyad specific variable in network formation
real CC=[N,G,P]; // space for individual specific variable in network formation
}
parameters {
real gamma1;
real gamma2;
real gamma3;
real gamma4;
}
model {
for(t in 1:P){
for(g in 1:G){
for(i in 1:N){
for(j in 1:N){
W[i, j, g, t] ~ bernoulli_logit(gamma1 + gamma2 * C[i, j, g, t] + gamma[3] * CC[i, g, t] + gamma[4] * CC[j, g, t]);
}}}}
}
I am getting the following error
Variable definition not possible in this block.
Variable definition base type mismatch, variable declared as base type real variable definition has base type row_vectorVariable definition dimensions mismatch, definition specifies 0, declaration specifies 1 error in ‘model4188be481_network_formation_stan’ at line 11, column 27