R/lmfitSaws.R

Defines functions `lmfitSaws`

`lmfitSaws`<-function(x,y){
    K<-length(y)
    p<-dim(x)[[2]]
    beta<- solve(t(x) %*% x ) %*% t(x) %*% matrix(y,K,1)
    resid<- y - x %*% beta
    omega<-array(NA,dim=c(K,p,p))
    u<-matrix(NA,K,p)
    for (i in 1:K){
        omega[i,,]<- matrix(x[i,],p,1) %*% matrix(x[i,],1,p) 
        u[i,]<- x[i,]*resid[i]
    }
    out<-list(coefficients=beta,u=u,omega=omega)
    out
}

Try the saws package in your browser

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

saws documentation built on June 24, 2022, 1:07 a.m.