cdlm: Linear model for compound decision problems

View source: R/cdlm.R

cdlmR Documentation

Linear model for compound decision problems

Description

Fits linear regression model that can incorporate covariates and structural information into a compound decision rule

Usage

cdlm(
  Y,
  s2,
  C = NULL,
  CY,
  CN = NULL,
  N = NULL,
  k3 = NULL,
  k4 = NULL,
  penalty = 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.

k3

third central moment of Y (n x 1)

k4

fourth central moment of Y (n x 1)

penalty

a vector c(p, M), constrains beta of regression model to have Lp norm at most M

Value

b

estimated regression coefficients

S

estimated covariance matrix of sqrt(n) (estimated beta - oracle beta)

est

estimated parameters of interest

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))

## no penalty
fit = cdlm(Y, s2, C, CY, CN, N, k3 = rep(0, n), k4 = 3 * s2^2)
mean((theta - fit$est)^2)
## z-scores
fit$b / sqrt(diag(fit$S) / n)

## add penalty
fit = cdlm(Y, s2, C, CY, CN, N, penalty = c(1, 0.1))
mean((theta - fit$est)^2)


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