Skip to content
GitLab
Explore
Sign in
Commits on Source (2)
new: needed regr.tests (so can play with variants)
· 1b5d7de9
Martin Maechler
authored
Sep 10, 2018
1b5d7de9
a bit more on platform-dependencies (BLAS/Lapack)
· 00923a3e
Martin Maechler
authored
Sep 10, 2018
00923a3e
Show whitespace changes
Inline
Side-by-side
DESCRIPTION
View file @
00923a3e
Package: CLA
Version: 0.90-2
Date: 2018-0
2-08
Date: 2018-0
9-10
Title: Critical Line Algorithm in Pure R
Author: Yanhao Shi <syhelena@163.com>,
Martin Maechler <maechler@stat.math.ethz.ch>
...
...
tests/SP500-ex.R
View file @
00923a3e
...
...
@@ -80,7 +80,9 @@ file.info("wtsn0.rds")$size # 27049
wtsn0.ref
<-
readRDS
(
"wtsn0.rds"
)
## see on all platforms what we get
all.equal
(
target
=
wtsn0.ref
,
current
=
wts.non0
,
tol
=
0
)
# expect TRUE only on 64bit (Lnx)
all.equal
(
target
=
wtsn0.ref
,
current
=
wts.non0
,
tol
=
0
)
# expect TRUE only on 64bit (Lnx, R's BLAS)
# 3.10416e-15 and 1.366427e-15 on other BLAS
stopifnot
(
all.equal
(
target
=
wtsn0.ref
,
current
=
wts.non0
,
tol
=
1e-13
))
...
...
@@ -134,17 +136,42 @@ if(all(non.0.assets == non.0.TARG)) { ## show differences:
cat
(
"\n'non.0.assets' differing from non.0.TARG:\n"
)
cat
(
"+1:\n"
);
dput
(
names
(
b64.n0
)[
non.0.assets
-
non.0.TARG
==
+1
])
cat
(
"-1:\n"
);
dput
(
names
(
b64.n0
)[
non.0.assets
-
non.0.TARG
==
-1
])
## solaris :
## +1:
## c("AET", "BCR", "CI", "CL", "ED", "FE", "HAL", "MCD", "SII", "SYK")
## -1:
## c("AZO", "BAX", "CLX", "COST", "DGX", "DVN", "ESRX", "LMT", "MUR",
## "PEP", "RIG", "SYMC", "TYC", "UST")
## ATLAS :
## +1:
## c("AZO", "BRL", "CCE", "CLX", "INTU", "JNJ", "K", "LMT", "MUR",
## "PEP", "SSP", "TYC", "UST", "XTO")
## -1:
## c("AET", "BCR", "CI", "ED", "FE", "MCD", "NEM", "SII", "SYK", "WMT")
## MKL:
## +1:
## c("CLX", "INTU", "LH", "LLL", "LMT", "PBG", "SYMC", "TYC")
## -1:
## c("AMGN", "BCR", "BUD", "CL", "CTL", "ED", "HAL", "NEM", "XTO")
## OpenBLAS:
## +1:
## c("BAX", "COST", "HST", "JNJ", "MDT", "MUR", "NOC", "PDCO", "WAG")
## -1:
## c("BCR", "CI", "CTL", "ED", "EIX", "HAL", "MCD", "RAI", "SYK")
if
(
any
(
isB
<-
abs
(
non.0.assets
-
non.0.TARG
)
>
1
))
{
cat
(
"more different, showing differences:\n"
)
dput
((
non.0.assets
-
non.0.TARG
)[
isB
])
}
## OpenBLAS (only!):
## c(XTO = -2L)
}
## They have the same names and only differ by +/- 1:
stopifnot
(
identical
(
names
(
b64.n0
),
names
(
b32.n0
))
## ______ ______
,
if
(
b64
)
identical
(
non.0.assets
,
non.0.TARG
)
,
if
(
b64
)
identical
(
non.0.assets
,
non.0.TARG
)
# fails on ATLAS, MKL, OpenBLAS
else
if
(
nonWindows
)
identical
(
non.0.assets
,
b32.n0
)
else
## 32-bit Windows
TRUE
## for now
...
...
tests/findSigMu-ex.R
0 → 100644
View file @
00923a3e
require
(
CLA
)
b64
<-
.Machine
$
sizeof.pointer
==
8
cat
(
sprintf
(
"%d bit platform type '%s'\n"
,
if
(
b64
)
64
else
32
,
.Platform
$
OS.type
))
(
nonWindows
<-
.Platform
$
OS.type
!=
"windows"
)
arch
<-
Sys.info
()[[
"machine"
]]
.M
<-
.Machine
;
str
(
.M
[
grep
(
"^sizeof"
,
names
(
.M
))])
## differentiate long-double..
## Do we have 64bit but no-long-double ?
b64nLD
<-
(
arch
==
"x86_64"
&&
.M
$
sizeof.longdouble
!=
16
)
if
(
b64nLD
)
arch
<-
paste0
(
arch
,
"--no-long-double"
)
arch
data
(
muS.sp500
)
## <<-- working from this data ---------------------
##--> ../man/findMu.Rd -- has this example
set.seed
(
2016
)
iS
<-
sample.int
(
length
(
muS.sp500
$
mu
),
17
)
cov17
<-
muS.sp500
$
covar
[
iS
,
iS
]
CLsp.17
<-
CLA
(
muS.sp500
$
mu
[
iS
],
covar
=
cov17
,
lB
=
0
,
uB
=
1
/
2
)
CLsp.17
# 16 turning points
tpS
<-
CLsp.17
$
MS_weights
[,
"Sig"
]
str
(
s0
<-
seq
(
0.0186
,
0.0477
,
by
=
0.0001
))
mu..
<-
findMu
(
s0
,
result
=
CLsp.17
,
covar
=
cov17
)
str
(
mu..
)
stopifnot
(
dim
(
mu..
$
weight
)
==
c
(
17
,
length
(
s0
)))
## and then plots
##--> ../man/findSig.Rd -- has this example
set.seed
(
2018
)
iS
<-
sample.int
(
length
(
muS.sp500
$
mu
),
21
)
cov21
<-
muS.sp500
$
covar
[
iS
,
iS
]
CLsp.21
<-
CLA
(
muS.sp500
$
mu
[
iS
],
covar
=
cov21
,
lB
=
0
,
uB
=
1
/
2
)
CLsp.21
# 14 turning points
tpM
<-
CLsp.21
$
MS_weights
[,
"Mu"
]
str
(
m0
<-
c
(
min
(
tpM
),
seq
(
0.00205
,
0.00525
,
by
=
0.00005
),
max
(
tpM
)))
sig.
<-
findSig
(
m0
,
result
=
CLsp.21
,
covar
=
cov21
)
str
(
sig.
)
stopifnot
(
dim
(
sig.
$
weight
)
==
c
(
21
,
length
(
m0
)))
## and then plots