mixedsde.sim(M, T, N = 100, model, random, fixed = 0, density.phi, param, sigma, t0 = 0, X0 = 0.01, invariant = 0, delta = T/N, op.plot = 0, add.plot = FALSE)If random = 2, $\alpha$ is a fixed effect: $dX_j(t)= (\alpha - \beta_j X_j(t))dt + \sigma dW_j(t) $
If random = c(1,2), $dX_j(t)= (\alpha_j- \beta_j X_j(t))dt + \sigma dW_j(t) $
Cox-Ingersoll-Ross model (CIR) If random = 1, $\beta$ is a fixed effect: $dX_j(t)= (\alpha_j- \beta X_j(t))dt + \sigma \sqrt{X_j(t)} dW_j(t) $
If random = 2, $\alpha$ is a fixed effect: $dX_j(t)= (\alpha - \beta_j X_j(t))dt + \sigma \sqrt{X_j(t)} dW_j(t) $
If random = c(1,2), $dX_j(t)= (\alpha_j- \beta_j X_j(t))dt + \sigma \sqrt{X_j(t)} dW_j(t) $
The initial value of each trajectory can be simulated from the invariant distribution of the process: Normal distribution with mean $\alpha/\beta$ and variance $\sigma^2/(2 \beta)$ for the OU, a gamma distribution $\Gamma(2\alpha/\sigma^2, \sigma^2/(2\beta))$ for the C-I-R model.
Density of the random effects Several densities are implemented for the random effects, depending on the number of random effects.
If two random effects, choice between
'normalnormal': Normal distributions for both $\alpha$ $\beta$ and param=c(mean_$\alpha$, sd_$\alpha$, mean_$\beta$, sd_$\beta$)
'gammagamma': Gamma distributions for both $\alpha$ $\beta$ and param=c(shape_$\alpha$, scale_$\alpha$, shape_$\beta$, scale_$\beta$)
'gammainvgamma': Gamma for $\alpha$, Inverse Gamma for $\beta$ and param=c(shape_$\alpha$, scale_$\alpha$, shape_$\beta$, scale_$\beta$)
'normalgamma': Normal for $\alpha$, Gamma for $\beta$ and param=c(mean_$\alpha$, sd_$\alpha$, shape_$\beta$, scale_$\beta$)
'normalinvgamma': Normal for $\alpha$, Inverse Gamma for $\beta$ and param=c(mean_$\alpha$, sd_$\alpha$, shape_$\beta$, scale_$\beta$)
'gammagamma2': Gamma $+2 * \sigma^2$ for $\alpha$, Gamma $+ 1$ for $\beta$ and param=c(shape_$\alpha$, scale_$\alpha$, shape_$\beta$, scale_$\beta$)
'gammainvgamma2': Gamma $+2 * \sigma^2$ for $\alpha$, Inverse Gamma for $\beta$ and param=c(shape_$\alpha$, scale_$\alpha$, shape_$\beta$, scale_$\beta$)
If only $\alpha$ is random, choice between
'normal': Normal distribution with param=c(mean, sd)
lognormal': logNormal distribution with param=c(mean, sd)
'mixture.normal': mixture of normal distributions $p N(\mu1,\sigma1^2) + (1-p)N(\mu2, \sigma2^2)$ with param=c(p, $\mu1, \sigma1, \mu2, \sigma2$)
'gamma': Gamma distribution with param=c(shape, scale)
'mixture.gamma': mixture of Gamma distribution $p \Gamma(shape1,scale1) + (1-p)\Gamma(shape2,scale2)$ with param=c(p, shape1, scale1, shape2, scale2)
'gamma2': Gamma distribution $+2 * \sigma^2$ with param=c(shape, scale)
'mixed.gamma2': mixture of Gamma distribution $p \Gamma(shape1,scale1) + (1-p) \Gamma(shape2,scale2)$ + $+2 * \sigma^2$ with param=c(p, shape1, scale1, shape2, scale2)
If only $\beta$ is random, choice between 'normal': Normal distribution with param=c(mean, sd)
'gamma': Gamma distribution with param=c(shape, scale)
'mixture.gamma': mixture of Gamma distribution $p \Gamma(shape1,scale1) + (1-p) \Gamma(shape2,scale2)$ with param=c(p, shape1, scale1, shape2, scale2)
#Simulation of 5 trajectories of the OU SDE with random =1, and a Gamma distribution.
simuOU <- mixedsde.sim(M=5, T=10,N=1000,model='OU', random=1,fixed=0.5,
density.phi='gamma', param=c(1.8, 0.8) , sigma=0.1,op.plot=1)
X <- simuOU$X ;
phi <- simuOU$phi
hist(phi)
Run the code above in your browser using DataLab