ismael ismael
2020-Feb-03 10:09 UTC
[Rd] Stroring and extracting AICs from an ARIMA model using a nested loop
It works!!! Thank you so much for your help! Sent from my iPhone> On Feb 3, 2020, at 3:47 AM, Rui Barradas <ruipbarradas at sapo.pt> wrote: > > ?Hello, > > You can solve the problem in two different ways. > > 1. Redefine storage1 as a matrix and extract the aic *in* the loop. > > storage1 <- matrix(0, 4, 4) > for(p in 0:3){ > for(q in 0:3){ > storage1[p + 1, q + 1] <- arima(etc)$aic > } > } > > > 2. define storage1 as a list. > > storage1 <- vector("list", 16) > i <- 0L > for(p in 0:3){ > for(q in 0:3){ > i <- i + 1L > storage1[[i]] <- arima(etc) > } > } > > lapply(storage1, '[[', "aic") # get the aic's. > > Maybe sapply is better it will return a vector. > > > Hope this helps, > > Rui Barradas > > > > > ?s 06:23 de 03/02/20, ismael ismael via R-devel escreveu: >> Hello >> I am trying to extract AICs from an ARIMA estimation with different >> combinations of p & q ( p =0,1,2,3 >> and q=0,1.2,3). I have tried using the following code unsucessfully. Can >> anyone help? >> code: >> storage1 <- numeric(16) >> for (p in 0:3){ >> for (q in 0:3){ >> storage1[p] <- arima(x,order=c(p,0,q), method="ML")} >> } >> storage1$aic >> [[alternative HTML version deleted]] >> ______________________________________________ >> R-devel at r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel
Martin Maechler
2020-Feb-03 11:04 UTC
[Rd] Stroring and extracting AICs from an ARIMA model using a nested loop
>>>>> ismael ismael via R-devel >>>>> on Mon, 3 Feb 2020 04:09:24 -0600 writes:> It works!!! > Thank you so much for your help! and it was an "R help" question which Rui so generously answered. But this is the R-devel mailing list. Please do *NOT* misuse it for R-help questions in the future: These should go to the R-help mailing list instead! Best, Martin Maechler >> On Feb 3, 2020, at 3:47 AM, Rui Barradas <ruipbarradas at sapo.pt> wrote: >> >> ?Hello, >> >> You can solve the problem in two different ways. >> >> 1. Redefine storage1 as a matrix and extract the aic *in* the loop. >> >> storage1 <- matrix(0, 4, 4) >> for(p in 0:3){ >> for(q in 0:3){ >> storage1[p + 1, q + 1] <- arima(etc)$aic >> } >> } >> >> >> 2. define storage1 as a list. >> >> storage1 <- vector("list", 16) >> i <- 0L >> for(p in 0:3){ >> for(q in 0:3){ >> i <- i + 1L >> storage1[[i]] <- arima(etc) >> } >> } >> >> lapply(storage1, '[[', "aic") # get the aic's. >> >> Maybe sapply is better it will return a vector. >> >> >> Hope this helps, >> >> Rui Barradas >> >> >> >> >> ?s 06:23 de 03/02/20, ismael ismael via R-devel escreveu: >>> Hello >>> I am trying to extract AICs from an ARIMA estimation with different >>> combinations of p & q ( p =0,1,2,3 >>> and q=0,1.2,3). I have tried using the following code unsucessfully. Can >>> anyone help? >>> code: >>> storage1 <- numeric(16) >>> for (p in 0:3){ >>> for (q in 0:3){ >>> storage1[p] <- arima(x,order=c(p,0,q), method="ML")} >>> } >>> storage1$aic >>> [[alternative HTML version deleted]] >>> ______________________________________________ >>> R-devel at r-project.org mailing list >>> https://stat.ethz.ch/mailman/listinfo/r-devel > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel
Rui Barradas
2020-Feb-03 17:32 UTC
[Rd] Stroring and extracting AICs from an ARIMA model using a nested loop
Hello, Inline. ?s 11:04 de 03/02/20, Martin Maechler escreveu:>>>>>> ismael ismael via R-devel >>>>>> on Mon, 3 Feb 2020 04:09:24 -0600 writes: > > > It works!!! > > Thank you so much for your help! > > and it was an "R help" question which Rui so generously answered. > > But this is the R-devel mailing list. > Please do *NOT* misuse it for R-help questions in the future: > > These should go to the R-help mailing list instead!Yes, and I had noticed it but then, after writing down the answer, forgot to mention it. Thanks for the warning. Rui Barradas> > Best, > Martin Maechler > > > >> On Feb 3, 2020, at 3:47 AM, Rui Barradas <ruipbarradas at sapo.pt> wrote: > >> > >> ?Hello, > >> > >> You can solve the problem in two different ways. > >> > >> 1. Redefine storage1 as a matrix and extract the aic *in* the loop. > >> > >> storage1 <- matrix(0, 4, 4) > >> for(p in 0:3){ > >> for(q in 0:3){ > >> storage1[p + 1, q + 1] <- arima(etc)$aic > >> } > >> } > >> > >> > >> 2. define storage1 as a list. > >> > >> storage1 <- vector("list", 16) > >> i <- 0L > >> for(p in 0:3){ > >> for(q in 0:3){ > >> i <- i + 1L > >> storage1[[i]] <- arima(etc) > >> } > >> } > >> > >> lapply(storage1, '[[', "aic") # get the aic's. > >> > >> Maybe sapply is better it will return a vector. > >> > >> > >> Hope this helps, > >> > >> Rui Barradas > >> > >> > >> > >> > >> ?s 06:23 de 03/02/20, ismael ismael via R-devel escreveu: > >>> Hello > >>> I am trying to extract AICs from an ARIMA estimation with different > >>> combinations of p & q ( p =0,1,2,3 > >>> and q=0,1.2,3). I have tried using the following code unsucessfully. Can > >>> anyone help? > >>> code: > >>> storage1 <- numeric(16) > >>> for (p in 0:3){ > >>> for (q in 0:3){ > >>> storage1[p] <- arima(x,order=c(p,0,q), method="ML")} > >>> } > >>> storage1$aic > >>> [[alternative HTML version deleted]] > >>> ______________________________________________ > >>> R-devel at r-project.org mailing list > >>> https://stat.ethz.ch/mailman/listinfo/r-devel > > > ______________________________________________ > > R-devel at r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-devel >
Seemingly Similar Threads
- Stroring and extracting AICs from an ARIMA model using a nested loop
- Stroring and extracting AICs from an ARIMA model using a nested loop
- Stroring and extracting AICs from an ARIMA model using a nested loop
- Stroring and extracting AICs from an ARIMA model using a nested loop
- AIC and BIC from arima()