When using ecdf() (or Ecdf ) in R, I get a number of knots equal to around 500. However, I need a number of knots that reflects the number of observations I have in the original dataset (in my case, 300).
How can I adjust the number of knots in ecdf? Or, is it possible?
Below is the R code:
install.packages("Hmisc");
library(Hmisc)
nobs <- 300
g1_true <- 2
eps <- rnorm(nobs, 3.5,2.1)
Z <- rbinom(n=nobs, size=3, p=0.5)
P <- g1_true*Z + eps
# marginal density for P
h.p <- density(P,bw="nrd0", kernel="epanechnikov")$y
# get the marginal distribution H(p)
H.p <- ecdf(h.p)
length(knots(H.p))