Class PanelData<S,​T extends Comparable<? super 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
    • Constructor Detail

      • PanelData

        protected PanelData​(String subjectHeader,
                            String timeHeader,
                            String[] headers)
        Constructs a panel of two-dimensional data.
        Parameters:
        subjectHeader - the name of the subjects
        timeHeader - the name of the times
        headers - the data/column names
    • Method Detail

      • addRow

        public void addRow​(S subject,
                           T time,
                           double... values)
        Inserts a row of data into the panel.
        Parameters:
        subject - the subject
        time - the time
        values - 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:
        true if 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 subject
        time - 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 data
        headers - the columns to be extracted
        transformations - 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 data
        headers - 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 data
        headers - the columns to be extracted
        transformations - the transformation to be applied to the column values
        Returns:
        the time series of panel values of the selected columns