[R] Problems using hetcor (polycor)
Mark Difford
mark_difford at yahoo.co.uk
Thu Aug 7 15:04:14 CEST 2008
Hi Birgitle,
It seems to be failing on those columns that have just a single "entry" (i.e
= 1, with the rest as 0; having just 1, an <NA>, and then 0s gets you
through). And there are other reasons for failure (in the call to get a
positive definite matrix).
The main problem lies in the calculation of standard errors for some
combinations. You can get a result for all columns by turning this off. You
can get standard errors for all the columns up to 60 by omitting columns 12,
23, and 44. You need to work out the rest yourself by "columning" forwards
till you get a failure, then drop that column from the index. There probably
isn't enough information to calculate SEs for the columns that cause an
error.
## This works with default settings but without columns 12, 23 and 44
hetcor(TestPart[,c(1:11,13:22,24:43,45)], pd=T, std.err=T,
use="complete.obs")
## The first fails; the second works
hetcor(TestPart[,c(1:11,13:22,24:43,45:60)], pd=T, std.err=F)
hetcor(TestPart[,c(1:72)], pd=F, std.err=F)
HTH, Mark.
Birgitle wrote:
>
> Sorry if this post should be long but I tried to give you a piece of my
> data to reproduce my error message using hetcor:
>
> Fehler in result$rho : $ operator is invalid for atomic vectors
> Zusätzlich: Warning messages:
> 1: In polychor(x, y, ML = ML, std.err = std.err) :
> 1 row with zero marginal removed
> 2: In polychor(x, y, ML = ML, std.err = std.err) :
> the table has fewer than 2 rows
>
>
> Error in result$rho : $ operator is invalid for atomic vectors
> Additional: Warning message:
> 1: In polychor(x, y, ML = ML, std.err = std.err) :
> 1 row with zero marginal removed
> 2: In polychor(x, y, ML = ML, std.err = std.err) :
> the table has fewer than 2 rows
>
> Use tab delimited data at the end of the post.
> Copy in Texteditor and save as TestPart.txt
>
> Then use the following code
>
> library(methods)
> setClass("of")
> setAs("character", "of", function(from) as.ordered(from))
>
> Classe81<-cclasses <- c(rep("factor", 64), rep("numeric",6), rep ("of",
> 12))
>
> TestPart<-read.table("TestPart.txt", header=TRUE,row.names=1,
> na.strings="NA" ,colClasses = Classe81)
>
> str(TestPart)
>
> library(polycor)
>
> TestPart.hetcor<-hetcor(TestPart, use="complete.obs")
>
> this will produce the above mentioned error message that I can not
> interprete.
>
> Would be great if somebody could help me to solve the problem.
>
> Thanks
>
> B.
>
>
>
>
> 1 2 3 4 7 8 9 10 12 13 14 15 16 17 18 19 21 22 23 25 27 28 29 30 31 33 34
> 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 58 59 60
> 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
> AX 1 1 0 0 1 0 0 1 0 0 0 0 0 0 0 1 0 1 0 0 1 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0
> 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 1 25 5 9 1 8.5 2.5 3 5 2 2 3 3 1 1 1 2 1
> 2
> BX 1 1 0 0 1 0 0 1 NA NA NA 0 0 0 0 1 0 0 1 0 0 1 0 NA NA NA NA NA NA NA
> NA 0 0 0 1 0 NA NA NA NA NA NA NA 0 0 0 0 1 1 0 0 0 1 1 NA NA 6 1 3.25
> 2.25 5 5 2 2 3 3 1 1 1 1 1 1
> CX 1 1 0 0 1 0 0 1 1 0 0 0 1 0 1 0 0 1 0 1 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0
> 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 15 3.5 6 1 5.5 5.5 5 5 2 2 1 2 1 1 1 1
> 2 2
> DX 1 1 0 0 1 0 0 1 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 1 0 1 0 0 0 1 0 0 0 0 1
> 1 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 50 17.5 7.5 2.5 8.5 5 5 5 2 2 2 3 1 1
> 1 1 3 3
> EX 1 0 1 0 1 0 0 1 NA NA NA 0 0 0 1 1 0 1 1 0 1 0 0 0 0 0 0 1 0 0 0 0 1 0
> 0 0 0 0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 1 0 NA NA 14.5 30 13 2.5 3 3 1 1 4 4 1
> 1 1 1 1 1
> FX 1 0 1 0 1 0 0 1 0 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1 0 1 0 1 0 0 0 0 1 1 0 0 1 1 0 0 0 0 0 1 1 0 0 1 0 0 1 0 1 0
> 0 1 0 1 1 0 0 0 0 0 1 1 0 0 0 0 1 0 200 27.5 6.5 25 2.45 2.25 5 5 2 2 2 3
> 1 1 1 2 7 7
> VY 0 0 1 0 0 1 0 1 0 1 0 0 0 0 1 1 0 0 1 1 0 1 0 0 1 0 1 0 0 1 0 0 1 1 1 0
> 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 1 0 135 17.5 5.5 17.5 2.75 2.25 5 5 2 2 2
> 3 1 1 1 2 5 7
> WY 0 0 1 0 0 1 0 1 0 1 0 0 0 0 0 1 0 0 1 1 0 0 0 0 1 0 1 0 0 1 1 0 1 0 1 1
> 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 1 0 1 240 35 5.5 14 3.25 2.75 5 5 2 2 2 3 1
> 1 1 2 7 7
> XY 0 0 1 0 0 1 0 1 0 1 0 0 0 0 1 1 0 0 1 1 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0
> 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 1 0 0 175 27.5 4 10.5 2.5 1.875 5 5 2 2 2 2
> 1 1 1 1 6 7
> YY 0 0 1 0 0 1 0 1 0 1 0 0 0 0 1 1 0 0 1 1 0 1 0 0 1 1 1 0 0 0 0 0 0 0 1 0
> 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 0 0 1 230 42.5 5.6 25 2.5 2.5 5 5 2 2 2 2 1
> 1 1 2 5 7
> ZY 0 1 0 0 0 1 0 1 0 1 0 0 0 0 1 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1
> 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 115 35 10.5 20 7.5 6.5 5 5 1 1 3 3 1 1
> 1
>
>
>
>
>
>
>
>
>
>
>
>
--
View this message in context: http://www.nabble.com/Problems-using-hetcor-%28polycor%29-tp18867343p18869967.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list