ssEst {BayesMassBal} | R Documentation |
Steady State Estimate
Description
Allows for the estimation of process steady state of a single stream for a process using flow rate data.
Usage
ssEst(y, BTE = c(100, 1000, 1), stationary = FALSE)
Arguments
y |
Vector of mass flow rate observations. Must be specified sequentially with |
BTE |
Numeric vector giving |
stationary |
Logical indicating if stationarity will be imposed when generating posterior draws. See Details. |
Details
The model of the following form is fit to the data:
y_t = \mu + \alpha y_{t-1} + \epsilon
Where \epsilon \sim \mathcal{N}(0,\sigma^2)
and t
indexes the time step.
A time series is stationary, and predictable, when |\alpha|< 1
. Stationarity can be enforced, using the argument setting stationary = TRUE
. This setting utilizes the priors p(\alpha) \sim \mathcal{N}
(0, 1000) truncated at (-1,1), and p(\mu) \sim \mathcal{N}
(0, var(y)*100
) for inference, producing a posterior distribution for \alpha
constrained to be within (-1,1).
When fitting a model where stationarity is not enforced, the Jeffreys prior of p(\mu,\alpha)\propto 1
is used.
The Jeffreys prior of p(\sigma^2)\propto 1/\sigma^2
is used for all inference of \sigma^2
A stationary time series will have an expected value of:
\frac{\mu}{1-\alpha}
Samples of this expectation are included in the output if stationary = TRUE
or if none of the samples of \alpha
lie outside of (-1,1).
The output list is a BMB
object, passing the output to plot.BayesMassBal
allows for observation of the results.
Value
Returns a list of outputs
samples |
List of vectors containing posterior draws of model parameters |
stationary |
Logical indicating the setting of the |
y |
Vector of observations initially passed to the |
type |
Character string giving details of the model fit. Primarily included for use with |
Examples
## Generating Data
y <- rep(NA, times = 21)
y[1] <- 0
mu <- 3
alpha <- 0.3
sig <- 2
for(i in 2:21){
y[i] <- mu + alpha*y[i-1] + rnorm(1)*sig
}
## Generating draws of model parameters
fit <- ssEst(y, BTE = c(100,500,1))