E <- RigaWeb$A
F <- RigaWeb$B
G <- RigaWeb$G
H <- RigaWeb$H
# 1. parsimonious (simplest) solution
pars <- lsei(E = E, F = F, G = G, H = H)$X
# 2.ranges of all unknowns, including the central value
xr <- xranges(E = E, F = F, G = G, H = H, central = TRUE)
# the central point is a valid solution:
X <- xr[,"central"]
max(abs(E%*%X - F))
min(G%*%X - H)
if (FALSE) # this does not work on windows i386!
# 3. Sample solution space; the central value is a good starting point
# for algorithms cda and rda - but these need many iterations
xs <- xsample(E = E, F = F, G = G, H = H,
iter = 10000, out = 1000, type = "rda", x0 = X)$X
# better convergence using 50000 iterations, but this takes a while
xs <- xsample(E = E, F = F, G = G, H = H,
iter = 50000, out = 1000, type = "rda", x0 = X)$X
pairs(xs, pch = ".", cex = 2, gap = 0, upper.panel = NULL)
# using mirror algorithm takes less iterations,
# but an iteration takes more time ; it is better to start in a corner...
# (i.e. no need to use X as starting value)
xs <- xsample(E = E, F = F, G = G, H = H,
iter = 1500, output = 500, type = "mirror")$X
pairs(xs, pch = ".", cex = 2, gap = 0, upper.panel = NULL,
yaxt = "n", xaxt = "n")
# Print results:
data.frame(pars = pars, xr[ ,1:2], Mean = colMeans(xs), sd = apply(xs, 2, sd))
Run the code above in your browser using DataLab