[R] polychoric correlation error

Rosenbaum, Janet jrosenba at rand.org
Sat Aug 5 00:48:46 CEST 2006


Dear all,

I get a strange error when I find polychoric correlations with the ML method, which I have been able to reproduce using randomly-generated data.

What is wrong?  
I realize that the data that I generated randomly is a bit strange, but it is the only way that I duplicate the error message.


> n<-100
> test.x<-rnorm(n, mean=0, sd=1)
> test.c<-test.x + rnorm(n, mean=0, sd=.5)
> thresh.x<-c(-2.5, -1, -.5, .5, 1000)
> thresh.c<-c(-1, 1, 2, 3, 1000)
> 
> discrete.x<-discrete.c<-vector(length=n)
> 
> for (i in 1:n) {
+ 	discrete.x[i]<-which.min(thresh.x < test.x[i] )
+ 	discrete.c[i]<-which.min(thresh.c < test.c[i] )
+ }
> pc<-polychor(discrete.x, discrete.c, std.err=T, ML=T)
Error in optim(c(optimise(f, interval = c(-1, 1))$minimum, rc, cc), f,  : 
	non-finite finite-difference value [1]
In addition: There were 50 or more warnings (use warnings() to see the first 50)
> print(pc)
Error in print(pc) : object "pc" not found
> warnings()
Warning messages:
1: NaNs produced in: log(x) 
2: NA/Inf replaced by maximum positive value
3: NaNs produced in: log(x) 


---

Thanks,

Janet

--------------------

This email message is for the sole use of the intended recip...{{dropped}}



More information about the R-help mailing list