Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/Simulate.Weights.R
Simulation of weights employing the Dirichlet distribution. The concentration parameters for the Dirichlet distribution are tentative weights, additionally constraints over partial sums of weights are introduced by a list ordered structure.
1 | Sim.Const.Weights(n, utilities, alpha, constraints)
|
n |
number of simulations |
utilities |
utility dataframe, first column is the identifier |
alpha |
concentration parameter for the Dirichlet distribution |
constraints |
list of sum constraints |
Employing the properties of the Dirichlet distribution, weights could be simulated with a given concentration, additionally this simulation can be carry out by subsets of weights only to meet specific constraints.
List with data.frames {simulation, weights} with total utilities and simulated weights
Pedro Guarderas pedro.felipe.guarderas@gmail.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | library( data.table )
N<-10
utilities<-data.table( id = 1:N,
u1 = runif( N, 0, 1 ),
u2 = runif( N, 0, 1 ),
u3 = runif( N, 0, 1 ),
u4 = runif( N, 0, 1 ) )
n<-100
alpha<-c( 0.2, 0.5, 0.1, 0.2 )
constraints<-list( list( c(1,2), 0.7 ),
list( c(3,4), 0.3 ) )
S<-Sim.Const.Weights( n, utilities, alpha, constraints )
plot.S<-Plot.Simulation.Weight( S$simulation, title = 'Simulations',
xlab = 'ID', ylab = 'Utility' )
plot( plot.S )
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.