regr: Fitting Regression Models

Description Usage Arguments Details Value Author(s) See Also Examples

Description

'regr' fits regression models of various types: ordinary, robust, quantile, Tobit, logistic, generalized linear, multinomial, ordered response, multivariate, ...

It is a wrapper function which calls the respective S fitting functions and yields an extensive result, to be used by the respective print and plot methods.

Usage

1
2
3
4
5
regr(formula, data=NULL, family=NULL, robust = FALSE, method=NULL, 
     nonlinear = FALSE, start=NULL, subset=NULL, weights=NULL, offset=NULL, ...)

## S3 method for class 'regr'
summary(object, ...)

Arguments

formula

a symbolic description of the model to be fit.

data

data frame containing the variables in the model.

family

character string describing the type of model and the fitting procedure. By default, regr will fit a model that is suitable for the response variable, if possible.
Can be either "gaussian" for ordinary regression, including multivariate response, "binomial" for logistic regression, "poisson" for Poisson regression, "multinomial" for multinomial regression, "polr" for ordered response (cumulative logits) regression, "weibull", "lognormal", "loglogistic", "extreme" for survival regression with the respective distribution, "ph" for Cox regression, or a suitable argument for glm, i.e.: A description of the error distribution and link function to be used in the model. This can be a character string naming a family function, a family function or the result of a call to a family function. (See 'family' for details of family functions.)

nonlinear

if TRUE, a non-linear model is expected, to be fitted by nlm

start

if nonlin is TRUE, starting values for nlm

robust

if TRUE, robust fitting is used if a function is available, see Details.

method

"rq" or "quantreg" requires fitting by quantile regression. Then, the argument tau is used for setting the quantile: regr(..., method="quantreg", tau=0.9). Otherwise, if suitable, a method argument that is passed to the fitting procedure, see also Details.

subset

an optional vector specifying a subset of observations to be used in the fitting process. Names of variables in data can be used to generate the vector.

weights

an optional vector of weights to be used for fitting.

offset

sometimes used to help specify the model.

...

additional arguments, which are passed to regr.control, see ?regr.control

object

'summary.regr' simply returns its only argument object.

Details

Contrasts: If (ordered) factors are generated in the formula (like y~ordered(f1)), the contrast functions contr.wsum and contr.wpoly will be equivalent to their unweighted versions.

Robust fitting is available for ordinary linear models, by setting robust = TRUE. By default, the function lmrob from package robustbase is called with the argument setting="KS2011". This default will be changed in future versions. Alternative methods can be obtained by setting the method argument. Choosing method="rlm" calls function rlm from package MASS with default method="MM". Any further elements of method will be passed on to the methods argument of the called function.

The 'summary' generic function does nothing to 'regr' objects, since all useful information is already collected in the object.

Logical explanatory variables are converted into numeric, in contrast to the official R fitting functions, which treat them as factors.

Value

regr returns a list object of class regr and secondary class as produced by the fitting function. The components include generally those of the results of the fitting function and its summary. The important additional components are:

termtable

data.frame, table for testing terms both for single and mulitple degree terms (continuous or binary explanatory variables and factors). The columns are The print method for the whole regr object will by default not show all of them.

allcoef

All coefficients. This is a list with a component for each term. Each component characterizes the coefficients similar to the termtable just explained, but without the columns df, stcoef, R2.x. Note that the interpretation of the coefficients of dummy variables depends on the contrasts used for the factor. Tests need to be interpreted correspondingly, and with caution.

stres

Standardized residuals

sigma

estimated standard deviation for normal errors,
sqrt(dispersion) for glm

h

leverage values

allvars

the variables used for fitting the model

binfac

levels of binary factors

fitfun, funcall

R function and call that has been used for fitting the model

Author(s)

Werner A. Stahel, Seminar for Statistics, ETH Zurich

See Also

lm, glm, rlm, multinom, polr,...

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
data(d.blast)
( r.blast <-
  regr(log10(tremor)~location+log10(distance)+log10(charge), data=d.blast) )

## Anorexia
data(anorexia, package="MASS")
r.anorexia <- regr(Postwt ~ Prewt + Treat + offset(Prewt),
                   data = anorexia)

## Annette Dobson (1990) "An Introduction to Generalized Linear Models".
     ## Page 9: Plant Weight Data.
ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
d.dob <- data.frame(group = gl(2,10,20, labels=c("Ctl","Trt")),
                    weight = c(ctl, trt))
(r.dob <- regr(weight ~ group, data=d.dob))

## multinomial regression
data(d.surveyenvir)
d.surveyenvir$dist.unordered <- factor(as.character(d.surveyenvir$disturbance))
t.r <- regr(dist.unordered~age+education+location, data=d.surveyenvir)

## ordered regression
data(housing, package="MASS")
t.r <- regr(Sat ~ Infl + Type + Cont, weights = Freq, data = housing)
plot(t.r)

## multivariate regression
data(d.fossiles)
r.mregr <-
  regr(cbind(sAngle,lLength,rWidth)~SST.Mean+Salinity+lChlorophyll+region+N,
                data=d.fossiles)

regr0 documentation built on May 2, 2019, 4:52 p.m.

Related to regr in regr0...