survey (version 3.9-1)

svysmooth: Scatterplot smoothing and density estimation

Description

Scatterplot smoothing and density estimation for probability-weighted data.

Usage

svysmooth(formula, design, method = "locpoly", bandwidth, ...)
## S3 method for class 'svysmooth':
plot(x, which=NULL, type="l", xlabs=NULL, ylab=NULL,...)
## S3 method for class 'svysmooth':
lines(x,which=NULL,...)

Arguments

formula
One-sided formula for density estimation, two-sided for smoothing
design
Survey design object
method
"locpoly" is the only method so far.
bandwidth
Smoothing bandwidth
which
Which plots to show (default is all)
type
as for plot
xlabs
Optional vector of x-axis labels
ylab
Optional y-axis label
...
More arguments
x
Object of class svysmooth

Value

  • An object of class svysmooth, a list of lists, each with x and y components.

Details

svysmooth does one-dimensional smoothing. If formula has multiple predictor variables a separate one-dimensional smooth is performed for each one. For method="locpoly" the extra arguments are passed to locpoly from the KernSmooth package.

See Also

svyhist for histograms

Examples

Run this code
data(api)
 dstrat<-svydesign(id=~1,strata=~stype, weights=~pw, data=apistrat, fpc=~fpc)

 smth<-svysmooth(api00~api99+ell,dstrat, bandwidth=c(40,10))
 dens<-svysmooth(~api99, dstrat,bandwidth=30)

 plot(smth)
 plot(smth, which="ell",lty=2)

 svyhist(~api99,design=dstrat)
 lines(dens,col="purple",lwd=3)

Run the code above in your browser using DataLab