Showing posts with label How to Produce return level plots depicting prior and posterior distributions of gev quantiles. Show all posts
Showing posts with label How to Produce return level plots depicting prior and posterior distributions of gev quantiles. Show all posts

Tuesday, April 16, 2019

How to Produce return level plots depicting prior and posterior distributions of gev quantiles

 How to Produce return level plots 

depicting prior and posterior distributions of gev quantiles

stock return correlation,cfa level i video,hay day tom level,cfa level 1,level,velocity,acceleration,inverter,solaredge,technology,robert knepper,games,power,brown,discrete fourier transform,business reports,uncertainty,cryptocurrencies,video market update,stock market update,project management

stock return correlation,cfa level i video,hay day tom level,cfa level 1,level,velocity,acceleration,inverter,solaredge,technology,robert knepper,games,power,brown,discrete fourier transform,business reports,uncertainty,cryptocurrencies,video market update,stock market update,project management

stock return correlation,cfa level i video,hay day tom level,cfa level 1,level,velocity,acceleration,inverter,solaredge,technology,robert knepper,games,power,brown,discrete fourier transform,business reports,uncertainty,cryptocurrencies,video market update,stock market update,project management

stock return correlation,cfa level i video,hay day tom level,cfa level 1,level,velocity,acceleration,inverter,solaredge,technology,robert knepper,games,power,brown,discrete fourier transform,business reports,uncertainty,cryptocurrencies,video market update,stock market

> library(evd)
Warning message:
package ‘evd’ was built under R version 3.5.3
> bvdata <- rbvevd(1000, dep = 0.5, model = "log")
> u <- apply(bvdata, 2,  quantile, probs = 0.9)
> M1 <- fbvpot(bvdata, u, model = "log")
> M2 <- fbvpot(bvdata, u, "log", dep = 0.5)
> anova(M1, M2)
Analysis of Deviance Table

   M.Df Deviance Df  Chisq Pr(>chisq)
M1    5     1433                   
M2    4     1434  1 0.9078     0.3407
> abvevd(dep = 2.7, model = "hr")
[1] 0.6444467
> abvevd(seq(0,1,0.25), dep = 0.3, asy = c(.7,.9), model = "alog")
[1] 1.0000000 0.8272414 0.7012552
[4] 0.7841595 1.0000000
> abvevd(alpha = 0.3, beta = 1.2, model = "negbi", plot = TRUE)
> bvdata <- rbvevd(100, dep = 0.7, model = "log")
> M1 <- fitted(fbvevd(bvdata, model = "log"))
> abvevd(dep = M1["dep"], model = "log", plot = TRUE)
> abvnonpar(data = bvdata, add = TRUE, lty = 2)
> install.packages("evdbayes")
Installing package into ‘C:/Users/ADMIN/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/evdbayes_1.1-1.zip'
Content type 'application/zip' length 771265 bytes (753 KB)
downloaded 753 KB

package ‘evdbayes’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\ADMIN\AppData\Local\Temp\Rtmp82fPZs\downloaded_packages
> data(rainfall)
Warning message:
In data(rainfall) : data set ‘rainfall’ not found
> library(evdbayes)
Warning message:
package ‘evdbayes’ was built under R version 3.5.2
> data(rainfall)
> prrain <- prior.quant(shape = c(38.9, 7.1, 47), scale = c(1.5, 6.3,
+                                                           2.6))
> n <- 10000; t0 <- c(43.2, 7.64, 0.32);
> s <- ar.choice(init = t0, prior = prrain, lh = "pp", data = rainfall,
+                thresh = 40, noy = 54, psd = rep(0.01, 3))
Accept Rate values and proposal standard deviations at each iterations...
Accept Rate Prop. Std
1 0.98 0.88 0.01 0.01 0.01
0.99 0.88 0.68 0.03 0.03 0.03
0.96 0.75 0.45 0.077 0.07 0.058
0.92 0.54 0.42 0.187 0.138 0.058
0.79 0.42 0.47 0.435 0.208 0.058
0.64 0.42 0.36 0.892 0.208 0.077
0.5 0.43 0.36 1.525 0.208 0.077
0.36 0.43 0.34 2.112 0.208 0.077
0.4 0.44 0.44 2.112 0.208 0.052
> mat <- diag(c(10000, 10000, 100))
> pn <- prior.norm(mean = c(0,0,0), cov = mat)
> prior.norm(mean = c(0,0,0), cov = mat, trendsd = 10)
$`prior`
[1] "dprior.norm"

$mean
[1] 0 0 0

$icov
[1] 1e-04 0e+00 0e+00 1e-04 0e+00 1e-02

$trendsd
[1] 10

attr(,"class")
[1] "evprior"
> prior.quant(shape = c(38.9,7.1,47), scale = c(1.5,6.3,2.6))
$`prior`
[1] "dprior.quant"

$prob
[1] 0.100 0.010 0.001

$shape
[1] 38.9  7.1 47.0

$scale
[1] 1.5 6.3 2.6

$trendsd
[1] 0

attr(,"class")
[1] "evprior"
> prior.prob(quant = c(85,88,95), alpha = c(4,2.5,2.25,0.25))
$`prior`
[1] "dprior.prob"

$quant
[1] 85 88 95

$alpha
[1] 4.00 2.50 2.25 0.25

$trendsd
[1] 0

attr(,"class")
[1] "evprior"
> ibeta(shape1 = 5, shape2 = 4)
    shape1     shape2       mean
5.00000000 4.00000000 0.55555556
       var       mode
0.02469136 0.57142857
> ibeta(mean = seq(0.1,0.9,0.2), var = 0.03)
    shape1   shape2 mean  var mode
1 0.200000 1.800000  0.1 0.03   NA
2 1.800000 4.200000  0.3 0.03  0.2
3 3.666667 3.666667  0.5 0.03  0.5
4 4.200000 1.800000  0.7 0.03  0.8
5 1.800000 0.200000  0.9 0.03   NA
> igamma(shape=c(38.9,7.1,47), scale=c(1.5,6.3,2.6))
  shape scale   mean     var   mode
1  38.9   1.5  58.35  87.525  56.85
2   7.1   6.3  44.73 281.799  38.43
3  47.0   2.6 122.20 317.720 119.60
> pn <- prior.norm(mean = c(0,0,0), cov = mat)
> prior.norm(mean = c(0,0,0), cov = mat, trendsd = 10)
$`prior`
[1] "dprior.norm"

$mean
[1] 0 0 0

$icov
[1] 1e-04 0e+00 0e+00 1e-04 0e+00 1e-02

$trendsd
[1] 10

attr(,"class")
[1] "evprior"
> prior.quant(shape = c(38.9,7.1,47), scale = c(1.5,6.3,2.6))
$`prior`
[1] "dprior.quant"

$prob
[1] 0.100 0.010 0.001

$shape
[1] 38.9  7.1 47.0

$scale
[1] 1.5 6.3 2.6

$trendsd
[1] 0

attr(,"class")
[1] "evprior"
> prior.prob(quant = c(85,88,95), alpha = c(4,2.5,2.25,0.25))
$`prior`
[1] "dprior.prob"

$quant
[1] 85 88 95

$alpha
[1] 4.00 2.50 2.25 0.25

$trendsd
[1] 0

attr(,"class")
[1] "evprior"
> data(portpirie)
> posterior(1000, init = c(5,1,0.1), prior = pn, lh = "gev",
+           data = portpirie, psd = c(.02,.1,.1))
           mu     sigma            xi
0    5.000000 1.0000000  0.1000000000
1    4.976646 1.0000000  0.1000000000
2    4.987224 1.0000000  0.0545349773
3    4.987224 1.0000000  0.0456365115
4    4.964454 1.1165769  0.2755992983
5    4.962236 1.1324592  0.3217933527
6    4.962236 1.1324592  0.1327535014
7    4.962236 1.1088315  0.1880980387
8    4.962236 1.1088315  0.1081257185
9    4.960956 1.1977180  0.2602283389
10   4.963090 1.1977180  0.3496444883
11   4.947890 1.3450166  0.4473917408
12   4.933351 1.3450166  0.4473917408
13   4.933351 1.4886071  0.5266445579
14   4.933351 1.6456376  0.4511559626
15   4.934832 1.6105426  0.4511559626
16   4.944959 1.6239882  0.5486416868
17   4.929174 1.6564021  0.5047713357
18   4.926007 1.6564021  0.5047713357
19   4.921031 1.4847650  0.5047713357
20   4.880370 1.4847650  0.5364808208
21   4.854576 1.4847650  0.5364808208
22   4.871415 1.4995749  0.5364808208
23   4.871415 1.3825038  0.5364808208
24   4.869950 1.3825038  0.7246099407
25   4.839804 1.4305620  0.8231729229
26   4.833038 1.4305620  0.7984826301
27   4.833038 1.4305620  0.9139122393
28   4.837856 1.4136947  0.9139122393
29   4.837856 1.4136947  0.9139122393
30   4.837856 1.4136947  0.8034009395
31   4.837856 1.4178104  0.8034009395
32   4.837856 1.4178104  0.7839458634
33   4.818766 1.4320038  0.9381293701
34   4.784381 1.4488483  0.9381293701
35   4.782059 1.4485882  0.9381293701
36   4.782059 1.5769022  0.9579222395
37   4.782059 1.5769022  0.9787728409
38   4.765275 1.5769022  1.0485155494
39   4.750973 1.5769022  1.1472901135
40   4.743595 1.5769022  1.1472901135
41   4.738423 1.5867626  1.1271639038
42   4.748601 1.5867626  1.1271639038
43   4.739929 1.5867626  1.1376379894
44   4.739929 1.5867626  1.2470206140
45   4.726751 1.6851000  1.2110142628
46   4.717529 1.6851000  1.2110142628
47   4.698512 1.6936496  1.2110142628
48   4.704271 1.6936496  1.2180396129
49   4.710539 1.6864232  1.4020619587
50   4.695635 1.6864232  1.4020619587
51   4.670896 1.6864232  1.3573499108
52   4.693424 1.7010780  1.4556082095
53   4.693424 1.7010780  1.4556082095
54   4.681682 1.7694762  1.4556082095
55   4.667695 1.7694762  1.4556082095
56   4.655019 1.7694762  1.4556082095
57   4.657900 1.7694762  1.4782550674
58   4.648193 1.7850311  1.4782550674
59   4.674806 1.7850311  1.4782550674
60   4.705642 1.7850311  1.4263342073
61   4.705642 1.7878899  1.5067524012
62   4.701261 1.7878899  1.4348918140
63   4.709435 1.7878899  1.4348918140
64   4.709435 1.7878899  1.4348918140
65   4.697228 1.7878899  1.4348918140
66   4.710302 1.7878899  1.4348918140
67   4.721801 1.7878899  1.4348918140
68   4.718063 1.7878899  1.4348918140
69   4.714399 1.7878899  1.4348918140
70   4.661984 1.7878899  1.3640107214
71   4.672535 1.7878899  1.3547244632
72   4.702867 1.7878899  1.3547244632
73   4.702867 1.7812073  1.3839817870
74   4.707000 1.7812073  1.3839817870
75   4.715984 1.7812073  1.3839817870
76   4.710645 1.7812073  1.3839817870
77   4.702650 1.7313997  1.4676779424
78   4.704446 1.7313997  1.4528937895
79   4.704446 1.7313997  1.4528937895
80   4.696768 1.8302092  1.4886994291
81   4.732685 1.8302092  1.4886994291
82   4.732685 1.8302092  1.4886994291
83   4.732685 1.8418105  1.4886994291
84   4.735570 1.8192720  1.4886994291
85   4.735570 1.8633624  1.4352013103
86   4.677870 1.8633624  1.4352013103
87   4.678843 1.8633624  1.4193843918
88   4.715133 1.8633624  1.4211985059
89   4.736064 1.8633624  1.5064096257
90   4.703928 1.8633624  1.5064096257
91   4.708908 1.7953108  1.5064096257
92   4.708908 1.7953108  1.4717540630
93   4.717754 1.7953108  1.4808761617
94   4.717754 1.7953108  1.3980112995
95   4.696941 1.7953108  1.3980112995
96   4.710966 1.7953108  1.3568928007
97   4.720897 1.7953108  1.3568928007
98   4.706024 1.7317993  1.3767172880
99   4.723700 1.7317993  1.3767172880
100  4.719024 1.7317993  1.3785822036
101  4.696468 1.7317993  1.3986188912
102  4.696468 1.7317993  1.3430343899
103  4.680086 1.7317993  1.4378573494
104  4.676389 1.7317993  1.4378573494
105  4.614589 1.7317993  1.4991248141
106  4.637611 1.7846503  1.4991248141
107  4.636665 1.7755891  1.4991248141
108  4.636665 1.7755891  1.4803569320
109  4.664592 1.7755891  1.5352234137
110  4.659931 1.7755891  1.5352234137
111  4.653376 1.7755891  1.5548868065
112  4.629371 1.7755891  1.5548868065
113  4.653106 1.7755891  1.5548868065
114  4.653106 1.7755891  1.5548868065
115  4.659927 1.7755891  1.5548868065
116  4.659927 1.8299117  1.5525072522
117  4.664836 1.8299117  1.5525072522
118  4.657834 1.8299117  1.6359429576
119  4.658262 1.8299117  1.6359429576
120  4.658262 1.8299117  1.6213671569
121  4.658262 1.8129374  1.6213671569
122  4.645090 1.8129374  1.5800629944
123  4.647530 1.8129374  1.5569151090
124  4.648152 1.7482401  1.5569151090
125  4.635668 1.7482401  1.5738889184
126  4.615787 1.7317330  1.5738889184
127  4.600744 1.7317330  1.5738889184
128  4.600744 1.6963426  1.5458880392
129  4.593287 1.6963426  1.5458880392
130  4.590932 1.6990436  1.5408202757
131  4.573277 1.6990436  1.6066529279
132  4.571897 1.6990436  1.6066529279
133  4.561636 1.6749511  1.6066529279
134  4.560202 1.6749511  1.6132048242
135  4.563335 1.6749511  1.5491899404
136  4.566307 1.6669180  1.5491899404
137  4.574035 1.6293741  1.5491899404
138  4.577198 1.6293741  1.5491899404
139  4.542384 1.6503563  1.5491899404
140  4.536577 1.6503563  1.5491899404
141  4.536577 1.6503563  1.5491899404
142  4.536577 1.5901309  1.5491899404
143  4.536577 1.5901309  1.4867202403
144  4.566162 1.5901309  1.4986137389
145  4.566162 1.5901309  1.4986137389
146  4.548122 1.5901309  1.5155271184
147  4.548122 1.5901309  1.5155271184
148  4.548122 1.5901309  1.5312086240
149  4.534285 1.5901309  1.5312086240
150  4.544618 1.5826497  1.5312086240
151  4.535445 1.6022422  1.5830809148
152  4.532782 1.6022422  1.5830809148
153  4.532782 1.6022422  1.5830809148
154  4.517738 1.6022422  1.5830809148
155  4.548284 1.6022422  1.5830809148
156  4.532527 1.6022422  1.5830809148
157  4.504540 1.6022422  1.5521113853
158  4.504056 1.6022422  1.5521113853
159  4.488232 1.6022422  1.4529382571
160  4.488232 1.4177555  1.4529382571
161  4.502148 1.4215472  1.3251313335
162  4.532721 1.4215472  1.3178457139
163  4.527353 1.4215472  1.3706932484
164  4.527353 1.4060900  1.3706932484
165  4.520855 1.4060900  1.3706932484
166  4.533237 1.4060900  1.3706932484
167  4.514588 1.4060900  1.3706932484
168  4.495767 1.4060900  1.3993192589
169  4.455610 1.4060900  1.4962607414
170  4.448240 1.4060900  1.5119138189
171  4.447938 1.4071737  1.5119138189
172  4.443150 1.4071737  1.5119138189
173  4.443150 1.4071737  1.5119138189
174  4.443150 1.4071737  1.5087571080
175  4.443150 1.4071737  1.5087571080
176  4.438206 1.4071737  1.5087571080
177  4.429200 1.4071737  1.5087571080
178  4.429200 1.4071737  1.3817314862
179  4.429200 1.4071737  1.4389670484
180  4.436212 1.4071737  1.5793566013
181  4.436212 1.4071737  1.4927470162
182  4.457551 1.3970917  1.4927470162
183  4.463782 1.3970917  1.3905491749
184  4.471943 1.3970917  1.4248715411
185  4.468481 1.3970917  1.4598247150
186  4.468481 1.3970917  1.4007045884
187  4.463229 1.4079464  1.4007045884
188  4.483282 1.4079464  1.3455802611
189  4.471832 1.3420639  1.3303047433
190  4.506369 1.3420639  1.3303047433
191  4.508575 1.3420639  1.3303047433
192  4.497945 1.3420639  1.3303047433
193  4.511964 1.3392850  1.3303047433
194  4.519991 1.3392850  1.2768699657
195  4.506735 1.3392850  1.2768699657
196  4.506735 1.3392850  1.2709678682
197  4.475381 1.3392850  1.2709678682
198  4.483775 1.3392850  1.2195952908
199  4.428471 1.0905730  1.1354031979
200  4.418423 1.0905730  1.1354031979
201  4.418423 1.0905730  1.1493191066
202  4.407910 1.0905730  1.1493191066
203  4.387139 1.1368532  1.1493191066
204  4.373874 1.0588280  1.2130018079
205  4.381805 1.0588280  1.0470364687
206  4.369287 1.0588280  1.1155509554
207  4.359393 1.0588280  1.1534158564
208  4.359393 1.0588280  1.1534158564
209  4.359393 1.0588280  1.2070598160
210  4.339310 1.0245975  1.2070598160
211  4.339310 1.0245975  1.2545388395
212  4.321967 1.0245975  1.2545388395
213  4.316014 1.0016666  1.2550906199
214  4.315815 1.0016666  1.1953085134
215  4.318247 0.9812468  1.2090626245
216  4.318247 0.9812468  1.2090626245
217  4.309341 0.9812468  1.2090626245
218  4.300026 0.9812468  1.2090626245
219  4.316166 1.0018892  1.2090626245
220  4.325849 1.0018892  1.2167568510
221  4.322658 1.0018892  1.2441175105
222  4.308090 1.0018892  1.2441175105
223  4.314044 1.0018892  1.2441175105
224  4.314044 1.0018892  1.2315376946
225  4.291394 1.0018892  1.1695012771
226  4.262602 1.0018892  1.2606849478
227  4.281373 1.0018892  1.2606849478
228  4.285426 1.0018892  1.2687947809
229  4.285426 1.0018892  1.2163962135
230  4.289216 1.0018892  1.1768191823
231  4.293209 0.9727771  1.1548763672
232  4.273138 0.9424036  1.1548763672
233  4.262746 0.9424036  1.1686367503
234  4.240521 0.9424036  1.1447272811
235  4.234846 0.9424036  1.1447272811
236  4.235089 0.9424036  1.1447272811
237  4.239638 0.9424036  1.1848605547
238  4.229485 0.9097967  1.2153463810
239  4.236197 0.9097967  1.1769055336
240  4.253593 0.9097967  1.1510852754
241  4.253593 0.9097967  1.1938278138
242  4.253593 0.9097967  1.1655419395
243  4.258779 0.9190295  1.2128293878
244  4.272174 0.9315449  1.2128293878
245  4.234540 0.9315449  1.2128293878
246  4.225071 0.9315449  1.3396822230
247  4.220600 0.9315449  1.1161933648
248  4.220600 0.9315449  1.2239753544
249  4.242787 0.9315449  1.2239753544
250  4.260978 0.9315449  1.2084801271
251  4.242036 0.9078502  1.2084801271
252  4.236893 0.9078502  1.2084801271
253  4.236893 0.9078502  1.2084801271
254  4.214256 0.9078502  1.1678504501
255  4.232026 0.9078502  1.1833074910
256  4.255563 0.9078502  1.1833074910
257  4.239681 0.9078502  1.1434002427
258  4.238553 0.9078502  1.1434002427
259  4.230957 0.8655561  1.1480567952
260  4.210900 0.8655561  1.1480567952
261  4.210900 0.8643709  1.2188754206
262  4.210900 0.8643709  1.2188754206
263  4.202742 0.8643709  1.2926611684
264  4.202742 0.8643709  1.2926611684
265  4.192976 0.8643709  1.2926611684
266  4.154749 0.8643709  1.2926611684
267  4.154749 0.8080481  1.2876733844
268  4.143600 0.8080481  1.2876733844
269  4.143600 0.7890600  1.2931871945
270  4.117110 0.7769238  1.1573849294
271  4.117110 0.7769238  1.0302329405
272  4.147396 0.7769238  1.0302329405
273  4.166059 0.7280484  1.0200871435
274  4.178315 0.7280484  1.0200871435
275  4.178315 0.7280484  1.0200871435
276  4.168117 0.7240596  0.8842400524
277  4.175171 0.6703717  0.8842400524
278  4.155155 0.6568888  0.8594345136
279  4.135936 0.6291070  0.8138133062
280  4.135936 0.6347733  0.8138133062
281  4.152718 0.6347733  0.8188741522
282  4.141528 0.6347733  0.8188741522
283  4.141528 0.5835078  0.6903902225
284  4.141528 0.5229095  0.6903902225
285  4.123859 0.5564615  0.7064754642
286  4.131249 0.5928917  0.7064754642
287  4.112764 0.5928917  0.7247658905
288  4.127481 0.5928917  0.6292776216
289  4.119133 0.5928917  0.5976156694
290  4.081995 0.5912989  0.7095852481
291  4.077307 0.4852712  0.7367740463
292  4.077307 0.4852712  0.7367740463
293  4.055037 0.4537958  0.7082804296
294  4.062359 0.4537958  0.6308051786
295  4.046443 0.4537958  0.6062573505
296  4.046443 0.4268292  0.5426418399
297  4.022442 0.4268292  0.6112886481
298  4.022442 0.3803540  0.6112886481
299  4.022442 0.3990584  0.6112886481
300  4.022442 0.3990584  0.6112886481
301  4.022442 0.4311548  0.5152380588
302  4.004924 0.4311548  0.3552307486
303  4.004924 0.4311548  0.5134922307
304  3.989801 0.4311548  0.6490079996
305  3.996109 0.4311548  0.6121506861
306  3.986168 0.4089814  0.6121506861
307  3.999658 0.4089814  0.6121506861
308  3.992783 0.3422798  0.6345206507
309  3.992783 0.3506305  0.6330538783
310  3.992783 0.4025407  0.5712894409
311  3.992783 0.3437646  0.5712894409
312  3.999414 0.3543084  0.5327009192
313  3.964070 0.3563417  0.4595415153
314  3.974800 0.3563417  0.4595415153
315  3.964589 0.3563417  0.4208324098
316  3.980096 0.3446920  0.3698751029
317  3.980096 0.3235982  0.3698751029
318  3.998100 0.3235982  0.3698751029
319  3.972822 0.3112434  0.3648098099
320  3.972822 0.3112434  0.3841689084
321  3.950454 0.3112434  0.3841689084
322  3.944283 0.3028799  0.2077552203
323  3.951940 0.3028799  0.2077552203
324  3.938907 0.3067762  0.1649977410
325  3.941277 0.2960191  0.1649977410
326  3.945417 0.2772171  0.1649977410
327  3.928883 0.2226055  0.1649977410
328  3.928883 0.2531670  0.0132236516
329  3.906074 0.2105743  0.0609158128
330  3.906074 0.2219674  0.0609158128
331  3.891366 0.2487743 -0.1212022033
332  3.898436 0.2397801 -0.0081773160
 [ reached getOption("max.print") -- omitted 668 rows ]
attr(,"ar")
            mu sigma   xi total
acc.rates 0.75  0.57 0.61  0.64
ext.rates 0.00  0.05 0.07  0.04
> require(grDevices)
> matplot((-4:5)^2, main = "Quadratic") # almost identical to plot(*)
> sines <- outer(1:20, 1:4, function(x, y) sin(x / 20 * pi * y))
> matplot(sines, pch = 1:4, type = "o", col = rainbow(ncol(sines)))
> matplot(sines, type = "b", pch = 21:23, col = 2:5, bg = 2:5,
+         main = "matplot(...., pch = 21:23, bg = 2:5)")
> x <- 0:50/50
> matplot(x, outer(x, 1:8, function(x, k) sin(k*pi * x)),
+         ylim = c(-2,2), type = "plobcsSh",
+         main= "matplot(,type = \"plobcsSh\" )")
> matplot(x, outer(x, 1:4, function(x, k) sin(k*pi * x)),
+         pch = letters[1:4], type = c("b","p","o"))
> lends <- c("round","butt","square")
> matplot(matrix(1:12, 4), type="c", lty=1, lwd=10, lend=lends)
> text(cbind(2.5, 2*c(1,3,5)-.4), lends, col= 1:3, cex = 1.5)
> table(iris$Species) # is data.frame with 'Species' factor

    setosa versicolor  virginica
        50         50         50
> iS <- iris$Species == "setosa"
> iV <- iris$Species == "versicolor"
> op <- par(bg = "bisque")
> matplot(c(1, 8), c(0, 4.5), type =  "n", xlab = "Length", ylab = "Width",
+         main = "Petal and Sepal Dimensions in Iris Blossoms")
> matpoints(iris[iS,c(1,3)], iris[iS,c(2,4)], pch = "sS", col = c(2,4))
> matpoints(iris[iV,c(1,3)], iris[iV,c(2,4)], pch = "vV", col = c(2,4))
> legend(1, 4, c("    Setosa Petals", "    Setosa Sepals",
+                "Versicolor Petals", "Versicolor Sepals"),
+        pch = "sSvV", col = rep(c(2,4), 2))
> nam.var <- colnames(iris)[-5]
> nam.spec <- as.character(iris[1+50*0:2, "Species"])
> iris.S <- array(NA, dim = c(50,4,3),
+                 dimnames = list(NULL, nam.var, nam.spec))
> for(i in 1:3) iris.S[,,i] <- data.matrix(iris[1:50+50*(i-1), -5])
>
> matplot(iris.S[, "Petal.Length",], iris.S[, "Petal.Width",], pch = "SCV",
+         col = rainbow(3, start = 0.8, end = 0.1),
+         sub = paste(c("S", "C", "V"), dimnames(iris.S)[[3]],
+                     sep = "=", collapse= ",  "),
+         main = "Fisher's Iris Data")
> par(op)

Black-Scholes formula-R

 Black-Scholes formula-R > BlackScholes <- function(TypeFlag = c("c", "p"), S, X, Time, r, b, sigma) { TypeFla...