Tarana Solaiman
2010-Mar-26 19:19 UTC
[R] CDF calculation from kernel density estimates for a 324X 15 matrix
Hi, I have a 324X15 matrix (No of years vs. heavy precipitation days) and I want to calculate the cdf at 5 different data points for each row. I tried by the following codes but it's not working. heavyprec <- read.csv (file="heavyprecdays_CSV.csv",header=TRUE,sep=",") a <- heavyprec pdf <- density (a, bw="SJ", kern= "gaussian") f <- approxfun (pdf$x, pdf$y) cdf <- integrate (f, -Inf, 25.25) # I also have to calculate cdf at 30, 33, 37 heavy precipitation days I know I am misunderstanding the code somewhere. But not being able to figure it out. Basically I want to calculate bandwidth for each of the 324 rows separately and then I need to calculate the kernel sensity estimate for each of 324 rows separately and cdf for all those rows separately at 5 different data points. So I guess I have to use for loops too? This is my 1st program in R and I am sorry if this problem sounds very easy. Any suggestions and help would be highly appreciated! Thanks very much in advance! -- Tarana Solaiman PhD Candidate, Dept. of Civil & Environmental Engineering The University of Western Ontario London, ON, Canada Email: tarana.solaiman@gmail.com [[alternative HTML version deleted]]