-
-
Save quantra-go-algo/ce20d9e9a6d155c8b37baf3608803015 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set the simulation ARMA parameters | |
params = c(.1, .25, .5, .75, .9, .99) | |
# Set the seed | |
set.seed(2023) | |
# Use a loop to simulate the ARMA models | |
for (i in 1:6) { | |
# Simulate an AR(p) model based on each parameter | |
df[,paste0('X',i)] <-arima.sim(1000, model=list(ar=params[i])) | |
# Create the string version of the parameter | |
param_string = as.character(params[i]) | |
# Change the AR(p) model column name | |
colnames(df)[i] = paste0("ARMA_1_0_0",substr(param_string,3,nchar(param_string)),"_0") | |
# Simulate an MA(q) model based on each parameter | |
df[,paste0('X',(i+6))] <-arima.sim(1000, model=list(ma=-params[i])) | |
# Change the MA(q) model column name | |
colnames(df)[(i+6)] = paste0("ARMA_0_1_0_0",substr(param_string,3,nchar(param_string))) } | |
# Create an ARMA(1,1) model | |
df[,paste0('X',13)] <-arima.sim(1000, model=list(ar=0.3, ma=-0.3)) | |
# Change the ARMA(1,1) model column name | |
colnames(df)[13] = paste0("ARMA_1_0_03_03") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment