Look at ?cumsum
andydol...@gmail.com 2009/4/28 Rachel Taylor <rachel...@hotmail.com> > > 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@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. > [[alternative HTML version deleted]] ______________________________________________ R-help@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.