1\name{mkrk.nominal}
2\alias{mkrk.nominal}
3\alias{mkrk.ordinal}
4\title{
5    Crafting Building Blocks for Discrete Splines
6}
7\description{
8    Craft numerical functions to be used by \code{mkterm} to assemble
9    model terms involving factors.
10}
11\usage{
12mkrk.nominal(levels)
13mkrk.ordinal(levels)
14}
15\arguments{
16    \item{levels}{Levels of the factor.}
17}
18\details{
19    For a nominal factor with levels \eqn{1,2,\dots,k}, the level means
20    \eqn{f(i)} will be shrunk towards each other through a penalty
21    proportional to
22    \deqn{(f(1)-f(.))^2+\dots+(f(k)-f(.))^2}
23    where \eqn{f(.)=(f(1)+\dots+f(k))/k}.
24
25    For a ordinal factor with levels \eqn{1<2<\dots<k}, the level means
26    \eqn{f(i)} will be shrunk towards each other through a penalty
27    proportional to
28    \deqn{(f(1)-f(2))^2+\dots+(f(k-1)-f(k))^2}
29}
30\value{
31    A list of two elements.
32    \item{fun}{Function definition.}
33    \item{env}{Portable local constants derived from the arguments.}
34}
35\note{
36    \code{mkrk.x} create a bivariate function
37    \code{fun(x,y,env,outer=FALSE)}, where \code{x}, \code{y} are real
38    arguments and local constants can be passed in through \code{env}.
39}
40\seealso{
41    \code{\link{mkterm}}, \code{\link{mkrk.cubic}}, and
42    \code{\link{mkrk.tp}}.
43}
44\keyword{internal}
45