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