Learn R Programming

irregulAR1 (version 1.0.0)

ar1_sim_conditional: Simulate from a stationary Gaussian AR(1) process.

Description

Simulate from a stationary Gaussian AR(1) process at n consecutive time points.

Usage

ar1_sim_conditional(pred_times, obs_times, x_obs, rho, sigma, mu_pred = 0,
  mu_obs = 0)

Arguments

pred_times

A vector of time points to simulate at.

obs_times

A vector of time points at which observations have been made.

x_obs

The observed values of the process.

rho

A real number strictly less than 1 in absolute value.

sigma

A positive real number.

mu_pred

A vector or scalar with expected values.

mu_obs

A vector or scalar with expected values.

Value

A vector of length length(pred_times) with the process values.

Examples

Run this code
# NOT RUN {
t_pred <- c(1, 3, 6:8, 10)
t_obs <- c(2, 5, 11:12)
x_obs <- rnorm(4)
rho <- 0.5
sigma <- 1
# Means equal 0
ar1_sim_conditional(t_pred, t_obs, x_obs, rho, sigma)
# Time-varying means
mu_pred <- t_pred + rnorm(length(t_pred))
mu_obs <- t_obs + rnorm(length(t_obs))
ar1_sim_conditional(t_pred, t_obs, x_obs + mu_obs, rho, sigma,
                    mu_pred, mu_obs)
# }

Run the code above in your browser using DataLab