cpm: Least squares estimates of a constrained polynomial...

Description Usage Arguments Value Examples

View source: R/constrained-polynomial-model.R

Description

Estimates univariate polynomials with parameters from a closed convex set. Some examples are shape constraints (e.g. montonicity, convexity) or simply linear parameter constraints such as β [1] >= 0.

Usage

1
2
cpm(formula, data, subset, weights, na.action, degree, constraint = NULL,
  oracle = NULL, start, c_region = c(-Inf, Inf), ...)

Arguments

formula

an object of class formula (or one that can be coerced to that class): a symbolic description of the model to be fitted.

data

an optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model. If not found in data, the variables are taken from environment(formula), typically the environment from which the function is called.

subset

NOT YET IMPLEMENTED an optional vector specifying a subset of observations to be used in the fitting process.

weights

NOT YET IMPLEMENTED.

na.action

a function which indicates what should happen when the data contain NAs. The default is set by the na.action setting of options, and is na.fail if that is unset. The 'factory-fresh' default is na.omit. Another possible value is NULL, no action. Value na.exclude can be useful.

degree

degree of polynomial to be fit.

constraint

an optional character string of "monotone" ("convex" coming soon).

oracle

an optional function of class oracle, returning TRUE when a given point is inside the constrained set and FALSE otherwise. See make_oracle.

start

intial value of COLS optimisation.

c_region

the applicable region for the constraint, default is c(-Inf,Inf), the real line.

...

arguments to be passed to cols_control.

Value

Constrained regression model with class creg. Currently a named list including objects: beta (parameter vector), fitted.values, residuals, and RSS.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
md <- cpm(y ~ x, degree = 5, constraint = "monotone", c_region = c(0,1))
print(md)
coef(md)
residuals(md)
fitted(md)

library(polynom)
fitted_pl <- polynomial(coef(md))
plot(fitted_pl, c(0,1))

## End(Not run)

bonStats/gcreg documentation built on May 20, 2019, 5:44 p.m.