Class PanelData<S,T extends Comparable<? super T>>
- java.lang.Object
-
- dev.nm.stat.regression.linear.panel.PanelData<S,T>
-
public class PanelData<S,T extends Comparable<? super T>> extends Object
A panel data refers to multi-dimensional data frequently involving measurements over time. Panel data contain observations of multiple phenomena obtained over multiple time periods for the same firms or individuals. In biostatistics, the term longitudinal data is often used instead, wherein a subject or cluster constitutes a panel member or individual in a longitudinal study.- See Also:
- Wikipedia: Panel data
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classPanelData.RowThis is one row of the data in a panel.static interfacePanelData.TransformationTransforms the data, e.g., taking log.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddRow(PanelData.Row row)Inserts a row of data into the panel.voidaddRow(S subject, T time, double... values)Inserts a row of data into the panel.List<S>getAllSubjects()Gets the name of all subjects.String[]getExtHeaders()Gets the extended headers, including the subject and time headers.StringgetExtHeadersString()Gets the extended headers, including the subject and time headers.double[][]getPanelValuesByHeaders(List<PanelData.Row> rows)Gets the values from a panel data.double[][]getPanelValuesByHeaders(List<PanelData.Row> rows, String[] headers)Gets the values from a panel data.double[][]getPanelValuesByHeaders(List<PanelData.Row> rows, String[] headers, PanelData.Transformation[] transformations)Gets the (transformed) values from a panel data.double[][]getPanelValuesByTime(List<PanelData.Row> rows)Gets the (transformed) values from a panel data.double[][]getPanelValuesByTime(List<PanelData.Row> rows, String[] headers, PanelData.Transformation[] transformations)Gets the (transformed) values from a panel data.PanelData.RowgetRow(S subject, T time)Gets one particular row indexed by a pair of subject and time.List<PanelData.Row>getRows()Gets all of the panel data.List<PanelData.Row>getRowsForSubject(S subject)Get all the rows pertaining to a particular subject.String[]getValueHeaders()Gets the headers, excluding the subject and time headers.StringgetValueHeadersString()Gets the headers, excluding the subject and time headers.static <S> PanelData<S,Instant>instantPanelData(String subjectHeader, String timeHeader, String[] headers)booleanisBalanced()Checks if the panel is balanced, i.e., all subjects have the same number of observations (times).static <S> PanelData<S,LocalDate>localDatePanelData(String subjectHeader, String timeHeader, String[] headers)static <S> PanelData<S,LocalDateTime>localDateTimePanelData(String subjectHeader, String timeHeader, String[] headers)intsize()Get the number of rows in the panel.StringtoString()static <S> PanelData<S,YearMonth>yearMonthPanelData(String subjectHeader, String timeHeader, String[] headers)static <S> PanelData<S,Year>yearPanelData(String subjectHeader, String timeHeader, String[] headers)
-
-
-
Method Detail
-
yearPanelData
public static <S> PanelData<S,Year> yearPanelData(String subjectHeader, String timeHeader, String[] headers)
-
yearMonthPanelData
public static <S> PanelData<S,YearMonth> yearMonthPanelData(String subjectHeader, String timeHeader, String[] headers)
-
localDatePanelData
public static <S> PanelData<S,LocalDate> localDatePanelData(String subjectHeader, String timeHeader, String[] headers)
-
localDateTimePanelData
public static <S> PanelData<S,LocalDateTime> localDateTimePanelData(String subjectHeader, String timeHeader, String[] headers)
-
instantPanelData
public static <S> PanelData<S,Instant> instantPanelData(String subjectHeader, String timeHeader, String[] headers)
-
addRow
public void addRow(S subject, T time, double... values)
Inserts a row of data into the panel.- Parameters:
subject- the subjecttime- the timevalues- the row data
-
addRow
public void addRow(PanelData.Row row)
Inserts a row of data into the panel.- Parameters:
row- a row
-
size
public int size()
Get the number of rows in the panel.- Returns:
- the number of rows
-
isBalanced
public boolean isBalanced()
Checks if the panel is balanced, i.e., all subjects have the same number of observations (times).- Returns:
trueif the panel is balanced
-
getExtHeaders
public String[] getExtHeaders()
Gets the extended headers, including the subject and time headers.- Returns:
- the array of extended headers
-
getExtHeadersString
public String getExtHeadersString()
Gets the extended headers, including the subject and time headers.- Returns:
- the string of extended headers
-
getValueHeaders
public String[] getValueHeaders()
Gets the headers, excluding the subject and time headers.- Returns:
- the array of the value headers
-
getValueHeadersString
public String getValueHeadersString()
Gets the headers, excluding the subject and time headers.- Returns:
- the string of value headers
-
getRows
public List<PanelData.Row> getRows()
Gets all of the panel data.- Returns:
- all rows in the panel
-
getRowsForSubject
public List<PanelData.Row> getRowsForSubject(S subject)
Get all the rows pertaining to a particular subject.- Parameters:
subject- the subject- Returns:
- all the rows pertaining to a particular subject
-
getRow
public PanelData.Row getRow(S subject, T time)
Gets one particular row indexed by a pair of subject and time.- Parameters:
subject- the subjecttime- the time- Returns:
- the indexed row
-
getAllSubjects
public List<S> getAllSubjects()
Gets the name of all subjects.- Returns:
- all subject names
-
getPanelValuesByHeaders
public double[][] getPanelValuesByHeaders(List<PanelData.Row> rows, String[] headers, PanelData.Transformation[] transformations)
Gets the (transformed) values from a panel data. Note: each row corresponds to a header value (a transpose of the panel data). In other words, each row in the 2D double array is a time series of the header of interest like a factor.- Parameters:
rows- the panel dataheaders- the columns to be extractedtransformations- the transformation to be applied to the column values- Returns:
- the (transformed) time series of panel values of the selected columns
-
getPanelValuesByHeaders
public double[][] getPanelValuesByHeaders(List<PanelData.Row> rows, String[] headers)
Gets the values from a panel data. Note: each row corresponds to a header value (a transpose of the panel data). In other words, each row in the 2D double array is a time series of the header of interest like a factor.- Parameters:
rows- the panel dataheaders- the columns to be extracted- Returns:
- the time series of panel values of the selected columns
-
getPanelValuesByHeaders
public double[][] getPanelValuesByHeaders(List<PanelData.Row> rows)
Gets the values from a panel data. Note: each row corresponds to a header value (a transpose of the panel data). In other words, each row in the 2D double array is a time series of the header of interest like a factor.- Parameters:
rows- the panel data- Returns:
- the time series of panel values
-
getPanelValuesByTime
public double[][] getPanelValuesByTime(List<PanelData.Row> rows)
Gets the (transformed) values from a panel data. Each row corresponds to one observation at a time.- Parameters:
rows- the panel data- Returns:
- the time series of panel values of the selected columns
-
getPanelValuesByTime
public double[][] getPanelValuesByTime(List<PanelData.Row> rows, String[] headers, PanelData.Transformation[] transformations)
Gets the (transformed) values from a panel data. Each row corresponds to one observation at a time.- Parameters:
rows- the panel dataheaders- the columns to be extractedtransformations- the transformation to be applied to the column values- Returns:
- the time series of panel values of the selected columns
-
-