if (FALSE) {
# Simple examples for iid data type
n <- 500
Z1 <- rexp(n,1)
Z2 <- rbinom(n,1,0.5)
Z <- cbind(Z1,Z2)
epsilon <- rnorm(n,0,1)
X <- runif(n,-2,1)
psi <- c(-1,0)
k <- length(psi)
PSI <- matrix(rep(psi,rep(n,k)),ncol=k)
XP <- matrix(rep(X,k),nrow=n)
XR <- cbind(1,X,pmax((XP-PSI),0),Z)
bet <- c(1,-1,3,-3,sqrt(3),-sqrt(3))
Y <- XR %*% bet + epsilon
# Estimation setting
tau <- 0.5
K.max <- 5
control <- fit.control(K.max = K.max)
Cn <- 1
mkqr.bea(y = Y, thre.x = X, cont.z = Z, tau = tau, Cn = Cn, control = control)
# Simple examples for longitudinal data
N <- 200
T <- 5
subject <- rep(1:N, each = T)
NT <- N * T
Z1 <- rexp(NT, 1)
Z2 <- rbinom(NT, 1, 0.5)
Z <- cbind(Z1, Z2)
epsilon <- rnorm(NT, 0, 1)
X <- runif(NT, -2, 1)
psi <- c(-1, 0)
k <- length(psi)
PSI <- matrix(rep(psi, rep(NT, k)), ncol = k)
a <- rnorm(N, 0, 1)
A <- rep(a, each = T)
XP <- matrix(rep(X, k), nrow = NT)
XR <- cbind(1, X, pmax((XP - PSI), 0), Z)
bet <- c(1, -1, 3, -3, sqrt(3), -sqrt(3))
Y <- XR %*% bet + A + epsilon
tau <- 0.5
k <- 2
# Example 1: the working independence estimator; the error structure is "general"
est.type <- "WI"
wi.type <- "Compound"
tau <- 0.5
K.max <- 5
control <- fit.control(K.max = K.max)
Cn <- 1
mkqr.bea(y = Y, thre.x = X, cont.z = Z, id = subject, tau = tau, Cn = Cn,
control = control, est.type = est.type, wi.type = wi.type)
# Example 2: the working correlated estimator; the correlation structure is "cs"
est.type <- "WC"
wc.type <- "cs"
tau <- 0.5
K.max <- 5
control <- fit.control(K.max = K.max)
Cn <- 1
mkqr.bea(y = Y, thre.x = X, cont.z = Z, id = subject, tau = tau, Cn = Cn,
control = control, est.type = est.type, wc.type = wc.type)
}
Run the code above in your browser using DataLab