Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 11th, 2012  |  syntax: None  |  size: 0.62 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. The nested loop is producing this error: Non-numeric argument to mathematical function
  2. library(emdbook)
  3.  
  4. prev<-read.delim("shape.txt", header=T)
  5. shape1<-prev$shape1
  6. shape1<-as.numeric(shape1)
  7. shape2<-prev$shape2
  8. shape1<-as.numeric(shape2)
  9.  
  10. pvec <- seq(0, 1, length=298)
  11.  
  12. postvec<-data.frame(posterior=1:298)
  13. dim(postvec)
  14.  
  15. for (i in 1:length(shape1))
  16. {
  17.     for (j in 1:length(shape2))
  18.     {
  19.     postvec[i]<- dbeta(pvec, shape1= shape1[i], shape2=shape2[j])
  20. }
  21. }
  22.        
  23. prev<-read.delim("shape.txt", header=T)
  24. shape1<-prev$shape1
  25. shape1<-as.numeric(shape1)
  26. shape2<-prev$shape2
  27. shape1<-as.numeric(shape2)
  28.        
  29. shape2<-as.numeric(shape2)