Learn R Programming

SpatialML (version 1.8.2)

random.test.data: Random Data Generator

Description

Generates a synthetic data set composed of one dependent variable, a number of independent variables drawn from Uniform(0, 1), and optionally the X and Y coordinates of a regular nrows x ncols grid. Useful for examples, unit testing and small simulation studies.

Usage

random.test.data(nrows = 10, ncols = 10, vars.no = 3,
                 dep.var.dis = c("normal", "poisson"),
                 xycoords = TRUE)

Value

A data frame with nrows * ncols rows containing one column dep, vars.no - 1 columns named X1, X2, ... and, when xycoords = TRUE, two extra columns X and Y.

Arguments

nrows

integer; number of rows of the regular grid. Default 10.

ncols

integer; number of columns of the regular grid. Default 10.

vars.no

integer; total number of model variables (1 dependent plus vars.no - 1 independent). Must be at least 2.

dep.var.dis

distribution of the dependent variable. One of "normal" (default, drawn from rnorm()) or "poisson" (drawn from rpois() with lambda = 7).

xycoords

logical; if TRUE (default) two columns X and Y containing the grid coordinates are appended.

Author

Stamatis Kalogirou stamatis.science@gmail.com

Details

The function is mostly intended to provide reproducible toy data for the package examples. The independent variables are named X1, X2, ..., X(vars.no - 1).

For reproducible results call set.seed() before random.test.data().

Examples

Run this code
set.seed(1)
RDF <- random.test.data(12, 12, 3)
head(RDF)

Run the code above in your browser using DataLab