Title: | G-Functions |
---|---|
Description: | Modified versions of the lag() and summary() functions: glag() and gsummary(). The prefix 'g' is a reminder of who to blame if things do not work as they should. |
Authors: | Genaro Sucarrat [aut, cre] |
Maintainer: | Genaro Sucarrat <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.0 |
Built: | 2024-11-14 03:42:50 UTC |
Source: | https://github.com/cran/gfunctions |
glag()
and gsummary()
: Modified versions of lag()
and summary()
glag()
and gsummary()
are modifications of the lag()
and summary()
functions from the stats package in that they return different information.
Version: | 1.0 |
Date: | 2024-04-16 |
Licence: | GPL-2 |
Genaro Sucarrat: | http://www.sucarrat.net/ | |
Maintainer: Genaro Sucarrat
zoo
and ts
objectsThe glag()
function is similar to the lag()
function from the stats package, but glag()
actually lags (the default in lag()
is to lead). The funtion glag()
also enables padding (for example NA
s or 0
s) of the lost entries. Contrary to the lag()
function, however, the default in glag()
is to pad (with NA
s). The glag()
is particularly suited for zoo
objects, since their indexing is retained. The prefix g
is a reminder of who to blame if things do not work properly.
## generic: glag(x, ...) ## Default S3 method: glag(x, k = 1, pad = TRUE, pad.value = NA, ...)
## generic: glag(x, ...) ## Default S3 method: glag(x, k = 1, pad = TRUE, pad.value = NA, ...)
x |
|
k |
integer equal to the lag (the default is 1). Negative values (that is, 'leading') is not possible. |
pad |
logical. If |
pad.value |
the padding value. |
... |
additional arguments |
A vector or matrix, or objects of class zoo
or ts
, with the lagged values.
Genaro Sucarrat, http://www.sucarrat.net/
##lag series with NA for the missing entries: x <- rnorm(5) glag(x) ##lag series with no padding: x <- rnorm(5) glag(x, pad = FALSE) ##lag series and retain the original zoo-index ordering: x <- as.zoo(rnorm(5)) glag(x) ##lag two periods: glag(x, k = 2)
##lag series with NA for the missing entries: x <- rnorm(5) glag(x) ##lag series with no padding: x <- rnorm(5) glag(x, pad = FALSE) ##lag series and retain the original zoo-index ordering: x <- as.zoo(rnorm(5)) glag(x) ##lag two periods: glag(x, k = 2)
gsummary()
functionThe gsummary()
function provides an alternative to the summary()
function by returning different information. The prefix g
is a reminder of who to blame if things do not work properly.
## generic: gsummary(object, ...) ## Default S3 method: gsummary(object, ...) ## S3 method for class 'data.frame' gsummary(object, ...) ## S3 method for class 'lm' gsummary(object, vcov.type = c("ordinary", "robust", "hac"), confint.level = 0.95, ...) ## S3 method for class 'glm' gsummary(object, confint.level = 0.95, ...)
## generic: gsummary(object, ...) ## Default S3 method: gsummary(object, ...) ## S3 method for class 'data.frame' gsummary(object, ...) ## S3 method for class 'lm' gsummary(object, vcov.type = c("ordinary", "robust", "hac"), confint.level = 0.95, ...) ## S3 method for class 'glm' gsummary(object, confint.level = 0.95, ...)
object |
an object of suitable class, for example |
vcov.type |
a character string that determines the variance-vcovariance estimator. If |
confint.level |
a number between 0 and 1 (the default is |
... |
additional arguments |
No value is returned, the function only prints. The content of the print depends on the class of its main argument object
.
Genaro Sucarrat, http://www.sucarrat.net/
Halbert White (1980): 'A Heteroskedasticity-Consistent Covariance Matrix Estimator and a Direct Test for Heteroskedasticity', Econometrica 48, pp. 817-838. Whitney K. Newey and Kenned D. West (1987): 'A Simple, Positive Semi-Definite, Heteroskedasticity and Autocorrelation Consistent Covariance Matrix', Econometrica 55, pp. 703-708.
summary()
##simulate some data: set.seed(123) y <- rnorm(20); x <- rnorm(20); z <- rnorm(20) ##illustrate gsummary.data.frame(): mydataframe <- as.data.frame(cbind(y,x,z)) gsummary(mydataframe) ##illustrate gsummary.lm(): mymodel <- lm(y ~ x + z) gsummary(mymodel) gsummary(mymodel, vcov.type="robust") gsummary(mymodel, vcov.type="hac") gsummary(mymodel, confint.level=0.90) gsummary(mymodel, confint.level=0.99) gsummary(mymodel, confint.level=NULL) ##illustrate gsummary.glm(): y <- as.numeric( y > 0 ) mymodel <- glm(y ~ x + z, family=binomial) gsummary(mymodel)
##simulate some data: set.seed(123) y <- rnorm(20); x <- rnorm(20); z <- rnorm(20) ##illustrate gsummary.data.frame(): mydataframe <- as.data.frame(cbind(y,x,z)) gsummary(mydataframe) ##illustrate gsummary.lm(): mymodel <- lm(y ~ x + z) gsummary(mymodel) gsummary(mymodel, vcov.type="robust") gsummary(mymodel, vcov.type="hac") gsummary(mymodel, confint.level=0.90) gsummary(mymodel, confint.level=0.99) gsummary(mymodel, confint.level=NULL) ##illustrate gsummary.glm(): y <- as.numeric( y > 0 ) mymodel <- glm(y ~ x + z, family=binomial) gsummary(mymodel)