I have created 100 random time series with these code
set.seed(1023172)
t<- seq(from=1,to=100,by=1)+10+rnorm(100,sd=7)
lst1 <- lapply(asplit(as.matrix(t), 1), ts, start = 2000, end = 2009)
print(lst1)
Then I want to convert this lst1 from a list to a data frame.
The list looks partly like this:
[[1]]
Time Series:
Start = 2000
End = 2009
Frequency = 1
[1] 7.791329 7.791329 7.791329 7.791329 7.791329 7.791329 7.791329 7.791329
[9] 7.791329 7.791329
[[2]]
Time Series:
Start = 2000
End = 2009
Frequency = 1
[1] 6.355925 6.355925 6.355925 6.355925 6.355925 6.355925 6.355925 6.355925
[9] 6.355925 6.355925
[[3]]
Time Series:
Start = 2000
End = 2009
Frequency = 1
[1] 8.250623 8.250623 8.250623 8.250623 8.250623 8.250623 8.250623 8.250623
[9] 8.250623 8.250623
[[4]]
Time Series:
Start = 2000
End = 2009
Frequency = 1
[1] 15.20932 15.20932 15.20932 15.20932 15.20932 15.20932 15.20932 15.20932
[9] 15.20932 15.20932
[[5]]
Time Series:
Start = 2000
End = 2009
Frequency = 1
[1] 19.12282 19.12282 19.12282 19.12282 19.12282 19.12282 19.12282 19.12282
[9] 19.12282 19.12282
[[6]]
Time Series:
Start = 2000
End = 2009
Frequency = 1
[1] 14.01422 14.01422 14.01422 14.01422 14.01422 14.01422 14.01422 14.01422
[9] 14.01422 14.01422
[[7]]
Time Series:
Start = 2000
End = 2009
Frequency = 1
[1] 10.38471 10.38471 10.38471 10.38471 10.38471 10.38471 10.38471 10.38471
[9] 10.38471 10.38471
I have tried df <- data.frame(matrix(unlist(lst1), ncol = max(lengths(lst1)), byrow = TRUE)), but the data type is always list.
Can anybody help?
Edited on 17.08--
the ultimate goal is to be able to fit dcc.garch on this dataset
so it it better to look like:
| year | ts1 | ts2 | ts3 | ts4 |
|---|---|---|---|---|
| 2000 | 1 | 2 | 3 | 4 |