I am reading this paper, which have discussed about how to use survey weights in Bayesian modeling using pseudo‐maximum likelihood method. I just ran the following stan model they have provided in the paper.
real wt_bin_lpmf(int[] y, vector mu, vector weights, int n){
real check_term;
check_term = 0.0;
for( i in 1:n )
{
check_term = check_term +
weights[i] * bernoulli_logit_lpmf(y[i] | mu[i]);
}
return check_term;
}}
data{
int<lower=1> n; // number of observations
int<lower=1> k; // number of linear predictors
int<lower=0, upper = 1> y[n]; // Response variable
vector<lower=0>[n] weights; // observation-indexed weights
matrix[n, k] X; // coefficient matrix
}
parameters{
vector[k] beta; /* regression coefficients from linear predictor */
}
transformed parameters{
vector[n] mu;
mu = X * beta; /* linear predictor */
} /* end transformed parameters block */
model{
/*improper prior on beta in (-inf,inf)*/
/* directly update the log-probability for sampling */
target += wt_bin_lpmf(y | mu, weights, n);
}
In this code, they have created a R function to calculate the pseudo‐maximum likelihood. When I am trying to run this stan file, I am getting this error.
PARSER FAILED TO PARSE INPUT COMPLETELY
STOPPED AT LINE 1:
It has stopped from the first line. What may be the reason for this?
Thank you