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 9, 2023
1 parent 043c9d6 commit a7af812
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 6 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-07
Date: 2023-11-09
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 @@ -237,7 +237,7 @@ NNS.M.reg <- function (X_n, Y, factor.2.dummy = TRUE, order = NULL, stn = NULL,
foreach::registerDoSEQ()
invisible(data.table::setDTthreads(0, throttle = NULL))
} else {
distances <- distances[, DISTANCES := NNS.distance(rpm = REGRESSION.POINT.MATRIX, dist.estimate = .SD, type = dist, k = n.best, class = type)[1], by = 1:nrow(point.est)]
distances <- distances[, DISTANCES := NNS.distance(rpm = REGRESSION.POINT.MATRIX, dist.estimate = .SD, type = dist, k = n.best, class = type)[1], by = 1:nrow(point.est)]

DISTANCES <- as.numeric(unlist(distances$DISTANCES))
}
Expand Down
7 changes: 3 additions & 4 deletions R/NNS_Distance.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ NNS.distance <- function(rpm, dist.estimate, type, k, class){

if(type!="FACTOR"){
rpm <- rbind(as.list(t(dist.estimate)), rpm[, .SD, .SDcols = 1:n])
rpm <- rpm[, names(rpm) := lapply(.SD, function(b) ((((b - min(b))^2) / max(1e-10, (max(b) - min(b))^2)) + (((b - min(b))) / max(1e-10, (max(b) - min(b)))))/2),
.SDcols = 1:n]
rpm <- rpm[, names(rpm) := lapply(.SD, function(b) NNS.rescale(b, 0, 1)), .SDcols = 1:n]
dist.estimate <- unlist(rpm[1, ])
rpm <- rpm[-1,]
}
Expand All @@ -35,11 +34,11 @@ NNS.distance <- function(rpm, dist.estimate, type, k, class){
M2 <- matrix(rep(raw.dist.estimate, l), byrow = T, ncol = n)

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

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

if(type=="FACTOR"){
Expand Down

0 comments on commit a7af812

Please sign in to comment.