-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting priors for K #373
Comments
See this issue + answer for a way to fix K to a single number. Basically, you should pick a distribution for K600_daily_meanlog that is very narrow (tiny meanlog_sdlog) and centered (meanlog_meanlog) on 66/d. Definitions of K600_daily_meanlog_meanlog and K600_daily_meanlog_sdlog are available at A useful discussion of the relationships among various forms of k, k2, K, K600, etc. can be found in Raymond et al. 2012 (https://doi.org/10.1215/21573689-1597669). |
Thank you, Allison! That cleared things up for me. What if I don't want to set K to a single number, but still used previously measured values to estimate K? Is that possible or is that exactly what I've done? |
Hi Sam, it's a bit tricker to set K to multiple numbers, but it can be done. If you have distinct Q on each day or are willing to spoof your Q inputs, you can set up a very strong prior with a multi-node K~Q relationship relating your measured K values to the daily mean Q values on those days. This would mean using a Kb model, i.e., |
Thank you, Alison. You've been very helpful. |
I think I closed this issue prematurely. I am ignorant of what a multi-node relationship is. There doesn't appear to be any type of relationship between my K and Q values, however. Without a strong relationship between the two, is it possible to develop this multi-node relationship? Are there any example codes of setting up the K ~ Q relationship? |
By multi-node relationship I meant a piecewise linear relationship between K and a variable named Q or discharge, which is what's provided by a Rather than passing in actual discharge values, you can pass in arbitrary values. For example, you can set Q to 1 for day 1, 2 for day 2, etc. in your You can specify as many values of You can set a tight prior on the value of Set a very small value for You might need to relax Use See I've never done this before (my focus has always been on learning rather than fixing K) and don't have time to work up example code, but if you can get the above instructions to work (I really think they will), please do share your code here so that others can benefit. |
I've attached my code, lnK and daily_Q files, out model outputs. First, thank you for you help. I was able to get the model to run, but the estimated DO is quite wonky and I'm getting negative GPP estimates. I've got low-GPP sites, and the model gives negative GPP for nearly all of my streams. I was told by AJ Reisinger that negative GPP on all dates probably indicates ER estimates are not reliable and that there's just not enough GPP to model metabolism. We have measured K values from previous work, so I fixed K600 to the mean of measured K600 (thank you for your help!) and was able to get positive GPP and ER rates that are within the range previously measured. If I've correctly followed your instructions and am still getting negative GPP and basically unmodellable days, should I just stick with my fixed k models, which is giving me reasonable estimates?
|
Thanks for sharing this code, Sam. I'm only seeing 9 values in sb4_lnK.csv, 8 of which get read by read.csv as non-header rows, but K600_lnQ_nodes_centers has length 10...is it possible that file is out of date relative to your code, or vice versa? The K600.daily predictions don't look like a great match to exp(lnK), though maybe it's because I'm not looking at the right lnK values...is that what you found, too? That said, the match seems close enough that I'm surprised that you're getting negative GPP with this model but positive GPP (significantly above 0?) with a Bayesian model. Hmm. If by "my fixed K models" you mean 2-parameter MLE models, I think it's plausible that those would work better for you. A major advantage of the Bayesian models is usually their ability to help you estimate K, so if you already have those numbers, the advantages relative to MLE models drop off substantially. (I do still expect some advantage because the Bayesian models can be state-space, including both process error and observation error, but K may well be the bigger issue for your data.) I would just caution against basing that decision entirely on whether your GPP values are coming out as you hope or not...that doesn't come across as especially sound science, and as AJ said, you need some signal (GPP relative to K) to pull truth out of a timeseries. If you have very high confidence in your outside estimates of K600, that's a better reason to use a fixed-K model than that the GPP is coming out positive. |
Also, are you sure K is as high as you say, and in the right units? Those DO predictions are abysmal, and I'm surprised the model couldn't at least find a better fit to the data even with high uncertainty in estimated GPP and ER values... Also, you may need to run these Bayesian models for a longer warmup period; it looks from your traceplots like they don't all converge until later in the saved-steps period. |
How you would you recommend going forward with such low-productivity streams? With GPP so close to zero (both positive and negative), can I say anything about metabolism in these systems with any confidence? |
I have previously measured reaeration rates that I would like to use as priors, but my problem is I don't know how to set that in the code. I have a k rate of 66/day. In issue #367, Bob Hall said to use the following specs:
K600_daily_meanlog_meanlog = 0
K600_daily_meanlog_sdlog =1
I don't have a background in Bayesian models, so I don't quite understand what these specs mean. In issue #367 , I believe the person had very low k600, so I interpret the specs given by Bob would limit the modeled k600 between 0 and 1. Is that what's going on?
Furthermore, what is the best way to convert k to k600? I assume that my measured reaeration rate isn't the standardized gas exchange rate and must be converted somehow.
tldr:
I have measured reaeration rates that I would like to use as priors for K600 but don't know how to specify that properly in the code.
Thanks!
The text was updated successfully, but these errors were encountered: