
spliner(formula, data = NULL, method = "fmm", monotonic = FALSE)
connector(formula, data = NULL, method = "linear")
smoother(formula, data, span = 0.5, degree = 2, ...)
linearModel(formula, data, ...)
spline
.TRUE/FALSE
flag specifying whether the spline should
respect monotonicity in the datasqrt(age)
or log(income)
,
only the variable itself, e.g. age
or income
, is an argument to the function.linearModel
takes a linear combination of the vectors specified on the right-hand side.
It differs from project
in that linearModel
returns a function
whereas project
returns the coefficients. NOTE: An intercept term is not included
unless that is explicitly part of the formula with +1
. This conflicts with the
standard usage of formulas as found in lm
. Another option for creating
such functions is to combine lm
and makeFun
.
spliner
and connector
currently work for only one input variable.
project
method for formulas
if (require(mosaicData)) {
data(CPS85)
f <- smoother(wage ~ age, span=.9, data=CPS85)
f(40)
derivf <- D(f(age) ~ age)
derivf(40)
g <- linearModel(log(wage) ~ age + educ + 1, data=CPS85)
g(age=40, educ=12)
# an alternative way to define g (Note: + 1 is the default for lm().)
g2 <- makeFun(lm(log(wage) ~ age + educ, data=CPS85))
g2(age=40, educ=12)
dgdeduc <- D(g(age=age, educ=educ) ~ educ)
dgdeduc(age=40, educ=12)
x<-1:5; y=c(1, 2, 4, 8, 8.2)
f1 <- spliner(y ~ x)
f1(x=8:10)
f2 <- connector(x~y)
}
Run the code above in your browser using DataLab