Skip to content

Commit

Permalink
NNS 10.3 Beta
Browse files Browse the repository at this point in the history
  • Loading branch information
OVVO-Financial authored Nov 7, 2023
1 parent 0c192e2 commit 1bf94f4
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: NNS
Type: Package
Title: Nonlinear Nonparametric Statistics
Version: 10.3
Date: 2023-11-06
Date: 2023-11-07
Authors@R: c(
person("Fred", "Viole", role=c("aut","cre"), email="ovvo.financial.systems@gmail.com"),
person("Roberto", "Spadim", role=c("ctb"))
Expand Down
Binary file modified NNS_10.3.tar.gz
Binary file not shown.
Binary file modified NNS_10.3.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion R/Multivariate_Regression.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ NNS.M.reg <- function (X_n, Y, factor.2.dummy = TRUE, order = NULL, stn = NULL,
original.IVs <- X_n
original.DV <- Y
n <- ncol(original.IVs)

if(is.null(ncol(X_n))) X_n <- t(t(X_n))

if(is.null(names(Y))){
Expand Down
15 changes: 8 additions & 7 deletions R/NNS_Distance.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,25 @@ NNS.distance <- function(rpm, rpm_class, dist.estimate, type, k, class){
dist.estimate <- unlist(rpm[1, ])
rpm <- rpm[-1,]
}

rpm$y.hat <- y.hat

M <- matrix(rep(dist.estimate, l), byrow = T, ncol = n)
M2 <- matrix(rep(raw.dist.estimate, l), byrow = T, ncol = n)

if(type=="L2"){
rpm$Sum <- Rfast::rowsums( t((t(rpm[, 1:n]) - dist.estimate)^2) * ((l - (rpm_class == raw.dist.estimate))/l), parallel = parallel)
rpm$Sum <- Rfast::rowsums( ((t(t(rpm[, 1:n])) - M)^2) * ((l - (rpm_class == M2))/l), parallel = parallel)
}

if(type=="L1"){
rpm$Sum <- Rfast::rowsums(abs(t(t(rpm[, 1:n]) - dist.estimate)) * ((l - (rpm_class == raw.dist.estimate))/l), parallel = parallel)
rpm$Sum <- Rfast::rowsums(abs(t(t(rpm[, 1:n])) - M) * ((l - (rpm_class == M2))/l), parallel = parallel)
}

if(type=="FACTOR"){
rpm$Sum <- (1/l + ( Rfast::rowsums((rpm_class == raw.dist.estimate), parallel = parallel)))^-1
rpm$Sum <- (1/l + ( Rfast::rowsums((rpm_class == M2), parallel = parallel)))^-1
}

rpm$Sum[rpm$Sum == 0] <- 1e-10

rpm$y.hat <- y.hat

data.table::setkey(rpm, Sum)

ll <- min(k, l)
Expand Down

0 comments on commit 1bf94f4

Please sign in to comment.