[R] loglin output

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Mon Nov 19 19:04:06 CET 2001


Juan Carlos Correa Morales <jccorrea at perseus.unalmed.edu.co> writes:

> Hi all R-users:
> 
> I am getting some differences from the loglin function in R and S-Plus. Is
> there a bug in the R function? 

Yes, there's a bug(let): If the last k variables are missing from the
model specification, the "dyadic" array has too few columns for the 
 
 vars <- (1:nvar)[dyadic[i - 1, ] > 0]

construction and you get vector recycling, etc. Models with a variable
completely missing rarely make sense, though:

> margin.table(temp$fit,5)
[1] 731.5 731.5
> margin.table(parentesco,5)
[1] 1320  143


For a quick workaround it seems to work to replace the above with

 vars <- (1:nvar)[which(dyadic[i - 1, ] > 0)]



> Juan C. Correa  
> 
> > parentesco<-array(c(27,12,23,7,394,142,421,94,18,13,24,4,48,25,55,
> 13,2,2,4,1,32,19,38,11,1,1,0,3,6,4,15,4),c(2,2,2,2,2))
> 
> Output from R 1.3.1
> 
> > temp<-loglin(parentesco,list(c(3,4),c(1,2)), param=T)
> 2 iterations: deviation 2.273737e-13 
> > temp
> $lrt
> [1] 1126.472
> 
> $pearson
> [1] 968.6632
> 
> $df
> [1] 25
> 
> $margin
> $margin[[1]]
> [1] 1 2
> 
> $margin[[2]]
> [1] 3 4
> 
> 
> $param
> $param$"(Intercept)"
> [1] 2.927703
> 
> $param$"1.5"
>            [,1]       [,2]
> [1,]  0.5819121  0.5819121
> [2,] -0.5819121 -0.5819121
> 
> $param$"2"
> [1]  0.09264558 -0.09264558
> 
> $param$"3"
> [1] -0.9171482  0.9171482
> 
> $param$"4"
> [1]  0.5276034 -0.5276034
> 
> $param$"1.2.5"
> , , 1
> 
>            [,1]       [,2]
> [1,] -0.1396115  0.1396115
> [2,]  0.1396115 -0.1396115
> 
> , , 2
> 
>            [,1]       [,2]
> [1,] -0.1396115  0.1396115
> [2,]  0.1396115 -0.1396115
> 
> 
> $param$"3.4"
>            [,1]       [,2]
> [1,] -0.4286906  0.4286906
> [2,]  0.4286906 -0.4286906
> 
> ============================================================
> Output from S-Plus 6
> 
> > temp<-loglin(parentesco,list(c(3,4),c(1,2)), param=T)
> 2 iterations: deviation 1.52588e-005 
> > temp
> $lrt:
> [1] 1126.472
> 
> $pearson:
> [1] 968.6632
> 
> $df:
> [1] 25
> 
> $margin:
> $margin[[1]]:
> [1] 3 4
> 
> $margin[[2]]:
> [1] 1 2
> 
> 
> 
> $param:
> $constant:
> [1] 2.927703
> 
> $"1":
> [1]  0.5819121 -0.5819121
> 
> $"2":
> [1]  0.09264556 -0.09264556
> 
> $"1 X 2":
>            [,1]       [,2] 
> [1,] -0.1396115  0.1396115
> [2,]  0.1396115 -0.1396115
> 
> $"3":
> [1] -0.9171482  0.9171482
> 
> $"4":
> [1]  0.5276034 -0.5276034
> 
> $"3 X 4":
>            [,1]       [,2] 
> [1,] -0.4286905  0.4286905
> [2,]  0.4286905 -0.4286905
> 
> 
> > 
> 
> 
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list