creating a vector of sums
?cumsum
On Tue, Apr 28, 2009 at 5:30 AM, Rachel Taylor <rachelt04 at hotmail.com> wrote:
Hi,
I am trying to create a function for a goodness-of-fit test for the Pareto Distribution for some loss data that I have.
So far I have the following:
function(X=OTOL)
{
n <- length(X)-1 #calculated the number of values (extra as 0 included)
i <- 2:640 #values of i
j <- 1:639 #values of i-1
Y <- (n-j+1)*((X[i])-(X[j])) #First part of GoF model
Y
}
Where OTOL is the ordered loss data (decreasing), and Y is a vector of length 639
What I need to do next is create another vector TY (of the same length) that is the the sum of part of the Y vector.
So TY[1]=Y[1]
TY[2]=Y[1]+Y[2]
TY[3]=Y[1]+Y[2]+Y[3]
and so on.
I have tried to do a sum(Y[j]) but it just comes out with a single value.
Any help is greatly appreciated, thank you.
Rachel
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?