Version: | 1.0-15 |
Title: | David Scott's ASH Routines |
Author: | S original by David W. Scott R port by Albrecht Gebhardt <albrecht.gebhardt@aau.at> adopted to recent S-PLUS by Stephen Kaluzny <spk@insightful.com> |
Maintainer: | Albrecht Gebhardt <albrecht.gebhardt@aau.at> |
Description: | David Scott's ASH routines ported from S-PLUS to R. |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
Date: | 2015-08-27 |
NeedsCompilation: | yes |
Packaged: | 2015-08-31 21:39:59 UTC; alge |
Repository: | CRAN |
Date/Publication: | 2015-09-01 17:56:55 |
Internal ash functions
Description
Internal ash functions
Details
These functions are not intended to be called by the user.
univariate ASH
Description
Computes univariate averaged shifted histogram (polynomial kernel)
Usage
ash1(bins, m, kopt)
Arguments
bins |
(input list) |
m |
(input) optional integer smoothing parameter; default=5. |
kopt |
(input) vector of length 2 specifying the kernel, which
is proportional to |
Value
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 |
See Also
Examples
x <- rnorm(100) # data
f <- ash1(bin1(x,nbin=50),5) # compute ash estimate
plot( f , type="l" ) # line plot of estimate
bivariate ASH
Description
Compute bivariate ASH estimate (product polynomial kernel)
Usage
ash2(bins, m, kopt)
Arguments
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 |
Value
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.
See Also
Examples
# 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)
univariate binning
Description
Function to compute array of bin counts for a data vector
Usage
bin1(x, ab, nbin=50)
Arguments
x |
(input) data vector |
ab |
(input vector of length 2): half-open interval for bins |
nbin |
(input integer): number of bins desired. Default 50. |
Value
bin1
returns a list including the vector of integer bin counts and
the ab vector and the number of points outside the ab interval.
See Also
Examples
x <- rnorm(100) # data vector
ab <- c(-5,5) # bin interval
bins <- bin1(x,ab,10) # bin x into 10 bins over ab
2D binning
Description
Bin bivariate data x
Usage
bin2(x, ab, nbin)
Arguments
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. |
Value
bin2
returns a list including the bivariate bin matrix
and the number of points outside the ab rectangle.
See Also
Examples
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