weightsAndrews(sandwich)
weightsAndrews()所属R语言包:sandwich
Kernel-based HAC Covariance Matrix Estimation
基于内核的HAC协方差矩阵的估计
译者:生物统计家园网 机器人LoveR
描述----------Description----------
A set of functions implementing a class of kernel-based heteroskedasticity and autocorrelation consistent (HAC) covariance matrix estimators as introduced by Andrews (1991).
一组功能,实现一类基于内核的异方差和自相关一致(HAC)推出的安卓(1991)的协方差矩阵估计。
用法----------Usage----------
kernHAC(x, order.by = NULL, prewhite = 1, bw = bwAndrews,
kernel = c("Quadratic Spectral", "Truncated", "Bartlett", "Parzen", "Tukey-Hanning"),
approx = c("AR(1)", "ARMA(1,1)"), adjust = TRUE, diagnostics = FALSE,
sandwich = TRUE, ar.method = "ols", tol = 1e-7, data = list(), verbose = FALSE, ...)
weightsAndrews(x, order.by = NULL, bw = bwAndrews,
kernel = c("Quadratic Spectral", "Truncated", "Bartlett", "Parzen", "Tukey-Hanning"),
prewhite = 1, ar.method = "ols", tol = 1e-7, data = list(), verbose = FALSE, ...)
bwAndrews(x, order.by = NULL, kernel = c("Quadratic Spectral", "Truncated",
"Bartlett", "Parzen", "Tukey-Hanning"), approx = c("AR(1)", "ARMA(1,1)"),
weights = NULL, prewhite = 1, ar.method = "ols", data = list(), ...)
参数----------Arguments----------
参数:x
a fitted model object.
拟合模型对象。
参数:order.by
Either a vector z or a formula with a single explanatory variable like ~ z. The observations in the model are ordered by the size of z. If set to NULL (the default) the observations are assumed to be ordered (e.g., a time series).
无论是向量z或用一个公式解释变量,如~ z。在模型中的观测是有序的的大小z。如果设置为NULL(默认值)观测值进行排序(例如,时间序列)。
参数:prewhite
logical or integer. Should the estimating functions be prewhitened? If TRUE or greater than 0 a VAR model of order as.integer(prewhite) is fitted via ar with method "ols" and demean = FALSE. The default is to use VAR(1) prewhitening.
逻辑或整数。应该估计功能是prewhitened的吗?如果TRUE或大于0的VAR模型订单as.integer(prewhite)安装通过ar的方法"ols"和demean = FALSE。默认情况下是使用VAR(1)prewhitening。
参数:bw
numeric or a function. The bandwidth of the kernel (corresponds to the truncation lag). If set to to a function (the default is bwAndrews) it is adaptively chosen.
数值或一个函数。内核的带宽(对应于截断滞后)。如果设置为一个函数(默认为bwAndrews)是自适应选择。
参数:kernel
a character specifying the kernel used. All kernels used are described in Andrews (1991).
用字符指定内核。安德鲁斯(1991年)中描述的所有内核使用的。
参数:approx
a character specifying the approximation method if the bandwidth bw has to be chosen by bwAndrews.
一个字符指定的近似方法,如果带宽bw具有所选择的bwAndrews。
参数:adjust
logical. Should a finite sample adjustment be made? This amounts to multiplication with n/(n-k) where n is the number of observations and k the number of estimated parameters.
逻辑。如果一个有限的样本调整呢?这相当于乘法n/(n-k)其中n是一些意见和k估计参数的数量。
参数:diagnostics
logical. Should additional model diagnostics be returned? See vcovHAC for details.
逻辑。额外的模型诊断回来了吗?见vcovHAC的详细信息。
参数:sandwich
logical. Should the sandwich estimator be computed? If set to FALSE only the middle matrix is returned.
逻辑。三明治估计计算?如果设置为FALSE只有中间的矩阵将被返回。
参数:ar.method
character. The method argument passed to ar for prewhitening (only, not for bandwidth selection).
字符。 method参数传递给ar(prewhitening,而不是带宽选择)。
参数:tol
numeric. Weights that exceed tol are used for computing the covariance matrix, all other weights are treated as 0.
数字。超过tol用于计算的协方差矩阵的权重,所有其他的权重被视为0。
参数:data
an optional data frame containing the variables in the order.by model. By default the variables are taken from the environment which the function is called from.
一个可选的数据框包含order.by模型中的变量。默认情况下,变量的环境中,该函数的调用。
参数:verbose
logical. Should the bandwidth parameter used be printed?
逻辑。如果所使用的带宽参数进行打印呢?
参数:...
further arguments passed to bwAndrews.
进一步的参数传递给bwAndrews。
参数:weights
numeric. A vector of weights used for weighting the estimated coefficients of the approximation model (as specified by approx). By default all weights are 1 except that for the intercept term (if there is more than one variable).
数字。一个用于加权的权重向量的近似模型的估计系数(指定的approx)。缺省情况下,所有的权重是1除了截距项(如果有一个以上的变量)。
Details
详细信息----------Details----------
kernHAC is a convenience interface to vcovHAC using weightsAndrews: first a weights function is defined and then vcovHAC is called.
kernHAC是一个方便的接口vcovHAC使用weightsAndrews:第一个权重函数的定义,然后vcovHAC被称为。
The kernel weights underlying weightsAndrews are directly accessible via the function kweights and require the specification of the bandwidth parameter bw. If this is not specified it can be chosen adaptively by the function bwAndrews (except for the "Truncated" kernel). The automatic bandwidth selection is based on an approximation of the estimating functions by either AR(1) or ARMA(1,1) processes. To aggregate the estimated parameters from these approximations a weighted sum is used. The weights in this aggregation are by default all equal to 1 except that corresponding to the intercept term which is set to 0 (unless there is no other variable in the model) making the covariance matrix scale invariant.
内核权值相关weightsAndrews是通过函数kweights直接访问的带宽参数bw需要的规格。如果它没有被指定,它可以选择由函数bwAndrews(除了"Truncated"内核)自适应。自动带宽的选择是基于由任何AR(1)或ARMA(1,1)过程的估计函数的近似。聚集参数估计值的加权和使用这些近似。 weights在此聚集的是默认情况下都等于1,除了相应的截距项设置为0(除非有没有其他变量的模型)的协方差矩阵规模不变的。
Further details can be found in Andrews (1991).
进一步的细节可以发现,在安德鲁斯(1991)。
The estimator of Newey & West (1987) is a special case of the class of estimators introduced by Andrews (1991). It can be obtained using the "Bartlett" kernel and setting bw to lag + 1. A convenience interface is provided in NeweyWest.
纽维 - 韦斯特(1987)的估计,是一个特殊的情况下推出的安德鲁斯(1991)之类的估计。可以使用"Bartlett"内核和设置bw到lag + 1的。在NeweyWest提供一个方便的接口。
值----------Value----------
kernHAC returns the same type of object as vcovHAC which is typically just the covariance matrix.
kernHAC返回相同类型的对象作为vcovHAC这是典型的协方差矩阵。
weightsAndrews returns a vector of weights.
weightsAndrews返回一个向量的权重。
bwAndrews returns the selected bandwidth parameter.
bwAndrews返回选定的带宽参数。
参考文献----------References----------
Heteroskedasticity and Autocorrelation Consistent Covariance Matrix Estimation. Econometrica, 59, 817–858.
A Simple, Positive Semi-Definite, Heteroskedasticity and Autocorrelation Consistent Covariance Matrix. Econometrica, 55, 703–708.
参见----------See Also----------
vcovHAC, NeweyWest, weightsLumley,
vcovHAC,NeweyWest,weightsLumley,
实例----------Examples----------
curve(kweights(x, kernel = "Quadratic", normalize = TRUE),
from = 0, to = 3.2, xlab = "x", ylab = "k(x)")
curve(kweights(x, kernel = "Bartlett", normalize = TRUE),
from = 0, to = 3.2, col = 2, add = TRUE)
curve(kweights(x, kernel = "Parzen", normalize = TRUE),
from = 0, to = 3.2, col = 3, add = TRUE)
curve(kweights(x, kernel = "Tukey", normalize = TRUE),
from = 0, to = 3.2, col = 4, add = TRUE)
curve(kweights(x, kernel = "Truncated", normalize = TRUE),
from = 0, to = 3.2, col = 5, add = TRUE)
## fit investment equation[适合投资方程]
data(Investment)
fm <- lm(RealInv ~ RealGNP + RealInt, data = Investment)
## compute quadratic spectral kernel HAC estimator[#计算二次谱内核HAC估计]
kernHAC(fm)
kernHAC(fm, verbose = TRUE)
## use Parzen kernel instead, VAR(2) prewhitening, no finite sample[#内核,而不是使用基于Parzen,VAR(2)prewhitening,没有有限样本]
## adjustment and Newey & West (1994) bandwidth selection[#调整和纽维西(1994年)的带宽选择]
kernHAC(fm, kernel = "Parzen", prewhite = 2, adjust = FALSE,
bw = bwNeweyWest, verbose = TRUE)
## compare with estimate under assumption of spheric errors[#比较与估计受到球形错误的假设]
vcov(fm)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|