Contents

Setting

Consider the standard linear model:

$$ y = X\beta + \epsilon,\ \epsilon\sim(0,\sigma^2) $$

Partition the regression coefficient $\beta=(\beta_{1},\beta_{2})$. Suppose interest lies in testing whether $\beta_{1}$ is fixed at a reference value. This package implements score tests of $H_{0}:\beta_{1}=\beta_{1}^{\dagger}$.

Example Data

Below, data are simulated for $n=10^{3}$ subjects. The outcome $y_{i}\in\mathbb{R}$ is normally distributed with unit variance. The subject-specific means depend on an intercept and four covariates. The function Fit.LinReg provides an implementation of linear regression.

library(LiST);
# Generate data
set.seed(102);
# Observations
n = 1e3;
# Design
X = cbind(1,matrix(rnorm(4*n),nrow=n));
colnames(X) = c("int",paste0("x",seq(1:4)));
# Regression coefficient
b = c(1,-0.1,0.2,-0.1,0);
# Linear predictor
h = as.numeric(X%*%b);
# Outcome
y = h+rnorm(n);
# Fitted linear model
M = Fit.LinReg(y=y,X=X);
show(M);

Score Tests

Standard Test

Score conducts a standard score test, using either the asymptotic variance or perturbation to estimate a $p$-value. The hypothesis test is specified using a logical vector L. Elements of L that are constrained under the null are set to TRUE, those which are estimated under the null are set to FALSE. At least one element of L must be TRUE (a test must be specified), and at least one element of L must be FALSE (the null model must be estimable). Below, hypotheses are tested on the example data.

cat("Score test of b4=0\n");
Score(y=y,X=X,L=c(F,F,F,F,T),method="asymptotic");
Score(y=y,X=X,L=c(F,F,F,F,T),method="perturbation");
cat("\n");
cat("Score test of b2=0\n");
Score(y=y,X=X,L=c(F,F,T,F,F),method="asymptotic");
Score(y=y,X=X,L=c(F,F,T,F,F),method="perturbation");
cat("\n");
cat("Score test of b1=b3=-0.1\n");
Score(y=y,X=X,L=c(F,T,F,T,F),b10=c(-0.1,-0.1),method="asymptotic");
Score(y=y,X=X,L=c(F,T,F,T,F),b10=c(-0.1,-0.1),method="perturbation");
cat("\n");

Weighted Score Test

wScore conducts a score test that affords different components of the hypothesis different weights. The following assesses $H_{0}:\beta_{3}=\beta_{4}=0$, equivalently $H_{0}:(\beta_{3}=0)\land(\beta_{4}=0)$, giving different weights to the different components. The first component $(\beta_{3}=0)$ is false, while the second component $(\beta_{4}=0)$ is true. The overall hypothesis is false. Whether or not the weighted test rejects depends on which component of the hypothesis is afforded more weight.

cat("Weighted score test of b3=b4=0\n");
wScore(y=y,X=X,L=c(F,F,F,T,T),w=c(10,1),method="asymptotic");
wScore(y=y,X=X,L=c(F,F,F,T,T),w=c(10,1),method="perturbation");
cat("\n");
cat("Weighted score test of b3=b4=0\n");
wScore(y=y,X=X,L=c(F,F,T,F,T),w=c(1,10),method="asymptotic");
wScore(y=y,X=X,L=c(F,F,T,F,T),w=c(1,10),method="perturbation");


zrmacc/LiST documentation built on May 9, 2019, 8:20 a.m.