addrv: Adding Random Variables to a Probability Space

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Adds a column to a data frame probability space containing the values of a random variable computed from the existing columns of the space.

Usage

1
addrv(space, FUN = NULL, invars = NULL, name = NULL, ...)

Arguments

space

a data frame with a probs column.

FUN

a function to be applied to each row of outcomes in space

invars

a character vector indicating input columns of space

name

an (optional) name to give the defined random variable.

...

an expression defining a random variable.

Details

There are two ways to add a random variable to a data frame probability space; see the examples. The argument FUN has precedence and will be used if specified. If name is not specified, then the new random variable will be called X. Note that this function only works for data frames, as a method for objects of class ps has not been implemented.

Value

The input data frame with an additional column called name.

Author(s)

G. Jay Kerns gkerns@ysu.edu.

See Also

See transform to add a column to a data frame of outcomes (not yet a probability space).

Examples

1
2
3
S <-rolldie(3, makespace = TRUE)
addrv(S, sum, name = "Y")
addrv(S, Z = X3 - X2 )

Example output

Loading required package: combinat

Attaching package: 'combinat'

The following object is masked from 'package:utils':

    combn

Loading required package: fAsianOptions
Loading required package: timeDate
Loading required package: timeSeries
Loading required package: fBasics


Rmetrics Package fBasics
Analysing Markets and calculating Basic Statistics
Copyright (C) 2005-2014 Rmetrics Association Zurich
Educational Software for Financial Engineering and Computational Science
Rmetrics is free software and comes with ABSOLUTELY NO WARRANTY.
https://www.rmetrics.org --- Mail to: info@rmetrics.org
Loading required package: fOptions


Rmetrics Package fOptions
Pricing and Evaluating Basic Options
Copyright (C) 2005-2014 Rmetrics Association Zurich
Educational Software for Financial Engineering and Computational Science
Rmetrics is free software and comes with ABSOLUTELY NO WARRANTY.
https://www.rmetrics.org --- Mail to: info@rmetrics.org
Loading required package: hypergeo
Loading required package: VGAM
Loading required package: stats4
Loading required package: splines

Attaching package: 'VGAM'

The following object is masked from 'package:hypergeo':

    is.zero

The following object is masked from 'package:fAsianOptions':

    erf


Attaching package: 'prob'

The following objects are masked from 'package:base':

    intersect, setdiff, union

    X1 X2 X3  Y      probs
1    1  1  1  3 0.00462963
2    2  1  1  4 0.00462963
3    3  1  1  5 0.00462963
4    4  1  1  6 0.00462963
5    5  1  1  7 0.00462963
6    6  1  1  8 0.00462963
7    1  2  1  4 0.00462963
8    2  2  1  5 0.00462963
9    3  2  1  6 0.00462963
10   4  2  1  7 0.00462963
11   5  2  1  8 0.00462963
12   6  2  1  9 0.00462963
13   1  3  1  5 0.00462963
14   2  3  1  6 0.00462963
15   3  3  1  7 0.00462963
16   4  3  1  8 0.00462963
17   5  3  1  9 0.00462963
18   6  3  1 10 0.00462963
19   1  4  1  6 0.00462963
20   2  4  1  7 0.00462963
21   3  4  1  8 0.00462963
22   4  4  1  9 0.00462963
23   5  4  1 10 0.00462963
24   6  4  1 11 0.00462963
25   1  5  1  7 0.00462963
26   2  5  1  8 0.00462963
27   3  5  1  9 0.00462963
28   4  5  1 10 0.00462963
29   5  5  1 11 0.00462963
30   6  5  1 12 0.00462963
31   1  6  1  8 0.00462963
32   2  6  1  9 0.00462963
33   3  6  1 10 0.00462963
34   4  6  1 11 0.00462963
35   5  6  1 12 0.00462963
36   6  6  1 13 0.00462963
37   1  1  2  4 0.00462963
38   2  1  2  5 0.00462963
39   3  1  2  6 0.00462963
40   4  1  2  7 0.00462963
41   5  1  2  8 0.00462963
42   6  1  2  9 0.00462963
43   1  2  2  5 0.00462963
44   2  2  2  6 0.00462963
45   3  2  2  7 0.00462963
46   4  2  2  8 0.00462963
47   5  2  2  9 0.00462963
48   6  2  2 10 0.00462963
49   1  3  2  6 0.00462963
50   2  3  2  7 0.00462963
51   3  3  2  8 0.00462963
52   4  3  2  9 0.00462963
53   5  3  2 10 0.00462963
54   6  3  2 11 0.00462963
55   1  4  2  7 0.00462963
56   2  4  2  8 0.00462963
57   3  4  2  9 0.00462963
58   4  4  2 10 0.00462963
59   5  4  2 11 0.00462963
60   6  4  2 12 0.00462963
61   1  5  2  8 0.00462963
62   2  5  2  9 0.00462963
63   3  5  2 10 0.00462963
64   4  5  2 11 0.00462963
65   5  5  2 12 0.00462963
66   6  5  2 13 0.00462963
67   1  6  2  9 0.00462963
68   2  6  2 10 0.00462963
69   3  6  2 11 0.00462963
70   4  6  2 12 0.00462963
71   5  6  2 13 0.00462963
72   6  6  2 14 0.00462963
73   1  1  3  5 0.00462963
74   2  1  3  6 0.00462963
75   3  1  3  7 0.00462963
76   4  1  3  8 0.00462963
77   5  1  3  9 0.00462963
78   6  1  3 10 0.00462963
79   1  2  3  6 0.00462963
80   2  2  3  7 0.00462963
81   3  2  3  8 0.00462963
82   4  2  3  9 0.00462963
83   5  2  3 10 0.00462963
84   6  2  3 11 0.00462963
85   1  3  3  7 0.00462963
86   2  3  3  8 0.00462963
87   3  3  3  9 0.00462963
88   4  3  3 10 0.00462963
89   5  3  3 11 0.00462963
90   6  3  3 12 0.00462963
91   1  4  3  8 0.00462963
92   2  4  3  9 0.00462963
93   3  4  3 10 0.00462963
94   4  4  3 11 0.00462963
95   5  4  3 12 0.00462963
96   6  4  3 13 0.00462963
97   1  5  3  9 0.00462963
98   2  5  3 10 0.00462963
99   3  5  3 11 0.00462963
100  4  5  3 12 0.00462963
101  5  5  3 13 0.00462963
102  6  5  3 14 0.00462963
103  1  6  3 10 0.00462963
104  2  6  3 11 0.00462963
105  3  6  3 12 0.00462963
106  4  6  3 13 0.00462963
107  5  6  3 14 0.00462963
108  6  6  3 15 0.00462963
109  1  1  4  6 0.00462963
110  2  1  4  7 0.00462963
111  3  1  4  8 0.00462963
112  4  1  4  9 0.00462963
113  5  1  4 10 0.00462963
114  6  1  4 11 0.00462963
115  1  2  4  7 0.00462963
116  2  2  4  8 0.00462963
117  3  2  4  9 0.00462963
118  4  2  4 10 0.00462963
119  5  2  4 11 0.00462963
120  6  2  4 12 0.00462963
121  1  3  4  8 0.00462963
122  2  3  4  9 0.00462963
123  3  3  4 10 0.00462963
124  4  3  4 11 0.00462963
125  5  3  4 12 0.00462963
126  6  3  4 13 0.00462963
127  1  4  4  9 0.00462963
128  2  4  4 10 0.00462963
129  3  4  4 11 0.00462963
130  4  4  4 12 0.00462963
131  5  4  4 13 0.00462963
132  6  4  4 14 0.00462963
133  1  5  4 10 0.00462963
134  2  5  4 11 0.00462963
135  3  5  4 12 0.00462963
136  4  5  4 13 0.00462963
137  5  5  4 14 0.00462963
138  6  5  4 15 0.00462963
139  1  6  4 11 0.00462963
140  2  6  4 12 0.00462963
141  3  6  4 13 0.00462963
142  4  6  4 14 0.00462963
143  5  6  4 15 0.00462963
144  6  6  4 16 0.00462963
145  1  1  5  7 0.00462963
146  2  1  5  8 0.00462963
147  3  1  5  9 0.00462963
148  4  1  5 10 0.00462963
149  5  1  5 11 0.00462963
150  6  1  5 12 0.00462963
151  1  2  5  8 0.00462963
152  2  2  5  9 0.00462963
153  3  2  5 10 0.00462963
154  4  2  5 11 0.00462963
155  5  2  5 12 0.00462963
156  6  2  5 13 0.00462963
157  1  3  5  9 0.00462963
158  2  3  5 10 0.00462963
159  3  3  5 11 0.00462963
160  4  3  5 12 0.00462963
161  5  3  5 13 0.00462963
162  6  3  5 14 0.00462963
163  1  4  5 10 0.00462963
164  2  4  5 11 0.00462963
165  3  4  5 12 0.00462963
166  4  4  5 13 0.00462963
167  5  4  5 14 0.00462963
168  6  4  5 15 0.00462963
169  1  5  5 11 0.00462963
170  2  5  5 12 0.00462963
171  3  5  5 13 0.00462963
172  4  5  5 14 0.00462963
173  5  5  5 15 0.00462963
174  6  5  5 16 0.00462963
175  1  6  5 12 0.00462963
176  2  6  5 13 0.00462963
177  3  6  5 14 0.00462963
178  4  6  5 15 0.00462963
179  5  6  5 16 0.00462963
180  6  6  5 17 0.00462963
181  1  1  6  8 0.00462963
182  2  1  6  9 0.00462963
183  3  1  6 10 0.00462963
184  4  1  6 11 0.00462963
185  5  1  6 12 0.00462963
186  6  1  6 13 0.00462963
187  1  2  6  9 0.00462963
188  2  2  6 10 0.00462963
189  3  2  6 11 0.00462963
190  4  2  6 12 0.00462963
191  5  2  6 13 0.00462963
192  6  2  6 14 0.00462963
193  1  3  6 10 0.00462963
194  2  3  6 11 0.00462963
195  3  3  6 12 0.00462963
196  4  3  6 13 0.00462963
197  5  3  6 14 0.00462963
198  6  3  6 15 0.00462963
199  1  4  6 11 0.00462963
200  2  4  6 12 0.00462963
201  3  4  6 13 0.00462963
202  4  4  6 14 0.00462963
203  5  4  6 15 0.00462963
204  6  4  6 16 0.00462963
205  1  5  6 12 0.00462963
206  2  5  6 13 0.00462963
207  3  5  6 14 0.00462963
208  4  5  6 15 0.00462963
209  5  5  6 16 0.00462963
210  6  5  6 17 0.00462963
211  1  6  6 13 0.00462963
212  2  6  6 14 0.00462963
213  3  6  6 15 0.00462963
214  4  6  6 16 0.00462963
215  5  6  6 17 0.00462963
216  6  6  6 18 0.00462963
    X1 X2 X3  Z      probs
1    1  1  1  0 0.00462963
2    2  1  1  0 0.00462963
3    3  1  1  0 0.00462963
4    4  1  1  0 0.00462963
5    5  1  1  0 0.00462963
6    6  1  1  0 0.00462963
7    1  2  1 -1 0.00462963
8    2  2  1 -1 0.00462963
9    3  2  1 -1 0.00462963
10   4  2  1 -1 0.00462963
11   5  2  1 -1 0.00462963
12   6  2  1 -1 0.00462963
13   1  3  1 -2 0.00462963
14   2  3  1 -2 0.00462963
15   3  3  1 -2 0.00462963
16   4  3  1 -2 0.00462963
17   5  3  1 -2 0.00462963
18   6  3  1 -2 0.00462963
19   1  4  1 -3 0.00462963
20   2  4  1 -3 0.00462963
21   3  4  1 -3 0.00462963
22   4  4  1 -3 0.00462963
23   5  4  1 -3 0.00462963
24   6  4  1 -3 0.00462963
25   1  5  1 -4 0.00462963
26   2  5  1 -4 0.00462963
27   3  5  1 -4 0.00462963
28   4  5  1 -4 0.00462963
29   5  5  1 -4 0.00462963
30   6  5  1 -4 0.00462963
31   1  6  1 -5 0.00462963
32   2  6  1 -5 0.00462963
33   3  6  1 -5 0.00462963
34   4  6  1 -5 0.00462963
35   5  6  1 -5 0.00462963
36   6  6  1 -5 0.00462963
37   1  1  2  1 0.00462963
38   2  1  2  1 0.00462963
39   3  1  2  1 0.00462963
40   4  1  2  1 0.00462963
41   5  1  2  1 0.00462963
42   6  1  2  1 0.00462963
43   1  2  2  0 0.00462963
44   2  2  2  0 0.00462963
45   3  2  2  0 0.00462963
46   4  2  2  0 0.00462963
47   5  2  2  0 0.00462963
48   6  2  2  0 0.00462963
49   1  3  2 -1 0.00462963
50   2  3  2 -1 0.00462963
51   3  3  2 -1 0.00462963
52   4  3  2 -1 0.00462963
53   5  3  2 -1 0.00462963
54   6  3  2 -1 0.00462963
55   1  4  2 -2 0.00462963
56   2  4  2 -2 0.00462963
57   3  4  2 -2 0.00462963
58   4  4  2 -2 0.00462963
59   5  4  2 -2 0.00462963
60   6  4  2 -2 0.00462963
61   1  5  2 -3 0.00462963
62   2  5  2 -3 0.00462963
63   3  5  2 -3 0.00462963
64   4  5  2 -3 0.00462963
65   5  5  2 -3 0.00462963
66   6  5  2 -3 0.00462963
67   1  6  2 -4 0.00462963
68   2  6  2 -4 0.00462963
69   3  6  2 -4 0.00462963
70   4  6  2 -4 0.00462963
71   5  6  2 -4 0.00462963
72   6  6  2 -4 0.00462963
73   1  1  3  2 0.00462963
74   2  1  3  2 0.00462963
75   3  1  3  2 0.00462963
76   4  1  3  2 0.00462963
77   5  1  3  2 0.00462963
78   6  1  3  2 0.00462963
79   1  2  3  1 0.00462963
80   2  2  3  1 0.00462963
81   3  2  3  1 0.00462963
82   4  2  3  1 0.00462963
83   5  2  3  1 0.00462963
84   6  2  3  1 0.00462963
85   1  3  3  0 0.00462963
86   2  3  3  0 0.00462963
87   3  3  3  0 0.00462963
88   4  3  3  0 0.00462963
89   5  3  3  0 0.00462963
90   6  3  3  0 0.00462963
91   1  4  3 -1 0.00462963
92   2  4  3 -1 0.00462963
93   3  4  3 -1 0.00462963
94   4  4  3 -1 0.00462963
95   5  4  3 -1 0.00462963
96   6  4  3 -1 0.00462963
97   1  5  3 -2 0.00462963
98   2  5  3 -2 0.00462963
99   3  5  3 -2 0.00462963
100  4  5  3 -2 0.00462963
101  5  5  3 -2 0.00462963
102  6  5  3 -2 0.00462963
103  1  6  3 -3 0.00462963
104  2  6  3 -3 0.00462963
105  3  6  3 -3 0.00462963
106  4  6  3 -3 0.00462963
107  5  6  3 -3 0.00462963
108  6  6  3 -3 0.00462963
109  1  1  4  3 0.00462963
110  2  1  4  3 0.00462963
111  3  1  4  3 0.00462963
112  4  1  4  3 0.00462963
113  5  1  4  3 0.00462963
114  6  1  4  3 0.00462963
115  1  2  4  2 0.00462963
116  2  2  4  2 0.00462963
117  3  2  4  2 0.00462963
118  4  2  4  2 0.00462963
119  5  2  4  2 0.00462963
120  6  2  4  2 0.00462963
121  1  3  4  1 0.00462963
122  2  3  4  1 0.00462963
123  3  3  4  1 0.00462963
124  4  3  4  1 0.00462963
125  5  3  4  1 0.00462963
126  6  3  4  1 0.00462963
127  1  4  4  0 0.00462963
128  2  4  4  0 0.00462963
129  3  4  4  0 0.00462963
130  4  4  4  0 0.00462963
131  5  4  4  0 0.00462963
132  6  4  4  0 0.00462963
133  1  5  4 -1 0.00462963
134  2  5  4 -1 0.00462963
135  3  5  4 -1 0.00462963
136  4  5  4 -1 0.00462963
137  5  5  4 -1 0.00462963
138  6  5  4 -1 0.00462963
139  1  6  4 -2 0.00462963
140  2  6  4 -2 0.00462963
141  3  6  4 -2 0.00462963
142  4  6  4 -2 0.00462963
143  5  6  4 -2 0.00462963
144  6  6  4 -2 0.00462963
145  1  1  5  4 0.00462963
146  2  1  5  4 0.00462963
147  3  1  5  4 0.00462963
148  4  1  5  4 0.00462963
149  5  1  5  4 0.00462963
150  6  1  5  4 0.00462963
151  1  2  5  3 0.00462963
152  2  2  5  3 0.00462963
153  3  2  5  3 0.00462963
154  4  2  5  3 0.00462963
155  5  2  5  3 0.00462963
156  6  2  5  3 0.00462963
157  1  3  5  2 0.00462963
158  2  3  5  2 0.00462963
159  3  3  5  2 0.00462963
160  4  3  5  2 0.00462963
161  5  3  5  2 0.00462963
162  6  3  5  2 0.00462963
163  1  4  5  1 0.00462963
164  2  4  5  1 0.00462963
165  3  4  5  1 0.00462963
166  4  4  5  1 0.00462963
167  5  4  5  1 0.00462963
168  6  4  5  1 0.00462963
169  1  5  5  0 0.00462963
170  2  5  5  0 0.00462963
171  3  5  5  0 0.00462963
172  4  5  5  0 0.00462963
173  5  5  5  0 0.00462963
174  6  5  5  0 0.00462963
175  1  6  5 -1 0.00462963
176  2  6  5 -1 0.00462963
177  3  6  5 -1 0.00462963
178  4  6  5 -1 0.00462963
179  5  6  5 -1 0.00462963
180  6  6  5 -1 0.00462963
181  1  1  6  5 0.00462963
182  2  1  6  5 0.00462963
183  3  1  6  5 0.00462963
184  4  1  6  5 0.00462963
185  5  1  6  5 0.00462963
186  6  1  6  5 0.00462963
187  1  2  6  4 0.00462963
188  2  2  6  4 0.00462963
189  3  2  6  4 0.00462963
190  4  2  6  4 0.00462963
191  5  2  6  4 0.00462963
192  6  2  6  4 0.00462963
193  1  3  6  3 0.00462963
194  2  3  6  3 0.00462963
195  3  3  6  3 0.00462963
196  4  3  6  3 0.00462963
197  5  3  6  3 0.00462963
198  6  3  6  3 0.00462963
199  1  4  6  2 0.00462963
200  2  4  6  2 0.00462963
201  3  4  6  2 0.00462963
202  4  4  6  2 0.00462963
203  5  4  6  2 0.00462963
204  6  4  6  2 0.00462963
205  1  5  6  1 0.00462963
206  2  5  6  1 0.00462963
207  3  5  6  1 0.00462963
208  4  5  6  1 0.00462963
209  5  5  6  1 0.00462963
210  6  5  6  1 0.00462963
211  1  6  6  0 0.00462963
212  2  6  6  0 0.00462963
213  3  6  6  0 0.00462963
214  4  6  6  0 0.00462963
215  5  6  6  0 0.00462963
216  6  6  6  0 0.00462963

prob documentation built on May 2, 2019, 6:11 p.m.