XYkZ: Helper function for fitting linear model for compound...

View source: R/cdlm.R

XYkZR Documentation

Helper function for fitting linear model for compound decision problems

Description

Calculates the design matrix X and other quantities that are used by the cdlm function

Usage

XYkZ(Y, s2, C = NULL, CY, CN = NULL, N = NULL)

Arguments

Y

observed data (n x 1)

s2

unbiased estimate of variance of Y (n x 1)

C

main effects in the linear regression (n x p_C)

CY

terms in the linear regression that interact with Y (n x p_Y)

CN

terms in the linear regression that interact with Y_i_k for i_k in the ith row of N. This should be a list of length q, where the kth item in the list is an n x p_k matrix.

N

neighbors of each index (n x q). This encodes structural information, where the ith row of N contains indices that are expected to be similar to the ith parameter of interest.

Value

X

design matrix

Yk

matrix of neighboring Y_k indicated by the N matrix

Z

vector Z used in the empirical risk function

Examples

n = 10
set.seed(1)
theta = sort(rnorm(n))
s2 = abs(theta) + runif(n)
Y = theta + rnorm(n, sd = sqrt(s2))
C = cbind(1, s2)
CY = cbind(1, 1 / s2)
N = cbind(c(n, 1:(n - 1)), c(2:n, 1))
CN = rep(list(matrix(1, n, 1)), ncol(N))
XYkZ(Y, s2, C, CY, CN, N)


sdzhao/cole documentation built on May 2, 2022, 9:42 a.m.