Type: | Package |
Title: | G-Functions |
Version: | 1.0 |
Date: | 2024-04-16 |
Author: | Genaro Sucarrat [aut, cre] |
Maintainer: | Genaro Sucarrat <gsucarrat@gmail.com> |
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. |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
Depends: | R (≥ 3.0.0), zoo, sandwich |
Imports: | methods, stats |
NeedsCompilation: | no |
Packaged: | 2024-04-16 16:46:17 UTC; sucarrat |
Repository: | CRAN |
Date/Publication: | 2024-04-17 10:00:02 UTC |
glag()
and gsummary()
: Modified versions of lag()
and summary()
Description
glag()
and gsummary()
are modifications of the lag()
and summary()
functions from the stats package in that they return different information.
Details
Version: | 1.0 |
Date: | 2024-04-16 |
Licence: | GPL-2 |
Author(s)
Genaro Sucarrat: | http://www.sucarrat.net/ | |
Maintainer: Genaro Sucarrat
See Also
Lag a vector or a matrix, with special treatment of zoo
and ts
objects
Description
The 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.
Usage
## generic:
glag(x, ...)
## Default S3 method:
glag(x, k = 1, pad = TRUE, pad.value = NA, ...)
Arguments
x |
a numeric vector or matrix, or objects of class |
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 |
Value
A vector or matrix, or objects of class zoo
or ts
, with the lagged values.
Author(s)
Genaro Sucarrat, http://www.sucarrat.net/
See Also
lag()
, lag.zoo()
Examples
##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)
The gsummary()
function
Description
The 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.
Usage
## 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, ...)
Arguments
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 |
Value
No value is returned, the function only prints. The content of the print depends on the class of its main argument object
.
Author(s)
Genaro Sucarrat, http://www.sucarrat.net/
References
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.
See Also
summary()
Examples
##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)