Error in mod$fit_ptr() : Exception: variable does not exist; processing stage=data initialization; variable name=

Can you post the R code that you’re running that’s giving the error?

Yes here it is with the error text.

> mm_saturator_ER<-
mm_name(‘bayes’, GPP_fun=‘satlight’, ER_fun=‘q10temp’,pool_K600=‘none’) %>%
specs(alpha_meanlog=.4,alpha_sdlog=.2,Pmax_mu=6,Pmax_sigma=.3, day_start = 4,day_end = 28,n_cores=4, n_chains=4, burnin_steps=500, saved_steps=500) %>%
metab(dat)
Error: data is missing these columns: temp.water
Timing stopped at: 0.36 0 0.36

Looking at the package documentation, it says:

A properly formatted input dataset for streamMetabolizer models has:

    exactly the right data columns and column names. Call metab_inputs() to see the requirements for a specific model type.
    data in the right units. See ?mm_data for definitions of each column.

Which means that required column names are hard-coded.

Looking at the documentation for the required column names, it’s required that the variable be called temp.water, not temp_water. This means that you need to revert your data preparation to be calling the variable temp.water and then modify your Stan code so that the variable name is temp.water not temp_water

Thanks @andrjohns. That was my suspect after giving up on changes. Thanks for pointing that out. Here is the error I got after reverting every thing back and re-running the code.

SYNTAX ERROR, MESSAGE(S) FROM PARSER:
Variable identifier may not contain a period (.)
    found period at position (indexed from 0)=4
    found identifier=temp.water
Variable identifier may not contain a period (.)
    found period at position (indexed from 0)=4
    found identifier=temp.water
 error in 'model4b1c4e6d2fdf_b_np_oipi_tr_psrqkm' at line 29, column 11
  -------------------------------------------------
    27:   vector[d] DO_obs[n];
    28:   vector[d] DO_sat[n];
    29:   vector[d] temp.water[n];
                  ^
    30:   vector[d] light[n];
  -------------------------------------------------

PARSER EXPECTED: <identifier>
Timing stopped at: 0.08 0 0.09
Warning message:
In metab_fun(specs = specs, data = data, data_daily = data_daily,  :
  Modeling failed
  Errors:
    failed to parse Stan model 'b_np_oipi_tr_psrqkm' due to the above error.

If it won’t let you call the variable a different name, then this is an issue you’ll need to raise with the package developers

Thanks @andrjohns I will write to them then. I appreciate your help.