The attached function working fine with R 1.3.0 but giving problem with R 1.5.1 (PR#1964)
stakb@nus.edu.sg
stakb@nus.edu.sg
Fri, 30 Aug 2002 10:10:41 +0200 (MET DST)
Full_Name: Kaushik Bhattacharyya
Version: 1.5.1
OS: Solaris
Submission from: (NULL) (137.132.3.10)
Main R-function used:
pp1
function(X)
{
x_as.matrix(X)
trial_function(a)
{
clusproj(x,a)
}
test.nlm_nlm(trial,rep(1,ncol(X)))
theta_test.nlm$estimate
theta_theta/sqrt(sum(theta^2))
cluster.index_round(1/test.nlm$min,6)
# print the results
###############
cat(paste("Projection direction = (",paste(round(theta,6),
collapse=","),")",sep=""),"\n")
cat("Projection index =",cluster.index,"\n")
##################
w <- clusterproj(x,theta)
# define first cluster break
n.break <- seq(w)[round(w,6)>=round(cluster.index,6)]
n.ord <- order(x%*%theta)
A.ndx <- n.ord[seq(n.break)]
B.ndx <- n.ord[seq(n.break+1,dim(x)[1])]
print(sort(A.ndx))
print(sort(B.ndx))
}
Functions in the main function:
clusterproj
function(X,a) {
a <- a/sqrt(sum(a^2))
XS <- sort(X%*%a)
n <- length(XS)
w <- (seq(n-1)*mean(XS)-cumsum(XS[seq(n-1)]))*diff(XS)/((n-1)*var(XS))
w
}
clusproj
function(X,a) {
a <- a/sqrt(sum(a^2))
XS <- sort(X%*%a)
n <- length (XS)
w <- (seq(n
-1)*mean(XS)-cumsum(XS[seq(n-1)]))*diff(XS)/((n-1)*var(XS))
1/max(w)
}
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._