Package colf. October 9, 2017

Similar documents
Package cattonum. R topics documented: May 2, Type Package Version Title Encode Categorical Features

Package fastdummies. January 8, 2018

Package glmnetutils. August 1, 2017

Package vinereg. August 10, 2018

Package ECctmc. May 1, 2018

Package robotstxt. November 12, 2017

Package cosinor. February 19, 2015

Package triebeard. August 29, 2016

Package tidyimpute. March 5, 2018

Package validara. October 19, 2017

Package nngeo. September 29, 2018

Package assertr. R topics documented: February 23, Type Package

Package labelvector. July 28, 2018

Package datasets.load

Package milr. June 8, 2017

Package readxl. April 18, 2017

Package geojsonsf. R topics documented: January 11, Type Package Title GeoJSON to Simple Feature Converter Version 1.3.

Package gppm. July 5, 2018

Package pwrab. R topics documented: June 6, Type Package Title Power Analysis for AB Testing Version 0.1.0

Package ezsummary. August 29, 2016

Package reghelper. April 8, 2017

Package knitrprogressbar

Package sqlscore. April 29, 2018

Package interplot. R topics documented: June 30, 2018

Package gggenes. R topics documented: November 7, Title Draw Gene Arrow Maps in 'ggplot2' Version 0.3.2

Package goodpractice

Package repec. August 31, 2018

Package ggimage. R topics documented: November 1, Title Use Image in 'ggplot2' Version 0.0.7

Package BiDimRegression

Package condusco. November 8, 2017

Package splines2. June 14, 2018

Package embed. November 19, 2018

Package censusr. R topics documented: June 14, Type Package Title Collect Data from the Census API Version 0.0.

Package kerasformula

Package docxtools. July 6, 2018

Package rwars. January 14, 2017

Package modmarg. R topics documented:

Package lumberjack. R topics documented: July 20, 2018

Package keyholder. May 19, 2018

Package fitbitscraper

Package caretensemble

Package svalues. July 15, 2018

Package purrrlyr. R topics documented: May 13, Title Tools at the Intersection of 'purrr' and 'dplyr' Version 0.0.2

Package TANDEM. R topics documented: June 15, Type Package

Package nima. May 23, 2018

Package ggimage. R topics documented: December 5, Title Use Image in 'ggplot2' Version 0.1.0

Package zeallot. R topics documented: September 28, Type Package

Package SEMrushR. November 3, 2018

Package widyr. August 14, 2017

Package virustotal. May 1, 2017

Package lgarch. September 15, 2015

Package canvasxpress

Package mixsqp. November 14, 2018

Package messaging. May 27, 2018

Package balance. October 12, 2018

Package sfdct. August 29, 2017

Package stapler. November 27, 2017

Package tibble. August 22, 2017

Package spark. July 21, 2017

Package bigreadr. R topics documented: August 13, Version Date Title Read Large Text Files

Package pdfsearch. July 10, 2018

Package glue. March 12, 2019

Package rpst. June 6, 2017

Package loggit. April 9, 2018

Package splithalf. March 17, 2018

Package arulescba. April 24, 2018

Package sfc. August 29, 2016

Package vip. June 15, 2018

Package raker. October 10, 2017

Package autocogs. September 22, Title Automatic Cognostic Summaries Version 0.1.1

Package GWRM. R topics documented: July 31, Type Package

Package rgho. R topics documented: January 18, 2017

Package barcoder. October 26, 2018

Package semver. January 6, 2017

Package editdata. October 7, 2017

Package githubinstall

Package queuecomputer

Package C50. December 1, 2017

Package rsppfp. November 20, 2018

Package dbx. July 5, 2018

Package kdtools. April 26, 2018

Package datapasta. January 24, 2018

Package strat. November 23, 2016

Package Cubist. December 2, 2017

Package catenary. May 4, 2018

Package dotwhisker. R topics documented: June 28, Type Package

Package rfsa. R topics documented: January 10, Type Package

Package eply. April 6, 2018

Package redlistr. May 11, 2018

Package internetarchive

Package lucid. August 24, 2018

Package profvis. R topics documented:

Package condformat. October 19, 2017

Package edfreader. R topics documented: May 21, 2017

Package TrafficBDE. March 1, 2018

Package ggloop. October 20, 2016

Package shinyfeedback

Package projector. February 27, 2018

Package BiocManager. November 13, 2018

Package geneslope. October 26, 2016

Transcription:

Type Package Package colf October 9, 2017 Title Constrained Optimization on Linear Function Version 0.1.3 URL https://github.com/lyzander/colf BugReports https://github.com/lyzander/colf/issues Depends R (>= 3.2.0), nlsr, stats, utils Performs least squares constrained optimization on a linear objective function. It contains a number of algorithms to choose from and offers a formula syntax similar to lm(). License MIT + file LICENSE LazyData TRUE RoxygenNote 5.0.1 Suggests testthat, knitr, rmarkdown VignetteBuilder knitr NeedsCompilation no Author Theo Boutaris [aut, cre, cph] Maintainer Theo Boutaris <theo.boutaris@lyzander.com> Repository CRAN Date/Publication 2017-10-09 20:24:44 UTC R topics documented: coef.colf_nlxb........................................ 2 colf_nls........................................... 2 colf_nlxb.......................................... 4 construct_formula...................................... 6 fitted.colf_nlxb....................................... 7 predict.colf_nls....................................... 8 predict.colf_nlxb...................................... 9 print.colf_nlxb....................................... 10 residuals.colf_nlxb..................................... 10 summary.colf_nlxb..................................... 11 1

2 colf_nls Index 12 coef.colf_nlxb Coefficients for colf_nlxb Coefficients for colf_nlxb ## S3 method for class 'colf_nlxb' coef(object,...) object A colf_nlxb object i.e. the result of running colf_nlxb A vector with the coefficients mymod <- colf_nlxb(mpg ~ hp + cyl, mtcars) #coefficients coef(mymod) colf_nls Non linear Least Squares Optimization on a Linear Objective Function Non linear least squares optimization using the port algorithm on a linear objective function. colf_nls(formula, data, start = NULL, trace = FALSE, control = NULL, na.action = c("na.omit", "na.fail", "na.exclude"), lower = -Inf, upper = Inf,...)

colf_nls 3 formula data Details start trace control na.action lower upper The formula. This has the same syntax and supports the same features as the formula in lm. See examples. A data frame containing the data of the variables in the formula. An atomic vector of same length as the number of parameters. If not provided a cheap guess will be made. If categorical variables are included these need to be takent into consideration as number of categories minus one. See examples and details. Logical. Defaults to FALSE. Set to TRUE if you want the intermediate progress to be reported an optional list of control settings. See nls.control for the names of the settable control values and their effect. A function which indicates what should happen if NAs are present in the data set. Defaults to options( na.action ). na.fail, or na.exclude can be used. Lower bounds of the parameters (atomic vector). If a single number, this will be applied to all parameters. Defaults to -Inf (unconstrained). Upper bounds of the parameters (atomic vector). If a single number, this will be applied to all parameters. Defaults to Inf (unconstrained).... Other arguments passed on to optimiser colf_nls uses nls, in an attempt to find the minimum of the residual sum of squares. The algorithm is applied on a linear objective function. The function provides an easy way to apply the optimizer on a linear objective function in a similar way to lm. start, lower and upper, if provided, can be either an atomic vector which has the same length as the number of parameters or a single number which will be replicated to match the length of the parameters. If categorical variables exist in the function these will be dummified. Out of one categorical variable, n - 1 will be created where n is the total number of categories in the variable. This needs to be taken into account when providing an atomic vector for start, lower or upper. Also, as with lm an intercept will be added which also needs to be taken into account. See Also Same as nls nls, nls.control #no constraints colf_nls(mpg ~ cyl + disp, mtcars)

4 colf_nlxb #no intercept colf_nls(mpg ~ 0 + cyl + disp, mtcars) #including categorical variables. These will be dummified. colf_nls(sepal.length ~ Sepal.Width + Species, iris) #lower boundary will be replicated for all parameters colf_nls(sepal.length ~ Sepal.Width + Species, iris, lower = 0.5) #species is categorical and contains 3 categories, thus we need to specify 4 lower bounds: #the first one for the intercept. #the second one for Sepal.Width #the two next for the dummy variables constructed from Species. colf_nls(sepal.length ~ Sepal.Width + Species, iris, lower = rep(0.5, 4)) colf_nlxb Nash Variant of the Marquardt algorithm on a linear objective function Non linear least squares solution via qr linear solver on a linear objective function. colf_nlxb(formula, data, start = NULL, trace = FALSE, lower = -Inf, upper = Inf, na.action = c("na.omit", "na.fail", "na.exclude"), masked = NULL, control = NULL,...) formula data start trace lower upper na.action The formula. This has the same syntax and supports the same features as the formula in lm. See examples. A data frame containing the data of the variables in the formula. An atomic vector of same length as the number of parameters. If not provided a cheap guess will be made. If categorical variables are included these need to be takent into consideration as number of categories minus one. See examples and details. Logical. Defaults to FALSE. Set to TRUE if you want the intermediate progress to be reported Lower bounds of the parameters (atomic vector). If a single number, this will be applied to all parameters. Defaults to -Inf (unconstrained). Upper bounds of the parameters (atomic vector). If a single number, this will be applied to all parameters. Defaults to Inf (unconstrained). A function which indicates what should happen if NAs are present in the data set. Defaults to options( na.action ). na.fail, or na.exclude can be used.

colf_nlxb 5 Details masked control Character vector of parameter names. These parameters will not be altered by the algorithm. A list of controls for the algorithm. These are: watch - Monitor progress. Logical, defaults to FALSE phi - Adds phi*identity to Jacobian inner product. Defaults to 1. lamda - Initial Marquardt adjustment. Defaults to 0.0001. offset - Shift to test floating point equality. Defaults to 100. laminc - Factor to use to increase lamda. Defaults to 10. lamdec - Factor to use to decrease lamda (lamdec / laminc). Defaults to 4. femax - Maximum evaluations of sum of squares function. Defaults to 10000. jemax - Maximum evaluations of the Jacobian. Defaults to 5000. rofftest - Use a termination of the relative offset orthogonality type. smallsstest - Exit the function if the sum of squares falls below (100 *.Machine$double.eps)^4 times the initial sumsquares. Defaults to TRUE.... Other arguments passed on to optimiser colf_nlxb uses Nash s (Nash, 1979) variant of the Marquardt algorithm, in an attempt to find the minimum of the residual sum of squares. The algorithm is applied on a linear objective function. The function provides an easy way to apply the optimizer on a linear objective function in a similar way to lm. start, lower and upper, if provided, can be either an atomic vector which has the same length as the number of parameters or a single number which will be replicated to match the length of the parameters. If categorical variables exist in the function these will be dummified. Out of one categorical variable, n - 1 will be created where n is the total number of categories in the variable. This needs to be taken into account when providing an atomic vector for start, lower or upper. Also, as with lm an intercept will be added which also needs to be taken into account. See Also Same as nlxb nlxb #no constraints colf_nlxb(mpg ~ cyl + disp, mtcars) #no intercept colf_nlxb(mpg ~ 0 + cyl + disp, mtcars) #including categorical variables. These will be dummified.

6 construct_formula colf_nlxb(sepal.length ~ Sepal.Width + Species, iris) #lower boundary will be replicated for all parameters colf_nlxb(sepal.length ~ Sepal.Width + Species, iris, lower = 0.5) #species is categorical and contains 3 categories, thus we need to specify 4 lower bounds: #the first one for the intercept. #the second one for Sepal.Width #the two next for the dummy variables constructed from Species. colf_nlxb(sepal.length ~ Sepal.Width + Species, iris, lower = rep(0.5, 4)) construct_formula Construct an nls-compatible formula from an lm style formula Construct an nls-compatible formula from an lm style formula construct_formula(formula, data) formula data The formula. This has the same syntax and supports the same features as the formula in lm. See examples. A data frame containing the data of the variables in the formula. Details construct_formula creates the parameters needed for the formula to be compatible with nls style functions. It also creates and returns the modelling set. construct_formula will make syntactically valid names (if applicable) otherwise the optimizers will fail. To make these names make.names is used. Check examples. See Also A list of three elements: model_formula - An nls compatible formula model_data - The modelling set created (inlcuding dummy variables, if any) x_param_names - The names of the parameters nls, make.names

fitted.colf_nlxb 7 #simple syntax construct_formula(mpg ~ hp + cyl, mtcars) #example of make.names to create syntactically valid names make.names('(foo/^@bar)') #function will create syntactically valid names (if applicable) #otherwise the optimizers will fail construct_formula(mpg ~ I(hp + cyl), mtcars) construct_formula(mpg ~ (hp + cyl + disp)^3, mtcars) fitted.colf_nlxb Fitted values for colf_nlxb Fitted values for colf_nlxb ## S3 method for class 'colf_nlxb' fitted(object,...) object A colf_nlxb object i.e. the result of running colf_nlxb A vector with the fitted values mymod <- colf_nlxb(mpg ~ hp + cyl, mtcars) #fitted values fitted(mymod)

8 predict.colf_nls predict.colf_nls Predict method for colf_nls Predict method for colf_nls ## S3 method for class 'colf_nls' predict(object, newdata,...) object newdata A colf_nls object A new data.frame which contains the same column names and classes as the original data.frame Details predict.colf_nls will use the fit model to predict on a new data set. When using predict.colf_nls make sure the column names and classes of the new data set are the same as the data the model was trained on. A vector with the predictions mymod <- colf_nls(mpg ~ hp + cyl, mtcars) #prediction predict(mymod, mtcars)

predict.colf_nlxb 9 predict.colf_nlxb Predict method for colf_nlxb Predict method for colf_nlxb ## S3 method for class 'colf_nlxb' predict(object, newdata,...) object newdata A colf_nls object A new data.frame which contains the same column names and classes as the original data.frame Details predict.colf_nlxb will use the fit model to predict on a new data set. When using predict.colf_nlxb make sure the column names and classes of the new data set are the same as the data the model was trained on. A vector with the predictions mymod <- colf_nlxb(mpg ~ hp + cyl, mtcars) #prediction predict(mymod, mtcars)

10 residuals.colf_nlxb print.colf_nlxb colf_nlxb Print method colf_nlxb Print method ## S3 method for class 'colf_nlxb' print(x,...) x Printing the colf_nlxb object A colf_nlxb object i.e. the result of running colf_nlxb mymod <- colf_nlxb(mpg ~ hp + cyl, mtcars) #print print(mymod) residuals.colf_nlxb Residuals for colf_nlxb Residuals for colf_nlxb ## S3 method for class 'colf_nlxb' residuals(object,...) object A colf_nlxb object i.e. the result of running colf_nlxb

summary.colf_nlxb 11 A vector with the residuals mymod <- colf_nlxb(mpg ~ hp + cyl, mtcars) #residuals residuals(mymod) resid(mymod) summary.colf_nlxb colf_nlxb Summary colf_nlxb Summary ## S3 method for class 'colf_nlxb' summary(object,...) object The summary of the model A colf_nlxb object i.e. the result of running colf_nlxb mymod <- colf_nlxb(mpg ~ hp + cyl, mtcars) #summary summary(mymod)

Index coef.colf_nlxb, 2 colf_nls, 2 colf_nlxb, 4 construct_formula, 6 fitted.colf_nlxb, 7 make.names, 6 nls, 3, 6 nls.control, 3 nlxb, 5 predict.colf_nls, 8 predict.colf_nlxb, 9 print.colf_nlxb, 10 residuals.colf_nlxb, 10 summary.colf_nlxb, 11 12