An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121113/6d9ee418/attachment.pl>
Simulation with cpm package
2 messages · Christopher David Desjardins, Uwe Ligges
5 days later
On 13.11.2012 15:45, Christopher Desjardins wrote:
Hi, I am running the following code based on the cpm vignette's code. I believe the code is syntactically correct but it just seems to hang R. I can get this to run if I set the sims to 100 but with 2000 it just hangs. Any ideas why?
No: Works for me and completes within 90 minutes. Uwe Ligges
Thanks,
Chris
library(cpm)
cpmTypes <- c("Kolmogorov-Smirnov","Mann-Whitney","Cramer-von-Mises")
changeMagnitudes <- c(1, 2, 4, 5)
changeLocations <- c(50,100,300)
sims <- 2000
ARL0 <- 500
startup <- 20
results <- list()
for (cpmType in cpmTypes) {
results[[cpmType]] <- matrix(numeric(length(changeMagnitudes) *
length(changeLocations)), nrow =
length(changeMagnitudes))
for (cm in 1:length(changeMagnitudes)) {
for (cl in 1:length(changeLocations)) {
print(sprintf("cpm:%s magnitude::%s location:%s",
cpmType, changeMagnitudes[cm], changeLocations[cl]))
temp <- numeric(sims)
for (s in 1:sims) {
x <-c(rchisq(changeLocations[cl], df=3), rchisq(2000,
df=changeMagnitudes[cm]))
temp[s] <-detectChangePoint(x, cpmType,
ARL0=ARL0,
startup=startup)$detectionTime
}
results[[cpmType]][cm,cl] <- mean(temp[temp > changeLocations[cl]]) -
changeLocations[cl]
}
} }
[[alternative HTML version deleted]]
______________________________________________ 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.