swh:1:snp:16c54c84bc54885e783d4424d714e5cc82f479a1
Raw File
Tip revision: db8668b63745f624236e566437c198010990b082 authored by Roger Koenker on 02 May 2022, 16:42:02 UTC
version 5.93
Tip revision: db8668b
RB-r.R
# Convert H_0:  R beta = r  to an exclusion restriction a la Section 3.7.3 of QR book
# Note the typo in the definition of yt in that source!

if(require(MASS)){ # For Null
require(quantreg) # For Null
X <- cbind(1, matrix(rnorm(500),100,5))
y <- rnorm(100)
R <- matrix(rnorm(18),3,6)
r <- rep(1,3)
R <- t(R)
P <- MASS::Null(R)
Xt <- t(lsfit(P,t(X),intercept = FALSE)$coef)
Zt <- t(lsfit(R,t(X),intercept = FALSE)$coef)
yt <- y - Zt %*% r
f0 <- rq(yt ~ Xt - 1)
f1 <- rq(yt ~ Xt + Zt - 1)
T <- anova(f0,f1)
}

back to top