[R] How to determine whether a value belong to a cumulative distribution?

Luigi Marongiu m@rong|u@|u|g| @end|ng |rom gm@||@com
Sun May 10 10:17:47 CEST 2020


Hello,
I am trying to translate a mathematical formula into R. The formula (or
rather a  set of formulas) is meant to determine the first outlier in a
sequence of measurements. To do this, a parameter r is calculated; this is
essentially the ratio between the variance of the value x and the sum of
the variances of the x-1 elements of the series. x follows a certain
distribution (namely, sigmoid), whereas r follows a cumulative empirical
one.
The text says:
"Each r is distributed as t under the model. Therefore, we can test the
hypothesis whether a single observation deviates from the model by
comparing r with the t distribution, where F(´) is the cumulative
distribution function of the t distribution:
                                P-value = 2 * [1 ± F(1 ± |r|)]
"
I generated a cumulative function with
```
cum_fun = ecdf(abs(x[1:n])
```
which gives me:
```
> n=3
> Empirical CDF
Call: ecdf(abs(x{1:n])
 x[1:3] = 5.5568, 6.5737, 7.2471
```
But now how can I determine if x belongs to the distribution?
If I do, as in the formula:
```
> p = 2 * (1-cum_fun)
Error in 1 - cum_fun : non-numeric argument to binary operator
```
Can I get a p-value associated with this association?
Thank you

-- 
Best regards,
Luigi

	[[alternative HTML version deleted]]



More information about the R-help mailing list