Learn R Programming

gamlss.util (version 4.3-4)

scattersmooth: Two dimensional Smooth scatter plots

Description

The function produced two dimensional smooth scatter plots. The method used is described in Eilers and Goeman (2004).

Usage

scattersmooth(x, y, nbin = 100, lambda = 1, ndot = 500, csize = 0.3, ticks = TRUE, xlim = c(min(x), max(x)), ylim = c(min(y), max(y)), show = TRUE, save = FALSE, data = NULL, xlab = NULL, ylab = NULL, cols = heat.colors(10:200), col.points = "blue", ...)

Arguments

x
the x-variable
y
the y-variable
nbin
the number of bins required for smoothing
lambda
the smoothing parameter
ndot
how many data points to show in the plot
csize
the size of the data points
ticks
whether ticks in the x and y axis appear in the plot
xlim
the x limit
ylim
the y limit
show
whether to show the graph or not
save
whether to save the output as a list or not
data
the data file data
xlab
the x label as character string
ylab
the y label as character string
cols
for changing the color scheme, the defaul is heat.colors(10:200). Other suggestions are gray(0:100/100), heat.colors(101), rainbow(100:200), terrain.colors(101), topo.colors(101), cm.colors(101). Note that if you have the package colorspace in R you can used heat_hcl(100) which was the default before.
col.points
the colours of the points
...
for extra arguments

Value

the function produces a two dimensional smooth plot and saves if save=TRUE a list with the following components:
Hraw
A nbin by nbin matrix containing the bin row data
Hsmooth
A nbib by nbib matrix containing the smooth two dimensional histogram
xgrid
the x-grid
ygrid
the y-grid
xbin
the bin for x values
ybin
the bin for y values
nmiss
number of missing values
seldots
the values of the plotted dots

Details

The function is similar to the function smoothScatter() in graphics but it used penelized bin smoother as described in Eilers and Goeman (2004) rather than kernel smoother.

References

Eilers, P. H. C. and Goeman, J. J. (2004). Enhancing scatterplots with smoothed density. Bioinformatics, Vol 20 no 5, pp 623-628.

Rigby, R. A. and Stasinopoulos D. M. (2005). Generalized additive models for location, scale and shape,(with discussion), Appl. Statist., 54, part 3, pp 507-554.

Stasinopoulos D. M. Rigby R.A. (2007) Generalized additive models for location scale and shape (GAMLSS) in R. Journal of Statistical Software, Vol. 23, Issue 7, Dec 2007, http://www.jstatsoft.org/v23/i07.

See Also

smoothScatter,gamlss

Examples

Run this code
m <- 1000
set.seed(pi)
phi <- 2 * pi * runif(m)
rho <- rchisq(m, df = 6)
x <- cos(phi) * rho
y <- sin(phi) * rho
H <- scattersmooth(x, y)
H1 <- scattersmooth(x, y, cols=rainbow(100:200)) 
#  If you have the package colorspace use instead 
# library(colorspace)
# H <- scattersmooth(x, y, cols=heat_hcl(100))
# H1 <- scattersmooth(x, y, cols=rainbow_hcl(100))
data(db)
scattersmooth(age, head,  data=db, cols=terrain.colors(101), ndot=2000, lambda=1)
# or if you have colorspace
#scattersmooth(age, head,  data=db, cols=terrain_hcl(100), ndot=2000, lambda=1)

Run the code above in your browser using DataLab