Description Usage Arguments Details Value Note Examples
Distance function given here are defined for the sole use within the model
definition for adoption.
These functions increase the processing speed in
adoption.
THESE FUNCTIONS SHOULD NEVER BE USED OUTSIDE THE MODEL DEFINITION FOR
adoption. THEY SHOULD BE USED ONLY IN THE SAME WAY AS
GIVEN IN THE EXAMPLES OF adoption, WITHOUT ANY MODIFICATIONS!
1 2 | GoldenbergDistance(param, dist, W, Goldenberg_C)
VarDistance(param, dist, W)
|
param |
the weight parameter. For the Goldenberg distance it has (at least) two parameters; for the VAR distance it has one parameter. |
dist |
the matrix for Euclidean distances between
the coordinates that are given by the function
|
W |
A square matrix of size |
Goldenberg_C |
Some large constant, e.g. 1e6 |
DO NOT USE THESE FUNCTIONS OUTSIDE THE MODEL DEFINITIONS FOR
adoption.
NULL
Since these distance function modify the values of the argument
W by reference, the use of these distance functions will nearly
always lead to a system crash if these functions are used wrongly.
However, it is save to use them in the model definition for defining
the weight function, e.g.,
weight = function(param, dist, W)
GoldenbergDistance(param, dist, W, Goldenberg_C)
which equivalent to (but much faster than)
weight = function(param, dist) {
neighbour <- dist <= param[1]
diag(neighbour) <- 0
neighbour / Goldenberg_C
}
Note that the weight is, in the first piece of code, defined with
an additional argument W more, which refers to a matrix of
correct size in adoption.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | Goldenberg <- list( ## model by Goldenberg, Libai, Muller (2010)
m = 1000L,
repetitions=10L,
dt = 1,
relative.instance = 0.2,
SOCIAL = c(1, 5, 5),
PRIVATE = c(5, 1, 5),
Ic.start = function(param, m, rep, ...) {
m * rnorm(m * rep, param[1], prod(param[1:2]))
},
Ic = function(param, Nt, m, start) {
Inf * (2 * (Nt > start) - 1) ## start has size m * rep, i.e. Nt is
## recycled
},
Ic.param = c("mean h" = 0.02,
"sigma" = 0.4),
Ic.param.min = c(0.005, 0.08),
Ic.param.max = c(0.1, 1.5),
coord = function(param, m) {
if (param[1] == 1) as.matrix(1:m)
else {
m2 <- ceiling(sqrt(m))
m3 <- ceiling(m / m2)
as.matrix(expand.grid(1:m2, 1:m3))[1:m, ]
}},
coord.param = c(dim = 2),
weight = function(param, dist, W) {
GoldenbergDistance(param, dist, W, 1e6)
},
weight.param.min = 1.5,
weight.param.max = 1.5,
weight.param = c("max distance d"=1.5),
Utrafo = function(U, threshold, ...) 1e6 * as.double(U>=threshold),
Uthreshold = 0, ## here: constant for any people; we might
Uthreshold.min = 0,
Uthreshold.max = 0,
Up.start = function(param, m, rep) rep(-1, m * rep),
Up = function(param, m, nT, rep, ...) {
pmax(-1e6 + 1,
-log(runif(nT * rep * m)/(1-param[1])) / log(1-param[2]))
},
Up.param = c(prob_a=0.1, prob_b=0.1),
Up.param.min = c(0.005, 0.05),
Up.param.max = c(0.99, 0.99),
"MAX/PLUS OPERATORS" = rep(5, 3),
alpha = c("alpha_1"=0, "alpha_2"=1),
alpha.min = c(0, 1),
alpha.max = c(0, 1),
beta = c("beta_1"=1, "beta_2"=1),
beta.min = c(1, 1),
beta.max = c(1, 1),
gamma = c("gamma_1"=0.5, "gamma_2"=0.5),
gamma.min = c(0.5, 0.5),
gamma.max = c(0.5, 0.5)
)
RFoptions(cores=2) ## see package RandomFieldsUtils
print(adoption(Goldenberg, join_models=FALSE, buttons2right=TRUE,
gui=interactive()))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.