solveSystem: Solve a system of equations.

Description Usage Arguments Value Examples

View source: R/solver.R

Description

solveSystem returns a set of endogenous variables that solve the system.

Usage

1
2
solveSystem(formulas, endogenous, exogenous, lowerBounds = NULL,
  upperBounds = NULL, maxIterations = 100, maxError = 5e-09)

Arguments

formulas

A list of formulas

endogenous

A list of variables to be used in evaluation (variables may be scalars, vectors or matrices)

exogenous

A list of parameters to be used in evaluation

lowerBounds

A list of lower bounds for endogenous variables

upperBounds

A list of upper bounds for endogenous variables

maxIterations

A maximum number of times the Newton algorithm should be applied (default value = 100)

maxError

Maximum total absolute error of all equations (default value = 5e-9)

Value

A vector of real numbers

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
solveSystem(formulas =
          list(price = price ~ 0.3 * variablecost + coefficient1,
               variablecost  = variablecost ~ 0.5 * price + coefficient2),
       endogenous = list(price = 1, variablecost=0.4),
       exogenous = list(coefficient1=0.56, coefficient2=0.7))
solveSystem(formulas =
          list(price = price ~ 0.3 * variablecost + coefficient1,
               variablecost  = variablecost ~ 0.5 * price + coefficient2),
       endogenous = list(price = c(wheat=1, rice=4), variablecost=c(wheat=0.4, rice=0.2)),
       exogenous = list(coefficient1=c(wheat=0.56, rice=4), coefficient2=c(wehat=0.7, rice=0.9)))

mivanic/solveR documentation built on Nov. 7, 2019, 12:13 a.m.