Conte-Ecology / conteStreamTemperature

Package for cleaning and analyzing stream daily stream temperature
MIT License
1 stars 1 forks source link

Error in Predict Function #20

Closed djhocking closed 9 years ago

djhocking commented 9 years ago

The new predictTemp function seems to work okay for data from the fitted model but is giving a RMSE of 2.1 for the validation data. This is definitely not correct. I haven't done a validation in a while because the old predict function was so slow but it should be below 1 (it used to be with the old function).

djhocking commented 9 years ago

Relatively easy fix, thankfully. I was replacing NA created via a left_join with 0 for the conditional random effects for sites, HUCs, and years without observed temperature data (i.e. no corresponding specific random effect). This would work if the random effects were all parameterized with a mean of 0 but in this case to get the multivariate normal working for the correlation among coviariates I used random effects not centered on 0 for HUC and year. I changed

df[ , names(B[-1])][is.na(df[ , names(B[-1])])] <- 0 # replace NA with mean

to

df[ , names(B[-1])][is.na(df[ , names(B[-1])])] <- colMeans(B[-1]) # replace NA with mean

and everything works perfectly. The validation data (20% of random sites held out) has a RMSE of 0.69 compared to the RMSE of 0.60 for the fitted (calibration) data, which is very good. Good thing I had just learned about rowSums and related functions. That made this much easier.