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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tool_transformations.R
\name{pseries}
\alias{pseries}
\alias{print.pseries}
\alias{as.matrix.pseries}
\alias{plot.pseries}
\alias{summary.pseries}
\alias{plot.summary.pseries}
\alias{print.summary.pseries}
\alias{Sum}
\alias{Sum.default}
\alias{Sum.pseries}
\alias{Sum.matrix}
\alias{Between}
\alias{Between.default}
\alias{Between.pseries}
\alias{Between.matrix}
\alias{between}
\alias{between.default}
\alias{between.pseries}
\alias{between.matrix}
\alias{Within}
\alias{Within.default}
\alias{Within.pseries}
\alias{Within.matrix}
\title{panel series}
\usage{
\method{print}{pseries}(x, ...)
\method{as.matrix}{pseries}(x, idbyrow = TRUE, ...)
\method{plot}{pseries}(
x,
plot = c("lattice", "superposed"),
scale = FALSE,
transparency = TRUE,
col = "blue",
lwd = 1,
...
)
\method{summary}{pseries}(object, ...)
\method{plot}{summary.pseries}(x, ...)
\method{print}{summary.pseries}(x, ...)
Sum(x, ...)
\method{Sum}{default}(x, effect, ...)
\method{Sum}{pseries}(x, effect = c("individual", "time", "group"), ...)
\method{Sum}{matrix}(x, effect, ...)
Between(x, ...)
\method{Between}{default}(x, effect, ...)
\method{Between}{pseries}(x, effect = c("individual", "time", "group"), ...)
\method{Between}{matrix}(x, effect, ...)
between(x, ...)
\method{between}{default}(x, effect, ...)
\method{between}{pseries}(x, effect = c("individual", "time", "group"), ...)
\method{between}{matrix}(x, effect, ...)
Within(x, ...)
\method{Within}{default}(x, effect, ...)
\method{Within}{pseries}(x, effect = c("individual", "time", "group", "twoways"), ...)
\method{Within}{matrix}(x, effect, ...)
}
\arguments{
\item{x, object}{a \code{pseries} or a matrix; or a \code{summary.pseries} object,}
\item{\dots}{further arguments, e. g., \code{na.rm = TRUE} for
transformation functions like \code{beetween}, see \strong{Details}
and \strong{Examples}.}
\item{idbyrow}{if \code{TRUE} in the \code{as.matrix} method, the lines of
the matrix are the individuals,}
\item{plot, scale, transparency, col, lwd}{plot arguments,}
\item{effect}{for the pseries methods: character string indicating the
\code{"individual"}, \code{"time"}, or \code{"group"} effect, for \code{Within}
\code{"twoways"} additionally; for non-pseries methods, \code{effect} is a factor
specifying the dimension (\code{"twoways"} is not possible),}
}
\value{
All these functions return an object of class \code{pseries} or a matrix,
except:\cr \code{between}, which returns a numeric vector or a matrix;
\code{as.matrix}, which returns a matrix.
}
\description{
A class for panel series for which several useful computations and
data transformations are available.
}
\details{
The functions \code{between}, \code{Between}, \code{Within}, and \code{Sum} perform specific
data transformations, i. e., the between, within, and sum transformation,
respectively.
\code{between} returns a vector/matrix containing the individual means (over
time) with the length of the vector equal to the number of
individuals (if \code{effect = "individual"} (default); if \code{effect = "time"},
it returns the time means (over individuals)). \code{Between}
duplicates the values and returns a vector/matrix which length/number of rows
is the number of total observations. \code{Within} returns a vector/matrix
containing the values in deviation from the individual means
(if \code{effect = "individual"}, from time means if \code{effect = "time"}), the so
called demeaned data. \code{Sum} returns a vector/matrix with sum per individual
(over time) or the sum per time period (over individuals) with
\code{effect = "individual"} or \code{effect = "time"}, respectively, and has length/
number of rows of the total observations (like \code{Between}).
For \code{between}, \code{Between}, \code{Within}, and \code{Sum} in presence of NA values it
can be useful to supply \code{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
\strong{Examples}.
}
\examples{
# 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
}
\seealso{
\code{\link[=is.pseries]{is.pseries()}} to check if an object is a pseries. For
more functions on class 'pseries' see \code{\link[=lag]{lag()}}, \code{\link[=lead]{lead()}},
\code{\link[=diff]{diff()}} for lagging values, leading values (negative lags) and
differencing.
}
\author{
Yves Croissant
}
\keyword{classes}
|