Description Usage Arguments Details Value Author(s) See Also Examples
A class for panel series for which several useful computations and data transformations are available.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | ## S3 method for class 'pseries'
print(x, ...)
## S3 method for class 'pseries'
as.matrix(x, idbyrow = TRUE, ...)
## S3 method for class 'pseries'
plot(
x,
plot = c("lattice", "superposed"),
scale = FALSE,
transparency = TRUE,
col = "blue",
lwd = 1,
...
)
## S3 method for class 'pseries'
summary(object, ...)
## S3 method for class 'summary.pseries'
plot(x, ...)
## S3 method for class 'summary.pseries'
print(x, ...)
Sum(x, ...)
## Default S3 method:
Sum(x, effect, ...)
## S3 method for class 'pseries'
Sum(x, effect = c("individual", "time", "group"), ...)
## S3 method for class 'matrix'
Sum(x, effect, ...)
Between(x, ...)
## Default S3 method:
Between(x, effect, ...)
## S3 method for class 'pseries'
Between(x, effect = c("individual", "time", "group"), ...)
## S3 method for class 'matrix'
Between(x, effect, ...)
between(x, ...)
## Default S3 method:
between(x, effect, ...)
## S3 method for class 'pseries'
between(x, effect = c("individual", "time", "group"), ...)
## S3 method for class 'matrix'
between(x, effect, ...)
Within(x, ...)
## Default S3 method:
Within(x, effect, ...)
## S3 method for class 'pseries'
Within(x, effect = c("individual", "time", "group", "twoways"), ...)
## S3 method for class 'matrix'
Within(x, effect, rm.null = TRUE, ...)
|
x, object |
a |
... |
further arguments, e. g., |
idbyrow |
if |
plot, scale, transparency, col, lwd |
plot arguments, |
effect |
for the pseries methods: character string indicating the
|
rm.null |
if |
The functions between
, Between
, Within
, and Sum
perform specific
data transformations, i. e., the between, within, and sum transformation,
respectively.
between
returns a vector/matrix containing the individual means (over
time) with the length of the vector equal to the number of
individuals (if effect = "individual"
(default); if effect = "time"
,
it returns the time means (over individuals)). Between
duplicates the values and returns a vector/matrix which length/number of rows
is the number of total observations. Within
returns a vector/matrix
containing the values in deviation from the individual means
(if effect = "individual"
, from time means if effect = "time"
), the so
called demeaned data. Sum
returns a vector/matrix with sum per individual
(over time) or the sum per time period (over individuals) with
effect = "individual"
or effect = "time"
, respectively, and has length/
number of rows of the total observations (like Between
).
For between
, Between
, Within
, and Sum
in presence of NA values it
can be useful to supply na.rm = TRUE
as an additional argument to
keep as many observations as possible in the resulting transformation.
na.rm is passed on to the mean()/sum() function used by these transformations
(i.e., it does not remove NAs prior to any processing!), see also
Examples.
All these functions return an object of class pseries
or a matrix,
except:
between
, which returns a numeric vector or a matrix;
as.matrix
, which returns a matrix.
Yves Croissant
is.pseries()
to check if an object is a pseries. For
more functions on class 'pseries' see lag()
, lead()
,
diff()
for lagging values, leading values (negative lags) and
differencing.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | # First, create a pdata.frame
data("EmplUK", package = "plm")
Em <- pdata.frame(EmplUK)
# Then extract a series, which becomes additionally a pseries
z <- Em$output
class(z)
# obtain the matrix representation
as.matrix(z)
# compute the between and within transformations
between(z)
Within(z)
# Between and Sum replicate the values for each time observation
Between(z)
Sum(z)
# between, Between, Within, and Sum transformations on other dimension
between(z, effect = "time")
Between(z, effect = "time")
Within(z, effect = "time")
Sum(z, effect = "time")
# NA treatment for between, Between, Within, and Sum
z2 <- z
z2[length(z2)] <- NA # set last value to NA
between(z2, na.rm = TRUE) # non-NA value for last individual
Between(z2, na.rm = TRUE) # only the NA observation is lost
Within(z2, na.rm = TRUE) # only the NA observation is lost
Sum(z2, na.rm = TRUE) # only the NA observation is lost
sum(is.na(Between(z2))) # 9 observations lost due to one NA value
sum(is.na(Between(z2, na.rm = TRUE))) # only the NA observation is lost
sum(is.na(Within(z2))) # 9 observations lost due to one NA value
sum(is.na(Within(z2, na.rm = TRUE))) # only the NA observation is lost
sum(is.na(Sum(z2))) # 9 observations lost due to one NA value
sum(is.na(Sum(z2, na.rm = TRUE))) # only the NA observation is lost
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.