Hi, I am fitting an ordered probit model.
In case of 50 ordinal categories as DV, my model successfully recovers true parameters.
However, in 100 ordinal category case, the model causes an error, saying
Chain 1: Rejecting initial value:
Chain 1: Log probability evaluates to log(0), i.e. negative infinity.
Chain 1: Stan can’t start sampling from this initial value.
The model can’t recover the true parameters even when I use the true values as initial values.
init=0 does not work also.
(By polr function from MASS package, the true parameters are recovered in 100 ordinal category case.)
How can I treat this situation?
Thank you.
data {
int<lower=2> K;
int<lower=0> N;
int<lower=1> D;
int<lower=1,upper=K> y[N];
row_vector[D] x[N];
}
parameters {
vector[D] beta;
ordered[K-1] c;
}
model {
for (n in 1:N)
y[n] ~ ordered_probit(x[n] * beta, c);
}
My R code for data generation is here.
ntime=1000
nanswer=100 #### Number of ordinal categories
n=ntime*nanswer
b0=0
b1=0.5
b2=-3
X1=runif(n,0,1)
X2=runif(n,0,1)
X=cbind(X1,X2)
sd.error=1
tau=matrix(0,n,1)
prob=seq(0.01,0.99,by=0.01) ## prob of each 100 ordinal category
#prob=seq(0.01,0.98,by=0.02) ## prob of each 50 ordinal category
Y=rep(NA,n)
XB=rep(NA,n)
XB=b0+b1*X1+b2*X2
Y.star<-rnorm(n,XB,sd.error)
tau=qnorm(prob,mean=mean(XB),sd=sqrt(var(XB)+sd.error^2)) # threshold parameters
Y[Y.star<tau[1]]<-1
Y[Y.star>=tau[nanswer-1]]<-nanswer
for(i in 2:(nanswer-1) ){
Y[Y.star>=tau[i-1] & Y.star<tau[i]]<-i
}
#library(dplyr)
#Y%>%as_tibble()%>%count(value)%>%print(n=100)
data=list(y=as.vector(Y),x=X,K=nanswer,N=n,D=2)
summary(MASS::polr(as.factor(Y) ~ X1 + X2,method="probit")) ## Estimation of true parameters by polr function
To include mathematical notation in your post put LaTeX syntax between two $
symbols, e.g.,
p(\theta | y) \propto p(\theta) p(y | \theta).