prepareCGOneFactorData
reads in a data frame and
settings
in order to create a
cgOneFactorData
object. The created object is designed to have exploratory and
fit methods applied to it.
prepareCGOneFactorData(dfr, format = "listed", analysisname = "", endptname = "", endptunits = "", logscale = TRUE, zeroscore = NULL, addconstant = NULL, rightcensor = NULL, leftcensor = NULL, digits = NULL, refgrp = NULL, stamps = FALSE)
format
argument."listed"
. Either "listed"
or
"groupcolumns"
must be used. Abbreviations of "l"
or "g"
, respectively,
or otherwise sufficient matching values can be used:
"listed"
"groupcolumns"
NA
's or be left
blank. Censored values can be represented; see the Details Input
Data Frame section below. Otherwise, any character data will be coerced to
numeric data with possibly undesirable results.
""
.""
.""
.TRUE
.logscale=TRUE
) is specified. The default value
is NULL
. To derive a score value to replace zero,
"estimate"
can be specified, see Details below on the algorithm used.logscale=TRUE
is desired. The default value is
NULL
. positive numeric value can be specified to be added, or a "simple"
algorthm specified to estimate a value to add. See Details secion
below on the algorithm used.TRUE
can be
used to coerce a binary status variable in the data frame to be
right censored for its values.The default value is NULL
.
See the Details Input Data Frame section
below for specifications and consequences.TRUE
can be
used to coerce a binary status variable in the data frame to be
right censored for its values. The default value is NULL
.
See the Details Input Data Frame section
below for specifications and consequences.NULL
, which will examine each individual data value and choose the
one that has the maximum number of digits after any trailing
zeroes are ignored. The max number of digits will be 4.NULL
,
which will just use the first level determined in the data frame.FALSE
.cgOneFactorData
object is returned, with the following slots:
dfr
argument in the function call.dfr
value if the input data frame was specified in the
groupcolumns
format.TRUE
or FALSE
on whether there are any
censored data observations.analysisname
analysisname
.endptname
endptname
.endptunits
endptunits
.endptscale
"log"
if
logscale=TRUE
and "original"
if
logscale=FALSE
.zeroscore
NULL
if the input argument
was NULL
. Otherwise has the derived (from
zeroscore="estimate"
)
or specified numeric value.addconstant
NULL
if the input argument
was NULL
. Otherwise has the specified numeric value.rightcensor
rightcensor
or is set to NULL
if no censored
observations are determined.leftcensor
leftcensor
or
is set to NULL
if no censored
observations are determined.digits
digits
or is set to the determined value of digits from the
input data. Will be an integer of 0, 1, 2, 3, or 4.grpnames
dfr
.refgrp
refgrp
.stamps
stamps
.dfr
can be of the format
"listed"
or "groupcolumns"
. Another distinguishing
characteristic is whether or not it contains censored data
representations. Censored observations can be represented by <
for
left-censoring
and >
for
right-censoring. The <
value refers to values less than or equal
to a numeric value. For example, <0.76< code=""> denotes a left-censored
value of 0.76
or less. Similarly,
>2.02
denotes a value of 2.02 or greater for
a right-censored value. There must be no space between the direction
indicator and the numeric value. These representations can be used in
either the listed
or groupcolumns
formats for dfr
.0.76<>
No interval-censored representations are currently handled when
format="groupcolumns"
.
If format="groupcolumns"
for dfr
is specified, then the
number of columns must equal the number of groups, and any censored
values must follow the <
and >
representations.
The individual group values are of mode character, since any
censored values will be represented for example as <0.76< code=""> or
>2.02
. If any of the groups have less number of
observations than any others, i.e. there are unequal sample sizes,
then the corresponding "no data" cells in the data frame need to
contain empty quote ""
values.0.76<>
If format="listed"
for dfr
is specified, then there may be
anywhere from two to four columns for an input data frame.
<
and >
can be used here. One or
both of
rightcensor
or leftcensor
may also be specified as a
number. If
a number is specified for rightcensor
, then all values in
the second column equal to this value will be processed as
right-censored. Analogously, if
a number is specified for leftcensor
, then all values in
the second column equal to this value will be processed as
left-censored. WARNING: This should be used cautiously to make sure the
equality occurs as desired. This convention is designed for simple
Type I censoring scenarios.
Surv
from the survival package, 0
=right censored, 1
=no censoring, and
2
=left censored. If rightcensor=NULL
and
leftcensor=NULL
are left as defaults in the call, and
values of 0, 1, and 2 are all represented, then the
processing will create a suitable data frame dfru
for
modeling that the canonical survreg
function understands. However, if 0 and 1 are the only specified values
in the third censoring status column, then one of
rightcensor=TRUE
or leftcensor=TRUE
must be specified,
but NOT both, or an error message will occur. A column of all 1's or
all 0's will also raise an error message.
rightcensor
and leftcensor
input
arguments are ignored and set to NULL
. IMPORTANT: The
convention of Surv
from the survival package, 0=right censored, 1=no censoring, and
2=left censored, 3=interval censored, and
type="interval"
,
is followed. For status=0, 1, and 2, the second and
third columns match in value, so that the status variable in the
fourth column distinguishes the lower and upper bounds for the
right-censored (0) and left-censored (2) cases.
For status=3, the two values differ to
define the interval boundaries. The
processing will create a suitable data frame dfru
for
modeling that the canonical survreg
and survfit
functions from the survival package understand.
zeroscore="estimate"
is specified, a number
close to zero is derived to replace all zeroes for subsequent
log-scale analyses. A spline fit (using spline
and
method="natural"
)
of the log of the
response vector on the original response vector is performed. The
zeroscore is then derived from the log-scale value of the spline curve at the original
scale value of zero. This approach comes from the concept of
arithmetic-logarithmic scaling discussed in Tukey, Ciminera, and
Heyse (1985).
addconstant="simple"
or
addconstant="VR"
is specified, a number is derived and added
to all response values.
"simple"
max - min
) of the response values
is multiplied by 0.0001
to derive the number to add to all the
response values.
"VR"
logtrans
function discussed in Venables and Ripley
(2002), pages 171-172 and available in the MASS
package. The algorithm applies a Box-Cox profile likelihood
approach with a log scale translation model.
Chambers, J.M, and Hastie, T.R. (1992), Statistical Modeling in S. Chapman & Hall/CRC.
Venables, W. N., and Ripley, B. D. (2002), Modern Applied Statistics with S. Fourth edition. Springer.
Surv
, canine
,
gmcsfcens
,
prepare
data(canine)
canine.data <- prepareCGOneFactorData(canine, format="groupcolumns",
analysisname="Canine",
endptname="Prostate Volume",
endptunits=expression(plain(cm)^3),
digits=1, logscale=TRUE, refgrp="CC")
## Censored Data
data(gmcsfcens)
gmcsfcens.data <- prepareCGOneFactorData(gmcsfcens, format="groupcolumns",
analysisname="cytokine",
endptname="GM-CSF (pg/ml)",
logscale=TRUE)
Run the code above in your browser using DataLab