Commit 93453c8f authored by Dirk Eddelbuettel's avatar Dirk Eddelbuettel

Import Debian changes 1.8-13-1

mgcv (1.8-13-1) unstable; urgency=medium

  * New upstream release
parents 59ffb32e fe6ab539
......@@ -2,10 +2,98 @@
*** denotes really big changes
Currently deprecated and liable to be removed:
- bam(...,sparse=TRUE) [1.8-5]
- single penalty tensor product smooths.
- p.type!=0 in summary.gam.
1.8-13
* Added help file ?one.se.rule on the `one standard error rule' for obtaining
smoother models.
* bam(...,discrete=TRUE) no longer complains about more coefficients than data.
* 's', 'te', 'ti' and 't2' modified to allow user to specify that the smooth
should pass through zero at a specified point. See ?identifiability.
* anova.gam modified to use more appropriate reference degrees of freedom
for multiple model call, where possible. Also fixed to allow multiple
formulae models and to use -2*logLik in place of `deviance' for
general.family models.
* offsets allowed with multinomial, ziplss and gaulss families.
* gevlss family implementing generalized extreme value location, sclae and
shape models.
* Faster code used in 'uniquecombs'. Speeds up discretization step in
'bam(...,discrete=TRUE)'. Could still be improved for multi-column case.
* modification to 'smoothCon' to allow resetting of smooth supplied
constraints - enables fix of bug in bam handling of 't2' terms, where
parameterization of penalty and model matrix did not previously match
properly.
* clarification of `exclude' argument to predict.gam in help files.
* modification to 'plot.gam' etc, so that 'ylim' is no longer shifted by
'shift'.
* ylim and ... handling improved for 'fs' plot method (thanks Dave Miller)
* gam.check now recognises RStudio and plots appropriately.
* bam(...,sparse=TRUE) removed - not efficient, because of unavoidability
of dense off diagonal terms in X'X or equivalent. Deprecated since 1.8-5.
* tweak to initial.sp/g to avoid infinite loop in s.p. initialization, in
rather unusual circumstances. Thanks to Mark Bravington.
* bam and gam have `drop.intercept' argument to force the parametric terms not
to include a constant in their span, even when there are factor variables.
* Fix in Vb.corr (2nd order edf correction) for fixed smoothing parameter case.
* added 'all.vars1' to enable terms like s(x$y) in model formulae.
* modification to gam.fit4 to ignore 'start' if it is immediately worse than
'null.coef'.
* cSplineDes can now accept a 'derivs' argument.
* added drop.intercept handling for multiple formulae (mod by Matteo Fasiolo).
* 'gam.side' fix to avoid duplication of smooth model matrices to be tested
against, when checking for numerical degeneracy. Problem could occasionally
cause a failure (especially with bam), when the total matrix to be tested
against ended upo with more columns than rows.
* 4 occurances of as.name("model.frame") changed to quote(stats::model.frame)
* fix in predict.bamd discrete prediction code to be a bit more relaxed about
use of as.factor, etc in formulae.
* fix in predict.gam handling of 'na.action' to avoid trying to get type of
na.action from name of na.action function - this was fragile to nesting
and could cause predict.bam to fail in the presence of NA's.
* fix of gam.outer so that general families (e.g. cox.ph) can have all
their smoothing parameters supplied without then ignoring the penalties!
* fix in multiple formulae handling of fixed smoothing parameters.
* Fix of bug in zlim handling in vis.gam perspective plot with standard
errors. Thanks Petra Kuhnert.
* probit link added to 'jagam' (suggested by Kenneth Knoblauch).
* 'Sl.' routines revised to allow operation with non-linearly parameterized
smoothers.
* bug fix in Hessian computation in gam.fit5 - leading diagonal of Hessian of
log|Hp| could be wrong where Hp is penalized Hessian.
* better use of crossprod in gamlss.gH
1.8-12
......
Package: mgcv
Version: 1.8-12
Version: 1.8-13
Author: Simon Wood <simon.wood@r-project.org>
Maintainer: Simon Wood <simon.wood@r-project.org>
Title: Mixed GAM Computation Vehicle with GCV/AIC/REML Smoothness
......@@ -16,6 +16,6 @@ LazyLoad: yes
ByteCompile: yes
License: GPL (>= 2)
NeedsCompilation: yes
Packaged: 2016-03-02 18:21:25 UTC; sw283
Packaged: 2016-07-20 08:12:21 UTC; sw283
Repository: CRAN
Date/Publication: 2016-03-03 07:57:37
Date/Publication: 2016-07-21 19:18:06
164ed459fdb2fc5b8c362d7509285707 *ChangeLog
05cb1cd52bd24d5ec3b6e370fac7fa86 *DESCRIPTION
5de85e587fe407b6155adbe7a4757259 *ChangeLog
b0a372da89d61623c335e7a9937dcfc0 *DESCRIPTION
eb723b61539feef013de476e68b5c50a *GPL-2
c0cdd9aeb293ae9be0e46458f0255bbf *NAMESPACE
dfb4c20ba65950cf6ef13e73512a59a1 *R/bam.r
9f7dfce7213f23c0ccddd7fc31279b2d *R/coxph.r
81dedc3a4d8529ae61099024a96fdb93 *R/efam.r
e977376bf0123ebd107132bbd185f612 *R/fast-REML.r
693a3d54326ccd997cf63a44633b11c5 *R/gam.fit3.r
4041a125a6cc574a31d0884f9f947957 *R/gam.fit4.r
595f7fa74dd678ae4be1f6968e174555 *NAMESPACE
5d66b16a4068c8848cfca1665e6cc5c7 *R/bam.r
aa23a9b76c09f06b4ec8e71ea903a0a8 *R/coxph.r
fdb1dd621eb177107bbfb5f5c11777b2 *R/efam.r
4b370253beb1eda19d389132ade30212 *R/fast-REML.r
dea8bcbb4668ad0a6dfe3420bebebf48 *R/gam.fit3.r
94ffbce0c3d9504fa0fabd41ca07e5fe *R/gam.fit4.r
1b620b840ca67c9759639bd6e53824e3 *R/gam.sim.r
5aa7c3e6ce301ae6fbd678a9b008e7c5 *R/gamlss.r
52292bf0d5c6e0132eea4ab68b1d2b40 *R/gamm.r
88c39fa594ea5b4105f4654f9f156d7a *R/jagam.r
535b90098a6deb5341962afe7ad82e85 *R/mgcv.r
a03433fd11911b28b59a2e339af9d100 *R/gamlss.r
cceac26b3d01513f8f87eacae91ddae0 *R/gamm.r
4a0ce642d904d7f871b5b766c04a2af4 *R/jagam.r
2a27e142e07820f285b4719c972caa3b *R/mgcv.r
2feca0dc9d354de7bc707c67a5891364 *R/misc.r
e64b3f08d86be17b1b641694794aebd4 *R/mvam.r
04d1a101dad47a624357982f473f49a3 *R/plots.r
9fadbd09a55b6ec6284c222840be1620 *R/smooth.r
03772998ab05887f2eeae10dd6efe983 *R/mvam.r
24d69c678592e666bd2304e671dd8dca *R/plots.r
9292ed3c8e22946033eddc1981d78ea4 *R/smooth.r
1dde3ff2f6c3227d1a4765e41d0cf92b *R/soap.r
76cc875719bf0ef9eab45ea5bfeccda6 *R/sparse.r
e468195a83fab90da8e760c2c3884bd3 *data/columb.polys.rda
......@@ -37,34 +37,34 @@ c574fe1ca9d55a9818d308906f16d16e *man/Beta.Rd
c45c0f78f753461b33a295883461e732 *man/Predict.matrix.cr.smooth.Rd
d0fa291cbbcef359c61e426f6ba38fbb *man/Predict.matrix.soap.film.Rd
f12468625253dd3603907de233762fd6 *man/Rrank.Rd
f50d43782718aa1ea66e0077952afc93 *man/Tweedie.Rd
80f8763baa4987579e2aa56073a9e94e *man/anova.gam.Rd
0d6c9d148c9fa98ae107367a796c7e6d *man/bam.Rd
3b8ce471159dd843bf26ab7eb17a9f33 *man/bam.update.Rd
d3e09165c6ca581db78d820a3c39329c *man/Tweedie.Rd
c93cf5b2e0def2e36cced3ee68912958 *man/anova.gam.Rd
209aff0fbe9653fc80f01ef80d04435f *man/bam.Rd
8c95ed4822108db4e8bc59d8eac9e77c *man/bam.update.Rd
cf5f1ee0aab639c7c4b9b357434f15b2 *man/bandchol.Rd
f4112e262b8280c024c80ff8fa02735f *man/bug.reports.mgcv.Rd
a2beb811b1093c5e82ef32d7de1f7d32 *man/cSplineDes.Rd
745cbf31eb14fc1c5916fc634c74d998 *man/bug.reports.mgcv.Rd
530b8b4bacffa9353561f19ecfccfe19 *man/cSplineDes.Rd
a72647229fd92763636941e61597995d *man/choose.k.Rd
c03748964ef606621418e428ae49b103 *man/columb.Rd
9906a83ce29a3b17044bc2a3c9940cee *man/concurvity.Rd
e2b382e4219c7089d0ecf97c0dd3e1ed *man/coxph.Rd
9fda5546321683530d3351ea1849fe7a *man/coxph.Rd
0a6d4b3858cbb69a5d375ecd09282256 *man/exclude.too.far.Rd
069e7d174bb0d35bf30675e74a47dfd3 *man/extract.lme.cov.Rd
3c590cbac6544535b43f4f0a05d7afae *man/family.mgcv.Rd
2878ef784cc418a8520133194f31bb44 *man/family.mgcv.Rd
44ad0563add1c560027d502ce41483f5 *man/fix.family.link.Rd
4d4eea9ad2b78e765a96b2a0065725c1 *man/fixDependence.Rd
e75719779e18c723ee1fd17e44e7901b *man/formXtViX.Rd
5af8941596cacadd1c54ebe2e7a83c23 *man/formula.gam.Rd
88888e966394c9f9792d9537341d053c *man/formula.gam.Rd
4da4d585b329769eb44f0c7a6e7dd554 *man/fs.test.Rd
6f405acde2d7b6f464cf45f5395113ba *man/full.score.Rd
bbdaff30f65445ab481bbfdca691aca8 *man/gam.Rd
912f575e1a6a7c9b1b94b2130fdfb38b *man/gam.Rd
adaf0bd8e82d9472823cf3f3fa05e111 *man/gam.check.Rd
49de68e2abeb557b994032e4d7b5407a *man/gam.control.Rd
44db24b66ce63bc16d2c8bc3f5b42ac5 *man/gam.convergence.Rd
1cf5145859af2263f4e3459f40e1ab23 *man/gam.fit.Rd
4728be401da6eceb8b0c257377dc5d01 *man/gam.fit3.Rd
8ba3991b5932b0775b452d20c9ff4d54 *man/gam.models.Rd
bc5b41aec269770fe8ffef5ee0902ae8 *man/gam.outer.Rd
c15f647511f54d05d9fc21760cf61d91 *man/gam.outer.Rd
c17814cea1b11e5ca374e72d6e1cbd98 *man/gam.scale.Rd
d828d474a4b069f9b9e3ebe5f05b70ec *man/gam.selection.Rd
310397e938dae8c6b818d2093e4aa354 *man/gam.side.Rd
......@@ -72,36 +72,39 @@ b2ff252537dd2155524b774b2435e66e *man/gam.vcomp.Rd
eb8648cc6b3c9374b899abd2f2b12f7b *man/gam2objective.Rd
717401fd7efa3b39d90418a5d1d0c216 *man/gamObject.Rd
a2593990d6a87f7b783d0435062dec02 *man/gamSim.Rd
327a7fff692c5dc42862555915ae7f8d *man/gamm.Rd
f30b9dc971521416a167a6b13302f06b *man/gaulss.Rd
235410d3b67b06368b5d87b2a342a27a *man/gamm.Rd
2c8676d65853d99efc1bfb7ebc454d8f *man/gaulss.Rd
398a5c12285401c1d37a8edb58780bc3 *man/get.var.Rd
164f3e338ff038e941b0bf9db95dcd16 *man/gevlss.Rd
39b47f30a7ea45382d62ca1753d876a8 *man/identifiability.Rd
4f96476abbf9692f52030d3859580a31 *man/in.out.Rd
6c33026ebb458483d34a04548c05d664 *man/inSide.Rd
2f222eeeb3d7bc42f93869bf8c2af58a *man/influence.gam.Rd
39b9de9dbac7d9dc5c849e1a37def675 *man/initial.sp.Rd
2a37ae59a9f9f5a0a58af45947eca524 *man/interpret.gam.Rd
ddb9a2b533b62a35cdd4338e6adb48f9 *man/jagam.Rd
07d2c259b9edf164f42935170b4fccd0 *man/ldTweedie.Rd
557a6b7a01d8c0ca7d4db3d9cf329ce6 *man/jagam.Rd
87d942b17bee05bb662270b894b183e6 *man/ldTweedie.Rd
58e73ac26b93dc9d28bb27c8699e12cf *man/linear.functional.terms.Rd
93035193b0faa32700e1421ce8c1e9f6 *man/logLik.gam.Rd
b1c95a20afd6eb0825c00b46b8c3cbfa *man/ls.size.Rd
9a2c8f14c7a56eca69f4a59bef27a9bf *man/magic.Rd
5169af4be5fccf9fa79b6de08e9ea035 *man/magic.post.proc.Rd
e5cb91b2fd8646476b8f1114228a33cf *man/mgcv-FAQ.Rd
7f1032c61d424980f4473ac9717dc797 *man/mgcv-FAQ.Rd
ba14a20f6fa77f066bac7cdfe88b8fff *man/mgcv-package.Rd
6db1ae82808e56bd44c04066e2ec09aa *man/mgcv-parallel.Rd
df702cea24d0f92044a973b66a57e21f *man/missing.data.Rd
00ccf213c31910cd14f1df65a300eb33 *man/model.matrix.gam.Rd
2f2fdc722c5e9e58664da9378451cd4a *man/mono.con.Rd
d33914a328f645af13f5a42914ca0f35 *man/mroot.Rd
324839278497102d76a0905339cf7950 *man/multinom.Rd
fafa20038af329d4d9c2e96023f7ee5c *man/mvn.Rd
d777fbaa68f4e7b7d628e39181afb45d *man/negbin.Rd
0748a44497317a19857f81bd76d162db *man/multinom.Rd
d70954045abda626a357951da5e2cbca *man/mvn.Rd
1064099913e539a75bf763c764bc72a1 *man/negbin.Rd
8a6a1926188511235f1e7406120c791e *man/new.name.Rd
00e39f302ab5efbe3b14265fffc16c18 *man/notExp.Rd
7a3280b766cab8424a12d6a8b1d5748e *man/notExp2.Rd
e8ecb5f0b5214ef0bae54a645a4d12d6 *man/null.space.dimension.Rd
b10897f9f57440b011c5589fef833001 *man/ocat.Rd
06910824bd8944cedb790e5787bddff8 *man/ocat.Rd
145a5adf3f90b6f2a9a109a97d9fd8fe *man/one.se.rule.Rd
9f49b00733e6117337f619cebfdfcf00 *man/pcls.Rd
ee9352ba4c531a8def16deddcab9a9fd *man/pdIdnot.Rd
8bc429d92aa9f58c4c43f2852e1f8123 *man/pdTens.Rd
......@@ -110,22 +113,22 @@ ee9352ba4c531a8def16deddcab9a9fd *man/pdIdnot.Rd
b903ebcf31703db156e033fdfa527d73 *man/plot.gam.Rd
c27a6b886929b1dc83bf4b90cae848f9 *man/polys.plot.Rd
49f15188b06a04ced66395511025f714 *man/predict.bam.Rd
3d811dd86252174c0108e2b1b75aaf9a *man/predict.gam.Rd
d9fcc12228600e5ad422a4d082cd51c9 *man/predict.gam.Rd
cf14ce6cf8e4147f0f5c6e5b93b2af73 *man/print.gam.Rd
6d0ce4e574fabceffdbedd46c91364cb *man/qq.gam.Rd
f77ca1471881d2f93c74864d076c0a0e *man/rTweedie.Rd
f834603ecaffd45099a0af864d25f691 *man/random.effects.Rd
fc1985e7dd5222182c4a8a939963b965 *man/random.effects.Rd
c523210ae95cb9aaa0aaa1c37da1a4c5 *man/residuals.gam.Rd
3c747a8066bcc28ae706ccf74f903d3e *man/rig.Rd
9f6f46f5c5da080bc82f9aa4685d364a *man/rmvn.Rd
a8ad211da595840e42f71abb405b20c1 *man/s.Rd
1eb8049d1020f6ef2d6deea0aa3da435 *man/scat.Rd
bec1ae0c4e77d9b0a6534671f364d76d *man/sdiag.Rd
845ec29324583d18c8dc150625e153e3 *man/s.Rd
d515e51ec98d73af6166f7b31aeaba9b *man/scat.Rd
898e7cc2def2ee234475e68d0b904b29 *man/sdiag.Rd
9641bb5e2573b5fcbdc303fcf160f3e6 *man/single.index.Rd
6f03e337d54221bc167d531e25af1eea *man/slanczos.Rd
8020154bd5c709d11f0e7cf043df886d *man/smooth.construct.Rd
4a689eba97e4fed138dccb8cad13205e *man/smooth.construct.ad.smooth.spec.Rd
f0311da9a0c1e3c3c087e8c377a6a3a6 *man/smooth.construct.bs.smooth.spec.Rd
9590099266d7f6fafd6bdd1e5c3f61da *man/smooth.construct.bs.smooth.spec.Rd
76013feaf70d00976bba0154b6f2c946 *man/smooth.construct.cr.smooth.spec.Rd
f5e6d0f5122f61c336827b3615482157 *man/smooth.construct.ds.smooth.spec.Rd
db75c958cbfb561914a3291ab58b9786 *man/smooth.construct.fs.smooth.spec.Rd
......@@ -139,20 +142,21 @@ b45d8e71bda4ceca8203dffea577e441 *man/smooth.construct.re.smooth.spec.Rd
8672633a1fad8df3cb1f53d7fa883620 *man/smooth.construct.tensor.smooth.spec.Rd
3e6d88ef6a8ab21bd6f120120602dcf6 *man/smooth.construct.tp.smooth.spec.Rd
d4083ff900aa69fa07610e0af2a2987b *man/smooth.terms.Rd
de1844d2760e849a16eec0f7c7a84e6a *man/smoothCon.Rd
ca676e32c30ddaedbce9f706327cc55b *man/smooth2random.Rd
844f9653d74441293d05a24dd3e2876a *man/smoothCon.Rd
b55a396da77559dac553613146633f97 *man/sp.vcov.Rd
83bd8e097711bf5bd0fff09822743d43 *man/spasm.construct.Rd
b9394812e5398ec95787c65c1325a027 *man/step.gam.Rd
f0791d830687d6155efb8a73db787401 *man/summary.gam.Rd
fd71e0a218ad840e6ce4b873f9fa083e *man/t2.Rd
41dbd27ba9ae4ac0960893942880d77b *man/te.Rd
9ee8b9bd71f1b777ceb638fa21143cb9 *man/t2.Rd
36db3873e3e810ab6ee481f177d2535c *man/te.Rd
6eebb6ef90374ee09453d6da6449ed79 *man/tensor.prod.model.matrix.Rd
f22f1cee0ff2b70628846d1d0f8e9a66 *man/trichol.Rd
42542181aa314eed22f05907a8546735 *man/uniquecombs.Rd
c6c5fe7f6bfe07b63080248020dab331 *man/uniquecombs.Rd
a16b3a5a4d13c705dcab8d1cd1b3347e *man/vcov.gam.Rd
281e73658c726997196727a99a4a1f9e *man/vis.gam.Rd
92f6aed4c16e1c470fea99c73d8225ca *man/ziP.Rd
8a565c75caf36baf2c7244163ab0e6d5 *man/ziplss.Rd
07a73758156dfa580c6e92edd34b0654 *man/ziP.Rd
8bc98d4cb86d851ea0970d68799522cb *man/ziplss.Rd
7bd0744ad8ea562d7a624e066ef3390c *po/R-de.po
0bdfcf98961b0d52b60f806dc1dba77e *po/R-en@quot.po
4e65e93fef4d034a399f90421e8f323a *po/R-fr.po
......@@ -167,21 +171,21 @@ dc1ef92ff4454734c3a24876e299b760 *po/ko.po
dfd4eec9edc7d1ab6354d47b6e2bd42f *po/pl.po
03972284b3400cf82cacd5d2dc4b8cb3 *src/Makevars
b0459e16b04844271cf5e6b53aca0e47 *src/coxph.c
91c7e18bb76056ed3d89541aae8ff561 *src/discrete.c
75d9ded0436a549de5b84b88c0da97e6 *src/gdi.c
555f6948880bff0b6fa23eeb51609c1c *src/discrete.c
ac57d36542385c458dca90cb0675439e *src/gdi.c
2436f9b328e80370ce2203dbf1dd813c *src/general.h
5a8f485ee3aeba83a201bb4f136f338c *src/init.c
7c1553b521f89ab43477245c44b9d006 *src/magic.c
92781b80e84fbb462c6e07afaf333d9b *src/mat.c
25921d60399f6aad99a4cd761fd72628 *src/matrix.c
acf1a2cff05d68856f2b6acee1e63cf7 *src/init.c
5d9a48e07b438a7c3b32c94fe67ae30c *src/magic.c
195fa3d343a58a362dfac0ce75b5eed7 *src/mat.c
0545dabf3524a110d616ea5e6373295d *src/matrix.c
6b781cbd5b9cfee68ad30bb7ce31ef3a *src/matrix.h
cba80885f5885bd48227696a239c53bb *src/mgcv.c
46b14087c9a2d8ca5a487cae292fde13 *src/mgcv.h
b679e9063bc032f364c3ec24d57ddb08 *src/misc.c
48cde0e19d5dd54b131ba66c777c0ec2 *src/mgcv.c
3e6fb646794403a7ad4d375f286117f0 *src/mgcv.h
97e3717e95a70b1470b4c3071e144d17 *src/misc.c
465b8790ca2dfb6e8c5635cacabf5460 *src/mvn.c
8f480dc455f9ff011c3e8f059efec2c5 *src/qp.c
cd563899be5b09897d1bf36a7889caa0 *src/qp.h
de9b9b608e787149d9dea0d3e0bdaa40 *src/soap.c
a03a7e869c79e7bc8a4f2f6d28fab214 *src/sparse-smooth.c
d5673b88f6f3d85c62a1337f49abba24 *src/soap.c
ce727da695456c5c7118b51751a7054d *src/sparse-smooth.c
fe0444bece322bc229e46b3d1c150779 *src/tprs.c
5bd85bf0319a7b7c755cf49c91a7cd94 *src/tprs.h
......@@ -9,7 +9,7 @@ export(anova.gam, bam, bam.update,bandchol, betar, cox.ph,concurvity,
gam2objective,
gamm, gam.check, gam.control,gam.fit3,
gam.fit, gam.outer,gam.vcomp, gamSim ,
gaulss,gam.side,get.var,
gaulss,gam.side,get.var,gevlss,
influence.gam,
in.out,inSide,interpret.gam,initial.sp,
jagam,
......@@ -44,7 +44,7 @@ export(anova.gam, bam, bam.update,bandchol, betar, cox.ph,concurvity,
residuals.gam,rig,rTweedie,rmvn,
Rrank,s,scat,sdiag,"sdiag<-",
sim2jam,
slanczos,
slanczos,smooth2random,
smoothCon,smooth.construct,smooth.construct2,
smooth.construct.bs.smooth.spec,
smooth.construct.cc.smooth.spec,
......
......@@ -143,19 +143,22 @@ compress.df <- function(dat,m=NULL) {
k <- attr(xu,"index")
## shuffle rows in order to avoid induced dependencies between discretized
## covariates (which can mess up gam.side)...
seed <- try(get(".Random.seed",envir=.GlobalEnv),silent=TRUE) ## store RNG seed
if (inherits(seed,"try-error")) {
runif(1)
seed <- get(".Random.seed",envir=.GlobalEnv)
}
kind <- RNGkind(NULL)
RNGkind("default","default")
set.seed(1) ## ensure repeatability
## any setting should be done in routine calling this one!!
#seed <- try(get(".Random.seed",envir=.GlobalEnv),silent=TRUE) ## store RNG seed
#if (inherits(seed,"try-error")) {
# runif(1)
# seed <- get(".Random.seed",envir=.GlobalEnv)
#}
#kind <- RNGkind(NULL)
#RNGkind("default","default")
## following line must be different to that used in
## tp constructor subsampling!
#set.seed(8547) ## ensure repeatability
ii <- sample(1:nrow(xu),nrow(xu),replace=FALSE) ## shuffling index
RNGkind(kind[1],kind[2])
assign(".Random.seed",seed,envir=.GlobalEnv) ## RNG behaves as if it had not been used
#RNGkind(kind[1],kind[2])
#assign(".Random.seed",seed,envir=.GlobalEnv) ## RNG behaves as if it had not been used
xu[ii,] <- xu ## shuffle rows of xu
k <- ii[k] ## correct k index accordingly
......@@ -183,7 +186,7 @@ check.term <- function(term,rec) {
discrete.mf <- function(gp,mf,pmf,m=NULL,full=TRUE) {
## discretize the covariates for the terms specified in smooth.spec
## id and factor by not allowed. pmf is a model frame for just the
## id not allowed. pmf is a model frame for just the
## parametric terms --- mini.mf is applied to this.
## if full is FALSE then parametric and response terms are ignored
## and what is returned is a list where columns can be of
......@@ -201,6 +204,19 @@ discrete.mf <- function(gp,mf,pmf,m=NULL,full=TRUE) {
## ... there is an element of nr and k.start for each variable of
## each smooth, but varaibles are onlt discretized and stored in mf
## once. If there are no matrix variables then k.start = 1:(ncol(k)+1)
# if (is.null(attr(mf,"terms"))) mf <- eval(gp$fake.formula[-2],mf) ## assumes model frame below
## some sub sampling here... want to set and restore RNG state used for this
## to ensure strict repeatability.
seed <- try(get(".Random.seed",envir=.GlobalEnv),silent=TRUE) ## store RNG seed
if (inherits(seed,"try-error")) {
runif(1)
seed <- get(".Random.seed",envir=.GlobalEnv)
}
kind <- RNGkind(NULL)
RNGkind("default", "default")
set.seed(8547) ## keep different to tps constructor!
mf0 <- list()
nk <- 0 ## count number of index vectors to avoid too much use of cbind
......@@ -260,67 +276,6 @@ discrete.mf <- function(gp,mf,pmf,m=NULL,full=TRUE) {
} ## end marginal jj loop
} ## term loop (i)
## old long winded code...
## deal with any by variable (should always go first as basically a 1D marginal)...
# if (gp$smooth.spec[[i]]$by!="NA") {
# termi <- gp$smooth.spec[[i]]$by ## var name
# ik.prev <- check.term(termi,rec) ## term already discretized?
# ik <- ik + 1 ## increment index counter
# if (ik.prev==0) { ## new discretization required
# mfd <- compress.df(mf[termi],m=mi)
# k[,ik] <- attr(mfd,"index")
# nr[ik] <- nrow(mfd)
# mf0 <- c(mf0,mfd)
# ## record variable discretization info...
# rec$vnames <- c(rec$vnames,termi)
# rec$ki <- c(rec$ki,ik)
# rec$d <- c(rec$d,1)
#
# } else { ## re-use an earlier discretization...
# k[,ik] <- k[,ik.prev]
# nr[ik] <- nr[ik.prev]
# }
# }
# if (inherits(gp$smooth.spec[[i]],"tensor.smooth.spec")) { ## tensor branch
# for (j in 1:length(gp$smooth.spec[[i]]$margin)) { ## loop through margins
# termj <- gp$smooth.spec[[i]]$margin[[j]]$term
# ik.prev <- check.term(termj,rec)
# ik <- ik + 1
# if (ik.prev==0) { ## new discretization required
# mfd <- compress.df(mf[termj],m=mi)
# k[,ik] <- attr(mfd,"index")
# nr[ik] <- nrow(mfd)
# mf0 <- c(mf0,mfd)
# ## record details...
# d <- length(termj)
# rec$vnames <- c(rec$vnames,termj)
# rec$ki <- c(rec$ki,rep(ik,d))
# rec$d <- c(rec$d,rep(d,d))
# } else { ## re-use an earlier discretization...
# k[,ik] <- k[,ik.prev]
# nr[ik] <- nr[ik.prev]
# }
# }
# } else { ## not te or ti...
# termi <- gp$smooth.spec[[i]]$term
# ik.prev <- check.term(termi,rec)
# ik <- ik + 1 ## index counter
# if (ik.prev==0) { ## new discretization required
# mfd <- compress.df(mf[termi],m=mi)
# k[,ik] <- attr(mfd,"index")
# nr[ik] <- nrow(mfd)
# mf0 <- c(mf0,mfd)
# d <- length(termi)
# rec$vnames <- c(rec$vnames,termi)
# rec$ki <- c(rec$ki,rep(ik,d))
# rec$d <- c(rec$d,rep(d,d))
# } else { ## re-use an earlier discretization...
# k[,ik] <- k[,ik.prev]
# nr[ik] <- nr[ik.prev]
# }
# }
#
# } ## main term loop
## obtain parametric terms and..
## pad mf0 so that all rows are the same length
......@@ -331,14 +286,7 @@ discrete.mf <- function(gp,mf,pmf,m=NULL,full=TRUE) {
pmf0 <- mini.mf(pmf,maxr) ## deal with parametric components
if (nrow(pmf0)>maxr) maxr <- nrow(pmf0)
mf0 <- c(mf0,pmf0) ## add parametric terms to end of mf0
seed <- try(get(".Random.seed",envir=.GlobalEnv),silent=TRUE) ## store RNG seed
if (inherits(seed,"try-error")) {
runif(1)
seed <- get(".Random.seed",envir=.GlobalEnv)
}
kind <- RNGkind(NULL)
RNGkind("default", "default")
set.seed(9)
for (i in 1:length(mf0)) {
me <- length(mf0[[i]])
if (me < maxr) mf0[[i]][(me+1):maxr] <- sample(mf0[[i]],maxr-me,replace=TRUE)
......@@ -355,9 +303,11 @@ discrete.mf <- function(gp,mf,pmf,m=NULL,full=TRUE) {
#mf <- mf[1:maxr,]
mf <- mf[sample(1:nrow(mf),maxr,replace=TRUE),]
for (na in names(mf0)) mf[[na]] <- mf0[[na]]
RNGkind(kind[1], kind[2])
assign(".Random.seed", seed, envir = .GlobalEnv)
} else mf <- mf0
## reset RNG to old state...
RNGkind(kind[1], kind[2])
assign(".Random.seed", seed, envir = .GlobalEnv)
## finally one more pass through, expanding k, k.start and nr to deal with replication that
## will occur with factor by variables...
......@@ -565,7 +515,7 @@ bgam.fitd <- function (G, mf, gp ,scale , coef=NULL,etastart = NULL,
## following reparameterizes X'X and f=X'y, according to initial reparameterizarion...
qrx$XX <- Sl.initial.repara(Sl,qrx$R,inverse=FALSE,both.sides=TRUE,cov=FALSE,nt=npt)
qrx$Xy <- Sl.initial.repara(Sl,qrx$f,inverse=FALSE,both.sides=FALSE,cov=FALSE,nt=npt)
qrx$Xy <- Sl.initial.repara(Sl,qrx$f,inverse=FALSE,both.sides=TRUE,cov=FALSE,nt=npt)
G$n <- nobs
} else { ## end of if (iter==1||!additive)
......@@ -1023,173 +973,6 @@ bgam.fit <- function (G, mf, chunk.size, gp ,scale ,gamma,method, coef=NULL,etas
bgam.fit2 <- function (G, mf, chunk.size, gp ,scale ,gamma,method, etastart = NULL,
mustart = NULL, offset = rep(0, nobs), control = gam.control(), intercept = TRUE,npt=1)
## version using sparse full model matrix in place of QR update...
## not multi-threaded, due to anyway disappointing performance
{ G$y <- y <- mf[[gp$response]]
weights <- G$w
conv <- FALSE
nobs <- nrow(mf)
##nvars <- ncol(G$X)
offset <- G$offset
family <- G$family
G$family <- gaussian() ## needed if REML/ML used
variance <- family$variance
dev.resids <- family$dev.resids
##aic <- family$aic
linkinv <- family$linkinv
mu.eta <- family$mu.eta
if (!is.function(variance) || !is.function(linkinv))
stop("'family' argument seems not to be a valid family object")
valideta <- family$valideta
if (is.null(valideta))
valideta <- function(eta) TRUE
validmu <- family$validmu
if (is.null(validmu))
validmu <- function(mu) TRUE
if (is.null(mustart)) {
eval(family$initialize)
}
else {
mukeep <- mustart
eval(family$initialize)
mustart <- mukeep
}
##coefold <- NULL
eta <- if (!is.null(etastart))
etastart
else family$linkfun(mustart)
mu <- linkinv(eta)
if (!(validmu(mu) && valideta(eta)))
stop("cannot find valid starting values: please specify some")
dev <- sum(dev.resids(y, mu, weights))*2 ## just to avoid converging at iter 1
##boundary <-
conv <- FALSE
G$n <- nobs
X <- G$X
## need to reset response and weights to post initialization values
## in particular to deal with binomial properly...
G$y <- y
G$w <- weights
conv <- FALSE
for (iter in 1L:control$maxit) { ## main fitting loop
devold <- dev
if (iter>1) eta <- as.numeric(X%*%coef) + offset
mu <- linkinv(eta)
mu.eta.val <- mu.eta(eta)
good <- (G$w > 0) & (mu.eta.val != 0)
z <- (eta - offset)[good] + (y - mu)/mu.eta.val
w <- (G$w[good] * mu.eta.val[good]^2)/variance(mu)[good]
dev <- sum(dev.resids(y,mu,G$w))
W <- Diagonal(length(w),sqrt(w))
if (sum(good)<nobs) {
XWX <- as(Matrix::crossprod(W%*%X[good,]),"matrix")
} else {
XWX <- as(Matrix::crossprod(W%*%X),"matrix")
}
qrx <- list(R = chol(XWX))
Wz <- W%*%z
## in following note that Q = WXR^{-1}
if (sum(good)<nobs) {
qrx$f <- forwardsolve(t(qrx$R),as.numeric(t(X[good,])%*%(W%*%Wz)))
} else {
qrx$f <- forwardsolve(t(qrx$R),as.numeric(t(X)%*%(W%*%Wz)))
}
qrx$y.norm2 <- sum(Wz^2)
rss.extra <- qrx$y.norm2 - sum(qrx$f^2)
if (control$trace)
message(gettextf("Deviance = %s Iterations - %d\n", dev, iter, domain = "R-mgcv"))
if (!is.finite(dev)) stop("Non-finite deviance")
## preparation for working model fit is ready, but need to test for convergence first
if (iter>2 && abs(dev - devold)/(0.1 + abs(dev)) < control$epsilon) {
conv <- TRUE
# coef <- start
break
}
if (method=="GCV.Cp") {
fit <- magic(qrx$f,qrx$R,G$sp,G$S,G$off,L=G$L,lsp0=G$lsp0,rank=G$rank,
H=G$H,C= matrix(0,0,ncol(qrx$R)), ##C=G$C,
gamma=gamma,scale=scale,gcv=(scale<=0),
extra.rss=rss.extra,n.score=G$n)
post <- magic.post.proc(qrx$R,fit,qrx$f*0+1)
} else { ## method is "REML" or "ML"
y <- G$y; w <- G$w; n <- G$n;offset <- G$offset
G$y <- qrx$f
G$w <- G$y*0+1
G$X <- qrx$R
G$n <- length(G$y)
G$offset <- G$y*0
G$dev.extra <- rss.extra
G$pearson.extra <- rss.extra
G$n.true <- n
object <- gam(G=G,method=method,gamma=gamma,scale=scale,control=gam.control(nthreads=npt))
y -> G$y; w -> G$w; n -> G$n;offset -> G$offset
}
gc()
if (method=="GCV.Cp") {
object <- list()
object$coefficients <- fit$b
object$edf <- post$edf
object$edf1 <- post$edf1
#object$F <- post$F
object$full.sp <- fit$sp.full
object$gcv.ubre <- fit$score
object$hat <- post$hat
object$mgcv.conv <- fit$gcv.info
object$optimizer="magic"
object$rank <- fit$gcv.info$rank
object$Ve <- post$Ve
object$Vp <- post$Vb
object$sig2 <- object$scale <- fit$scale
object$sp <- fit$sp
names(object$sp) <- names(G$sp)
class(object)<-c("gam")
}
coef <- object$coefficients
if (any(!is.finite(coef))) {
conv <- FALSE
warning("non-finite coefficients at iteration ",
iter)
break
}
} ## fitting iteration
if (!conv)
warning("algorithm did not converge")
eps <- 10 * .Machine$double.eps
if (family$family == "binomial") {
if (any(mu > 1 - eps) || any(mu < eps))
warning("fitted probabilities numerically 0 or 1 occurred")
}
if (family$family == "poisson") {
if (any(mu < eps))
warning("fitted rates numerically 0 occurred")
}
object$iter <- iter
object$wt <- w
object$R <- qrx$R
object$y <- G$y
object$prior.weights <- G$w
rm(G);gc()
object
} ## end bgam.fit2
ar.qr.up <- function(arg) {
## function to perform QR updating with AR residuals, on one execution thread
......@@ -1253,21 +1036,24 @@ predict.bam <- function(object,newdata,type="link",se.fit=FALSE,terms=NULL,exclu
block.size=50000,newdata.guaranteed=FALSE,na.action=na.pass,
cluster=NULL,discrete=TRUE,n.threads=1,...) {
## function for prediction from a bam object, possibly in parallel
## remove some un-needed stuff from object
#if (is.function(na.action)) na.action <- deparse(substitute(na.action)) ## otherwise predict.gam can't detect type
if (discrete && !is.null(object$dinfo)) {
return(predict.bamd(object,newdata,type,se.fit,terms,exclude,
block.size,newdata.guaranteed,na.action,n.threads,...))
}
## remove some un-needed stuff from object
object$Sl <- object$qrx <- object$R <- object$F <- object$Ve <-
object$Vc <- object$G <- object$residuals <- object$fitted.values <-
object$linear.predictors <- NULL
gc()
if (!is.null(cluster)&&inherits(cluster,"cluster")) {
## require(parallel)
n.threads <- length(cluster)
} else n.threads <- 1
if (missing(newdata)) n <- nrow(object$model) else n <- nrow(newdata)
if (missing(newdata)) n <- nrow(object$model) else {
n <- if (is.matrix(newdata[[1]])) nrow(newdata[[1]]) else length(newdata[[1]])
}
if (n < 100*n.threads) n.threads <- 1 ## not worth the overheads
if (n.threads==1) { ## single threaded call
if (missing(newdata)) return(