Giter Club home page Giter Club logo

treeclim's Introduction

Build Status CRAN_Status_Badge CRAN_Download_Badge Coverage Status MIT licensed

treeclim

An R package for modelling tree/climate relationships. The package features:

  • static, moving, and evolving response and correlation functions
  • seasonal correlations
  • a "dendro-flavoured" linear model
  • evaluation of reconstruction skills
  • a test for spurious moving correlations
  • nice default plots

Usage

library(treeclim)
munich_spruce_calib <- dcc(muc_spruce, muc_clim)
plot(munich_spruce_calib)
skills(munich_spruce_calib)

See the docs and the wiki for details.

Citation

Zang, C., and F. Biondi. 2015. treeclim: an R package for the numerical calibration of proxy-climate relationships. Ecography 38:431–436.

treeclim's People

Contributors

cszang avatar

Stargazers

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

Watchers

 avatar  avatar

treeclim's Issues

Error error: Col::rows(): indices out of bounds or incorrectly used

Hello,

I am analyzing the ITRDB dataset and running the dcc() function on several chronologies and am getting the following error for some files.

> dcc(jord001_chr,jord001_clim)
treeclim tries to use the maximum overlap in timespan for chronology and climate data. The overlap starts in 1900, but to be able to use climate data from the previous year(s) (as you chose by setting 'selection' accordingly), the analysis starts in 1901.
Running for timespan 1901 - 1995...

error: Col::rows(): indices out of bounds or incorrectly used
Error in respo(boot_data$climate, boot_data$chrono) : 
  Col::rows(): indices out of bounds or incorrectly used

I can't figure out what is wrong although it seems that the problem is with the climate data. I say that because when I run the same chronology file with different climate data it works.

> dcc(jord001_chr,jord003_clim)
treeclim tries to use the maximum overlap in timespan for chronology and climate data. The overlap starts in 1900, but to be able to use climate data from the previous year(s) (as you chose by setting 'selection' accordingly), the analysis starts in 1901.
Running for timespan 1901 - 1995...
Coefficients (significance flags correspond to p < 0.05):
              id varname month   coef significant ci_lower ci_upper
prec.prev.jun  1    prec   Jun -0.064       FALSE   -0.200    0.088
prec.prev.jul  2    prec   Jul  0.015       FALSE   -0.189    0.204
prec.prev.aug  3    prec   Aug  0.042       FALSE   -0.084    0.181
prec.prev.sep  4    prec   Sep -0.026       FALSE   -0.204    0.154
prec.prev.oct  5    prec   Oct -0.042       FALSE   -0.211    0.126
prec.prev.nov  6    prec   Nov  0.024       FALSE   -0.145    0.186
prec.prev.dec  7    prec   Dec  0.049       FALSE   -0.151    0.251
prec.curr.jan  8    prec   JAN  0.141       FALSE   -0.028    0.288
prec.curr.feb  9    prec   FEB  0.111       FALSE   -0.059    0.304
prec.curr.mar 10    prec   MAR  0.071       FALSE   -0.084    0.201
prec.curr.apr 11    prec   APR -0.031       FALSE   -0.229    0.141
prec.curr.may 12    prec   MAY  0.106       FALSE   -0.067    0.277
prec.curr.jun 13    prec   JUN  0.017       FALSE   -0.149    0.194
prec.curr.jul 14    prec   JUL -0.025       FALSE   -0.149    0.100
prec.curr.aug 15    prec   AUG  0.009       FALSE   -0.112    0.232
prec.curr.sep 16    prec   SEP  0.045       FALSE   -0.163    0.217
temp.prev.jun 17    temp   Jun -0.106       FALSE   -0.310    0.093
temp.prev.jul 18    temp   Jul  0.059       FALSE   -0.121    0.215
temp.prev.aug 19    temp   Aug -0.236        TRUE   -0.420   -0.035
temp.prev.sep 20    temp   Sep -0.173       FALSE   -0.340    0.019
temp.prev.oct 21    temp   Oct -0.010       FALSE   -0.228    0.209
temp.prev.nov 22    temp   Nov -0.166       FALSE   -0.347    0.030
temp.prev.dec 23    temp   Dec -0.065       FALSE   -0.199    0.064
temp.curr.jan 24    temp   JAN -0.117       FALSE   -0.262    0.051
temp.curr.feb 25    temp   FEB -0.061       FALSE   -0.193    0.100
temp.curr.mar 26    temp   MAR -0.045       FALSE   -0.217    0.135
temp.curr.apr 27    temp   APR -0.010       FALSE   -0.192    0.149
temp.curr.may 28    temp   MAY -0.118       FALSE   -0.299    0.032
temp.curr.jun 29    temp   JUN  0.036       FALSE   -0.134    0.243
temp.curr.jul 30    temp   JUL -0.094       FALSE   -0.283    0.099
temp.curr.aug 31    temp   AUG -0.022       FALSE   -0.200    0.192
temp.curr.sep 32    temp   SEP  0.208       FALSE   -0.003    0.414

Forgive me for not following the instructions about using reprex but I found some issues while trying and I didn't know how to attach the data too, since using dput() would have taken a huge space here. Because of that, I am attaching the Rds files in order for you to reproduce the error.

Thank you,

Best,

error_dcc.zip

Unable to install on Apple M1 macOS Sonoma 14.5

> install.packages("~/Desktop/treeclim_2.0.6.0.tar", repos = NULL, type = "source")
* installing *source* package ‘treeclim’ ...
** package ‘treeclim’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
make: *** /Users/user/.R/Makevars: Is a directory.  Stop.
Warning in system(paste(MAKE, p1(paste("-f", shQuote(makefiles))), "compilers"),  :
  running command 'make -f 'Makevars' -f '/Library/Frameworks/R.framework/Resources/etc/Makeconf' -f '/Library/Frameworks/R.framework/Resources/share/make/shlib.mk' -f '/Users/user/.R/Makevars' compilers' had status 2
Error in if (nzchar(cxx)) { : argument is of length zero
* removing ‘/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/treeclim’
Warning in install.packages :
  installation of package ‘/Users/user/Desktop/treeclim_2.0.6.0.tar’ had non-zero exit status

How can I solve this problem?

RStudio Version 2024.04.0+735 (2024.04.0+735)

Apple M1 macOS Sonoma 14.5

Problem in loading library and dcc function

Brief description of the problem
I have an error in loading library for treeclim. And the dcc function is not working. I had this problem since I installed new version of R studio.

# insert reprex here

library(treeclim)
Loading required package: Rcpp
Error: package or namespace load failed for ‘treeclim’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
there is no package called ‘zoo’
In addition: Warning message:
package ‘treeclim’ was built under R version 4.0.4

out=dcc(chrono,spei3,selection =-6:9)
Error in dcc(chrono, spei3, selection = -6:9) :
could not find function "dcc"

Error when running dcc function NA/NaN argument error


I keep getting an error when running dcc() with my data. Error in x[1, 1]:x[dim(x)[1], 1] : NA/NaN argument

I have ran the same dataset but without na rows resulting with the same error.

update: 13- column format runs with no error

resp <- dcc(chrono = MB_all_ponderosa, climate = prism_met)

Error in x[1, 1]:x[dim(x)[1], 1] : NA/NaN argument

prism_met.csv
MB_all_ponderosa.csv

Add scaling method (sensu Esper et al. 2005)

Scaling results in homogeneous variability between the instrumental target and proxy, at the expense of inflated error variance. Still, this method is used and should be incorporated into treeclim.

Key question: where? This will probably only be interesting for the skills() related aspects.

R version 4.4.0

Hi there,

I recently updated my Windows system to R version 4.4.0 and R studio version RStudio 2024.04.2+764 "Chocolate Cosmos". It seems as if the treeclim package is not compatible with this version of R. Are there plans to update treeclim or are there alternatives I can use?

Thanks!

Couple of issues

I am new here so probably I do not know how to post that kind of stuff; anyway I would like to ask for some improvements.

My question is connected to seascorr. I have been using it in original MATLAB, but since I would love to see them here I have make some notes what I miss:

  1. Can you make correlation y-axis scaled up to 1 all the time (maybe as an option)?
  2. Can they be colored by user choice?
  3. Can we add primary and secondary factors names in the graph?
  4. Can we pick up two significance levels and show those numbers in the figure?
  5. Can you add also Monte Carlo simulation?
  6. Original version test stability in time (graph and statistical test) - can you add that?
  7. Scatterplots for the most significant seasons
  8. I would like to see a window in which we can compare original and model data?
  9. I would love to add title to the plot.

Point me out how I can improve that question.

Best regards
Wojciech

Failure with dev testthat

I see:

── ERROR (test_eval_selection.R:40:3): the design matrix is constructed correctl
Error: `desc` must be a string
Backtrace:
    █
 1. └─testthat::test_that(...) test_eval_selection.R:40:2

Because test_that() now checks that its first argument is string.

I'm planning to submit testthat to CRAN in about a month.

Order of months fed to climate argument in dcc() can give spurious results


I have found a problem with the dcc() function where it can give spurious results if the months in the climate input are not ordered "correctly". For example in a data.frame, the function assumes that months are ordered like this: 1,2,3,4,5,6,7,8,9,10,11,12, even if they are not. See the example below where I have reordered months (without changing the data), but the function gives a spurious result.

This seems like a simple fix. All the function needs is something equivalent to this before running correlations:
climate <- climate[order(climate$year, climate$months, decreasing = F),]

Although perhaps a better fix would involve lookup tables or some other matching or indexing.

I'm not sure if this problem extends beyond dcc(), but it seems worth a look.

# Example from dcc() function help page
dc_resp <- dcc(muc_spruce, muc_clim)
plot(dc_resp) # expected result

# Change order of climate data
muc_clim_wrong <- muc_clim[order(muc_clim$month, decreasing = T),]

# Note that the data is still correct:
# months are associated with the correct respective values
aggregate(temp ~ month, data = muc_clim, mean)
aggregate(temp ~ month, data = muc_clim_wrong, mean)

# Run the function again
dc_resp_wrong <- dcc(muc_spruce, muc_clim_wrong)

# Very different results when months are not ordered as expected.
# Plot labels stay the same.
plot(dc_resp_wrong) # different from expected result

# Simply reordering by month doesn't fix the problem:
muc_clim_still_wrong <- muc_clim_wrong[order(muc_clim_wrong$month, decreasing = F),]
dc_resp_still_wrong <- dcc(muc_spruce, muc_clim_still_wrong)
plot(dc_resp_still_wrong)

# This does work though:
muc_clim_right <- muc_clim_wrong[order(muc_clim_wrong$year, muc_clim_wrong$month, decreasing = F),]
dc_resp_right <- dcc(muc_spruce, muc_clim_right)
plot(dc_resp_right)

Compute RE/CE with LOOCV

For short overlaps of proxy and climate data, a more sophisticated validation scheme would be helpful. To this end, treeclim should be able to evaluate RE/CE using LOOCV.

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.