
Last chance! 50% off unlimited learning
Sale ends in
model
, model.brief
Automatically selects and then provides an analysis of a linear model: OLS regression, Logistic regression, ANOVA, or a t-test depending on the proprieties of the data. Comprehensive regression analysis with graphics from a single, simple function call with many default settings, each of which can be re-specified. By default the data exists as a data frame with the default name of mydata
, such as data read by the lessR
rad
function. Specify the model in the function call according to an R formula
, that is, the response variable followed by a tilde, followed by the list of predictor variables, each pair separated by a plus sign.
Model(my.formula, dframe=mydata, brief=FALSE, ...)model.brief(..., brief=TRUE)
model(...)
formula
for specifying a model. For
example, for a response variable named Y and two predictor variables, X1 and
X2, specify the corresponding linear model as Y ~ X1 + X2.mydata
, otherwise explicitly specify.lm
which provide the core computations.Model
is to combine many standard R function calls into one, as well as provide ancillary analyses such as as graphics, organizing output into tables and sorting to assist interpretation of the output, all from a single function. Currently the supported models are OLS regression, ANOVA and the t-test. For more details of each of these methods, see the lessR
functions Regression
, Logit
, ANOVA
and ttest
, respectively, which, in turn are based on many standard R functions.All invocations of the model
function are based on the standard R formula
.
formula
, lm
, glm
, summary.lm
, anova
, confint
, fitted
, resid
, rstudent
, cooks.distance
# Generate random data, place in data frame mydata
n <- 200
X1 <- rnorm(n)
X2 <- rnorm(n)
Y <- .7*X1 + .2*X2 + .6*rnorm(n)
Ybin <- cut(Y, breaks=2, labels=FALSE)
# instead, if read data with the rad function
# then the result is the data frame called mydata
mydata <- round(data.frame(X1, X2, Y, Ybin),2)
rm(Y); rm(Ybin); rm(X1); rm(X2)
# One-predictor regression
# Provide all default analyses including scatterplot etc.
Model(Y ~ X1)
# alternate form
model(Y ~ X1)
# Multiple regression model
# Provide all default analyses, including interactive 3d scatterplot
Model(Y ~ X1 + X2)
# Logit analysis
# Y is binary, 0 or 1
Recode(Ybin, old=c(1,2), new=c(0,1))
Model(Ybin ~ X1)
# t-test
Model(breaks ~ wool, dframe=warpbreaks)
# ANOVA analysis
# from another data frame other than the default \code{mydata}
# breaks is numerical, wool and tension are categorical
Model(breaks ~ wool + tension, dframe=warpbreaks)
Run the code above in your browser using DataLab