
R version 2.14.0 (2011-10-31)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-unknown-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> 
> 
> ## package: haplo.stats
> ## test script: Ginv
> 
> ## settings
> 
> verbose=TRUE
> 
> require(haplo.stats)
Loading required package: haplo.stats
> 
> # test Ginv on a matrix that is knowns to cause problems for LINPACK
> # implementation of svd used in Ginv.
> 
> # this varx matrix comes from running haplo.scan (within haplo.stats)
> # on the 11-loci hla.demo dataset.  
> source("dump.varx.s")
> 
> # Jason Sinnwell 3/2004
> 
>   if(verbose) cat("setting up data...\n")
setting up data...
> 
>   if(verbose) cat("test matrix (441x441) that causes error in LINPACK, but not LAPACK svd\n")
test matrix (441x441) that causes error in LINPACK, but not LAPACK svd
> 
>   ginv.varx <- Ginv(varx)
>   
> # Ginv.q version 1.4 is known to fail and get a numerical error
> 
> # ginv.varx$Ginv[1:5,1:5]
> 
>   ginv.varx.eps <- Ginv(varx, eps=1e-4)
> 
> #  ginv.varx.eps$Ginv[1:5,1:5]
> 
> if(verbose) cat("the zero matrix should give ginv=0, rank=0\n")
the zero matrix should give ginv=0, rank=0
>   zeroMat <- matrix(0)
>   epsMat <- matrix(1e-7)
>   zeroGinv <- Ginv(zeroMat)
>   epsGinv <- Ginv(epsMat)
>   
>   # a matrix with an NA should give a warning
> #  naMat <- matrix(c(1,0,NA,0,2,1,1,1,3),ncol=3)
> #  na.ginv <- Ginv(naMat)
> 
> 
> # if(verbose) cat("sinking print results to a file\n")
>   
> #if(update) {
> #  sink(file=goldfile)
> #}  else {
> #  sink("sink.Ginv.out")
> #}
> 
>  ## print all testable results (via a diff command) to a file  
> print(ginv.varx$Ginv[1:5,1:5])
             [,1]          [,2]        [,3]          [,4]        [,5]
[1,] 129.30181529   2.020565287  -10.048992 -4.276933e-03   1.4289919
[2,]   2.02056529 129.301815287  -10.048992 -4.276852e-03   1.4289919
[3,] -10.04899156 -10.048991553 3239.425101  4.098196e+00 -10.6405650
[4,]  -0.00427691  -0.004276945    4.098196  8.731269e+03  -0.5958503
[5,]   1.42899185   1.428991852  -10.640565 -5.958504e-01 255.3999184
> 
> ginv.varx$rank
[1] 327
> 
> print(ginv.varx.eps$Ginv[1:5,1:5])
           [,1]       [,2]        [,3]        [,4]       [,5]
[1,] 129.216281   1.935031   -9.689699   -1.161165   1.343310
[2,]   1.935031 129.216281   -9.689699   -1.161165   1.343310
[3,]  -9.689699  -9.689699 3237.757722  -11.376206 -10.280652
[4,]  -1.161165  -1.161165  -11.376206 6101.228011  -1.754314
[5,]   1.343310   1.343310  -10.280652   -1.754314 255.314089
> 
> ginv.varx.eps$rank
[1] 325
> 
> print(zeroGinv)
$Ginv
     [,1]
[1,]    0

$rank
     [,1]
[1,]    0

> 
> print(epsGinv)
$Ginv
     [,1]
[1,]    0

$rank
     [,1]
[1,]    0

> 
> #sink()
>   
> 
> 
> 
> 
