riv {riv} | R Documentation |
Finds robust instrumental variables estimator using high breakdown point S-estimator of multivariate location and covariance.
riv(Y,Xex=FALSE,Xend,W,intercept=TRUE,method=c("robust","classical"),nsamp=500,bdp=.5,approx=1000)
Y |
a vector of responses, say of length n. |
Xex |
a matrix of the exogenous variables, i.e. the variables which are uncorrelated with the error. Default = FALSE, i.e. no exogenous variable is present in the model. |
Xend |
a matrix of the endogenous variables, i.e. the variables which are correlated with the error. Say of dimension n X (kend). |
W |
a matrix of instruments, say of dimension n x k. |
intercept |
if TRUE (default) a model with intercept is considered. |
method |
the method to be used. The "robust " method (default) is based on the S-estimator of multivariate location and covariance, and "classical " method is based on the sample mean and covariance. See Details section |
nsamp |
number of subsamples to compute the S-estimator of multivariate location and covariance. |
bdp |
breakdown point value of the S-estimator, must be 0.15, 0.25 or 0.5 (default). |
approx |
number of observations generated from the multivariate normal distribution with mean zero and the identity matrix as variance (default = 1000). |
For method "robust
" the estimator is constructed by using a robust S-estimator of multivariate location and covariance based on the Tukey's biweight function (see slc
).
The estimated variance and covariance matrix is based on the empirical influence function. See references for more details.
For method "classical
" the estimator is the classical instrumental variables estimator based on the sample mean and sample covariance.
A list with components
coefficients |
regression coefficients. if intercept = TRUE the first coefficient is the intercept. |
VC |
estimated variance-covariance matrix. |
MD |
Mahalanobis distances from the estimator (only computed if method = "robust "). |
MSE |
vector of three components: sigma.hat1 = the mean square error estimation,
sigma.hat2 = the mean square error estimation taking into account the weights associated to each observation (only computed if method = "robust " and k = kend),
sigma.hat3 = the squared median absolute deviation (only computed if method = "robust "). |
weight |
the weights assigned to each observation (only computed if method = "robust " and k = kend). |
Kaufmann B. beat.kaufmann@epfl.ch
Cohen-Freue G.V. gcohen@stat.ubc.ca
Zamar R.H. ruben@stat.ubc.ca
LOPUHAÄ,H.P. (1989). On the Relation between S-estimators and M-estimators of Multivariate Location and Covariance. Ann. Statist. 17 1662-1683.
COHEN-FREUE,G.V. and ZAMAR,R.H. (2005). A Robust Instrumental Variables Estimator.
## load data earthquake: the first column contains the response Y, the second the endogenous variable X ## and the third column is the instrument W. data(earthquake) riv.eq <- riv(earthquake[,1],FALSE,earthquake[,2],earthquake[,3]) ## plot of the riv estimates and the outlying observations are identified by filled points plot(earthquake[,2],earthquake[,1],xlab="X",ylab="Y",cex=1.5) abline(riv.eq$Summary.Table[,1]) case <- 1:62 text(earthquake[riv.eq$MD>sqrt(qchisq(0.95, 3)),2],earthquake[riv.eq$MD>sqrt(qchisq(0.95, 3)),1], case[riv.eq$MD>sqrt(qchisq(0.95, 3))],pos=c(1,4,2,2,3,2)) points(earthquake[riv.eq$MD>sqrt(qchisq(0.95, 3)),2],earthquake[riv.eq$MD>sqrt(qchisq(0.95, 3)),1],cex=1.5,pch=19) ## Mahalanobis distances of the S-estimator of multivariate location and covariance (slc) case <- 1:62 plot(riv.eq$MD,xlab="Case number",ylab="Mahalanobis Distance",cex = 1.5) abline(h=sqrt(qchisq(0.95, 3))) text(case[riv.eq$MD>sqrt(qchisq(0.95, 3))],riv.eq$MD[riv.eq$MD>sqrt(qchisq(0.95, 3))], case[riv.eq$MD>sqrt(qchisq(0.95, 3))],pos=c(3,3,3,3,2,3)) ## Weights associated to each observation plot(riv.eq$weight,xlab="Case number",ylab="Weight",cex=1.5) abline(h=0) text(case[riv.eq$MD>sqrt(qchisq(0.95, 3))],riv.eq$weight[riv.eq$MD>sqrt(qchisq(0.95, 3))], case[riv.eq$MD>sqrt(qchisq(0.95, 3))],pos=c(3,3,3,2,3,3),col=c("black","black","red","black","red","black")) points(case[riv.eq$weight==0],riv.eq$weight[riv.eq$weight==0],col="red",cex=1.5,pch=19) ## load data mortality data(mortality) Y <- as.matrix(mortality[,1]) ## M070 Xex <- as.matrix(mortality[,c(2,3,5,6)]) ## MAGE,CI68,DENS,NONW Xend <- as.matrix(mortality[,4]) ## MDOC colnames(Xend) <- colnames(mortality)[4] W <- as.matrix(mortality[,7:8]) ## EDUC,IN69 ## Classical instrumental variables estimator riv(Y,Xex,Xend,W,method="classical")