[R] Replication of linear model/autoregressive model

R. Michael Weylandt michael.weylandt at gmail.com
Sat Jun 16 05:01:55 CEST 2012


On Fri, Jun 15, 2012 at 6:56 AM, Al Ehan <aehan3616 at gmail.com> wrote:
> Hi,
>
> I would like to make a replication of 10 of a linear, first order
> Autoregressive function, with respect to the replication of its innovation,
> e. for example:
>
> #where e is a random variables of innovation (from GEV distribution-that
> explains the rgev)
> #by using the arima.sim model from TSA package, I try to produce Y
> replicates, with respect to every replicates of e,
> #means for e[,1], I want to have say Y[,1].
>
> The code:
>
> e=replicate(10,rgev(20,xi=0.2,mu= 931.1512,sigma= 168.2702 ))
> Y=replicate(10,ts(arima.sim(list(ar=0.775),n=20,innov=e,start.innov=e)))
>
> what I get is the same random variables for every replicates of Y.

Well, what would you expect? You're passing the same values of e each
time. What you probably want to do is to put the rgev call as the
innov argument to arima.sim(). Take a look at the second example of
?arima.sim to see how its done (change the rt to rgev and you're good
to go.

Michael


>
> Can somebody help me in giving tips for the right way to simulate 'Y'
> replicates, with respect to the 'e' sets generated ?
>
> Thanks in advance,
> aen
>
> Below is the result for both e and Y
>
> e is:
>           [,1]      [,2]      [,3]      [,4]      [,5]      [,6]      [,7]
>     [,8]      [,9]     [,10]
>  [1,] 1004.6556 1052.4383 1182.9386  740.7879  917.9408 1068.8516  939.3510
>  767.9687 1404.9391  887.2097
>  [2,]  976.1445 2065.3058 1375.2125  771.4417  813.0629  752.6230  855.2689
>  783.9922 1040.5202 1021.9163
>  [3,]  806.4278 1093.6128 1105.2453  961.5645 2680.4879 1223.3578 1016.8091
> 1328.9994 1069.0436  770.2141
>  [4,]  941.7239  835.8723 1281.5915  758.4810 1157.0755  989.6987 1374.7398
>  819.5419 2145.2202  912.0083
>  [5,] 1278.2288 1230.8805  950.0978 1020.4950 1176.2052  917.6511  938.0180
> 1134.2910  948.9680 1239.7596
>  [6,] 1370.5071 1152.9871  918.1371 1206.5982 1031.8577 1055.5165 1058.2840
>  992.4400 1385.1229  860.9707
>  [7,]  792.2280 1088.3310  843.1889  850.0649 1090.4600 1063.3509  849.8213
>  857.7559  918.9895  924.3551
>  [8,] 1342.4464  986.0477 1150.8336  876.8476  736.7059  874.5117  791.1349
> 1221.8736 1274.5753 1251.5058
>  [9,]  855.5112  679.0765  896.8450 1035.9713  887.1466  966.9135 1097.9867
>  698.7444 1037.1916  925.6284
> [10,]  896.1308 1390.8897 1226.0070  940.0661 1122.1520 1282.2764 1100.4923
> 1028.7810  769.0136 1164.6884
> [11,] 1395.6821 1714.6703 1120.4880  957.8550  823.9834  890.8857  688.2862
> 1337.0698 1068.7425  979.0459
> [12,] 1000.8848  965.1944 1312.5296  780.4713  797.3911 1258.8812  768.1990
>  780.7888 1308.3333 1429.7170
> [13,]  923.6432 1736.6128 1744.1737  911.3581  986.5247  840.6579 1094.8875
> 1088.8576 1571.3999 1534.5975
> [14,] 1436.3669 1256.7590  835.3184 1233.7610  799.4020  906.7561  858.1808
>  774.7084  909.1261 1080.8908
> [15,] 1013.2007 1705.9792 1560.2684 1214.5330 1075.3175  946.8204 1002.4946
> 1096.0830 1254.5292 1186.1904
> [16,] 1234.8287 1127.0824  979.2170  867.8832 1326.6990  723.8658 1025.6396
>  707.3958 1033.7781 1182.6379
> [17,] 1289.7771 1083.7075  854.0004 1077.5405 1646.2762  743.7637 1132.9710
> 1004.6940  993.6281 1062.2983
> [18,]  985.4911 1023.1982 1115.5055 1274.4555  882.3684  949.3805 1092.2195
> 2973.9311  949.8960 1314.0438
> [19,]  965.2564  955.7152 1333.8170 1216.1322  758.6732 1224.0608  830.8886
> 1463.0854 1073.4099  865.2163
> [20,]  939.8106  840.0662  911.5299  678.0191  766.2572 1119.6836  719.0916
> 1068.7629  891.5782 1195.1606
>
>
> Y:.
>          [,1]     [,2]     [,3]     [,4]     [,5]     [,6]     [,7]
> [,8]     [,9]    [,10]
>  [1,] 5021.075 5021.075 5021.075 5021.075 5021.075 5021.075 5021.075
> 5021.075 5021.075 5021.075
>  [2,] 4867.478 4867.478 4867.478 4867.478 4867.478 4867.478 4867.478
> 4867.478 4867.478 4867.478
>  [3,] 4578.723 4578.723 4578.723 4578.723 4578.723 4578.723 4578.723
> 4578.723 4578.723 4578.723
>  [4,] 4490.234 4490.234 4490.234 4490.234 4490.234 4490.234 4490.234
> 4490.234 4490.234 4490.234
>  [5,] 4758.160 4758.160 4758.160 4758.160 4758.160 4758.160 4758.160
> 4758.160 4758.160 4758.160
>  [6,] 5058.081 5058.081 5058.081 5058.081 5058.081 5058.081 5058.081
> 5058.081 5058.081 5058.081
>  [7,] 4712.241 4712.241 4712.241 4712.241 4712.241 4712.241 4712.241
> 4712.241 4712.241 4712.241
>  [8,] 4994.433 4994.433 4994.433 4994.433 4994.433 4994.433 4994.433
> 4994.433 4994.433 4994.433
>  [9,] 4726.197 4726.197 4726.197 4726.197 4726.197 4726.197 4726.197
> 4726.197 4726.197 4726.197
> [10,] 4558.934 4558.934 4558.934 4558.934 4558.934 4558.934 4558.934
> 4558.934 4558.934 4558.934
> [11,] 4928.856 4928.856 4928.856 4928.856 4928.856 4928.856 4928.856
> 4928.856 4928.856 4928.856
> [12,] 4820.748 4820.748 4820.748 4820.748 4820.748 4820.748 4820.748
> 4820.748 4820.748 4820.748
> [13,] 4659.723 4659.723 4659.723 4659.723 4659.723 4659.723 4659.723
> 4659.723 4659.723 4659.723
> [14,] 5047.652 5047.652 5047.652 5047.652 5047.652 5047.652 5047.652
> 5047.652 5047.652 5047.652
> [15,] 4925.131 4925.131 4925.131 4925.131 4925.131 4925.131 4925.131
> 4925.131 4925.131 4925.131
> [16,] 5051.805 5051.805 5051.805 5051.805 5051.805 5051.805 5051.805
> 5051.805 5051.805 5051.805
> [17,] 5204.926 5204.926 5204.926 5204.926 5204.926 5204.926 5204.926
> 5204.926 5204.926 5204.926
> [18,] 5019.309 5019.309 5019.309 5019.309 5019.309 5019.309 5019.309
> 5019.309 5019.309 5019.309
> [19,] 4855.221 4855.221 4855.221 4855.221 4855.221 4855.221 4855.221
> 4855.221 4855.221 4855.221
> [20,] 4702.607 4702.607 4702.607 4702.607 4702.607 4702.607 4702.607
> 4702.607 4702.607 4702.607
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list