varsample: Samples the probability density function of variables of...

Description Usage Arguments Value Author(s) See Also Examples

View source: R/varsample.R

Description

Uses random samples of an under- or overdetermined linear problem to estimate the distribution of equations

Based on a random sample of x (e.g. produced with xsample), produces the corresponding set of "variables" consisting of linear equations in the unknowns.

Var = EqA.x+EqB

Usage

1
varsample (X, EqA, EqB=NULL)

Arguments

X

matrix whose rows contain the sampled values of the unknowns x in EqA*x-EqB.

EqA

numeric matrix containing the coefficients that define the variables.

EqB

numeric vector containing the right-hand side of the variable equation.

Value

a matrix whose rows contain the sampled values of the variables.

Author(s)

Karline Soetaert <karline.soetaert@nioz.nl>

See Also

Minkdiet, for a description of the Mink diet example.

varranges, to estimate ranges of inverse variables.

xsample, to randomly sample the lsei problem.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# The probability distribution of vertebrate and invertebrate
# food in the diet of Mink
# food items of Mink are (in that order):

# fish mussels crabs shrimp rodents amphipods ducks
# V    I       I     I      V       I         V 
# V= vertebrate, I = invertebrate

# In matrix form:
VarA <- matrix(ncol = 7, byrow = TRUE, data = c(
        0, 1, 1, 1, 0, 1, 0,   # invertebrates  
        1, 0, 0, 0, 1, 0, 1))  # vertebrates

# first sample the Minkdiet problem
E <- rbind(Minkdiet$Prey, rep(1, 7))
F <- c(Minkdiet$Mink, 1)
X <- xsample(E = E, F = F, G = diag(7), H = rep(0, 7), iter = 1000)$X

#then determine Diet Composition in terms of vertebrate and invertebrate food
DC <- varsample(X = X, EqA = VarA)
hist(DC[,1], freq = FALSE, xlab = "fraction",
     main = "invertebrate food in Mink diet", col = "lightblue")

limSolve documentation built on Nov. 12, 2019, 3 p.m.