Example #1
0
SEXP R_ExpectCovarLinearStatistic(SEXP x, SEXP y, SEXP weights,
                                  SEXP expcovinf) {

    SEXP ans;
    int n, p, q, pq;

    /* determine the dimensions and some checks */

    n  = nrow(x);
    p  = ncol(x);
    q  = ncol(y);
    pq = p * q;

    if (nrow(y) != n)
        error("y does not have %d rows", n);
    if (LENGTH(weights) != n)
        error("vector of case weights does not have %d elements", n);

    PROTECT(ans = NEW_OBJECT(MAKE_CLASS("ExpectCovar")));
    SET_SLOT(ans, coin_expectationSym,
             PROTECT(allocVector(REALSXP, pq)));
    SET_SLOT(ans, coin_covarianceSym,
             PROTECT(allocMatrix(REALSXP, pq, pq)));

    C_ExpectCovarLinearStatistic(REAL(x), p, q,
        REAL(weights), n, expcovinf, ans);

    UNPROTECT(3);
    return(ans);
}
Example #2
0
void C_LinStatExpCov(const double *x, const int p,
                     const double *y, const int q,
                     const double *weights, const int n,
                     const int cexpcovinf, SEXP expcovinf, SEXP ans) {

    C_LinearStatistic(x, p, y, q, weights, n, 
                      REAL(GET_SLOT(ans, PL2_linearstatisticSym)));
    if (cexpcovinf)
        C_ExpectCovarInfluence(y, q, weights, n, expcovinf);
    C_ExpectCovarLinearStatistic(x, p, y, q, weights, n, 
                                 expcovinf, ans);
}