sqlocpoly {surveyNG} | R Documentation |
This function performs weighted density estimation and smoothing, using the binned local polynomial smoothers in the KernSmooth
package.
sqlocpoly(formula, design, bandwidth, M = 401)
formula |
One-sided formula for density estimation, two-sided for smoothing |
design |
sqlsurvey object |
bandwidth |
Smoothing bandwidth |
M |
Number of grid points |
The binning is performed in SQL, so for large data sets the computation time is roughly linear in M
and in the number of observations. M
should be a few times larger than range(x)/bandwidth
, but can often be reduced from the default value.
An object of class svysmooth
sqclus1<-sqlsurvey(id="dnum", fpc="fpc", weights="pw", strata="fpc", data=system.file("apiclus1.db",package="surveyNG"), table.name="clus1", key="snum") dens <- sqlocpoly(~api00, sqclus1, bandwidth=50) smooth <- sqlocpoly(api00~api99, sqclus1, bandwidth=50) dens plot(dens) plot(smooth) close(sqclus1)