# Creating Homogeneous Groups

### Description

A function to create homogeneous groups of named objects according to an objective function evaluated at a covariate. It can be useful to design experiments which contain a fixed covariate factor.

### Usage

1 | ```
creategroups(x, ngroups, sizes, fun = mean, tol = 0.01, maxit = 200)
``` |

### Arguments

`x` |
a numeric vector of a covariate at which to evaluate the objective function. |

`ngroups` |
the number of groups to create. |

`sizes` |
a numeric vector of length equal to |

`fun` |
the objective function, i.e., to create groups with similar |

`tol` |
the tolerance level to define the groups as homogenenous; see details. |

`maxit` |
the maximum number of iterations; default is 200. |

### Details

`creategroups`

uses a `tol`

value to evaluate the following statistic:
*h = ∑_{j}^{ngroups} abs( t_{j+1} - t_j ) / ngroups*, where *t_j = fun(group_j)*.
If *h ≤q tol*, the groups are considered homogeneous.

### Value

A list of

`covar ` |
a character indicating the name of the covariate. |

`func ` |
a character indicating the name of the objective function. |

`val.func ` |
a numeric vector containing the values evaluated by |

`niter ` |
the number of iteration require to achieve convergence. |

`labels ` |
a list containing the labels of the objects in each group. |

`groups ` |
a list of named vectors containing the values for the groups |

### Author(s)

Anderson Rodrigo da Silva <anderson.agro@hotmail.com>

### Examples

1 2 3 4 5 6 | ```
x <- rnorm(10, 1, 0.5)
names(x) <- letters[1:10]
creategroups(x, ngroups = 2, sizes = c(5, 5))
creategroups(x, ngroups = 3, sizes = c(3, 4, 3), tol = 0.05)
# End (not run)
``` |