Rstan::read_stan_csv chokes on NaN


#1

For some reason rstan will not let me load output files with NaN values (which happen because the model
program covers a variety of model types and outputs some irrelevant values). Is there a flag to create the
object anyway?

> tp <- rstan::read_stan_csv(csvfiles=dir(pattern='output-chain-.\\.csv'))
Error in validObject(.Object) : 
  invalid class “stanfit” object: The following variables have undefined values:  predicted_district_delta.1,The following variables have undefined values:  predicted_district_delta.2,The following variables have undefined values:  predicted_district_delta.3,The following variables have undefined values:  predicted_district_delta.4,The following variables have undefined values:  predicted_district_delta.5,The following variables have undefined values:  predicted_district_delta.6,The following variables have undefined values:  predicted_district_delta.7,The following variables have undefined values:  predicted_district_delta.8,The following variables have undefined values:  predicted_district_delta.9,The following variables have undefined values:  predicted_district_delta.10,The following variables have undefined values:  predicted_district_delta.11,The following variables have undefined values:  predicted_district_delta.12,The following variables have undefined values:  pre
In addition: Warning message:
closing unused connection 3 (output-chain-1.csv)

#2

No. IIRC, having NaN values in the stanfit object causes problems. If something in generated quantities is irrelevant according to some static condition, then you should be able to make it be of length zero.


#3

sed is my new best friend, again.