Home > database >  Computing ECDF of a data for parameter estimation using weighted nonlinear least square in R
Computing ECDF of a data for parameter estimation using weighted nonlinear least square in R

Time:11-16

I am writing a code for estimating the parameter of a GPD using weighted nonlinear least square(WNLS) method. The WNLS method consist of 2 steps

step 1: $(\hat{\xi_1} , \hat{b_1}) = arg\ \min_{(\xi,b)} \sum_{i=1}^{n} [\log(1-F_n(x_i)) - log(1-G_{\xi,b}(x_i))]$, here $F_n$ is the ECDF and $1-G_{\xi,b}$ is the generalized pareto distribution.

Can anyone let me know how to calculate EDF function $F_n$ for a data "X" in R? Does ecdf(X)(X) will calculate the ECDF? If so then, what is the need for ecdf(X) other than plotting? Also it would be really helpful if someone share some example code which involves the calculation of ECDF for data.

CodePudding user response:

The ecdf call creates a function. That is, you can apply ecdf(X) to other data, as your ecdf(X)(X) call does. However, you might want to apply ecdf(X) to something other than X itself. If you want to know the empirical quantile to which three numbers a, b, and c_ correspond, an easy way to do that is to call ecdf(X)(c(a, b, c_)).

  •  Tags:  
  • r nls
  • Related