freqdist {lazy.tools}R Documentation

Frequency distribution of multivariate numeric data with case weight

Description

Frequency distribution of multivariate numeric data with case weight

Usage

freqdist(
  x,
  weights = 1,
  npoints = NULL,
  min = NULL,
  max = NULL,
  prob = 0,
  wid = 6,
  dig = 1,
  maxf = NULL,
  rev = 0,
  class = 0,
  omitmiss = 0,
  midpoints = NULL,
  title = NULL,
  digits = 3,
  print = 0,
  plot = 0
)

Arguments

x

numeric vector or column vector

weights

case weight

npoints

# of mid-points

min

minimum value of mid-points

max

maximum value of mid-points
For the multivariate x, (npoints, min, max) can be vectors
specifying different numbers for each variable.

prob

= 1 to return relative frequency in stead of frequency

wid

Format of mid-point value (wid.dig)

dig

Format of mid-point value (wid.dig)

maxf

max value of frequency for plot

rev

= 1 to change the last element of x first.

class

= 1 to output classification

omitmiss

= 1 to omit the missing grids

midpoints

vector of predefied mid-point values
For the multivariate x, midpoints defines the midpoints of each variable,
not their cartesian products.

title

tile to be used in plot

digits

Format for mid-points

print

= 1 to print result

plot

= 1 to plot historgam

Details

(npoints, min, max) defines the mid-points.
If min or max is NULL, min(x) and max(x) will be used.
midpoints has priority over (npoints, min, max).
The out of range observations, that is, those x satisfying
x < midpoints[1] or midpoints[npoints] < x
will be be included in midpoints[1] and midpoints[npoints], resp.

Try this to see how the obs on the border are classified.
xx=c(1,2,3,4,5,6,7)
brks=c(0,2,4,6,8)
cc=cut(xx,brks)

Value

A list consisting of
midpoints= list of midpoints
midpoints1= list of midpoints with lost values
midpindex cartesian product of midpoints number
grid= cartesian product of midpoints
grid[,j]=midpoints[[j]][midpindex[,j]], j=1,2,...,nvar
freq= column vector of frequency at midpoints
breaks= breaks associated with the midpoints
class= classification of each obs into the midpoints if class=1.
nobs= sum of weights

Examples

set.seed(1701)
n <- 1000
X <- matrix(rnorm(2*n),n,2)
res <- freqdist( X, npoints=7,min=-3,max=3, print=1, weights=1, plot=1)

X <- expand.grid(seq(-3,3),seq(-3,3))
weight <- round(n*exp(-0.5*rowSums(X^2)))
res1 <- freqdist( X, weight, npoints=c(7,5),min=-3,max=3, print=1, plot=1)
rm(X)


[Package lazy.tools version 0.1.4 ]