Title: | David Scott's ASH Routines |
---|---|
Description: | David Scott's ASH routines ported from S-PLUS to R. |
Authors: | S original by David W. Scott R port by Albrecht Gebhardt <[email protected]> adopted to recent S-PLUS by Stephen Kaluzny <[email protected]> |
Maintainer: | Albrecht Gebhardt <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.0-15 |
Built: | 2024-12-18 06:47:19 UTC |
Source: | CRAN |
Internal ash functions
These functions are not intended to be called by the user.
Computes univariate averaged shifted histogram (polynomial kernel)
ash1(bins, m, kopt)
ash1(bins, m, kopt)
bins |
(input list) |
m |
(input) optional integer smoothing parameter; default=5. |
kopt |
(input) vector of length 2 specifying the kernel, which
is proportional to |
returns structure suitable for input to plot
dd
x=t |
vector of bin center locations |
y=f |
vector of ash estimates |
ier |
0=normal exit; 1=estimate nonzero outside interval ab |
x <- rnorm(100) # data f <- ash1(bin1(x,nbin=50),5) # compute ash estimate plot( f , type="l" ) # line plot of estimate
x <- rnorm(100) # data f <- ash1(bin1(x,nbin=50),5) # compute ash estimate plot( f , type="l" ) # line plot of estimate
Compute bivariate ASH estimate (product polynomial kernel)
ash2(bins, m, kopt)
ash2(bins, m, kopt)
bins |
(input list) bin count matrix nc and interval matrix ab from |
m |
(input integer vector of length 2) x and y direction smoothing parameters. Default is 5 by 5. |
kopt |
see |
Matrix of ASH estimates returned. Components x,y,z can be given to the contour function directly. Other input variables returned in list for record keeping.
# Continuing example from help(bin2) m <- c(5,5) f <- ash2(bins,m) image(f$x,f$y,f$z) contour(f$x,f$y,f$z,add=TRUE)
# Continuing example from help(bin2) m <- c(5,5) f <- ash2(bins,m) image(f$x,f$y,f$z) contour(f$x,f$y,f$z,add=TRUE)
Function to compute array of bin counts for a data vector
bin1(x, ab, nbin=50)
bin1(x, ab, nbin=50)
x |
(input) data vector |
ab |
(input vector of length 2): half-open interval for bins |
nbin |
(input integer): number of bins desired. Default 50. |
bin1
returns a list including the vector of integer bin counts and
the ab vector and the number of points outside the ab interval.
x <- rnorm(100) # data vector ab <- c(-5,5) # bin interval bins <- bin1(x,ab,10) # bin x into 10 bins over ab
x <- rnorm(100) # data vector ab <- c(-5,5) # bin interval bins <- bin1(x,ab,10) # bin x into 10 bins over ab
Bin bivariate data x
bin2(x, ab, nbin)
bin2(x, ab, nbin)
x |
(input matrix with 2 columns) data sample |
ab |
(input 2 x 2 matrix) rows 1 and 2 contain x and y axis bin intervals, respectively. If not specified, the ranges are stretched by 5% at each end for each dimension. |
nbin |
(input vector of length 2) number of bins along x and y axes. Default is 20 by 20. |
bin2
returns a list including the bivariate bin matrix
and the number of points outside the ab rectangle.
x <- matrix( rnorm(200), 100 , 2) # bivariate normal n=100 ab <- matrix( c(-5,-5,5,5), 2, 2) # interval [-5,5) x [-5,5) nbin <- c( 20, 20) # 400 bins bins <- bin2(x, ab, nbin) # bin counts,ab,nskip
x <- matrix( rnorm(200), 100 , 2) # bivariate normal n=100 ab <- matrix( c(-5,-5,5,5), 2, 2) # interval [-5,5) x [-5,5) nbin <- c( 20, 20) # 400 bins bins <- bin2(x, ab, nbin) # bin counts,ab,nskip