R/UndoPointsUpdatemp.R

"UndoPointsUpdatemp" <-
function(X,coeff,nbrs,newnbrs,index,remove,r,N,pointsin,gamweights,lengths,lengthrem){

alpha<-matrix(0,1,length(nbrs))

pos<-NULL
for (i in 1:length(nbrs)){
	pos[i]<-min(which(newnbrs==nbrs[i]))
}


if ((r>1)&(r<=N)) {
	alpha<-lengths[index]*lengthrem/(sum(lengths[index]^2))
	coeff[nbrs]<-coeff[nbrs]-alpha*coeff[remove]
	lengths[index]<-as.row(lengths[index])
	prod<-gamweights[pos]*lengthrem
	prod<-as.row(prod)
	lengths[index]<-lengths[index]-prod
}

if ((r==1)|(r==(N+1))) {
	q<-which(pointsin==nbrs)
	alpha<-lengthrem/lengths[q]
	coeff[pointsin[q]]<-coeff[pointsin[q]]-alpha*coeff[remove]
	lengths[q]<-lengths[q]-lengthrem
} 

return(list(coeff=coeff,lengths=lengths,alpha=alpha))
}

Try the adlift package in your browser

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

adlift documentation built on March 31, 2023, 11:03 p.m.