nmfkc.kernel constructs a kernel matrix from covariate matrices.
It supports Gaussian, Exponential, Periodic, Linear, Normalized Linear, and Polynomial kernels.
nmfkc.kernel(
U,
V = NULL,
kernel = c("Gaussian", "Exponential", "Periodic", "Linear", "NormalizedLinear",
"Polynomial"),
...
)Satoh, K. (2024). Applying Non-negative Matrix Factorization with Covariates to the Longitudinal Data as Growth Curve Model. arXiv preprint arXiv:2403.05359. https://arxiv.org/abs/2403.05359
Covariate matrix \(U(K,N) = (u_1, \dots, u_N)\). Each row may be normalized in advance.
Covariate matrix \(V(K,M) = (v_1, \dots, v_M)\), typically used for prediction. If NULL, the default is U.
Kernel function to use. Default is "Gaussian". Options are "Gaussian", "Exponential", "Periodic", "Linear", "NormalizedLinear", and "Polynomial".
Additional arguments passed to the specific kernel function (e.g., beta, degree).
Kernel matrix \(A(N,M)\).
nmfkc.kernel, nmfkc.cv
# install.packages("remotes")
# remotes::install_github("ksatohds/nmfkc")
# Example.
Y <- matrix(cars$dist,nrow=1)
U <- matrix(c(5,10,15,20,25),nrow=1)
V <- matrix(cars$speed,nrow=1)
A <- nmfkc.kernel(U,V,beta=28/1000)
dim(A)
#> [1] 5 50
result <- nmfkc(Y,A,Q=1)
#> Y(1,50)~X(1,1)C(1,5)A(5,50)=XB(1,50)...
#> 0sec
plot(as.vector(V),as.vector(Y))
lines(as.vector(V),as.vector(result$XB),col=2,lwd=2)