Skip to content

Commit eb7e459

Browse files
committed
Fixed function names to add () in DESCRIPTION, per CRAN request.
1 parent 8f56b90 commit eb7e459

File tree

3 files changed

+104
-102
lines changed

3 files changed

+104
-102
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Version: 0.3.0
55
Author: Kaplan Daniel [aut, cre],
66
Pruim Randall [aut, cre]
77
Maintainer: Daniel Kaplan <[email protected]>
8-
Description: Provides functions for evaluating, displaying, and interpreting statistical models. The goal is to abstract the operations on models from the particular architecture of the model. For instance, calculating effect sizes rather than looking at coefficients. The package includes interfaces to both regression and classification architectures, including lm, glm, random forests and recursive partitioning, knn, linear and quadratic discriminant analysis, and models produced by the caret package's train. It's straightforward to add in other other model architectures.
8+
Description: Provides functions for evaluating, displaying, and interpreting statistical models. The goal is to abstract the operations on models from the particular architecture of the model. For instance, calculating effect sizes rather than looking at coefficients. The package includes interfaces to both regression and classification architectures, including lm(), glm(), MASS::rlm(), random forests and recursive partitioning, k-nearest neighbors, linear and quadratic discriminant analysis, and models produced by the caret package's `train()`. It's straightforward to add in other other model architectures.
99
License: MIT + file LICENSE
1010
Encoding: UTF-8
1111
LazyData: TRUE

vignettes/Basics.Rmd

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ theme_update(legend.position = "top")
2323
knitr::opts_chunk$set(fig.align = "center", fig.show = "hold", out.width = "45%")
2424
```
2525

26-
The `mosaicModel` package provides a basic interface for interpreting and displaying models. From the early beginnings of R, methods such as `summary`, `plot`, and `predict` provided a consistent vocabulary for generating model output and reports, but the format and contents of those reports depended strongly on the specifics of the model architecture. For example, for architectures such as `lm` and `glm`, the `summary` method produces a regression table showing point estimates and standard errors on model coefficients. But other widely used architectures such as random forests or k-nearest neighbors do not generate coefficients and so need to be displayed and interpreted in other ways.
26+
The `mosaicModel` package provides a basic interface for interpreting and displaying models. From the early beginnings of R, methods such as `summary()`, `plot()`, and `predict()` provided a consistent vocabulary for generating model output and reports, but the format and contents of those reports depended strongly on the specifics of the model architecture. For example, for architectures such as `lm()` and `glm()`, the `summary()` method produces a regression table showing point estimates and standard errors on model coefficients. But other widely used architectures such as random forests or k-nearest neighbors do not generate coefficients and so need to be displayed and interpreted in other ways.
2727

2828
To provide a general interface for displaying and interpreting models, the `mosaicModel` package provides an alternative structure of operations that make sense for a wide range of model architectures, including those typically grouped under the term "machine learning."
2929

@@ -40,8 +40,8 @@ The package implements operations that can be applied to a wide range of model a
4040
`mosaicModel` stays out of the business of training models. You do that using functions, e.g.
4141

4242
- the familiar `lm` or `glm` provided by the `stats` package
43-
- `train` from the `caret` package for machine learning
44-
- `rpart`, `randomForest`, `rlm`, and other functions provided by other packages
43+
- `train()` from the `caret` package for machine learning
44+
- `rpart()`, `randomForest`, `rlm`, and other functions provided by other packages
4545

4646
The package authors will try to expand the repertoire as demand requires. (See the section on [adding new model architectures](#new-architectures).)
4747

@@ -73,9 +73,9 @@ fuel_mod_1 <- lm(mpg ~ hp * transmission, data = mtcars)
7373
fuel_mod_2 <- lm(mpg ~ ns(hp, 2) * transmission, data = mtcars)
7474
```
7575

76-
The second model includes a nonlinear dependence on horsepower. You can think of `ns` as standing for "not straight" with the integer describing the amount of "curviness" allowed.
76+
The second model includes a nonlinear dependence on horsepower. You can think of `ns()` as standing for "not straight" with the integer describing the amount of "curviness" allowed.
7777

78-
For models involving only a very few explanatory variables, a plot of the model can give immediate insight. The `mod_plot` function reduces the work to make such a plot.
78+
For models involving only a very few explanatory variables, a plot of the model can give immediate insight. The `mod_plot()` function reduces the work to make such a plot.
7979

8080
```{r out.width = "30%"}
8181
mod_plot(fuel_mod_1)
@@ -120,7 +120,7 @@ Since this is a classifier, the plot of the model function shows the *probabilit
120120

121121
If your interest is in a class other than *virginica*, you can specify the class you want with an additional argument, e.g. `class_level = "setosa"`.
122122

123-
The second iris model has four explanatory variables. This is as many as `mod_plot` will display:
123+
The second iris model has four explanatory variables. This is as many as `mod_plot()` will display:
124124

125125
```{r out.width = "80%", fig.width = 8, fig.height = 8}
126126
mod_plot(iris_mod_2, class_level = "setosa")
@@ -136,12 +136,12 @@ mod_plot(iris_mod_2, ~ Petal.Length + Petal.Width + Sepal.Width)
136136

137137
## Model outputs
138138

139-
The `mod_plot` function creates a graphical display of the output of the model for a range of model inputs. The `mod_eval` function (which `mod_plot` uses internally), produces the output in tabular form, e.g.
139+
The `mod_plot` function creates a graphical display of the output of the model for a range of model inputs. The `mod_eval()` function (which `mod_plot()` uses internally), produces the output in tabular form, e.g.
140140

141141
```{r}
142142
mod_eval(fuel_mod_1, transmission = "manual", hp = 200)
143143
```
144-
`mod_eval` tries to do something sensible if you don't specify a value (or a range of values) for an explanatory variable.
144+
`mod_eval()` tries to do something sensible if you don't specify a value (or a range of values) for an explanatory variable.
145145
```{r}
146146
mod_eval(fuel_mod_1)
147147
```
@@ -163,12 +163,12 @@ mod_eval(iris_mod_1, nlevels = 2)
163163

164164
It's often helpful in interpreting a model to know how the output changes with a change in one of the inputs. Traditionally, model coefficients have been used for this purpose. But not all model architectures produce coefficients (e.g. random forest) and even in those that do use of interactions and nonlinear terms spreads out the information across multiple coefficients. As an alternative, `mod_effect` calculates a model input at one set of values, repeats the calculation after modifying a selected input, and combines the result into a "rate-of-change/slope" or a finite-difference.
165165

166-
Here, `mod_effect` is calculating the rate of change of fuel consumption (remember, the output of `fuel_mod_1` is in term of `mpg`) with respect to `hp`:
166+
Here, `mod_effect()` is calculating the rate of change of fuel consumption (remember, the output of `fuel_mod_1` is in term of `mpg`) with respect to `hp`:
167167

168168
```{r}
169169
mod_effect(fuel_mod_2, ~ hp)
170170
```
171-
Since no specific inputs were specified, `mod_effect` attempted to do something sensible.
171+
Since no specific inputs were specified, `mod_effect()` attempted to do something sensible.
172172

173173
You can, of course, specify the inputs you want, for instance:
174174
```{r}
@@ -256,7 +256,7 @@ The result suggests a lower bias but higher variance for the second fuel model c
256256

257257
## Available model architectures
258258

259-
"Architecture" is used to refer to the class of model. For instance, a linear model, random forests, recursive partitioning. Use the model training functions, such as `lm`, `glm`, `rlm` in the `stats` package or in other packages such as `caret` or `zelig`.
259+
"Architecture" is used to refer to the class of model. For instance, a linear model, random forests, recursive partitioning. Use the model training functions, such as `lm()`, `glm()`, `rlm()` in the `stats` package or in other packages such as `caret` or `zelig`.
260260

261261
You can find out which model architectures are available with the command
262262
```{r}
@@ -272,16 +272,16 @@ The package authors would like to have this package ready-to-run with commonly u
272272
R programmers can add their own model architectures by adding S3 methods for these functions:
273273

274274

275-
- `formula_from_mod`
276-
- `data_from_mod`
277-
- `mod_eval_fun` evaluates the model at specified values of the input variables. This is much like `predict()`, from which it is often built.
275+
- `formula_from_mod()`
276+
- `data_from_mod()`
277+
- `mod_eval_fun()` evaluates the model at specified values of the input variables. This is much like `predict()`, from which it is often built.
278278
- `construct_fitting_call`
279279

280280
The code for the generic and some methods are in the source .R files of the same name. This may give you some idea of how to write your own methods.
281281

282282
It often happens that there is a sensible default method that covers lots of model architectures. You can try this out directly by running `mosaicModel:::data_from_mod.default()` (or a similar name) on the model architecture you want to support.
283283

284-
To illustrate, let's add a set of methods for the `MASS` package's `lda` and `qda` model architectures for classification.
284+
To illustrate, let's add a set of methods for the `MASS` package's `lda()` and `qda()` model architectures for classification.
285285

286286
Step 1 is to create a model of the architecture you're interested in. Remember that you will need to attach any packages needed for that kind of model.
287287

@@ -314,30 +314,30 @@ mod_eval_fun(my_mod)
314314
Error in mod_eval_fun.default(my_mod) : The modelMosaic package doesn't have access to an evaluation function for this kind of model object.
315315
```
316316

317-
Now, of course, there is a `mod_eval_fun` method for models of class `knn3`. How did we go about implementing it?
317+
Now, of course, there is a `mod_eval_fun()` method for models of class `knn3`. How did we go about implementing it?
318318

319-
To start, let's see if there is a `predict` method defined. This is a pretty common practice among those writing model-training functions. Regretably, there is considerable variety in the programming interface to `predict` methods, so it's quite common to have to implement a wrapper to interface any existing `predict` method to `mosaicModel`.
319+
To start, let's see if there is a `predict` method defined. This is a pretty common practice among those writing model-training functions. Regretably, there is considerable variety in the programming interface to `predict()` methods, so it's quite common to have to implement a wrapper to interface any existing `predict()` method to `mosaicModel`.
320320
```{r}
321321
methods(class = "lda")
322322
```
323323

324-
Refer to the help page for `predict.lda` to see what the argument names are. `newdata =` is often the name of the argument for specifying the model inputs, but sometimes it's `x` or `data` or whatever.
324+
Refer to the help page for `predict.lda()` to see what the argument names are. `newdata =` is often the name of the argument for specifying the model inputs, but sometimes it's `x` or `data` or whatever.
325325

326-
Since `lda`/`qda` is a classifier, the form of output we would like to produce is a table of probabilities for each class level for each input class. This is the standard expected by `mosaicModel`. Let's look at the output of `predict`:
326+
Since `lda`/`qda` is a classifier, the form of output we would like to produce is a table of probabilities for each class level for each input class. This is the standard expected by `mosaicModel`. Let's look at the output of `predict()`:
327327

328328
```{r}
329329
predict(my_mod) %>% str()
330330
```
331331

332-
This is something of a detective story, but a person very familiar with `lda` and with R will see that the `predict` method produces a list of two items. The second one called `posterior` and is a matrix with 150 rows and 3 columns, corresponding to the size of the training data.
332+
This is something of a detective story, but a person very familiar with `lda()` and with R will see that the `predict` method produces a list of two items. The second one called `posterior` and is a matrix with 150 rows and 3 columns, corresponding to the size of the training data.
333333

334-
Once located, do what you need in order to coerce the output to a data frame and remove row names (for consistency of output). Here's the `mod_eval_fun.lda` function from `mosaicModel`.
334+
Once located, do what you need in order to coerce the output to a data frame and remove row names (for consistency of output). Here's the `mod_eval_fun.lda()` function from `mosaicModel`.
335335

336336
```{r}
337337
mosaicModel:::mod_eval_fun.lda
338338
```
339339

340-
The arguments to the function are the same as for all the `mod_eval_fun` methods. The body of the function pulls out the `posterior` component, coerces it to a data frame and removes the row names. It isn't always this easy. But once the function is available in your session, you can test it out. (Make sure to give it a data set as inputs to the model)
340+
The arguments to the function are the same as for all the `mod_eval_fun()` methods. The body of the function pulls out the `posterior` component, coerces it to a data frame and removes the row names. It isn't always this easy. But once the function is available in your session, you can test it out. (Make sure to give it a data set as inputs to the model)
341341

342342
```{r error = TRUE}
343343
mod_eval_fun(my_mod, data = iris[c(30, 80, 120),])

vignettes/Basics.html

Lines changed: 81 additions & 79 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)