% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/KNNRLD.R
\name{KNNRLD}
\alias{KNNRLD}
\title{Standard K-Nearest Neighbor Regression for Longitudinal Data}
\usage{
KNNRLD(xnew, y, x, k = 5)
}
\arguments{
\item{xnew}{A matrix of predictor values for prediction (test set).}

\item{y}{A matrix or data frame of longitudinal responses (training set).}

\item{x}{A matrix or data frame of training predictor values.}

\item{k}{Number of nearest neighbors to use. Can be a scalar or a vector.}
}
\value{
A list of matrices with predicted values for each value of k.
Each matrix has dimensions nrow(xnew) x ncol(y).
}
\description{
This function performs KNN regression for longitudinal data without clustering.
It predicts longitudinal outcomes for new observations based on the weighted
average of their k nearest neighbors in the predictor space.
}
\examples{
\donttest{
set.seed(123)
n <- 30
T <- 3
d <- 2
x <- matrix(runif(n * d), nrow = n)
y <- matrix(rnorm(n * T), nrow = n)
train_idx <- sample(1:n, 20)
test_idx <- setdiff(1:n, train_idx)
pred <- KNNRLD(
  xnew = x[test_idx, ],
  y = y[train_idx, ],
  x = x[train_idx, ],
  k = 3
)
head(pred[[1]])
}

}
