[R] Histogram with two colors depending on condition

2008-07-17 Thread Mohammad Ehsanul Karim
Dear List, Say, we generate data like this- dat<-rnorm(1000,1,2) hist(dat) How do i make the histogram, say, red (col = 2) before X = dat = 0, and rest say, green (col = 3) beyond X = dat = 0 in R? The resulting histogram could be like this http://ehsan.karim.googlepages.com/histogram.JPG (e

Re: [R] Likelihood optimization numerically

2008-01-27 Thread Mohammad Ehsanul Karim
unreliable: use optimize 2: In fn(par, ...) : value out of range in 'gammafn' Can anyone provide me hint? Thank you for your time. Ehsan http://www.youtube.com/profile_play_list?user=wildsc0p - Original Message ---- From: Mohammad Ehsanul Karim <[EMAIL PROTECTED]> To: r-

[R] Likelihood optimization numerically

2008-01-26 Thread Mohammad Ehsanul Karim
Dear List, I am not sure how should i optimize a log-likelihood numerically: Here is a Text book example from Statistical Inference by George Casella, 2nd Edition Casella and Berger, Roger L. Berger (2002, pp. 355, ex. 7.4 # 7.2.b): data = x = c(20.0, 23.9, 20.9, 23.8, 25.0, 24.0, 21.7, 23.8, 22

[R] Metropolis-Hastings within Gibbs coding error

2007-12-04 Thread Mohammad Ehsanul Karim
Dear list, After running for a while, it crashes and gives the following error message: can anybody suggest how to deal with this? Error in if (ratio0[i] < log(runif(1))) { : missing value where TRUE/FALSE needed ### original program p2 <- function (Nsim=1000){ x<

Re: [R] Survreg(), Surv() and interval-censored data

2007-11-28 Thread Mohammad Ehsanul Karim
Can anybody give me a neat example of interval censored data analysis codes in R? Given that suvreg(Surv(c(1,1,NA,3),c(2,NA,2,3),type="interval2")~1) works why does survreg(Surv(data[,1],data[,2],type="interval2")~1) not work where data is : T.1 T.2 Status 1 0.0