R/SRM_COMPUTE_ULS_FUNCTION.R

Defines functions SRM_COMPUTE_ULS_FUNCTION

## File Name: SRM_COMPUTE_ULS_FUNCTION.R
## File Version: 0.19


SRM_COMPUTE_ULS_FUNCTION <- function(args_eval, inv_type=NULL)
{
    ey <- args_eval$ey   # y - mu_y
    SIGMA_Y <- args_eval$SIGMA_Y
    muy <- args_eval$muy
    ny <- length(ey)
    f1 <- sum(ey^2) / ny
    f1 <- 0
    # cross-product matrix
    cpm <- ey * matrix(ey, nrow=ny, ncol=ny, byrow=TRUE)
    cov_resid <- cpm - SIGMA_Y  # observed minus expected

    # least squares function for covariance
    f2 <- sum(cov_resid^2) / ny
    ll <- f1 + f2
    #-- output
    res <- list(ll=-ll, cov_resid=cov_resid)
    return(res)
}

Try the srm package in your browser

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

srm documentation built on Nov. 3, 2022, 5:06 p.m.