Learn R Programming

optR (version 1.2.5)

optR.formula: Optimization & predictive modelling Toolsets

Description

optR package to perform the optimization using numerical methods

Usage

"optR"(formula, data = list(), weights = NULL, method = c("gauss, LU, gaussseidel", "cgm", "choleski"), iter = 500, tol = 1e-07, keep.data = TRUE, contrasts = NULL, ...)

Arguments

formula
: formula to build model
data
: data used to build model
weights
: Observation weights
method
: "gauss" for gaussian elimination and "LU" for LU factorization
iter
: Number of Iterations
tol
: Convergence tolerance
keep.data
: If TRUE returns input data
contrasts
: Data frame contract values
...
: S3 Class

Value

U : Decomposed matrix for Gauss-ELimination Ax=b is converted into Ux=c where U is upper triangular matrix for LU decomposition U contain the values for L & U decomposition LUx=bc : transformed b & for LU transformation c is y from equation Ux=yestimates : Return x values for linear system

Examples

Run this code
# Solving equation Ax=b
b<-matrix(c(-14,36, 6), nrow=3,ncol=1,byrow=TRUE)
A<-matrix(c(6,-4,1, -4,6,-4,1,-4,6), nrow=3,ncol=3, byrow = TRUE)
Z<-optR(b~A-1, method="gauss") # -1 to remove the constant vector

Z<-optR(b~A-1, method="LU") # -1 to remove the constant vector

require(utils)
set.seed(129)
n <- 10 ; p <- 4
X <- matrix(rnorm(n * p), n, p) # no intercept!
y <- rnorm(n)
data<-cbind(X, y)
colnames(data)<-c("var1", "var2", "var3", "var4", "y")
Z<-optR(y~var1+var2+var3+var4+var1*var2-1, data=data.frame(data), method="cgm")

Run the code above in your browser using DataLab