imputeWLS: impute using WLS

Usage Arguments Examples

Usage

1
imputeWLS(y, k, ginv, sinv, mu, eps = 1e-06, itmax = 100, verbose = FALSE)

Arguments

y
k
ginv
sinv
mu
eps
itmax
verbose

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function(y,k,ginv,sinv,mu,eps=1e-6,itmax=100,verbose=FALSE)
{
n<-nrow(y); m<-ncol(y); itel<-1
res<-y-mu; ras<-ginv%*%res%*%sinv; ff<-sum(ras*res)
wgt<-outer(diag(ginv),diag(sinv))
repeat {
    thmax<-0
    for (i in 1:n) for (j in 1:m) {
	    if (!is.na(k[i,j])) next()
	    rij<-ras[i,j]; wij<-wgt[i,j]
        th<--rij/wij
        thmax<-max(thmax,abs(th))
        z[i,j]<-z[i,j]+th
        ff<-ff-(rij^2)/wij
        ras<-ras+th*outer(ginv[,i],sinv[,j])
        }
    if (verbose)
           cat("itel",formatC(itel,format="d",width=4)," maxth",formatC(thmax,format="f",digits=8,width=15)," func",formatC(ff,format="f",digits=8,width=15),"\n")
    if ((thmax < eps) || (itel == itmax)) break()
    itel<-itel+1
    }
return(y)
  }

mnbem documentation built on May 2, 2019, 6:16 p.m.

Related to imputeWLS in mnbem...