Fit models to a cgOneFactorData object

Description

Fits a one-factor model based on the cgOneFactorData object. The created object is designed for one-factor / one-way / unpaired samples collected data, and is of class cgOneFactorFit.

Usage

1
2
## S4 method for signature 'cgOneFactorData'
fit(data, type="rr", ...)

Arguments

data

A data object of class cgOneFactorData.

type

Type of model to fit, represented by a character value. The default value is "rr". The four current possibilities are:

"ols"

Only fit an ordinary, classical least squares model with the base lm linear model function.

"rr"

Fit a Resistant / Robust model based on M- and S-estimation, using the rlm function from the MASS package (Venables and Ripley, 2002). This is the default character value for the type argument. See the ... argument and Details below for what options are available when rlm is used in this wrapper method.

"aft"

Fit an accelerated failure time model, using the survreg function from the survival package. If the data object has censored data and a slot state of has.censored=TRUE, then type="aft" will be set. See the ... argument and Details below for what options are used when survreg is used in this wrapper method; in particular, the robust argument.

"uv"

Fit an unequal variances model, with a simple wrapper method around the gls from the nlme package. No optional arguments are passed down to gls through the ... argument.

...

Additional arguments, both optional, that are allowed to be specified dependent on the choice of the type argument. Otherwise they have no effect on the fit:

maxIter

If type="rr" or type="aft", then maxIter can be specified as a numeric postive integer. The default value of maxIter is 100. For "rr", this gets passed to the maxit argument in the rlm method. For "aft", this gets passed to the maxiter argument in the survreg function.

sandaft

If type="aft", then sandaft is passed to the robust argument of the survreg function. The default value of sandaft is TRUE when type="aft", which applies the Huber-type (1967) sandwich estimator to the variance-covariance matrix of the group estimates.

Details

In the current version of the cg package, most default settings for rlm are kept for the fit.cgOneFactorData method wrapper call when type="rr", with no capability to choose another value for an arguments such as psi, scale.est, and k2. The method argument is set to "MM".

Analogously most survreg default settings are kept for the fit.cgOneFactorData method wrapper call when type="aft", with no capability to modify the arguments. Most notably the dist argument is set to "lognormal" or "gaussian", depending on whether a log scale analysis request is evident in the cgOneFactorData object or not, respectively.

Value

Creates an object of class cgOneFactorFit, with the following slots:

olsfit

The contents of a lm fit to the data. This is always populated with an lm object no matter the choice of the type argument, even though it is certainly inappropriate in the type="aft" case.

rrfit

The contents of a rlm fit to the data, housed as a rrfit class object. If type="rr" is not selected, then this is set to a simple character value of "No fit was selected.".

aftfit

The contents of a survreg fit to the data, with some annotations, to be a aftfit class object. If type="aft" is not selected, then this is set to a simple character value of "No fit was selected.".

uvfit

The contents of a gls fit to the data, housed as a uvfit class object. If type="uv" is not selected, then this is set to a simple character value of "No fit was selected.".

settings

A list of properties carried as-is from the data argument object of class cgOneFactorData. In particular, if zeroscore is specified as a non-NULL number in the cgOneFactorData object in the data argument, then a score value near zero was derived to replace all zeroes for subsequent log-scale analyses. Alternatively, if addconstant is specified as a non-NULL number in the cgOneFactorData object in the data argument, then a value was added to shift up all observations for subsequent log-scale analyses.

Note

Contact cg@billpikounis.net for bug reports, questions, concerns, and comments.

Author(s)

Bill Pikounis [aut, cre, cph], John Oleynick [aut], Eva Ye [ctb]

References

Huber, P. J. (1967), "The Behavior of Maximum Likelihood Estimates Under Nonstandard Conditions", Proceedings of the Fifth Berkeley Symposium on Mathematical Statistics and Probability, Volume 1, 221-233.

Venables, W. N. and Ripley, B. D. (2002), Modern Applied Statistics with S. Fourth edition. Springer.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
data(canine)
canine.data <- prepareCGOneFactorData(canine, format="groupcolumns",
                                      analysisname="Canine",
                                      endptname="Prostate Volume",
                                      endptunits=expression(plain(cm)^3),
                                      digits=1, logscale=TRUE, refgrp="CC")
									  
canine.fit <- fit(data=canine.data, type="rr")


data(gmcsfcens)
gmcsfcens.data <- prepareCGOneFactorData(gmcsfcens, format="groupcolumns",
                                         analysisname="cytokine",
                                         endptname="GM-CSF (pg/ml)",
                                         logscale=TRUE)

gmcsfcens.fit <- fit(gmcsfcens.data, type="aft")

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.