% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/nmfkc.R
\name{nmfkc.kernel.beta.cv}
\alias{nmfkc.kernel.beta.cv}
\title{Optimize beta of the Gaussian kernel function by cross-validation}
\usage{
nmfkc.kernel.beta.cv(Y, rank = 2, U, V = NULL, beta = NULL, plot = TRUE, ...)
}
\arguments{
\item{Y}{Observation matrix \eqn{Y(P,N)}.}

\item{rank}{Rank of the basis matrix.}

\item{U}{Covariate matrix \eqn{U(K,N) = (u_1, \dots, u_N)}. Each row may be normalized in advance.}

\item{V}{Covariate matrix \eqn{V(K,M) = (v_1, \dots, v_M)}, typically used for prediction. If \code{NULL}, the default is \code{U}.}

\item{beta}{A numeric vector of candidate kernel parameters to evaluate via cross-validation.}

\item{plot}{Logical. If TRUE (default), plots the objective function values for each candidate \code{beta}.}

\item{...}{Additional arguments passed to \code{nmfkc.cv}.}
}
\value{
A list with components:
\item{beta}{The beta value that minimizes the cross-validation objective function.}
\item{objfunc}{Objective function values for each candidate \code{beta}.}
}
\description{
\code{nmfkc.kernel.beta.cv} selects the optimal beta parameter of the kernel function by applying cross-validation over a set of candidate values.
}
\examples{
# Example.
Y <- matrix(cars$dist,nrow=1)
U <- matrix(c(5,10,15,20,25),nrow=1)
V <- matrix(cars$speed,nrow=1)
nmfkc.kernel.beta.cv(Y,rank=1,U,V,beta=25:30/1000)
A <- nmfkc.kernel(U,V,beta=28/1000)
result <- nmfkc(Y,A,rank=1)
plot(as.vector(V),as.vector(Y))
lines(as.vector(V),as.vector(result$XB),col=2,lwd=2)
}
\seealso{
\code{\link{nmfkc.kernel.gaussian}}, \code{\link{nmfkc.kernel.beta.nearest.med}},
\code{\link{nmfkc.kernel}}
}
