<commit_before># Model
Streampulse metabolism modeling code

# Workflow
Fitting metabolism models with streampulse follows two steps:

1. Downloading data from the streampulse platform
2. Fitting the chosen model
  * `model_name = "streamMetabolizer"` runs [streamMetabolizer](https://github.com/USGS-R/streamMetabolizer)
    - `model_type="bayes"` fits a Bayesian model (recommended)
    - `model_type="mle"` fits a maximum likelihood model
  * `model_name = "BASE"` runs [BASE](https://github.com/dgiling/BASE)

The code for these functions is contained in three files: `sp_functions.R`, `gapfill_functions.R`, and `BASE_functions.R` (which are copied from the `dgiling` repo).

# Code
This example is also available as code in [`model_streampulse.R`](https://github.com/streampulse/model/blob/master/model_streampulse.R).

```r
# You need to have an internet connection for this code to function.
# REQUIRED packages
library(coda)
library(dplyr)
library(httr)
library(jsonlite)
library(R2jags)
library(streamMetabolizer)<commit_msg>update code for fitting models<commit_after># Model
Streampulse metabolism modeling code

# Workflow
Fitting metabolism models with streampulse follows two steps:

1. Downloading/formatting data from the streampulse platform
2. Fitting the chosen model
  * `model_name = "streamMetabolizer"` runs [streamMetabolizer](https://github.com/USGS-R/streamMetabolizer)
    - `model_type="bayes"` fits a Bayesian model (recommended)
    - `model_type="mle"` fits a maximum likelihood model
  * `model_name = "BASE"` runs [BASE](https://github.com/dgiling/BASE)

The code for these functions is contained in three files: `sp_functions.R`, `gapfill_functions.R`, and `BASE_functions.R` (which are copied from the `dgiling` repo).

# Code
This example is also available as code in [`model_streampulse.R`](https://github.com/streampulse/model/blob/master/model_streampulse.R).

```r
# You need to have an internet connection for this code to function.
# REQUIRED packages
library(coda)
library(dplyr)
library(httr)
library(jsonlite)
library(R2jags)
library(streamMetabolizer)
{'fraction_non_alphanumeric': 0.10438512869399429, 'fraction_numerical': 0.002859866539561487, 'mean_word_length': 5.60062893081761, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6552784', 'n_tokens_mistral': 666, 'n_tokens_neox': 638, 'n_words': 201}