KClass | R Documentation |
KClass
computes the k-Class estimate for the ivmodel
object.
KClass(ivmodel,
beta0 = 0, alpha = 0.05, k = c(0, 1),
manyweakSE = FALSE, heteroSE = FALSE,clusterID = NULL)
ivmodel |
|
beta0 |
Null value |
alpha |
The significance level for hypothesis testing. Default is 0.05. |
k |
A vector of |
manyweakSE |
Should many weak instrument (and heteroscedastic-robust) asymptotics in Hansen, Hausman and Newey (2008) be used to compute standard errors? (Not supported for k=0) |
heteroSE |
Should heteroscedastic-robust standard errors be used? Default is FALSE. |
clusterID |
If cluster-robust standard errors are desired, provide a vector of length that's identical to the sample size. For example, if n = 6 and clusterID = c(1,1,1,2,2,2), there would be two clusters where the first cluster is formed by the first three observations and the second cluster is formed by the last three observations. clusterID can be numeric, character, or factor. |
KClass
computes the k-Class estimate for the instrumental variables model in ivmodel
, specifically for the parameter \beta
. It generates a point estimate, a standard error associated with the point estimate, a test statistic and a p value under the null hypothesis H_0: \beta = \beta_0
in ivmodel
along with a 1-\alpha
confidence interval.
KClass
returns a list containing the following components
k |
A row matrix of k values supplied to |
point.est |
A row matrix of point estimates of |
std.err |
A row matrix of standard errors of the estimates, with each row corresponding to the k values supplied. |
test.stat |
A row matrix of test statistics for testing the null hypothesis |
p.value |
A row matrix of p value of the test under the null hypothesis |
ci |
A matrix of two columns specifying the confidence interval, with each row corresponding to the k values supplied. |
Yang Jiang, Hyunseung Kang, and Dylan Small
See also ivmodel
for details on the instrumental variables model.
data(card.data)
Y=card.data[,"lwage"]
D=card.data[,"educ"]
Z=card.data[,c("nearc4","nearc2")]
Xname=c("exper", "expersq", "black", "south", "smsa", "reg661",
"reg662", "reg663", "reg664", "reg665", "reg666", "reg667",
"reg668", "smsa66")
X=card.data[,Xname]
card.model2IV = ivmodel(Y=Y,D=D,Z=Z,X=X)
KClass(card.model2IV,
k=c(0,1,0.5))
## Not run:
## The following code tests the mank weak IV standard error for LIML and Fuller.
example <- function(q = 10, rho1 = 0.5, n1 = 10000,
sigma.uv = 0.5, beta = 1, gamma = rep(1/sqrt(q), q)) {
Sigma1 <- outer(1:q, 1:q, function(i, j) rho1^abs(i - j))
library(MASS)
Z1 <- mvrnorm(n1, rep(1, q), Sigma1)
Z1 <- matrix(2 * as.numeric(Z1 > 0) - 1, nrow = n1)
UV1 <- mvrnorm(n1, rep(0, 2), matrix(c(1, sigma.uv, sigma.uv, 1), 2))
X1 <- Z1
Y1 <- X1
list(Z1 = Z1, X1 = X1, Y1 = Y1)
}
one.sim <- function(manyweakSE) {
data <- example(q = 100, n1 = 200)
fit <- ivmodel(data$Y1, data$X1, data$Z1, manyweakSE = manyweakSE)
1 > coef(fit)[, 2] - 1.96 * coef(fit)[, 3] & 1 < coef(fit)[, 2] + 1.96 * coef(fit)[, 3]
}
res <- replicate(200, one.sim(TRUE))
apply(res, 1, mean)
res <- replicate(200, one.sim(FALSE))
apply(res, 1, mean)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.