Description Usage Arguments Details Value Author(s) References Examples

View source: R/graphical_tools_lin.R

This function provides the mode forest.

1 2 |

`data` |
Sample in which the mode forest is computed. |

`bws` |
Vector or range of bandwidths. If it is a vector of size two, then it is used a grid of bandwidths between the given values. Default lower bandwidth is twice the distance between the grid points used for estimating the density and upper bandwidth equal to the range of the data. Unless it is specified a vector of size greater than two, the number of bandwidths employed is equal to the second element of |

`gridsize` |
Number of grid points in the horizontal (values of the variable, first element) and vertical (bandwidths, second element) axis. Default is |

`B` |
Number of replicates used for generating the mode forest. Default |

`n` |
The number of equally spaced points at which the density is to be estimated. When n > 512, it is rounded up to a power of 2 as in the |

`cbw1` |
Number of modes for which the first critical bandwidth is calculated. This is the first bandwidth used to compute the mode tree when |

`cbw2` |
Number of modes for which the second critical bandwidth is calculated. This is the last bandwidth used to compute the mode tree when |

`display` |
Logical, if |

`logbw` |
Logical, if |

`from` |
First plotted value of the variable. Default is below the data minimum. |

`to` |
Last plotted value of the variable. Default is above the data maximum. |

`logbw.regulargrid` |
Logical, if |

`...` |
Arguments to be passed to subsequent methods, |

The mode forest for the sample given in `data`

is computed. For this calculation, a kernel density estimator with Gaussian kernel and bandwidths `bws`

is used. The mode forest is generated by looking simultaneously at a collection of mode trees generated by the original sample and `B`

random resamples drawn with replacement from `data`

. When the mode forest is plotted, this tool represents the number of times an estimated mode falls in each location-bandwidth (horizontal-vertical axis) pixel. The pixels are then shaded proportionally to counts (large counts corresponding to darker pixels and low counts to lighter ones).

The NAs will be automatically removed.

A list with class `"gtmod"`

containing the following components:

`modeforest` |
Matrix including the percentage of times that a mode tree falls in each location-bandwidth pixel. |

`range.x` |
Employed location values to represent the mode forest. |

`range.bws` |
Employed bandwidths to compute the different mode trees. |

`logbw` |
Logical value indicating if the bandwidths are given in the log10 scale. |

`sample.size` |
The number of non-missing observations in the sample used for obtaining the mode forest. |

`call` |
The unevaluated expression, which consists of the named function applied to the given arguments. |

Jose Ameijeiras-Alonso, Rosa M. Crujeiras and Alberto Rodríguez-Casal

Minnotte, M. C., Marchette, D. J. and Wegman, E. J. (1998). The bumpy road to the mode forest, *Journal of Computational and Graphical Statistics*, **7**, 239–251.

1 2 3 4 5 6 |

```
Call:
modeforest(data = data, bws = c(0.2, 0.5), B = 29)
n=50. Location values range: -2.810946 2.213695
Number of employed bandwidths: 151. log10 bandwidths scale: FALSE
Bandwidths range: 0.2 0.5
Warning message:
In modeforest(data, bws = c(0.2, 0.5), B = 29) :
A grid of 'bws' between the given ones were used
Call:
modetree(data = data, bws = c(0.2, 0.5), addplot = TRUE, col.lines = "red")
n=50. Location values range: -2.791471 2.19422
Number of employed bandwidths: 151. log10 bandwidths scale: FALSE
Bandwidths range: 0.2 0.5
Warning message:
In modetree(data, bws = c(0.2, 0.5), addplot = TRUE, col.lines = "red") :
A grid of 'bws' between the given ones were used
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.