Coder Social home page Coder Social logo

rcarbon's Introduction

cran version development version rstudio mirror downloads rstudio mirror downloads R-CMD-check

rcarbon

This package enables the calibration and analysis of radiocarbon dates, often but not exclusively for the purposes of archaeological research. It includes functions not only for basic calibration, uncalibration, and plotting of one or more dates, but also a statistical framework for building demographic and related longitudinal inferences from aggregate radiocarbon date lists, including: Monte-Carlo simulation tests (Timpson et al 2014), random mark permutation tests (Crema et al 2016, Bevan et al 2017), a point-to-point test (Edinborough et al 2017), and spatial permutation tests (Crema, Bevan, and Shennan 2017). For more details see the associated paper (Crema and Bevan 2021).

To install the stable version from CRAN:

install.packages('rcarbon')

To install the latest development version:

# "devtools" package required 
devtools::install_github('ahb108/rcarbon')

Citation

To cite rcarbon in publications use:

Crema, E.R., Bevan, A. 2021 Inference from Large Sets of Radiocarbon Dates: Software and Methods Radiocarbon 63(1),23-39 doi:10.1017/RDC.2020.95

References

Bevan, A. Colledge,S., Fuller, D., Fyfe, R., Shennan, S., Stevens, C. 2017.Holocene fluctuations in human population demonstrate repeated links to food production and climate. Proceedings of the National Academy of Sciences of the United States of America. doi:10.1073/pnas.1709190114
Crema, E.R., Bevan, A. 2021 Inference from Large Sets of Radiocarbon Dates: Software and Methods Radiocarbon 63(1),23-39. doi:10.1017/RDC.2020.95

Crema, E.R., Bevan, A., Shennan, S., 2017. Spatio-temporal approaches to archaeological radiocarbon dates. Journal of Archaeological Science 87, 1–9. doi:10.1016/j.jas.2017.09.007

Crema, E.R., Habu, J., Kobayashi, K., Madella, M., 2016. Summed Probability Distribution of 14 C Dates Suggests Regional Divergences in the Population Dynamics of the Jomon Period in Eastern Japan. PLOS ONE 11, e0154809. doi:10.1371/journal.pone.0154809

Edinborough, K., Porcic, M., Martindale, A., Brown, T.J., Supernant, K, Ames, K.M. 2017. Radiocarbon test for demographic events in written and oral history, Proceedings of the National Academy of Sciences of the United States of America, 114 (47), 12436–12441. doi:10.1073/pnas.1713012114

Timpson, A., Colledge, S., Crema, E., Edinborough, K., Kerig, T., Manning, K., Thomas, M.G., Shennan, S., 2014. Reconstructing regional population fluctuations in the European Neolithic using radiocarbon dates: a new case-study using an improved method. Journal of Archaeological Science 52, 549–557. doi:10.1016/j.jas.2014.08.011

Case Studies Using rcarbon

Antolín, F., Martínez-Grau, H., Steiner, B. L., Follmann, F., Soteras, R., Häberle, S., et al. 2022. Neolithic occupations (c. 5200-3400 cal BC) at Isolino Virginia (Lake Varese, Italy) and the onset of the pile-dwelling phenomenon around the Alps. Journal of Archaeological Science: Reports, 42, 103375.

Arroyo-Kalin, M., & Riris, P. (2021). Did pre-Columbian populations of the Amazonian biome reach carrying capacity during the Late Holocene? Philosophical Transactions of the Royal Society B: Biological Sciences, 376(1816), 20190715.

Aubán, J.B., Jiménez-Puerto, J., Ruiz, P.E., Gordo, S.P., 2018. C14 y poblamiento en las comarcas centro-meridionales del País Valenciano (c. 7000-1500 cal BC). Recerques del Museu d’Alcoi 0, 35-48–48.

Barnett, R. L., Charman, D. J., Johns, C., Ward, S. L., Bevan, A., Bradley, S. L., et al. 2020. Nonlinear landscape and cultural response to sea-level rise. Science Advances, 6(45), eabb6376. 6

Becker, F., Knitter, D., Nykamp, M., Schütt, B., 2020. Meta-Analysis of Geomorphodynamics in the Western Lower Bakırçay Plain (Aegean Region, Turkey). Land 9, 338.

Benito, X., Luethje, M., Schneider, T., Fritz, S.C., Baker, P.A., Pedersen, E.J., Gaüzère, P., de Novaes Nascimento, M., Bush, M., Ruhi, A., 2021. Ecological resilience in tropical Andean lakes: A paleolimnological perspective. Limnology and Oceanography n/a.

Bergsvik, K. A., Darmark, K., Hjelle, K. L., Aksdal, J., & Åstveit, L. I. (2021). Demographic developments in Stone Age coastal western Norway by proxy of radiocarbon dates, stray finds and palynological data. Quaternary Science Reviews, 259, 106898.

Bevan, A. Colledge,S., Fuller, D., Fyfe, R., Shennan, S., Stevens, C. 2017.Holocene fluctuations in human population demonstrate repeated links to food production and climate. Proceedings of the National Academy of Sciences of the United States of America, 114 (49) E10524-E10531. doi:10.1073/pnas.1709190114

Bevan, A., & Crema, E. R. 2021. Modifiable reporting unit problems and time series of long-term human activity. Philosophical Transactions of the Royal Society B: Biological Sciences, 376(1816), 20190726.

Bird, D., Freeman, J., Robinson, E., Maughan, G., Finley, J.B., Lambert, P.M., Kelly, R.L., 2020. A first empirical analysis of population stability in North America using radiocarbon records. The Holocene, 30(9), 1345–1359.

Broodbank, C., Lucarini, G. 2019. The Dynamics of Mediterranean Africa, ca. 9600–1000 bc: An Interpretative Synthesis of Knowns and Unknowns, Journal of Mediterranean Archaeology, 32(2), 195-267.

Broughton,J.M., Weitzel,E.M. 2018. Population reconstructions for humans and megafauna suggest mixed causes for North American Pleistocene extinctions.Nature Communications, 9, 5441. doi:10.1038/s41467-018-07897-1

Brown, A., A., Crema, E. R. 2019. Māori Population Growth in Pre-contact New Zealand: Regional Population Dynamics Inferred From Summed Probability Distributions of Radiocarbon Dates. The Journal of Island and Coastal Archaeology, 1–19.

Cahiza, P., Garate, E., Sabatini, G., Gheggi, S., Iniesta, M.L., Carosio, S., García, G., 2021. Temporal dynamics of La Rioja village landscapes, Argentina. Journal of Archaeological Science: Reports 39, 103123.

Carter, V. A., Brunelle, A., Power, M. J., DeRose, R. J., Bekker, M. F., Hart, I., et al. (2021). Legacies of Indigenous land use shaped past wildfire regimes in the Basin-Plateau Region, USA. Communications Earth & Environment, 2(1), 1–9.

Cascalheira, J., Alcaraz-Castaño, M., Alcolea-González, J., de Andrés-Herrero, M., Arrizabalaga, A., Aura Tortosa, J.E., Garcia-Ibaibarriaga, N., Iriarte-Chiapusso, M.-J., 2020. Paleoenvironments and human adaptations during the Last Glacial Maximum in the Iberian Peninsula: A review. Quaternary International 581–582, 28-51.

Cheddadi, R., Palmisano, A., López-Sáez, J. A., Nourelbait, M., Zielhofer, C., Tabel, J., et al. 2019. Human demography changes in Morocco and environmental imprint during the Holocene The Holocene, 0959683619826657. doi:10.1177/0959683619826657

Crema, E.R., Bevan, A. 2020 Inference from Large Sets of Radiocarbon Dates: Software and Methods Radiocarbon, doi:10.1017/RDC.2020.95

Crema, E.R., Bevan, A., Shennan, S., 2017. Spatio-temporal approaches to archaeological radiocarbon dates. Journal of Archaeological Science 87, 1–9. doi:10.1016/j.jas.2017.09.007

Crema, E. R., & Shoda, S. 2021. A Bayesian approach for fitting and comparing demographic growth models of radiocarbon dates: A case study on the Jomon-Yayoi transition in Kyushu (Japan). PLOS ONE, 16(5), e0251695.

Crema, E.R. 2020 Non-Stationarity and Local Spatial Analysis, In Gillings, M., Hacıgüzeller, P., Lock,G. (Eds.) Archaeological Spatial Analysis: A Methodological Guide, Taylor & Francis, London.

Crema, E.R., Kobayashi, K., 2020. A multi-proxy inference of Jōmon population dynamics using bayesian phase models, residential data, and summed probability distribution of 14C dates. Journal of Archaeological Science 117, 105136.

Crema, E. R. 2022. Statistical Inference of Prehistoric Demography from Frequency Distributions of Radiocarbon Dates: A Review and a Guide for the Perplexed. Journal of Archaeological Method and Theory.

Deforce K., Groenewoudt B., Haneca K. 2020. 2500 years of charcoal production in the Low Countries: The chronology and typology of charcoal kilns and their relation with early iron production.. Quaternary International.

Deza-Araujo, M., Morales-Molino, C., Conedera, M., Henne, P. D., Krebs, P., Hinz, M., et al. (2022). A new indicator approach to reconstruct agricultural land use in Europe from sedimentary pollen assemblages. Palaeogeography, Palaeoclimatology, Palaeoecology, 599, 111051.

de Groot, B., 2020. The impact of population fluctuations on the spatial spread of Neolithic ceramic traditions in West Anatolia and South-East Europe. Journal of Anthropological Archaeology 57, 101121. doi:10.1016/j.jaa.2019.101121

de Groot, B., Bloxam, A., 2022. Radiocarbon approaches for mapping technological change: The spread of the potter’s wheel in the Iberian Peninsula, 1000–0 BCE. Journal of Archaeological Science: Reports 41, 103288.

de Souza, J. G., Robinson, M., Maezumi, S. Y., Capriles, J., Hoggarth, J. A., Lombardo, U., et al. 2019. Climate change and cultural resilience in late pre-Columbian Amazonia. Nature Ecology & Evolution, 1. doi:10.1038/s41559-019-0924-0

de Souza, P., Cartajena, I., Riquelme, R., Maldonado, A., Porras, M. E. de, Santander, B., et al. (2021). Late Pleistocene–Early Holocene human settlement and environmental dynamics in the southern Atacama Desert highlands (24.0°S–24.5°S, Northern Chile). Geoarchaeology.

DiNapoli, R. J., Crema, E. R., Lipo, C. P., Rieth, T. M., & Hunt, T. L. (2021). Approximate Bayesian Computation of radiocarbon and paleoenvironmental record shows population resilience on Rapa Nui (Easter Island). Nature Communications, 12(1), 3939.

Doering, B. N. 2021. Subarctic landscape adaptations and paleodemography: A 14,000-year history of climate change and human settlement in central Alaska and Yukon. Quaternary Science Reviews, 268, 107139.

Edinborough, K., Martineau, R., Dufraisse, A., Shennan, S., Imbeaux, M., Dumontet, A., et al. (2021). A Neolithic population model based on new radiocarbon dates from mining, funerary and population scaled activity in the Saint-Gond Marshes region of North East France. Quaternary International.

Ekholm, T. 2021. Hunter-gatherer adaptions during the Early Holocene in Northern Sweden. The Holocene, 31(1), 83–94.

Feeser, I., Dörfler, W., Kneisel, J., Hinz, M., & Dreibrodt, S. 2019. Human impact and population dynamics in the Neolithic and Bronze Age: Multi-proxy evidence from north-western Central Europe. The Holocene, 0959683619857223. doi:10.1177/0959683619857223

Freeman, J., Anderies, J. M., Beckman, N. G., Robinson, E., Baggio, J. A., Bird, D., et al. (2021). Landscape Engineering Impacts the Long-Term Stability of Agricultural Populations. Human Ecology.

Freeman, J., Baggio, J.A., Robinson, E., Byers, D.A., Gayo, E., Finley, J.B., Meyer, J.A., Kelly, R.L., Anderies, J.M., 2018. Synchronization of energy consumption by human societies throughout the Holocene. Proceedings of the National Academy of Sciences of the United States of America, 115 (40) 9962-9967. doi:10.1073/pnas.1802859115

Freeman, J., Hard, R. J., Mauldin, R. P., & Anderies, J. M. (2021). Radiocarbon data may support a Malthus-Boserup model of hunter-gatherer population expansion. Journal of Anthropological Archaeology, 63, 101321.

Fritz, C., Tosello, G., Fleury, G., Kasarhérou, E., Walter, P., Duranthon, F., et al. 2021. First record of the sound produced by the oldest Upper Paleolithic seashell horn. Science Advances, 7(7), eabe9510.

Fyfe, R.M., Woodbridge, J., Palmisano, A., Bevan, A., Shennan, S., Burjachs, F., Legarra Herrero, B., García Puchol, O., Carrión, J.-S., Revelles, J., Roberts, C.N., 2019. Prehistoric palaeodemographics and regional land cover change in eastern Iberia. The Holocene 0959683619826643. doi:10.1177/0959683619826643

Gil, A.F., Villalba, R., Franchetti, F.R., Otaola, C., Abbona, C.C., Peralta, E.A., Neme, G., 2020. Between Foragers and Farmers: Climate Change and Human Strategies in Northwestern Patagonia. Quaternary 3, 17.

Gjesfjeld, E., Etnier, M.A., Takase, K., Brown, W.A., Fitzhugh, B., 2020. Biogeography and adaptation in the Kuril Islands, Northeast Asia. World Archaeology, 1–25.

Gjesfjeld, E., Silvestro, D., Chang, J., Koch, B., Foster, J.G., Alfaro, M.E., 2020. A quantitative workflow for modeling diversification in material culture. PLOS ONE 15, e0227579.

Gretzinger, J., Molak, M., Reiter, E., Pfrengle, S., Urban, C., Neukamm, J., et al. 2019. Large-scale mitogenomic analysis of the phylogeography of the Late Pleistocene cave bear. Scientific Reports, 9. DOI: 10.1038/s41598-019-47073-z.

Harrison, S.P., Gaillard, M.-J., Stocker, B.D., Vander Linden, M., Klein Goldewijk, K., Boles, O., Braconnot, P., Dawson, A., Fluet-Chouinard, E., Kaplan, J.O., Kastner, T., Pausata, F.S.R., Robinson, E., Whitehouse, N.J., Madella, M., Morrison, K.D., 2020. Development and testing scenarios for implementing land use and land cover changes during the Holocene in Earth system model experiments. Geoscientific Model Development 13, 805–824.

Hixon, S.W., Douglass, K.G., Godfrey, L.R., Eccles, L., Crowley, B.E., Rakotozafy, L.M.A., Clark, G., Haberle, S., Anderson, A., Wright, H.T., Kennett, D.J., 2021. Ecological Consequences of a Millennium of Introduced Dogs on Madagascar. Frontiers in Ecology and Evolution 9, 428.

Jones, T. L., Coltrain, J. B., Jacobs, D. K., Porcasi, J., Brewer, S. C., Buckner, J. C., et al. (2021). Causes and consequences of the late Holocene extinction of the marine flightless duck (Chendytes lawi) in the northeastern Pacific. Quaternary Science Reviews, 260, 106914.

Jørgensen, E. K., & Riede, F. 2019. Convergent catastrophes and the termination of the Arctic Norwegian Stone Age: A multi-proxy assessment of the demographic and adaptive responses of mid-Holocene collectors to biophysical forcing. The Holocene, 0959683619862036.

Jorgeson, I.A., Breslawski, R.P., Fisher, A.E., 2020. Radiocarbon simulation fails to support the temporal synchroneity requirement of the Younger Dryas impact hypothesis. Quaternary Research 1–17.

Kitchel, N.R., Mackie, M.E., 2021. Plants and Subsistence during the Fluted-Point Period of the Northeast. American Antiquity 1–9.

Kim, H., Lee, G.-A., Crema, E.R., 2021. Bayesian analyses question the role of climate in Chulmun demography. Scientific Reports 11, 23797.

Kwak, S., Obata, H., Lee, G.-A., 2020. Broad-spectrum foodways in southern coastal Korea in the Holocene: Isotopic and archaeobotanical signatures in Neolithic shell middens. The Journal of Island and Coastal Archaeology 0, 1–29.

Lawrence, D., Palmisano, A., & Gruchy, M. W. de. 2021. Collapse and continuity: A multi-proxy reconstruction of settlement organization and population trajectories in the Northern Fertile Crescent during the 4.2kya Rapid Climate Change event. PLOS ONE, 16(1), e0244871.

Lima, M., Gayo, E.M., Latorre, C., Santoro, C.M., Estay, S.A., Cañellas-Boltà, N., Margalef, O., Giralt, S., Sáez, A., Pla-Rabes, S., Chr. Stenseth, N., 2020. Ecology of the collapse of Rapa Nui society. Proceedings of the Royal Society B: Biological Sciences 287, 20200662.

Liu, L., Chen, X., Wright, H., Xu, H., Li, Y., Chen, G., et al. 2019. Rise and fall of complex societies in the Yiluo region, North China: The spatial and temporal changes. Quaternary International.

López, J. M., Neme, G., & Gil, A. F. 2019. Resource intensification and zooarchaeological record in the southern margins of pre-Hispanic Andean agriculture. Archaeological and Anthropological Sciences, 11(10), 5287–5300.

Lucarini, G., Wilkinson, T., Crema, E.R., Palombini, A., Bevan, A., Broodbank, C., 2020. The MedAfriCarbon Radiocarbon Database and Web Application. Archaeological Dynamics in Mediterranean Africa, ca. 9600–700 BC. Journal of Open Archaeology Data 8, 1.

MacInnes, D. 2019. The impact of population dynamics on social complexity in Neolithic Orkney. Journal of Archaeological Science: Reports, 24, 721–728. doi:10.1016/j.jasrep.2019.02.036

McCool, W.C., Tung, T.A., Coltrain, J.B., Accinelli Obando, A.J., Kennett, D.J., 2021. The character of conflict: A bioarchaeological study of violence in the Nasca highlands of Peru during the Late Intermediate Period (950–1450 C.E.). American Journal of Physical Anthropology 174, 614–630.

McCool, W.C., Anderson, A.S., Kennett, D.J., 2021. Using a multimethod life history approach to navigate the osteological paradox: A case study from Prehispanic Nasca, Peru. American Journal of Physical Anthropology 175, 816–833.

Mjærum, A., Loftsgarden, K., & Solheim, S. 2022. Human-vegetation dynamics in Holocene south-eastern Norway based on radiocarbon dated charcoal from archaeological excavations. The Holocene, 32(7), 690–702.

Nielsen, S.V., Persson, P., Solheim, S., 2019. De-Neolithisation in southern Norway inferred from statistical modelling of radiocarbon dates. Journal of Anthropological Archaeology 53, 82–91. doi:10.1016/j.jaa.2018.11.004

Nielsen, S. V. (2021). A Late Mesolithic Forager Dispersal Caused Pre-Agricultural Demographic Transition in Norway. Oxford Journal of Archaeology, 40(2), 153–175.

Nykamp, M., Becker, F., Braun, R., Pöllath, N., Knitter, D., Peters, J., Schütt, B., 2021. Sediment cascades and the entangled relationship between human impact and natural dynamics at the pre-pottery Neolithic site of Göbekli Tepe, Anatolia. Earth Surface Processes and Landforms 46, 430–442.

Palmisano, A., Bevan, A., Shennan, S. 2017. Comparing archaeological proxies for long-term population patterns: An example from central Italy. Journal of Archaeological Science, 87, 59-72. doi:10.1016/j.jas.2017.10.001

Palmisano, A., Bevan, A., Kabelindde, A., Roberts, N., & Shennan, S. (2021). Long-Term Demographic Trends in Prehistoric Italy: Climate Impacts and Regionalised Socio-Ecological Trajectories. Journal of World Prehistory.

Palmisano, A., Lawrence, D., de Gruchy, M. W., Bevan, A., & Shennan, S. 2021. Holocene regional population dynamics and climatic trends in the Near East: A first comparison using archaeo-demographic proxies. Quaternary Science Reviews, 252, 106739.

Palmisano, A., Woodbridge, J., Roberts, N., Bevan, A., Fyfe, R., Shennan, S., et al. 2019. Holocene landscape dynamics and long-term population trends in the Levant. The Holocene, 0959683619826642. doi:10.1177/0959683619826642

Park, G., Marwick, B., 2022. How did the introduction of stemmed points affect mobility and site occupation during the late Pleistocene in Korea? Quaternary Science Reviews 277, 107312.

Porčić, M., 2020. Observations on the origin and demography of the Vinča culture. Quaternary International.

Porčić, M., Blagojević, T., Pendić, J., & Stefanović, S. 2021. The Neolithic Demographic Transition in the Central Balkans: population dynamics reconstruction based on new radiocarbon evidence. Philosophical Transactions of the Royal Society B: Biological Sciences, 376(1816), 20190712.

Prates, L., & Perez, S. I. (2021). Late Pleistocene South American megafaunal extinctions associated with rise of Fishtail points and human population. Nature Communications, 12(1), 2175.

Prates, L., Politis, G.G., Perez, S.I., 2020. Rapid radiation of humans in South America after the last glacial maximum: A radiocarbon-based study. PLOS ONE 15, e0236023.

Marie Prentiss, A., Edinborough, K., Crema, E. R., Kuijt, I., Goodale, N., Ryan, E., et al. 2022. Divergent population dynamics in the middle to late Holocene lower Fraser valley and mid-Fraser canyon, British Columbia. Journal of Archaeological Science: Reports, 44, 103512.

Ren, X., Xu, J., Wang, H., Storozum, M., Lu, P., Mo, D., et al. 2021. Holocene fluctuations in vegetation and human population demonstrate social resilience in the prehistory of the Central Plains of China. Environmental Research Letters.

Riris, P. 2018 Dates as data revisited: A statistical examination of the Peruvian preceramic radiocarbon record. Journal of Archaeological Science, 97, 67-76. doi:10.1016/j.jas.2018.06.008

Riris, P., Arroyo-Kalin, M. 2018. Widespread Population Decline in South America Correlates with Mid-holocene Climate Change Scientific Reports, 9, Article number: 6850 (2019). doi:10.1038/s41598-019-43086-w.

Riris, P., de Souza, J.G., 2021. Formal Tests for Resistance-Resilience in Archaeological Time Series. Frontiers in Ecology and Evolution 9, 906.

Riris, P., & Silva, F. 2021. Resolution and the detection of cultural dispersals: development and application of spatiotemporal methods in Lowland South America. Humanities and Social Sciences Communications, 8(1), 1–13.

Roberts, N., Woodbridge, J., Palmisano, A., Bevan, A., Fyfe, R., & Shennan, S. 2019. Mediterranean landscape change during the Holocene: Synthesis, comparison and regional trends in population, land cover and climate. The Holocene, 0959683619826697.

Robinson, E., Nicholson, C., & Kelly, R. L. 2019. The Importance of Spatial Data to Open-Access National Archaeological Databases and the Development of Paleodemography Research. Advances in Archaeological Practice, 1–14. doi:10.1017/aap.2019.29

Robinson, E., Bocinsky, R. K., Bird, D., Freeman, J., & Kelly, R. L. (2021). Dendrochronological dates confirm a Late Prehistoric population decline in the American Southwest derived from radiocarbon dates. Philosophical Transactions of the Royal Society B: Biological Sciences, 376(1816), 20190718.

Roscoe, P., Sandweiss, D. H., & Robinson, E. 2021. Population density and size facilitate interactive capacity and the rise of the state. Philosophical Transactions of the Royal Society B: Biological Sciences, 376(1816), 20190725.

Ruiz-Redondo, A., Vukosavljević, N., Tomasso, A., Peresani, M., Davies, W., Vander Linden, M., 2022. Mid and Late Upper Palaeolithic in the Adriatic Basin: Chronology, transitions and human adaptations to a changing landscape. Quaternary Science Reviews 276, 107319.

Saag, L., Laneman, M., Varul, L., Malve, M., Valk, H., Razzak, M. A., et al. 2019. The Arrival of Siberian Ancestry Connecting the Eastern Baltic to Uralic Speakers further East. Current Biology

Sánchez, R. M. M., Rodríguez, J. C. V., Caro, J. G., Pardo-Gordó, S., Pérez-Jordà, G., & Peña-Chocarro, L. (2021). Reflections on the Other Side. A Southern Iberia Origin for the First Pottery Production of Northern Morocco? Open Archaeology, 7(1), 1054–1065.

Schauer, P., Shennan, S., Bevan, A., Cook, G., Edinborough, K., Fyfe, R., et al. 2019. Supply and demand in prehistory? Economics of Neolithic mining in northwest Europe. Journal of Anthropological Archaeology, 54, 149–160. doi:10.1016/j.jaa.2019.03.001

Schauer, P., Shennan, S., Bevan, A., Colledge, S., Edinborough, K., Kerig, T., & Pearson, M. P. (2021). Cycles in Stone Mining and Copper Circulation in Europe 5500–2000 bc: A View from Space. European Journal of Archaeology, 24(2), 204–225.

Schauer, P., Bevan, A., Shennan, S., Edinborough, K., Kerig, T., Pearson, M.P., 2019. British Neolithic Axehead Distributions and Their Implications. Journal of Archaeological Method and Theory. doi:/10.1007/s10816-019-09438-6

Schirrmacher, J., Kneisel, J., Knitter, D., Hamer, W., Hinz, M., Schneider, R.R., Weinelt, M., 2020. Spatial patterns of temperature, precipitation, and settlement dynamics on the Iberian Peninsula during the Chalcolithic and the Bronze Age. Quaternary Science Reviews 233, 106220.

Schroeter, N., Mingram, J., Kalanke, J., Lauterbach, S., Tjallingii, R., Schwab, V. F., & Gleixner, G. (2021). The Reservoir Age Effect Varies With the Mobilization of Pre-Aged Organic Carbon in a High-Altitude Central Asian Catchment. Frontiers in Earth Science, 0.

Seidensticker, D., Hubau, W., Verschuren, D., Fortes-Lima, C., Maret, P. de, Schlebusch, C. M., & Bostoen, K. 2021. Population collapse in Congo rainforest from 400 CE urges reassessment of the Bantu Expansion. Science Advances, 7(7), eabd8352.

Solheim, S., 2020. Mesolithic coastal landscapes : Demography, settlement patterns and subsistence economy in southeastern Norway. In Schülke. A (Eds.) ,Coastal Landscapes of the Mesolithic, Taylor and Francis.

Solheim, S. (2021). TIMING THE EMERGENCE AND DEVELOPMENT OF ARABLE FARMING IN SOUTHEASTERN NORWAY BY USING SUMMED PROBABILITY DISTRIBUTION OF RADIOCARBON DATES AND A BAYESIAN AGE MODEL. Radiocarbon, 63(5), 1503–1524.

Stoddart, S., Woodbridge, J., Palmisano, A., Mercuri, A. M., Mensing, S. A., Colombaroli, D., et al. 2019. Tyrrhenian central Italy: Holocene population and landscape ecology. The Holocene, 0959683619826696. doi:10.1177/0959683619826696

Sweeney, L., Harrison, S. P., & Linden, M. V. 2022. Assessing anthropogenic influence on fire history during the Holocene in the Iberian Peninsula. Quaternary Science Reviews, 287, 107562.

Szpak, P., Savelle, J. M., Conolly, J., & Richards, M. P. 2019. Variation in late holocene marine environments in the Canadian Arctic Archipelago: Evidence from ringed seal bone collagen stable isotope compositions. Quaternary Science Reviews, 211, 136–155. doi:10.1016/j.quascirev.2019.03.016

Tallavara, M., Personen, P. 2018. Human ecodynamics in the north-west coast of Finland 10,000–2000 years ago.Quaternary International,doi:/10.1016/j.quaint.2018.06.032

Tallavaara, M., & Jørgensen, E. K. 2021. Why are population growth rate estimates of past and present hunter–gatherers so different? Philosophical Transactions of the Royal Society B: Biological Sciences, 376(1816), 20190708.

ter Schure, A. T. M. ter, M. Bajard, K. Loftsgarden, H. I. Høeg, E. Ballo, J. Bakke, E. W. N. Støren, et al. 2021 Anthropogenic and Environmental Drivers of Vegetation Change in Southeastern Norway during the Holocene. Quaternary Science Reviews 270, 107175.

Thompson, A. E., Feinman, G. M., Lemly, M., & Prufer, K. M. 2021. Inequality, networks, and the financing of Classic Maya political power. Journal of Archaeological Science, 133, 105441.

Thomson, M.J., MacDonald, G.M., 2020. Climate and growing season variability impacted the intensity and distribution of Fremont maize farmers during and after the Medieval Climate Anomaly based on a statistically downscaled climate model. Environ. Res. Lett.

Van der Bilt, W. G. M., Born, A., & Haaga, K. A. 2019. Was Common Era glacier expansion in the Arctic Atlantic region triggered by unforced atmospheric cooling? Quaternary Science Reviews, 105860. doi:10.1016/j.quascirev.2019.07.042

Van Maldegem, E., Vandendriessche, H., Verhegge, J., Sergant, J., Meylemans, E., Perdaen, Y., et al. 2021. Population collapse or human resilience in response to the 9.3 and 8.2 ka cooling events: A multi-proxy analysis of Mesolithic occupation in the Scheldt basin (Belgium). Journal of Anthropological Archaeology, 64, 101348.

Vander Linden, M., & Silva, F. 2021. Dispersals as demographic processes: testing and describing the spread of the Neolithic in the Balkans. Philosophical Transactions of the Royal Society B: Biological Sciences, 376(1816), 20200231.

Vogels, O., Fäder, E., Lenssen-Erz, T., 2020. A matter of diversity? Identifying past hunter-gatherer aggregation camps through data driven analyses of rock art sites. Quaternary International.

Weiberg, E., Bevan, A., Kouli, K., Katsianis, M., Woodbridge, J., Bonnier, A., et al. 2019. Long-term trends of land use and demography in Greece: A comparative study The Holocene, 0959683619826641. doi:10.1177/0959683619826641

Zhang, F., Li, S., Sun, C., Li, W., Zhao, X., Chen, Z., et al. 2022. Human Impacts Overwhelmed Hydroclimate Control of Soil Erosion in China 5,000 Years Ago. Geophysical Research Letters, 49(5), e2021GL096983.

Weitzel, E.M., Codding, B.F., Carmody, S.B., Zeanah, D.W., 2020. Food Production and Domestication Produced Both Cooperative and Competitive Social Dynamics in Eastern North America. Environmental Archaeology 0, 1–14.

Wilson, K. M., & Hill, M. G. (2020). Synthesis and assessment of the flat-headed peccary record in North America. Quaternary Science Reviews, 248, 106601.

Wilson, K. M., McCool, W. C., Brewer, S. C., Zamora-Wilson, N., Schryver, P. J., Lamson, R. L. F., et al. 2022. Climate and demography drive 7000 years of dietary change in the Central Andes. Scientific Reports, 12(1), 2026.

Woodbridge, J., Roberts, C. N., Palmisano, A., Bevan, A., Shennan, S., Fyfe, R., et al. 2019. Pollen-inferred regional vegetation patterns and demographic change in Southern Anatolia through the Holocene. The Holocene, 0959683619826635. doi:10.1177/0959683619826635

rcarbon's People

Contributors

ahb108 avatar benmarwick avatar bocinsky avatar ercrema avatar joeroe avatar nfrerebeau avatar philriris avatar pmschauer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rcarbon's Issues

Y Axis Scale in Multiplot

Hi Enrico,
Thanks for a fantastic package!

I love the ability to plot multiple radiocarbon dates using multiplot but it would be great to be able to define the values on the y axis. For example, where dates are plotted in stratigraphic order, it would be very useful to be able to reference the depth to each sample.

For example, when calibrating the attached set of dates using the code below

AllCSVDates<-calibrate(x=Kwamter14C$14C B.P. (CRA),ids = Kwamter14C$Lab Code, errors=Kwamter14C$Standard Deviation,calCurves = Kwamter14C$'Cal Curves', resOffsets = Kwamter14C$'DeltaR', resErrors = Kwamter14C$'Error')

I have plotted them using this code
multiplot(AllCSVDates,decreasing=NULL,rescale=TRUE,HPD=TRUE,credMass = 0.95,label=TRUE,ylab="Depth",ydisp=TRUE)

Which creates a y axis with a default scale but I would like to show the depth of each sample from the original Kwamter14C CSV.

Is this currently possible and, if not, could I suggest this as a future enhancement please?

Cheers,
Ian

Kwamter14C_V2.csv

modelTest fails in R 4.x

I am trying to use modelTest, with the same code as I used successfully earlier this year. The only difference is that I've updated to R 4.0.2

It now always fails with the error:

"Error in makePSOCKcluster(names = spec, ...) :
Cluster setup failed. 1 worker of 1 failed to connect."

Here is my code. I've specified the number of cores or simply left out that argument with the only difference being the number of "workers" that "failed to connect."

model.all <- LUP_Meso_dates %>% dplyr::filter(date.COV<=0.1 & cal.curve != "normal") %>% with(., calibrate(x=date.BP.mean, errors=date.BP.SD, calCurves = cal.curve, normalised=TRUE, calMatrix=FALSE)) %>% modelTest(., errors = subset(LUP_Meso_dates, C14.COV<=0.1 & cal.curve != "normal")$C14sdev, timeRange = c(10000,8000), runm = 500, model="exponential", datenormalised=TRUE, nsim = 200, method = 'calsample', bins = date.bins)

I'm using a Mac. It has failed with both Mac OS X 14 and 15. It failed with the binary and with the most current source code from this Git repository.

Error in plotting stacks-day output

I've created a stacked spd and want to plot it. The code to create the object runs fine with no errors. But when I try to plot it, I get the following error (same with all plot types).

> plot(stacked.spd, type = "multipanel")

Error in PrDens[, i] <- x$spds[[i]][[2]][[2]] : 
  number of items to replace is not a multiple of replacement length

I've tried a number of things and nothing seems to work. There are 6 groups. Is that a problem?

stacked SPD class object and associated plot function

Generate a new class of multiple SPDs. Requires the following functions:

  • stackspd() for automatically computing multiple SPDs grouped by an user-defined parameter.
  • a stackCalSPD class object generated as an output of stackspd().
  • plot. stackCalSPD() for displaying multiple spd either separately, or cumulatively, or as proportions.

corrupt help file

I just installed the latest and greatest version of rcarbon from GitHub and the help database is coming up as corrupted.

Error in fetch(key) : lazy-load database '/Users/cmbarton/Library/R/3.5/library/rcarbon/help/rcarbon.rdb' is corrupt

Feature wish: stackspd sorting matches factor levels (or something else)

The sorting of the groups for stackspd is not clear, but I think it is the default order of the grouping variable in the data.frame. This can be pretty random.

It would be better if either a) there is an explicit way to order these or at least b) using the level of the grouping variable if it is a factor or alphabetically if it is character.

Plot.SpdModleTest function Unable to display positive and negative area

Using the SPD model to analyze the carbon 14 data, the bbty parameter is “f” in the plot function is used to draw the positive and negative area, but the area cannot be displayed. However, the summary function can find the significant area.
library(openxlsx) data<-read.xlsx(file.choose()) caldates <- calibrate(x=data$BP, errors=data$SD, normalised=FALSE) bins <- binPrep(sites=data$SiteName, ages=data$BP, h=50) nsim=200 #Number of simulations expnull <- modelTest(caldates, errors=data$SD, bins=bins, nsim=nsim, runm=50,ncores = 3, timeRange=c(8000,1000), model="exponential", datenormalised=FALSE) #plot(expnull, xlim=c(8000,1000)) #round(expnull$pval,4) #p-value summary(expnull) plot( expnull, calendar = "BP", type = "spd", ylim = c(0,0.2), xlim = c(8000,1000), col.obs = "black", col.env = rgb(0, 0, 0, 0.2), lwd.obs = 0.5, xaxs = "i", yaxs = "i", bbty = "f", bbtyRet = TRUE, drawaxes = TRUE )
the result figure:
image
the summary result:
image

errors in testModel with long time series

I'm interested in using rcarbon testModel in some long time series, but there seem to be some limits that are not quite clear. Below, I show a couple of tests I did with a set of Upper Paleolithic dates. I'm doing this on my MacBook, but it does have a Core i7 processor (4 effective cores from 2 hardware cores) and 16Gb RAM.

test Model runs quickly in a few minutes when I set the time range to 19000-9000 years. But I get a vector memory exhausted error with a range of 20000-8000. And if I set the range a little higher, I get a different error about a limit of 50 iterations. Any thoughts as to what is happening here?

See below

azilian_model <- modelTest(azilian_caldate, errors = aziliandates_c14$C14sdev, timeRange = c(25000,8000), runm = 500, model="exponential", datenormalised=FALSE, nsim = 100, ncores = 4)

[1] "Aggregating observed dates..."
[1] "Monte-Carlo test..."
Error in nls(y ~ exp(a + b * x), data = data.frame(x = time, y = finalSPD), :
number of iterations exceeded maximum of 50

azilian_model <- modelTest(azilian_caldate, errors = aziliandates_c14$C14sdev, timeRange = c(20000,8000), runm = 500, model="exponential", datenormalised=FALSE, nsim = 100, ncores = 4)

[1] "Aggregating observed dates..."
[1] "Monte-Carlo test..."
Error: vector memory exhausted (limit reached?)

no underscores in site names?

alldate_bins <- binPrep(alldates$site, alldates$C14mean, 100)
Error in binPrep(alldates$site, alldates$C14mean, 100) :
sites should not contain elements with underscores

Why???

These are strings.

Feature wish: show decimal places in plot.stackCalSPD multi panel plot

I'm still working with the stackspd function. It is very useful for comparing SPD's of course. Multipanel has the best display for comparison and I'm trying to adjust arguments to get the most understandable and honest display. Rescale makes all the SPD curves equally visible. But it doesn't show the difference between higher and lower probability curves. Turning it off makes some of the curves nearly flat since all have the same y-scale. Turning on spdnormalize is somewhere in between for visualization. But it loses the y scale because the labels are all rounded to 1 decimal place.

I suggest 2 improvements

  1. Have an option to let the y-scale be set independently for each panel or be the same across all panels (e.g., like in ggplot facet_wrap)
  2. Have an argument to let the user choose how many decimal places to display on the y-scale. This would help on the other plot types too.

Trouble with the SPpermTest

Hi,

I'm exploring this package (which is great by the way) and I'm having an issue trying to make the Spatial Analysis with the SPpermTest that I can't solve. When I run the SPpermTest everything goes ok until it starts making the permutations, that's when R shows this error:

Error in if (max(pval) > 1) { : missing value where TRUE/FALSE needed

Everything works fine but this is the only analysis that I can't figure out what's wrong. Hope someone could help me.
Thanks!

"cannot allocate vector of size ..." error message in uncalibrate.CalGrid

Problem

  • A user reported the a cannot allocate vector of size 4.1Gb error message when using the modelTest() function on a machine running windows 8.1 with 12Gb of RAM.
  • The error was caused by the uncalibrate.CalGrid() function and does not happen when the timeRange parameter is reduced from the original c(12000,150) to c(6000,100).
  • The error was not reproduced on a Laptop running Ubuntu 16.04 nor on a Desktop machine with MacOSX 10.13.3, both with 16Gb of RAM. Increasing the timeRange to c(50000,150) also did not produce the error (although it slowed down the execution time considerably).

Further Tests

  • It is worth checking this on other machines to determine whether the problem is the OS or the limited amount of RAM

Possible Solutions

  1. Update the following lines on uncalibrate.CalGrid() to reduce memory allocation

  2. Mention the problem for users with limited RAM in the help documentation.

modelTest() does not accept "intcal20", "shcal20", or "marine20" as a calCurves argument

Amended function:

modelTest <- function (x, errors, nsim, bins = NA, runm = NA, timeRange = NA,
backsight = 50, changexpr = expression((t1/t0)^(1/d) - 1),
gridclip = TRUE, raw = FALSE, model = c("exponential"),
method = c("uncalsample"), predgrid = NA, normalised = NA,
datenormalised = NA, spdnormalised = FALSE, ncores = 1, fitonly = FALSE,
a = 0, b = 0, edgeSize = 500, verbose = TRUE)
{
caltimeRange = c(55000, 0)
if (any(x$metadata$CalCurve %in% c("intcal13", "shcal13", "intcal20", "marine20", "shcal20",
"marine13", "intcal13nhpine16", "shcal13shkauri16"))) {
caltimeRange = c(50000, 0)
}
if (fitonly == TRUE) {
nsim <- 1
}
if (ncores > 1 & !requireNamespace("doSNOW", quietly = TRUE)) {
warning("the doParallel package is required for multi-core processing; ncores has been set to 1")
ncores = 1
}
else {
cl <- snow::makeCluster(ncores)
registerDoSNOW(cl)
on.exit(snow::stopCluster(cl))
}
if (!any(method %in% c("uncalsample", "calsample"))) {
stop("The 'method' argument must be either 'uncalsample' or 'calsample'")
}
ccrange = c(max(medCal(x)), min(medCal(x)))
if (anyNA(timeRange)) {
timeRange = ccrange
}
if (is.na(normalised)) {
normalised = FALSE
if (x$metadata$Normalised[1] == TRUE) {
normalised = TRUE
}
}
if (normalised != x$metadata$Normalised[1]) {
warning("The normalisation setting of x and normalised are different")
}
if (!is.na(datenormalised)) {
if (datenormalised != normalised) {
warning("'datenormalised' is not equal to 'normalised'. The datenormalised setting will be used for the normalisation setting of the calibration of simulated dates")
normalised = datenormalised
}
if (datenormalised != x$metadata$Normalised[1]) {
if (x$metadata$Normalised[1]) {
warning("Input dates are normalised but datenormalised is set to FALSE. The datenormalised setting will be ignored")
normalised = datenormalised
}
if (!x$metadata$Normalised[1]) {
warning("Input dates are not normalised but datenormalised is set to TRUE. The datenormalised setting will be ignored")
normalised = datenormalised
}
}
}
calCurves = x$metadata$CalCurve
if (!all(calCurves %in% c("intcal13", "shcal13", "intcal20", "marine20", "shcal20",
"marine13", "intcal13nhpine16", "shcal13shkauri16"))) {
stop("modelTest() currently accepts only dates calibrated with the following calibration curves: 'intcal13','intcal13nhpine16','shcal13','shcal13shkauri16', and 'marine13'")
}
unique.calCurves = as.character(sort(unique(calCurves)))
ncc = length(unique.calCurves)
if (verbose) {
print("Aggregating observed dates...")
}
if (is.na(bins[1])) {
samplesize <- t(matrix(table(calCurves), nrow = ncc,
ncol = nsim))
colnames(samplesize) = names(table(calCurves))
}
else {
samplesize <- curveSamples(bins = bins, calCurves = calCurves,
nsim = nsim)
if (ncc == 1) {
samplesize = matrix(samplesize, ncol = 1, nrow = length(samplesize))
colnames(samplesize) = names(table(calCurves))
}
}
if (ncc > 1) {
samplesize = samplesize[, unique.calCurves]
}
if (is.na(bins[1])) {
bins <- as.character(1:nrow(x$metadata))
}
observed <- spd(x = x, bins = bins, timeRange = timeRange,
runm = runm, spdnormalised = spdnormalised, verbose = FALSE,
edgeSize = edgeSize)
finalSPD <- observed$grid$PrDens
sim <- matrix(NA, nrow = length(finalSPD), ncol = nsim)
if (verbose & !fitonly) {
print("Monte-Carlo test...")
flush.console()
}
fit.time <- seq(timeRange[1], timeRange[2], -1)
pred.time <- fit.time
if (gridclip) {
st = max(ccrange[1], timeRange[1]) + edgeSize
en = min(ccrange[2], timeRange[2]) - edgeSize
pred.time <- seq(st, en, -1)
}
fit <- NA
if (model == "exponential") {
fit <- nls(y ~ exp(a + b * x), data = data.frame(x = fit.time,
y = finalSPD), start = list(a = a, b = b))
est <- predict(fit, list(x = pred.time))
predgrid <- data.frame(calBP = pred.time, PrDens = est)
}
else if (model == "uniform") {
predgrid <- data.frame(calBP = pred.time, PrDens = mean(finalSPD))
}
else if (model == "linear") {
fit <- lm(y ~ x, data = data.frame(x = fit.time, y = finalSPD))
est <- predict(fit, list(x = pred.time))
predgrid <- data.frame(calBP = pred.time, PrDens = est)
}
else if (model == "custom") {
if (length(predgrid) != 2) {
stop("If you choose a custom model, you must provide a proper predgrid argument (two-column data.frame of calBP and predicted densities).")
}
if (!all(colnames(predgrid) %in% c("calBP", "PrDens"))) {
stop("Column names in the predgrid argument should be 'calBP' and 'PrDens'")
}
}
else {
stop("Specified model not one of current choices.")
}
if (fitonly) {
print("Done (SPD and fitted model only).")
predgrid <- subset(predgrid, calBP <= timeRange[1] &
calBP >= timeRange[2])
res <- list(result = NA, sim = NA, pval = NA, osbSPD = observed,
fit = predgrid, fitobject = fit)
return(res)
}
if (edgeSize > 0) {
predgrid = rbind.data.frame(data.frame(calBP = (max(predgrid$calBP) +
edgeSize):c(predgrid$calBP[1] + 1), PrDens = 0),
predgrid)
predgrid = rbind.data.frame(predgrid, data.frame(calBP = min(predgrid$calBP):(min(predgrid$calBP) -
edgeSize), PrDens = 0))
if (any(predgrid$calBP <= 0 | predgrid$calBP >= caltimeRange[1])) {
warning("edgeSize reduced")
predgrid = subset(predgrid, calBP <= caltimeRange[1] &
calBP >= 0)
}
}
cragrids = vector("list", length = ncc)
for (i in 1:ncc) {
tmp.grid <- uncalibrate(as.CalGrid(predgrid), calCurves = unique.calCurves[i],
compact = FALSE, verbose = FALSE)
cragrids[[i]] <- tmp.grid
if (gridclip) {
cragrids[[i]] <- tmp.grid[tmp.grid$CRA <= max(x$metadata$CRA) &
tmp.grid$CRA >= min(x$metadata$CRA), ]
}
}
opts = NULL
if (verbose) {
if (ncores > 1) {
print(paste("Running in parallel on ", getDoParWorkers(),
" workers...", sep = ""))
}
pb <- txtProgressBar(min = 0, max = nsim, style = 3)
progress <- function(n) setTxtProgressBar(pb, n)
opts <- list(progress = progress)
}
if (ncores == 1) {
for (s in 1:nsim) {
if (verbose) {
setTxtProgressBar(pb, s)
}
if (method == "uncalsample") {
randomDates <- vector("list", length = ncc)
ccurve.tmp <- numeric()
for (i in 1:ncc) {
randomDates[[i]] = sample(cragrids[[i]]$CRA,
replace = TRUE, size = samplesize[s, i],
prob = cragrids[[i]]$PrDens)
ccurve.tmp = c(ccurve.tmp, rep(unique.calCurves[i],
samplesize[s, i]))
}
randomSDs <- sample(size = length(unlist(randomDates)),
errors, replace = TRUE)
}
if (method == "calsample") {
randomDates <- vector("list", length = ncc)
ccurve.tmp <- numeric()
for (i in 1:ncc) {
randomDates[[i]] = sample(cragrids[[i]]$CRA,
replace = TRUE, size = samplesize[s, i],
prob = cragrids[[i]]$Raw)
ccurve.tmp = c(ccurve.tmp, rep(unique.calCurves[i],
samplesize[s, i]))
}
randomSDs <- sample(size = length(unlist(randomDates)),
errors, replace = TRUE)
}
tmp <- calibrate(x = unlist(randomDates), errors = randomSDs,
timeRange = timeRange, calCurves = ccurve.tmp,
normalised = normalised, ncores = 1, verbose = FALSE,
calMatrix = TRUE)
simDateMatrix <- tmp$calmatrix
sim[, s] <- apply(simDateMatrix, 1, sum)
sim[, s] <- (sim[, s]/sum(sim[, s])) * sum(predgrid$PrDens[predgrid$calBP <=
timeRange[1] & predgrid$calBP >= timeRange[2]])
if (spdnormalised) {
sim[, s] <- (sim[, s]/sum(sim[, s]))
}
if (!is.na(runm)) {
sim[, s] <- runMean(sim[, s], runm, edge = "fill")
}
}
}
if (ncores > 1) {
sim <- foreach(s = 1:nsim, .combine = "cbind",
.packages = "rcarbon", .options.snow = opts) %dopar%
{
randomDates <- vector("list", length = ncc)
ccurve.tmp <- numeric()
if (method == "uncalsample") {
for (i in 1:ncc) {
randomDates[[i]] = sample(cragrids[[i]]$CRA,
replace = TRUE, size = samplesize[s, i],
prob = cragrids[[i]]$PrDens)
ccurve.tmp = c(ccurve.tmp, rep(unique.calCurves[i],
samplesize[s, i]))
}
}
if (method == "calsample") {
for (i in 1:ncc) {
randomDates[[i]] = sample(cragrids[[i]]$CRA,
replace = TRUE, size = samplesize[s, i],
prob = cragrids[[i]]$Raw)
ccurve.tmp = c(ccurve.tmp, rep(unique.calCurves[i],
samplesize[s, i]))
}
}
randomSDs <- sample(size = length(unlist(randomDates)),
errors, replace = TRUE)
tmp <- calibrate(x = unlist(randomDates), errors = randomSDs,
timeRange = timeRange, calCurves = ccurve.tmp,
normalised = normalised, ncores = 1, verbose = FALSE,
calMatrix = TRUE)
simDateMatrix <- tmp$calmatrix
aux <- apply(simDateMatrix, 1, sum)
aux <- (aux/sum(aux)) * sum(predgrid$PrDens[predgrid$calBP <=
timeRange[1] & predgrid$calBP >= timeRange[2]])
if (spdnormalised) {
aux <- (aux/sum(aux))
}
if (!is.na(runm)) {
aux <- runMean(aux, runm, edge = "fill")
}
aux
}
}
if (verbose) {
close(pb)
}
timeSequence = timeRange[1]:timeRange[2]
foo = function(spd, backsight, timeSequence, changexpr) {
obs = rep(NA, length(timeSequence))
for (i in 1:c(length(obs) - backsight)) {
d = backsight
t0 = spd[i]
t1 = spd[i + backsight]
obs[i + backsight] = eval(changexpr)
if (t1 == 0 | t0 == 0) {
obs[i + backsight] = NA
}
}
return(obs)
}
obs.roc = foo(finalSPD, backsight = backsight, timeSequence = timeSequence,
changexpr = changexpr)
sim.roc = apply(sim, 2, foo, backsight = backsight, timeSequence = timeSequence,
changexpr = changexpr)
lo <- apply(sim, 1, quantile, prob = 0.025, na.rm = TRUE)
hi <- apply(sim, 1, quantile, prob = 0.975, na.rm = TRUE)
lo.roc = apply(sim.roc, 1, quantile, prob = 0.025, na.rm = TRUE)
hi.roc = apply(sim.roc, 1, quantile, prob = 0.975, na.rm = TRUE)
Zsim <- t(apply(sim, 1, scale))
zLo <- apply(Zsim, 1, quantile, prob = 0.025, na.rm = TRUE)
zHi <- apply(Zsim, 1, quantile, prob = 0.975, na.rm = TRUE)
Zsim.roc <- t(apply(sim.roc, 1, scale))
zLo.roc <- apply(Zsim.roc, 1, quantile, prob = 0.025, na.rm = TRUE)
zHi.roc <- apply(Zsim.roc, 1, quantile, prob = 0.975, na.rm = TRUE)
Zscore_empirical <- (finalSPD - apply(sim, 1, mean))/apply(sim,
1, sd)
Zscore_empirical.roc <- (obs.roc - apply(sim.roc, 1, mean))/apply(sim.roc,
1, sd)
busts <- which(Zscore_empirical < zLo)
booms <- which(Zscore_empirical > zHi)
busts2 <- which(finalSPD < lo)
booms2 <- which(finalSPD > hi)
busts.roc <- which(Zscore_empirical.roc < zLo.roc)
booms.roc <- which(Zscore_empirical.roc > zHi.roc)
busts2.roc <- which(obs.roc < lo.roc)
booms2.roc <- which(obs.roc > hi.roc)
observedStatistic <- sum(c(zLo[busts] - Zscore_empirical[busts]),
c(Zscore_empirical[booms] - zHi[booms]))
observedStatistic.roc <- sum(c(zLo.roc[busts.roc] - Zscore_empirical.roc[busts.roc]),
c(Zscore_empirical.roc[booms.roc] - zHi.roc[booms.roc]))
expectedstatistic <- abs(apply(Zsim, 2, function(x, y) {
a = x - y
i = which(a < 0)
return(sum(a[i]))
}, y = zLo)) + apply(Zsim, 2, function(x, y) {
a = x - y
i = which(a > 0)
return(sum(a[i]))
}, y = zHi)
expectedstatistic.roc <- abs(apply(Zsim.roc, 2, function(x,
y) {
a = x - y
i = which(a < 0)
return(sum(a[i]))
}, y = zLo.roc)) + apply(Zsim.roc, 2, function(x, y) {
a = x - y
i = which(a > 0)
return(sum(a[i]))
}, y = zHi.roc)
pvalue <- c(length(expectedstatistic[expectedstatistic >
observedStatistic]) + 1)/c(nsim + 1)
pvalue.roc <- c(length(expectedstatistic.roc[expectedstatistic.roc >
observedStatistic.roc]) + 1)/c(nsim + 1)
result <- data.frame(calBP = observed$grid$calBP, PrDens = finalSPD,
lo = lo, hi = hi)
result.roc <- data.frame(calBP = timeSequence, roc = obs.roc,
lo.roc = lo.roc, hi.roc = hi.roc)
predgrid <- subset(predgrid, calBP <= timeRange[1] & calBP >=
timeRange[2])
if (raw == FALSE) {
sim <- NA
sim.roc <- NA
}
res <- list(result = result, result.roc = result.roc, sim = sim,
sim.roc = sim.roc, pval = pvalue, pval.roc = pvalue.roc,
fit = predgrid, fitobject = fit, nbins = length(unique(bins)),
n = nrow(x$metadata), nsim = nsim, backsight = backsight)
class(res) <- "SpdModelTest"
if (verbose) {
print("Done.")
}
return(res)
}

Add a "none" option in the calCurves argument in calibrate()

Some dataset might contain dates not requiring any calibration (e.g. historical artefacts with known dates) - setting the calCurve argument to "none" should return a CalDates class object where the entire probability mass is in the calendar date provided by the user (i.e. the argument x). A warning message should be supplied in case the matching error is not 0 or NA.

Error reporting: empty or unrecognised calibration curve

Providing calibrate with an empty or unrecognised calCurves calibration curve provides the cryptic error message which is difficult to solve:

Error in file(con, "r") : cannot open the connection

Before reading readLines(calCurveFile, encoding = "UTF-8"), can calibrate check with file.exists first?

modelTest (calling uncalibrate.CalGrid) does not recognize calibration curves

I have a data.frame with columns for uncalibrated mean date, standard deviation, and the calibration curve to use. In the calibration curve column, I just use 'intcal13', 'marine13', and 'normal'. calibrate works fine and recognizes the calibration curves.

caldate_mesolithic <- calibrate(x=mesolithic_dates$C14mean, errors=mesolithic_dates$C14sdev, calCurves = mesolithic_dates$calib.curve, normalised=FALSE, calMatrix=TRUE)

But when I try modelTest (using most of the parameters given in the example), it gives the error below. The problem seems to be in uncalibrated.CalGrid

nsim = 5
meso_model <- modelTest(caldate_mesolithic, errors = mesolithic_dates$C14sdev, timeRange = c(14000,5000), runm = 100, model="exponential", datenormalised=FALSE, nsim = nsim)

[1] "Aggregating observed dates..."
[1] "Monte-Carlo test..."
]Error in uncalibrate.CalGrid(as.CalGrid(predgrid), calCurves = unique.calCurves[i], : calCurves must be a character vector specifying one or more known curves or a custom three-column matrix/data.frame (see ?calibrate.default).

Here is the traceback:
4.stop("calCurves must be a character vector specifying one or more known curves or a custom three-column matrix/data.frame (see ?calibrate.default).")
3.uncalibrate.CalGrid(as.CalGrid(predgrid), calCurves = unique.calCurves[i], compact = FALSE, verbose = FALSE)
2.uncalibrate(as.CalGrid(predgrid), calCurves = unique.calCurves[i], compact = FALSE, verbose = FALSE)
1.modelTest(caldate_mesolithic, errors = mesolithic_dates$C14sdev, timeRange = c(14000, 5000), runm = 100, model = "exponential", datenormalised = FALSE, nsim = nsim)

Erroneous output w/ unclear warning when dates falling outside timeRange supplied to calibrate()

The following calls:

test.dat <- rcarbon::euroevol[1:100,]
    
test.cal <- calibrate(x=test.dat$C14Age,
                             errors=test.dat$C14SD, 
                             ids=test.dat$C14ID,
                             calCurves='intcal13', 
                             timeRange=c(5000,100),
                             normalised=FALSE, 
                             ncores=1,
                             calMatrix=TRUE)
    
test.sum <- summary(test.cal)

Results in the data.frame object test.sum with a column structured like so:

 $ OneSigma_BP_1: Factor w/ 1 level "c(startCalBP = NA) to c(startCalBP = NA) to c(startCalBP = NA) to c(startCalBP = NA) to c(startCalBP = NA) to c"| __truncated__: 1 1 1 1 1 1 1 1 1 1 ...

The following warnings are given but they don't seem related to the issue as they are present when the time range is expanded to include all dates:

Warning message:
In if (is.na(x$calmatrix)) { :
  the condition has length > 1 and only the first element will be used

Doubt About simulation envelope is FLAT

Here I am,again.Thank you for your effort about my question last week. But, i noticed that the simulation envelope is FLAT.
image
I read the paper(Crema, E., & Bevan, A. (2021). INFERENCE FROM LARGE SETS OF RADIOCARBON DATES: SOFTWARE AND METHODS. Radiocarbon, 63(1), 23-39. doi:10.1017/RDC.2020.95) and found maybe just normalized problem.
image
When I came to read the help of calibrate function ,the "normalised " parameter default is TRUE.I just have some doubt
and want to know how to fix it.
my data and code as usual as the issues named "Plot.SpdModleTest function Unable to display positive and negative area #57"

user-defined timeRange overridden in spd() when datenormalised is set to TRUE

When datenormalised is set to TRUE in spd(), the user-defined timeRange is overridden:

library(rcarbon)
data(euroevol)
DK=subset(euroevol,Country=="Denmark") #subset of Danish dates
x1=calibrate(x=DK$C14Age,errors=DK$C14SD,calCurves='intcal20',normalised=TRUE)
x2=calibrate(x=DK$C14Age,errors=DK$C14SD,calCurves='intcal20',normalised=FALSE)

par(mfrow=c(2,2))
plot(spd(x1,timeRange=c(20000,2000),datenormalised=TRUE))
plot(spd(x1,timeRange=c(20000,2000),datenormalised=FALSE))
plot(spd(x2,timeRange=c(20000,2000),datenormalised=TRUE))
plot(spd(x2,timeRange=c(20000,2000),datenormalised=FALSE))

image

This is caused by the following lines in spd():

rcarbon/R/aggregation.R

Lines 184 to 196 in 92d8b5a

if(datenormalised)
{
true.timeRange=timeRange
ccrange=range(medCal(x))
ccrange[2]=ccrange[2]+edgeSize
ccrange[1]=ccrange[1]-edgeSize
if (ccrange[1]<0|ccrange[2]>caltimeRange[1])
{
stop(paste0("timeRange beyond calibration curve. Ensure that timeRange[1]+edgeSize is smaller than ", caltimeRange[1]," and timeRange[2]-edgeSize is larger than 0"))
}
timeRange[1]=ccrange[2]
timeRange[2]=ccrange[1]
}

I think this was designed to handle situations where the user defined timeRange was narrower than the date range, which had an impact in the way the normalisations of the dates were carried out. Can be fixed by having using an internal timeRange to solve the issue but effectively using the timeRange provided the user for display purposes. Will work on this in the next few days.

hpdi > add probabilities?

Dear rcarbon developers,

Would it be a good idea to include the probabilities for each date interval to the output of hpdi()?

Adding this ugly for-loop after line 623 of calibration.R should do the trick (I think):

ends <- indices[c(gaps, length(indices))]

      # compute summed probability for each interval
      p_interval <- as.integer(length(starts))
      for ( j in 1:length(starts) ){
           p_interval[j] <- sum(grd$PrDens[starts[j]:ends[j]])
           p_interval[j] <- round(p_interval[j] * 100, 1)
      }
      result[[i]] <- cbind(startCalBP = grd$calBP[starts],
                           endCalBP = grd$calBP[ends],
                           p_perc = p_interval)

Probably more efficient code could be written (but not by me :-/).
Thanks for all the time and effort you've invested into the development of rcarbon!

Kind regards,
Kristof.

Typo in spd2gg() example

The penultimate line:

emdyd.gg <- spd2gg(emedyd.spd,breaks=seq(16000,9000,-1000))

should read

emdyd.gg <- spd2gg(emdyd.spd,breaks=seq(16000,9000,-1000))

for the code to run correctly as in the example.

uncalibrate documentation error

The uncalibrate documentation says
roundyear | An optional vector of IDs for each date (ignored if x is a CalGrid object).
but supplying IDs generates an error message

uncalibrate(1000,25,roundyear = "Test-34")
Error in if (roundyear) { : argument is not interpretable as logical

Examning the code in rcarbon:::uncalibrate.default, roundyear seems to be a logical indicating whether to round dates or not.

Update reference to spatstat package

Spatstat will soon be divided into multiple packages and references should be updated accordingly. The following rcarbon function imports spatstat functions:

All imported spatstat functions will be in spatsta.core. So:

  • In the NAMESPACE file, the entry 'import(spatstat)' should be replaced by 'import(spatstat.core)'.
  • In .R files, #' @import spatstat should be replaced with #' @import spatstat.core.
  • In .R files, \code{\link[spatstat]{functionname}}, should be replaced with \code{\link[spatstat,core]{functionname}},

This should be carried out when spatstat.core is released on CRAN.

bug on test-branch version calibrate() when ncores>2

The calibrate() function on the test branch fast_calibration fails when ncores>1.

set.seed(1)
n=100
x=sample(3000:7000,size=n)
y=rep(20,n)
curves = c('intcal13','intcal20','shcal13','marine20','shcal20')
calcurves = sample(curves,size=n,replace=TRUE)
res= calibrate(x,y,calCurves=calcurves,verbose=TRUE,ncores=2)

generates the error

Error in { : task 1 failed - "incorrect number of dimensions"
In addition: Warning message:
In calibrate.default(x, y, calCurves = calcurves, verbose = TRUE,  :
  timeRange value not supported with the selected curve(s); calibrating using timeRange=c(50000,0)
Called from: e$fun(obj, substitute(ex), parent.frame(), e$data)

bug on test-branch version calibrate() when F14C=TRUE and multiple calibration curves used

The calibrate() function on the test branch fast_calibration fails when F14C=TRUE. The error occurs only when multiple curves are used

set.seed(1)
n=100
x=sample(3000:7000,size=n)
y=rep(20,n)
curves = c('intcal13','intcal20','shcal13','marine20','shcal20')
calcurves = sample(curves,size=n,replace=TRUE)
res= calibrate(x,y,verbose=TRUE,F14C=TRUE) #No errors
res= calibrate(x,y,calCurves=calcurves,verbose=TRUE,F14C=TRUE) #No errors

generates the error

Error in { : 
  task 3 failed - "One or more dates are outside the calibration range"
In addition: Warning message:
In calibrate.default(x, y, calCurves = calcurves, verbose = TRUE,  :
  timeRange value not supported with the selected curve(s); calibrating using timeRange=c(50000,0)
Called from: e$fun(obj, substitute(ex), parent.frame(), e$data)

tidyverse packages don't recognise calGrid objects as data frames

Version 1.0.0 of dplyr included a breaking change that requires extra classes to be added before the classes they extend, not after (see dplyr v.1.0.0 release notes, tidyverse/dplyr#5066, and r-lib/vctrs#972). I couldn't find a full explanation for this change, but I assume the logic is that because R dispatches S3 classes in the order they're listed, they should be ordered from least to most generic.

rcarbon seems to mostly prepend extra classes, except for the calGrid class produced by calibrate():

> calibrated <- rcarbon::calibrate(c(1000,2000,3000), rep(50, 3))
> class(calibrated)
[1] "CalDates" "list"    
> class(calibrated$grids[[1]])
[1] "data.frame" "calGrid" 

This means that various tidyverse packages no longer recognise calGrids as data frames. For example, if you want to extract them into a table, it will throw an error unless you first rewrite the class vector:

> caltable <- dplyr::tibble(id = c(1,2,3), calgrid = calibrated$grid)
> tidyr::unnest(caltable, calgrid)
Error: Input must be a vector, not a `data.frame/calGrid` object.

> caltable$calgrid <- lapply(caltable$calgrid, function(x) {
+   class(x) <- rev(class(x))
+   return(x)
+ })
> tidyr::unnest(caltable, calgrid)
# A tibble: 1,299 x 3
      id calBP    PrDens
   <dbl> <dbl>     <dbl>
 1     1  1170 0.0000157
 2     1  1169 0.0000168
 3     1  1168 0.0000181
 4     1  1167 0.0000195
 5     1  1166 0.0000210
 6     1  1165 0.0000225
 7     1  1164 0.0000186
 8     1  1163 0.0000153
 9     1  1078 0.0000135
10     1  1077 0.0000141
# … with 1,289 more rows

The fix should be a simple case of making sure calGrid is always prepended to existing classes rather than appended – I'd be happy to submit a pull request if you don't think it will cause problems elsewhere?

summary with multiple probabilities and BC/AD scale

Summarizing several calibrated dates causes a warning if we pass several probabilities as arguments and causes an error if we change the time scale to BC/AD:

x <- rcarbon::calibrate(x = c(4000, 4200), errors = c(30, 40))
summary(x) # OK
summary(x, prob = 0.95) # OK
summary(x, prob = c(0.68, 0.95)) # warning
Warning message:
In if (is.na(prob)) { :
  la condition a une longueur > 1 et seul le premier élément est utilisé

This warning can be prevented if summary.CalDates() tests for missing values with anyNA() instead of is.na().

summary(x, calendar = "BP") # OK
summary(x, calendar = "BCAD") # error
Error in if (any(x < 0)) { : 
  valeur manquante là où TRUE / FALSE est requis 

The error can be avoided by checking for missing values in BPtoBCAD() (same in BCADtoBP()).

I've changed the code on my side, if it is ok with you I can make a PR.

Typo in modelTest?

Shouldn't be this two instances of CalBP in test.R uncapitalized?
208 if (!all(colnames(predgrid)%in%c("CalBP","PrDens")))
209 {
210 stop("Column names in the predgrid argument should be 'CalBP' and 'PrDens'")

To Do/Wish List

  • Add EUROEVOL dataset
  • Add additional datasets
  • Define/choose bootstrap routine
  • Move codes of spatial.R to test.R, plots.R, and utilities.R.
  • Remove F14C option from calibration.R?
  • Remove oxcalSingleDate() and jagsSingleCalibrate() option from calibration.R?
  • Add summary() function for calDates class objects
  • Add function for computing bin medians and update barCodes()
  • What does bbty='s' do in plot.SpdModelTest?
  • Add relative risk surface functions?
  • highlight portions of spd curves (edges) that use a smaller number of points in the moving window when runm>0?

error in label display when running plot.CalDates

The following command
plot(calibrate(4275,20),label="a")
now produces the error:
Error in legend("topright", label, bty = "n", cex = cex.label) : object 'cex.label' not found
A separate cex.label argument should be added and has to be distinguished from cex.lab that is used for axis label. Perhaps the latter can be renamed into cex.xylab ad the former to cex.lab?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.