Skip to content

Commit

Permalink
version 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Parnell authored and gaborcsardi committed Jan 23, 2013
1 parent 60b4f65 commit 2b09ed3
Show file tree
Hide file tree
Showing 27 changed files with 528 additions and 224 deletions.
13 changes: 7 additions & 6 deletions DESCRIPTION
@@ -1,17 +1,18 @@
Package: Bclim
Type: Package
Title: Bayesian Palaeoclimate Reconstruction from Pollen
Version: 2.1
Date: 2012-06-18
Version: 2.2
Date: 2013-01-23
Author: Andrew Parnell, Thinh Doan and James Sweeney
Maintainer: Andrew Parnell <Andrew.Parnell@ucd.ie>
Depends: mclust, hdrcde, statmod, MASS
Suggests: Bchron, doMC, foreach
Description: This package takes pollen/time data from lake cores and
produces a Bayesian posterior distribution of palaeoclimate
from that location after fitting a non-linear non-Gaussian
state-space model.
License: GPL (> 2)
Packaged: 2012-06-21 11:28:30 UTC; andrewparnell
state-space model. This latest version fixes a bug where
volatilities were estimated incorrectly
License: GPL (>= 2)
Packaged: 2013-01-23 13:15:04 UTC; aparnell
Repository: CRAN
Date/Publication: 2012-06-22 05:42:18
Date/Publication: 2013-01-23 16:20:13
44 changes: 22 additions & 22 deletions MD5
@@ -1,31 +1,31 @@
80b2f4ee1626d401c712ddd63d3ccea0 *DESCRIPTION
af121cad74c504d64bd80caf0a2640f8 *NAMESPACE
3055d527f9894b4cb6ee8d6b238ac748 *DESCRIPTION
8e419122bd6a5b07a3a495d573138afc *NAMESPACE
5f2912b0a548a38cd6d4eb0cf7b7e477 *R/Bclim-internal.R
c6f874826f8e6697c8eec0b90413f529 *R/Bclim.R
f776eb835eb11d4c792b0cf2cca720e5 *R/BclimCompile.R
a620ff083452b9c4b375ecc23fcbc3c4 *R/BclimInterp.R
4cff32608adc1207131105a1982713e9 *R/BclimInterp.R
af57a23af5cd03c0f897ade4349cb3d2 *R/BclimLayer.R
761805ea8ab41e32ec315b2065eb6a55 *R/BclimMCMC.R
645e6ad9edbe2262d5a66f6c631b8e42 *R/BclimMixPar.R
041a88b7f1a4e3db237178fe3c5422f8 *R/BclimMCMC.R
c382207be84fe453dc5d4b7c35c4da95 *R/BclimMixPar.R
89588b14f7687294d938dd3f7ca1b1cc *R/BclimMixSer.R
856245e1980b34b2eea6bb3f130c9c08 *R/BclimRun.R
5a49d5a089a94c542e156c58340dd6c7 *R/IGb.R
49e12baf19dd1ca736d363d561343e18 *R/IGp.R
159639435b3bc30535e839516d5b7cf6 *R/IGrv.R
ae7de8c8b413e9cd687dcacab7ec7a3a *R/NIGB.R
c4c4b74e9f3177cf7ef6130e01636081 *R/NIGp3.R
f48b41d0a322f1bfa36fac12444f3bd4 *R/NIGB.R
3c8d4d5c7857fb8cf3a1eb8a841642f2 *R/NIGp3.R
9b83e343f86b627f055a360f78511deb *R/plotBclim.R
d385f12dbe1227314f75a2b58b53e2ea *R/plotBclimVol.R
54dbbd2174637d2b96a74f65066706ea *R/zzz.R
79d3bbeec2f031b8b540de2d8291df8f *man/Bclim-package.Rd
1baa9cbbb86f16e4b508a30b5a6f2e85 *man/BclimCompile.Rd
3604dcb5b47d278420a3357235e6797f *man/BclimInterp.Rd
eba7fbd97a896a794b26ebcee5e784fc *man/Bclim-package.Rd
3b3ae1db0dd7153c87186a432aeff7c6 *man/BclimCompile.Rd
844027ba79272149b55c70e30dde004a *man/BclimInterp.Rd
cb66a992d9bdf6fdd8f0c9449f573f4f *man/BclimLayer.Rd
d8a8f65896e65e2fb267f8e42265de98 *man/BclimMCMC.Rd
8e663516c0b187ae1ae3eeb99b45a8a6 *man/BclimMixPar.Rd
e84429c8ecbf2f98bcdefe298eab802e *man/BclimMixSer.Rd
3b2c60bb1b8212f936d4d8f9829ebfeb *man/BclimRun.Rd
b0a7474ed56d099f97d9633de18b009b *man/plotBclim.Rd
11f1d95937b7b6d8c1cf8d48f909fd28 *man/plotBclimVol.Rd
27c1cba70042855c1032932a5c7f3626 *src/BclimMCMC3D.c
fd2b950219625b2cc6fed00790569963 *man/BclimMCMC.Rd
bc6b60f2b815ecf01afe6d3379879482 *man/BclimMixPar.Rd
d3e0c28f0ba477c4b69f042d18564b1f *man/BclimMixSer.Rd
d098a650d48d745dfcd4ef089baa1cb4 *man/BclimRun.Rd
2a5fdad1ccd8655ef2a5a9457b876578 *man/NIGB.Rd
78acf6ecd9f34501621bb24312632701 *man/NIGp3.Rd
f46732a1c4585ce1457b92572090dde7 *man/plotBclim.Rd
d869628c17b2764282187b609858549e *man/plotBclimVol.Rd
5b72d41aaa4cd831235669faa9f3e617 *src/BclimMCMC3D.c
efa94aa42c370a9851dca166219f9c0f *src/PalaeoRecon3D.c
9594b50dc5caaf135522c553475a55a9 *src/use.c
effde32cdc7ea252698c65b8e9b48b58 *src/use.c
1c8929a0e47b44cb06b0586a95adbbac *src/use.h
2 changes: 2 additions & 0 deletions NAMESPACE
@@ -1,3 +1,5 @@
exportPattern("^[[:alpha:]]+")

useDynLib(Bclim)

export(Bclim, BclimLayer, BclimMixPar, BclimMixSer, BclimMCMC, BclimCompile, BclimInterp, plotBclim, plotBclimVol)
134 changes: 134 additions & 0 deletions R/Bclim-internal.R
@@ -0,0 +1,134 @@
.Random.seed <-
c(403L, 10L, 1579219043L, 450026753L, 1134948464L, -205808626L,
1257716857L, 1589496843L, -132782790L, -661769156L, 1864729471L,
-119582507L, 1831445740L, -144064958L, -1530687075L, 1706542103L,
2074745214L, -286441672L, -588351461L, -1880491655L, 1016176584L,
732890102L, 1769100849L, -747900829L, -1826926542L, 185871748L,
1997706183L, 290674333L, 1278049812L, 947717306L, -709988091L,
-313199905L, 96247654L, 263124720L, -475787757L, 1973864369L,
-640675232L, -1279479810L, -276127863L, 2040510651L, -2133740406L,
1497450348L, -2147281681L, -1056538843L, -2136675876L, -2077403214L,
-1953800531L, -631941529L, 477898126L, 387076712L, -1266512277L,
-281942007L, 126260888L, 814895558L, 1409646881L, 1131680179L,
-227971806L, -1006287084L, 458047383L, -1051828339L, -1130765660L,
1752427658L, -1701281035L, 1064510799L, -88378794L, 1308774656L,
1622762563L, 1762469857L, -401569968L, -1589610066L, -244861095L,
1258732907L, 22963418L, 1168633244L, 913412511L, -927190027L,
1253941900L, 763488098L, -2022533315L, 1173827511L, 1218083934L,
477983128L, -1224223493L, -626745191L, -245657304L, 2044372950L,
-360102831L, -5574909L, 196585106L, 1714873380L, -617157913L,
-1779368131L, -2009727052L, 1155097626L, -1966702747L, 30827007L,
1664363654L, 1105702928L, -1169689933L, -862391983L, 1607553280L,
-1706896418L, 615907369L, -2064853029L, -1111030550L, 594469516L,
-1864172081L, -1938771579L, 919177788L, 1014558482L, 1538151437L,
-1251745977L, -459449042L, -1066705784L, 408291723L, -118025879L,
-379462856L, -88341018L, 990208385L, 1332573459L, 1440608962L,
-1436131980L, 686611831L, 1546839661L, -1114347260L, 2086829098L,
-449064555L, 710051375L, 1172480822L, -359867552L, -804331101L,
-1962024255L, -1588987216L, -1675020850L, 268626233L, -1719892661L,
-2056073478L, -2046836740L, -1710571457L, 429881621L, -1605664212L,
369069826L, 1872518109L, -1543776553L, 1561829822L, -1186561032L,
-332859429L, -184890823L, 1659521928L, -1230800074L, -2076448399L,
512574371L, 1840993010L, 754692676L, -154526457L, -1329077027L,
567759316L, 2005169402L, 1773497413L, 473136287L, 383589926L,
930257584L, 1847265107L, 1539785329L, -1326641248L, 218179390L,
-238522807L, -129135877L, -1539687734L, -1769706452L, 1248228399L,
-132326171L, -1698769508L, 587339762L, -1800748435L, 237684647L,
-1258735154L, 2025590568L, -1205418709L, -1867536567L, 738159704L,
-504342266L, 1369531617L, -628276109L, 1212158178L, -1034078124L,
-305504937L, -1421841075L, -1677905692L, 951413962L, -1834172107L,
2013611919L, -1903094634L, 1124654144L, 1805913347L, -939097823L,
514116112L, 290197998L, -957921895L, 110469675L, -2067967206L,
244689372L, 1606983647L, 719022005L, -800194228L, 1894746018L,
1838722813L, 1864204279L, -1017214690L, 1484403672L, 245159227L,
290697945L, -347689368L, -1337380970L, -1761846511L, 642086083L,
605617362L, -1986647708L, 71257255L, -1894075907L, 734551028L,
-38054694L, 1558033957L, -879088833L, -149370682L, 156861776L,
-88789645L, -1516669039L, 185240000L, -1919589424L, 2060326242L,
-281985304L, -1397105460L, -517588484L, 1700503026L, 445586560L,
-204842508L, -1156963704L, -1383130310L, -2059934384L, -596810644L,
1911434644L, 228550738L, -2026578464L, -548481844L, 2060820128L,
-1039519358L, -603029272L, 701000428L, -431645380L, -694572942L,
596214384L, 1096047140L, -1656174536L, 723794202L, -990845744L,
2089589052L, 1420178324L, -1710590078L, -194532416L, 2084189756L,
1712849296L, 1551345698L, 237726984L, -650278772L, 157110044L,
663870610L, 689720704L, 1171271700L, 1645111080L, -1868855750L,
65685968L, -1377509012L, 959273908L, -1782812142L, -59394080L,
1078925772L, 331012320L, -1071721438L, -1249739992L, 1200007692L,
-445787332L, 1622140914L, 1938268912L, -1609455036L, -530934184L,
-1049413830L, 497317872L, 1936804540L, 1784014100L, 703147202L,
382798944L, 1569283452L, -70869040L, 984320290L, 1392832168L,
-1073209460L, 304383164L, 207237938L, -18393536L, 128955572L,
-920171448L, -91025990L, -2013726192L, 854592748L, 1019736404L,
156605202L, -946944608L, 913765068L, 708315744L, -2048530494L,
924050216L, 712655276L, 965162300L, -547667086L, -2130262736L,
692051748L, 1063085368L, -463730982L, 455514000L, 1603560188L,
1595997076L, 641909826L, -569586432L, 30113852L, 827297104L,
-923765598L, -1700103352L, -1740558580L, -261837092L, -1917843630L,
1656571520L, 1350299732L, 88556520L, -1289704710L, -808759984L,
340891436L, -30897292L, -1677556846L, 1276562016L, -1225666676L,
-1491314848L, -820839454L, 720997288L, -83153716L, -1210004996L,
1053953970L, -2031804944L, -672186940L, -1870712488L, 1981859194L,
469343664L, 1352582076L, 1736796244L, 302571458L, -1942874080L,
-1410797380L, 374020688L, -2081482782L, 1628790376L, -42541492L,
-850564868L, -488132622L, 1533011200L, -1193534604L, 711972872L,
2127817146L, 353668560L, 1675875308L, -1798804588L, -724907054L,
-1983025312L, -2035222196L, 1114579232L, -871108734L, -189116696L,
-1214203668L, 435994172L, 1314661234L, -824850832L, 1962601508L,
109174584L, -629210982L, -2060286256L, 985244860L, -1092318572L,
1086610050L, -1423945536L, 1651270972L, -1958016880L, 1210498594L,
201325064L, 1728648460L, 1838047900L, -2081548782L, 282587520L,
-1255906796L, -1519190488L, -2039725766L, 363322320L, 1920241260L,
382106420L, 53949074L, 374834528L, 129447244L, 1769382880L, -1732681822L,
-1358717016L, -960303220L, -440206660L, -465691790L, -1589673744L,
-1098904508L, 1477799256L, -1314041798L, 1533395824L, 931746876L,
816868116L, 393366978L, 264211680L, 1816164220L, -1951164720L,
-1237902686L, -1450290136L, 1306837260L, 1229147068L, 1805092146L,
1350268864L, 291759668L, -319493176L, 1439900858L, 559073168L,
680241644L, -1200548780L, 1731107474L, 63957792L, 985588172L,
-3187744L, 1617483458L, 653366824L, -1346818388L, 1267599036L,
666108402L, -76605136L, -1994471260L, -1612416328L, -924737702L,
-420921968L, -510087812L, -738766572L, -2072236734L, 1578431232L,
1888791484L, 2167632L, -1559976670L, -1329206968L, -2106022846L,
-1076126633L, -1770784863L, 1917683814L, -2135666588L, -2023724139L,
1406180543L, 1912147032L, -1004849034L, 1317546115L, -1907816251L,
288097762L, 568421456L, -1329248903L, -518604117L, 1985012252L,
1446133066L, 1203348799L, -1155980407L, -732292194L, -1959396788L,
1881316381L, 1185363367L, -2050307888L, -1368794514L, -1007909605L,
-1600061827L, -1515647894L, 1077852424L, 80620977L, -1516959197L,
-1235898588L, 1453004754L, -1843186649L, 1104866929L, 196695222L,
1153242196L, -1576358683L, 1256069359L, -1967354840L, 1839675526L,
230179507L, 65094677L, 314463858L, 419156672L, 1267611433L, -2098350693L,
-2095934868L, 914310778L, 2146547631L, -181169479L, -563381042L,
-426633700L, -1940640371L, 2018802679L, 715669248L, -922413730L,
642956843L, 90517805L, -1069412966L, 1069767512L, -1622302015L,
1009583475L, -975317356L, -1160633566L, -880366025L, 899595009L,
211386886L, 1382588484L, -1434406539L, -996436769L, -254810056L,
-478171114L, 166420515L, -1826832411L, -1279866366L, 364992624L,
-900895207L, -1642485L, -995497220L, 1376647978L, 1834069343L,
1348445417L, -1408650242L, 52809708L, 1885117245L, -1171237113L,
-228487440L, 357969550L, 1959618747L, 73604253L, -1689137078L,
395522664L, -1669530031L, -1668627133L, -994036668L, 721499890L,
1573764807L, -496810863L, 813087254L, -1171953548L, 13773573L,
1030193487L, -279592120L, 1074574054L, 1613997075L, -1327637643L,
-847103150L, -761058400L, 1724169865L, 2068433595L, 83931404L,
-2131178342L, 1072484879L, 1401632345L, 813419246L, -903429764L,
-379981331L, -565707113L, 763681120L, -1506845378L, -278557173L,
873560717L, -773179462L, 1214170616L, -1553489503L, -1553037485L,
1918355060L, 1016465410L, 1168142999L, 689904737L, 333723814L,
-1100994396L, 1010295125L, 393708031L, 262961304L, 113370550L,
-105689533L, 1824093061L, -1099392990L, -40297712L, 615757497L,
-863696021L, 330293852L, 202555274L, 256634751L, -1358232887L,
391162718L, 1982353420L, -1667252259L, -1582232857L, -213900528L,
1675311662L, 804659419L, -1920606787L, -967529686L, -65084472L,
-621747983L, -2056544669L, -1045337500L, -1138701934L, -902388121L,
269919793L, -238609546L, 1442115732L, 1602223781L, 1298557871L,
1243023464L, -1478943674L, 812944852L)
.onAttach <-
function(libname, pkgname) {
Bclimver <- read.dcf(file=system.file("DESCRIPTION", package=pkgname),
fields="Version")
packageStartupMessage(paste(pkgname, Bclimver))
packageStartupMessage("Welcome to Bclim. Type help(Bclim) to get started.")
packageStartupMessage("See http://mathsci.ucd.ie/~parnell_a/Bclim.html for updates, bugs and a tutorial.")
}
65 changes: 65 additions & 0 deletions R/Bclim.R
@@ -0,0 +1,65 @@
Bclim <-
function(pollen.loc,chron.loc,core.name="Core",time.grid=seq(0,14,length=100),rsfile,nchrons=10000,parallel=FALSE,save.as.you.go=TRUE) {

if(!file.exists(pollen.loc)) stop(cat("Pollen data not found. Check",pollen.loc))
if(!file.exists(chron.loc)) stop(cat("Chronology data not found. Check",chron.loc))

pollen.data <- as.matrix(read.table(pollen.loc,header=TRUE))
temp.chron <- read.table(chron.loc,nrows=5)

# Some error handling
if(ncol(pollen.data)!=28) stop("Number of pollen taxa should be 28")
if(nrow(pollen.data)!=ncol(temp.chron)) stop("Number of columns in chronology should be the same
as the number of rows in the pollen data")

### Run Stage 1 - calculate layer posteriors
cat("Stage 1 of 4: calculating layer posteriors...\n")
step1filename <- paste(gsub(" ","_",core.name),"_step1.RData",sep="")
if(!file.exists(step1filename)) {
step1 <- BclimLayer(pollen.loc,rsfile)
if(save.as.you.go) save(step1,file=paste(gsub(" ","_",core.name),"_step1.RData",sep=""))
} else {
load(step1filename)
}

### Run Stage 2
cat("Stage 2 of 4: approximating as mixtures of Gaussians...\n")
step2filename <- paste(gsub(" ","_",core.name),"_step2.RData",sep="")
if(!file.exists(step2filename)) {
if(parallel) {
step2 <- BclimMixPar(step1)
} else {
step2 <- BclimMixSer(step1)
}
if(save.as.you.go) save(step2,file=paste(gsub(" ","_",core.name),"_step2.RData",sep=""))
} else {
load(step2filename)
}

### Run Stage 3
cat("Stage 3 of 4: estimating parameters...\n")
step2$Chronsfile <- chron.loc
step3filename <- paste(gsub(" ","_",core.name),"_step3.RData",sep="")
if(!file.exists(step3filename)) {
step3 <- BclimMCMC(step2,chron.loc,nchron=nchrons)
if(save.as.you.go) save(step3,file=paste(gsub(" ","_",core.name),"_step3.RData",sep=""))
} else {
load(step3filename)
}

### Run Stage 4
cat("Stage 4 of 4: interpolating onto grid...\n")
step4filename <- paste(gsub(" ","_",core.name),"_step4.RData",sep="")
if(!file.exists(step4filename)) {
step4 <- BclimInterp(step2,step3,time.grid)
if(save.as.you.go) save(step4,file=paste(gsub(" ","_",core.name),"_step4.RData",sep=""))
} else {
load(step4filename)
}

# Output results
cat("Compiling results...\n")
results <- BclimCompile(step1,step2,step3,step4,core.name=core.name)
cat("Done!\n")
return(results)
}

0 comments on commit 2b09ed3

Please sign in to comment.