R/calcA.R

Defines functions calcA

Documented in calcA

calcA <- function(X,bx,kernelx="g") {
  X <- as.matrix(X)
  n <- nrow(X)
  KK <- matrix(0,ncol=n,nrow=n)
  Ddemi <- rep(0,n)
  poids <- function(kernelx="g",X,bx,valx){
    X <- as.matrix(X)
    n <- nrow(X)
    p <- ncol(X)
    VALX <- matrix(rep(valx,n),ncol=p,byrow=TRUE)
    BX <- matrix(rep(bx,n),ncol=p,byrow=TRUE)
    MAT <- (X-VALX)/BX
    if(kernelx=="e"){noyau <- epane}
    if(kernelx=="g"){noyau <- gaussien}
    if(kernelx=="q"){noyau <- quartic}
    if(kernelx=="u"){noyau <- uniform}
    vv <- noyau(MAT)
    vv <- apply(vv,1,prod)
    return(W=vv)
  }
  for(i in 1:n){
    w <- poids(kernelx,X,bx,X[i,])
    KK[i,] <- w
    Ddemi[i] <- sqrt(1/sum(w))
  }
  A <- t(Ddemi*KK)*Ddemi
  return(list(A=A,Ddemi=Ddemi,df=sum(diag(A))))
}

Try the ibr package in your browser

Any scripts or data that you put into this service are public.

ibr documentation built on Sept. 13, 2023, 5:08 p.m.