Package 'lgtdl'

Title: A Set of Methods for Longitudinal Data Objects
Description: A very simple implementation of a class for longitudinal data.
Authors: R. Gentleman
Maintainer: Arthur Allignol <[email protected]>
License: GPL (>= 2)
Version: 1.1.5
Built: 2025-02-17 04:29:40 UTC
Source: https://github.com/cran/lgtdl

Help Index


Longitudinal Class

Description

as.lgtdl coerces its argument to class lgtdl if possible. is.lgtdl returns TRUE if its argument is of class lgtdl and FALSE otherwise.

Usage

as.lgtdl(x, row.names=NULL)
is.lgtdl(x)

Arguments

x

An object which is coerced to a lgtdl object for as.lgtdl or tested with is.lgtdl.

row.names

An optional set of row names to be used for the names of the covariates in the resulting lgtdl object.

Value

is.lgtdl

Returns TRUE if its argument is of class lgtdl.

as.lgtdl

Returns an object of class lgtdl.

Author(s)

Robert Gentleman

See Also

plot.lgtdl, lgtdl

Examples

x1<-data.frame(time=c(1,3,5), cov=c(4,6,8))
  x2<-data.frame(time=c(11,13,15), interest=c(66,45,88))

  x1<-as.lgtdl(x1)
  x2<-as.lgtdl(x2)

  is.lgtdl(TRUE)

A function to extract the covariate from an object of class lgtdl.

Description

The covariate component of the lgtdl object is returned.

Usage

getcov(x, ...)
## S3 method for class 'lgtdl'
getcov(x, cov, ...)

Arguments

x

The lgtdl object.

cov

The name of the covariate to be extracted.

...

Ignored, there for potential future use.

Value

The covariate, as either a matrix or vector, is returned.

Author(s)

Robert Gentleman

See Also

lgtdl, as.lgtdl

Examples

x1<-data.frame(time=c(1,3,5), cov=c(4,6,8))
  x2<-data.frame(time=c(11,13,15), interest=c(66,45,88))

  x1<-as.lgtdl(x1)
  x2<-as.lgtdl(x2)
  getcov(x1)
  getcov(x2)

A function to provide estimates of the response for a longitudinal data object. The estimate is obtained by linear interpolation from the preceding and following observations.

Description

A linear interpolation, using approx, is used to obtain estimates of the covariate at times other than those observed.

Usage

interplinear(x, ...)
## S3 method for class 'lgtdl'
interplinear(x, time, cov = NULL, ...)
## S3 method for class 'AsIs'
interplinear(x, ...)

Arguments

x

The lgtdl object that is to be interpolated.

time

The time(s) at which interpolation is desired.

cov

The name of the covariate in the lgtdl object on which the interpolation should be based. It is not required if there is only one covariate.

...

Ignored.

Value

A vector containing the interpolated estimates of the covariate values at the requested times.

Author(s)

Robert Gentleman

See Also

interpprev

Examples

x1<-data.frame(time=c(1,3,5), cov=c(4,6,8))
  x2<-data.frame(time=c(11,13,15), interest=c(66,45,88))
  x1<-as.lgtdl(x1)
  x2<-as.lgtdl(x2)
  interpprev(x1, 4)
  interpprev(x2, c(12, 14))

Interpolation Using the Previous Value

Description

These functions provide an interpolation mechanism for objects of class lgtdl. The AsIs method is the vectorized version.

Usage

interpprev(x, ...)
## S3 method for class 'lgtdl'
interpprev(x, time, cov, ...)
## S3 method for class 'AsIs'
interpprev(x, ...)

Arguments

x

x is either an object of class lgtdl or of class AsIs. It is the object on which interpolation is to be performed.

time

A vector of times at which interpolation is requested.

cov

The name of the covariate on which interpolation is requested. It is only required if x has more than one covariate.

...

Ignored.

Details

If objects of class lgtdl are inserted into a data frame they become a vector with class AsIs. In order to operate on these we provide a method for that class. The method is simply a vectorized version.

Value

interpprev.lgtdl returns a numeric vector of the interpolated values of the covariate at the time(s) specified by time. interpprev.AsIs returns a vector of interpolated values of the covariate. In this case the vector contains one value for each element x. time must be either the same length as x or of length one. In the latter case all interpolations are done at that time.

Author(s)

Robert Gentleman

See Also

interplinear

Examples

x1<-data.frame(time=c(1,3,5), cov=c(4,6,8))
  x2<-data.frame(time=c(11,13,15), interest=c(66,45,88))
  x1<-as.lgtdl(x1)
  x2<-as.lgtdl(x2)
  interpprev(x1, c(2,4))
  interpprev(x2, c(12, 14))

Longitudinal Class

Description

The lgtdl class is a simple class of R/S objects that make it simpler to manipulate longitudinal data.

Author(s)

Robert Gentleman

References

Gentleman Robert (2001). Modeling with Objects. Proceedings of the 2nd International Workshop on Distributed Statistical Computing. http://r-project.org/nosvn/conferences/DSC-2001/Proceedings/Gentleman.pdf


A function for plotting lgtdl objects.

Description

A lgtdly object consists of a time component and one or more covariates measured or observed at the times specified in the time component. This function plots the covariate trajectories as lines on the y axis.

Usage

## S3 method for class 'lgtdl'
plot(x, ...)

Arguments

x

An object of class lgtdl.

...

Optional arguments to control the plotting.

Details

One should be able to specify values for any of the graphics parameters to change the appearance of the plot.

Value

No value is returned. A line plot of the longitudinal object is rendered on the active graphics device.

Author(s)

Robert Gentleman

See Also

lgtdl

Examples

x1<-data.frame(time=c(1,3,5), cov=c(4,6,8))
  x2<-data.frame(time=c(11,13,15), interest=c(66,45,88))

  x1<-as.lgtdl(x1)
  x2<-as.lgtdl(x2)
  plot(x1)
  plot(x2)

Produce a character string suitable for printing.

Description

Data frames can contain lgtdl objects as elements. When the data frame is printed this function provides a suitable string for printing.

Usage

## S3 method for class 'lgtdl'
toString(x, width, ...)

Arguments

x

The object to be formated.

width

To control the width of the returned string-ignored.

...

Ignored.

Value

A character string. Currently it is "lgtdl, length = " with the length of the time component added.

Author(s)

Robert Gentleman

See Also

toString