Learn R Programming

bda (version 1.1.1-7)

histo: Draw histogram based on data with rounding errors

Description

Draw histogram based on data with rounding errors.

Usage

histo(x, m=NULL, alpha=0.05, binned=FALSE,just="center",scale=1.0)

Arguments

x
a numeric value or a vector.
m
number of bins.
alpha
Significance level. Default: 0.05.
binned
Have the data been binned. Default: FALSE.
just
How the data were binned: 'center' (default), 'left' or 'right'.
scale
Data can be rescaled. Default: 1 (no rescaling).

Value

  • If 'scale'=100, the data will be rescaled by dividing all values by 100. For exam the birth weight are usually rounded to 100mg.

Details

The cross validation score will be return as 'Jh'.

See Also

edf, pcb.

Examples

Run this code
x = rnorm(10000)
m=2:100
Jh = NULL
for(i in m){
  out=histo(x,i)
  Jh=c(Jh,out$Jh)
}
plot(Jh~m,type='l')

j = m[which(Jh==min(Jh))]
(out1=histo(x,j))
plot(out1)
lines(dnorm(sort(x))~sort(x))

Run the code above in your browser using DataLab