The order of the data cause different fitting result

I changed the order of the data, sorted it by ID from smallest to largest, input it into the model after the same preprocessing, and got a completely different fitting result from before sorting. Why?

fit_m01_1 <- stan(file=paste0(getwd(),'/stan_model/m01_RW.stan'), data=data_list,
                             pars    = pars_m01_1,
                             chains  = 3,
                             iter    = 4000,
                             warmup  = 2000,
                             thin    = 1,
                             control = list(adapt_delta   = 0.95,
                                            stepsize      = 1,
                                            max_treedepth = 10))


Can you share the code for how you processed and sorted the data? It’s almost certainly occurring due to an error here.

Thank you very much.
The original data diagram is as shown in the figure. I sorted the data in Excel based on the subid in ascending order (starting from 1), and then performed the same processing in R. The code used in R is not convenient to show, but after sorting the original data 1, the fitting results are the same as data 2. However, the unsorted original data 1 does not fit the results.

I’m sorry, but I’d have to see the R code of reading in the data and sorting it before I can help diagnose the issue.

it‘s the code


Here is the code, can you provide some help?