dftorep | R Documentation |

`dftorep`

forms an object of class, `repeated`

, from a
dataframe with the option of removing any observations where response
and covariate values have NAs. For repeated measurements, observations
on the same individual must be together in the table. A number of
validity checks are performed on the data.

Such objects can be printed and plotted. Methods are available for
extracting the response, the numbers of observations per individual,
the times, the weights, the units of measurement/Jacobian, the nesting
variable, the covariates, and their names: `response`

,
`nobs`

, `times`

,
`weights`

, `delta`

,
`nesting`

, `covariates`

, and
`names`

.

dftorep(dataframe, response, id=NULL, times=NULL, censor=NULL, totals=NULL, weights=NULL, nest=NULL, delta=NULL, coordinates=NULL, type=NULL, ccov=NULL, tvcov=NULL, na.rm=TRUE)

`dataframe` |
A dataframe. |

`response` |
A character vector giving the column name(s) of the dataframe for the response variable(s). |

`id` |
A character vector giving the column name of the dataframe for the identification numbers of the individuals. If the numbers are not consecutive integers, a warning is given. If NULL, one observation per individual is assumed if |

`times` |
An optional character vector giving the column name of the dataframe for the times vector. |

`censor` |
An optional character vector giving the column name(s)
of the dataframe for the censor indicator(s). This must be the same
length as |

`totals` |
An optional character vector giving the column name(s)
of the dataframe for the totals for binomial data. This must be the same
length as |

`weights` |
An optional character vector giving the column name of the dataframe for the weights vector. |

`nest` |
An optional character vector giving the column name of the dataframe for the nesting vector within individuals. This is the second level of nesting for repeated measurements, with the individual being the first level. Values for an individual must be consecutive increasing integers. |

`delta` |
An optional character vector giving the column name(s)
of the dataframe for the units of measurement/Jacobian(s) of the
response(s). This must be the same length as If all response variables have the same unit of measurement, this can be that one number. If each response variable has the same unit of measurement for all its values, this can be a numeric vector of length the number of response variables. |

`coordinates` |
An optional character vector giving the two or three column name(s) of the dataframe for the spatial coordinates. |

`type` |
An optional character vector giving the types of response variables: nominal, ordinal, discrete, duration, continuous, multivariate, or unknown. |

`ccov` |
An optional character vector giving the column names of the dataframe for the time-constant or inter-individual covariates. For repeated measurements, if the value is not constant for all observations on an individual, an error is produced. |

`tvcov` |
An optional character vector giving the column names of the dataframe for the time-varying or intra-individual covariates. |

`na.rm` |
If TRUE, observations with NAs in any variables selected are removed in the object returned. Otherwise, the corresponding indicator variable is returned in a slot in the object. |

Returns an object of class, `repeated`

, containing a list of the
response object (`z$response`

, so that, for example, the response vector
is `z$response$y`

; see `restovec`

), and
possibly the two classes of covariate objects (`z$ccov`

and
`z$tvcov`

; see `tcctomat`

and
`tvctomat`

).

J.K. Lindsey

`lvna`

, `read.list`

,
`read.rep`

, `restovec`

,
`rmna`

, `tcctomat`

,
`tvctomat`

y <- data.frame(y1=rpois(20,5),y2=rpois(20,5)) y[2,2] <- NA idd <- c(rep(1,5),rep(2,10),rep(3,5)) tt <- c(1:5,1:10,1:5) totals <- data.frame(tot1=rep(12,20),tot2=rep(12,20)) x2 <- c(rep(1,5),rep(2,10),rep(3,5)) df <- data.frame(y,id=idd,tt=tt,totals,x1=rnorm(20),x2=x2) df dftorep(df,resp=c("y1","y2"),times="tt",id="id",totals=c("tot1","tot2"), tvcov="x1",ccov="x2") dftorep(df,resp=c("y1","y2"),times="tt",id="id",totals=c("tot1","tot2"), tvcov="x1",ccov="x2",na.rm=FALSE) # x1 is not a time-constant covariate #dftorep(df,resp=c("y1","y2"),times="tt",id="id",ccov="x1",na.rm=FALSE)

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.