simulated_function {GPEMR} | R Documentation |
This function simulates data for independent trajectories based on specified growth models and estimates the model parameters. The simulation can be performed for several models, including Logistic, Exponential, Theta-logistic, Von Bertalanffy, and Gompertz. It also allows for calculation of global and local parameter estimates using the negative log-likelihood function.
simulated_function(
time_points = 1:10,
n = 10,
window_size = 3,
model,
parameter,
sigma2 = 2,
rho = 0.5,
x_0 = 10,
cov = FALSE,
Plot_est = FALSE
)
time_points |
A numeric vector representing the time points for which the data should be simulated. |
n |
An integer specifying the number of independent trajectories to simulate. |
window_size |
An integer specifying the window size for local estimation. |
model |
A character string specifying the growth model to use. Options include 'Logistic', 'Exponential', 'Theta-logistic', 'Von-bertalanffy', and 'Gompertz'. |
parameter |
A list of model-specific parameters required for the mean function. |
sigma2 |
A numeric value for the variance of the process. |
rho |
A numeric value for the correlation coefficient. |
x_0 |
A numeric value for the initial state. |
cov |
A logical value indicating whether to print the covariance matrix. Default is FALSE. |
Plot_est |
A logical value indicating whether to plot the parameter estimates. Default is FALSE. |
The function first checks if the parameters are provided as a list. It then calculates the mean function based on the specified model and forms the covariance matrix. Multivariate normal data for the specified number of trajectories is generated using the mvtnorm::rmvnorm function. The negative log-likelihood function is defined and minimized using the optim function to estimate global parameters. Local parameter estimation is performed using a sliding window approach.
The available models are:
Logistic: Requires parameters r (growth rate) and K (carrying capacity).
Exponential: Requires parameter r (growth rate).
Theta-logistic: Requires parameters r (growth rate), theta, and K (carrying capacity).
Von-bertalanffy: Requires parameters r (growth rate) and K (asymptotic size).
Gompertz: Requires parameters b and c.
A list containing the simulated data, global parameter estimates, global covariance matrix, local parameter estimates, and optionally local covariance matrices.
res <- simulated_function(
model = 'Logistic',
parameter = list(r = 0.2, K = 100),
cov = TRUE,
Plot_est = TRUE)