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)
Y <- XR %*% bet + epsilon
result_iid <- mkqr.fit(Y, X, Z, tau = 0.5, k = k)
# 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"
result_WI_Compound <- mkqr.fit(y = Y, thre.x = X, cont.z = Z, id = subject, tau = tau,
k = k, 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"
result_WC_cs <- mkqr.fit(y = Y, thre.x = X, cont.z = Z, id = subject, tau = tau,
k = k, est.type = est.type, wc.type = wc.type)
}
Run the code above in your browser using DataLab