computes the derivative of a function in a point using kernel estimation
densfun(formula, design, x, h = NULL, FUN = "F", na.rm = FALSE, ...)
a formula specifying the income variable
a design object of class survey.design
from the survey
library.
the point where the derivative is calculated
value of the bandwidth based on the whole sample
if F
estimates the derivative of the cdf function; if big_s
estimates the derivative of total in the tails of the distribution
Should cases with missing values be dropped?
future expansion
the value of the derivative at x
library(laeken)
data(eusilc) ; names( eusilc ) <- tolower( names( eusilc ) )
library(survey)
des_eusilc <- svydesign(ids = ~rb030, strata =~db040, weights = ~rb050, data = eusilc)
des_eusilc <- convey_prep( des_eusilc )
densfun (~eqincome, design=des_eusilc, 10000, FUN="F" )
#> [1] 3.706938e-05
# linearized design using a variable with missings
densfun ( ~ py010n , design = des_eusilc, 10000, FUN="F" )
#> [1] NA
densfun ( ~ py010n , design = des_eusilc , 10000,FUN="F", na.rm = TRUE )
#> [1] 1.469898e-05