Learn R Programming

gplm (version 0.7-4)

create.grid: Create a grid for kernel estimation

Description

Helps to define a grid for kernel denity or regression estimates (univariate or multivariate).

Usage

create.grid(grid.list, sort=TRUE)

Arguments

grid.list
list of 1-dimensional vectors containing the grid values for each dimension
sort
sort the vectors (can be set to FALSE if vectors are already sorted in ascending order)

Value

m x d grid matrix

Details

This function allows easily to define grids for the "gplm" package. If the data are d-dimensional and the grid vector lengths are n1, ... nd, then the output is a (n1*...*nd) x d matrix with each row corresponding to one d-dimensional data point at which the function estimate is to be calculated.

See Also

expand.grid, kde, kreg

Examples

Run this code
  v1 <- 1:5
  v2 <- 3:1
  grid <- create.grid(list(v1,v2))

  x <- matrix(rnorm(60),30,2)
  v1 <- seq(min(x[,1]),max(x[,1]),length=10)
  v2 <- seq(min(x[,2]),max(x[,2]),length=5)
  grid <- create.grid(list(v1,v2))

Run the code above in your browser using DataLab