GithubHelp home page GithubHelp logo

fdapde / fdapde-r Goto Github PK

View Code? Open in Web Editor NEW
12.0 2.0 3.0 226 KB

The R wrapper to the fdaPDE library for physics-informed spatial and functional data analysis.

License: GNU General Public License v3.0

R 50.70% C 0.83% C++ 48.47%
functional-data-analysis nonparametric-statistics r spatial-data-analysis

fdapde-r's Introduction

fdaPDE

This repository contains the development version of fdaPDE package.

New features wrt CRAN: Wald inference on the nonparametric term for space-time models.

Compiled in Ubuntu using g++ compiler and in macOS: for the precise versions tested, see the report. If using a Linux machine, it is advisable to install rgl, geometry, plot3D and plot3Drgl before fdaPDE.

Image.FEM has been restored. Bugs in fPCA, boundary conditions and space-varying regression have been fixed. Issues of point location in 2.5D have been fixed. Compiled in Win RStudio, Ubuntu using g++ compiler and in macOS: for the precise versions tested, see the report. If using a Linux machine, it is advisable to install rgl, geometry, plot3D and before fdaPDE. If using Windows, it is advisable to install Rtools and then rgl, plot3D, geometry and RcppEigen libraries.

Subfolder structure:

/src contains all C++ code and a special file named Makevars necessary to build and install the R package. The code is now organized in subfolders and divided into source files and header files. See the report for the precise new orgaization. We suggest to use a base-8 scale as spacing scale for visualization, in order to preserve the code style.

/R contains the R functions that wrap the C++ calls,

/data contains the data to run the tests in the examples,

/man contains the manual for the package.

Installation:

Two different methods are proposed in order to install the package in the R environment.
Download the .zip file from the repository, unzip it, and for the installation choose one of the two following methods:

  • R console: install.packages("/path/to/fdaPDE", type='source', repos=NULL)

  • From the Terminal: $ R CMD build <path to folder to be installed>
    $ R CMD INSTALL -l <path name of the R library tree> <path to folder to be installed>

see the installation section in the report for more information.

Remarks:

  1. the shift of indexes from R to C++ is done within the R functions smooth.FEM and FPCA.FEM Do not use C++ scripts directly on the R mesh objects, unless you take care of shifing indexes by yourself.

fdapde-r's People

Contributors

alepalu avatar

Stargazers

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

Watchers

 avatar  avatar

fdapde-r's Issues

Missing expected type for the first argument of function FunctionSpace()

FunctionSpace() does not complain when an object of a type different from MeshObject is passed as the first argument. Instead, it returns an error that is not clear.

Code

library(fdaPDE2)

data("unit_square", package = "fdaPDE2")
domain <- Mesh(unit_square)

Vh <- FunctionSpace(domain, fe_order = 1)

Error

> data("unit_square", package = "fdaPDE2")
> domain <- Mesh(unit_square)
> 
> ## the functional space of finite element functions of order 1, over the unit square
> Vh <- FunctionSpace(unit_square, fe_order = 1)
Error in eval(parse(text = paste("cpp_lagrange_basis_", mesh$domain_type,  : 
  object 'cpp_lagrange_basis__fe1' not found

package fail to install on mac-os systems (`apple-clang`)

Installing the R package on a mac-os system makes the compilation fail. Error reported:

In file included from R_Model.cpp:23:
   In file included from fdaPDE/fdaPDE/models.h:20:
   In file included from fdaPDE/fdaPDE/models/model_base.h:20:
   In file included from fdaPDE/fdaPDE/core/fdaPDE/mesh.h:20:
   fdaPDE/fdaPDE/core/fdaPDE/mesh/mesh.h:202:56: error: declaration of 'N' shadows template parameter
       static constexpr bool is_manifold = is_manifold<M, N>::value;
                                                          ^
   fdaPDE/fdaPDE/core/fdaPDE/mesh/mesh.h:59:22: note: template parameter is declared here
   template <int M, int N> class Mesh {
                        ^
   fdaPDE/fdaPDE/core/fdaPDE/mesh/mesh.h:202:56: error: default initialization of an object of const type 'const bool'
       static constexpr bool is_manifold = is_manifold<M, N>::value;
                                                          ^
                                                            = false
   fdaPDE/fdaPDE/core/fdaPDE/mesh/mesh.h:202:57: error: expected ';' at end of declaration list
       static constexpr bool is_manifold = is_manifold<M, N>::value;
                                                           ^
                                                           ;
   In file included from R_Model.cpp:23:
   In file included from fdaPDE/fdaPDE/models.h:20:
   In file included from fdaPDE/fdaPDE/models/model_base.h:21:
   In file included from fdaPDE/fdaPDE/core/fdaPDE/utils.h:24:
   fdaPDE/fdaPDE/core/fdaPDE/utils/type_erasure.h:222:28: error: use 'template' keyword to treat 'fn_ptrs' as a dependent template name
           size_ = (size<typename I::fn_ptrs<T_>>::value + ...);
                                     ^
                                     template 
   fdaPDE/fdaPDE/core/fdaPDE/utils/type_erasure.h:225:55: error: use 'template' keyword to treat 'fn_ptrs' as a dependent template name
           init_vtable<0, T_>(typename merge<typename I::fn_ptrs<T_>...>::type(), vtable_);
                                                         ^
                                                         template 
   fdaPDE/fdaPDE/core/fdaPDE/utils/type_erasure.h:230:67: error: use 'template' keyword to treat 'fn_ptrs' as a dependent template name
               base_ += size<typename std::decay<decltype(i)>::type::fn_ptrs<T_>>::value;
                                                                     ^
                                                                     template 
   In file included from R_Model.cpp:23:
   In file included from fdaPDE/fdaPDE/models.h:20:
   In file included from fdaPDE/fdaPDE/models/model_base.h:22:
   In file included from fdaPDE/fdaPDE/core/fdaPDE/pde.h:20:
   In file included from fdaPDE/fdaPDE/core/fdaPDE/pde/pde.h:29:
   fdaPDE/fdaPDE/core/fdaPDE/pde/differential_operators.h:48:51: error: template template argument has different template parameters than its corresponding template template parameter
       static constexpr bool value = has_instance_of<dT, decltype(std::declval<E>().get_operator_type())>::value;
                                                     ^
   fdaPDE/fdaPDE/core/fdaPDE/pde/differential_operators.h:36:1: note: too many template parameters in template template argument
   FDAPDE_DEFINE_DIFFERENTIAL_OPERATOR(dT,          dt         );
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fdaPDE/fdaPDE/core/fdaPDE/pde/differential_operators.h:28:5: note: expanded from macro 'FDAPDE_DEFINE_DIFFERENTIAL_OPERATOR'
       template <typename T, typename... Ts> class OP { };                                                                \
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fdaPDE/fdaPDE/core/fdaPDE/utils/traits.h:58:11: note: previous template template parameter is here
   template <template <typename F> typename E, typename Tuple> struct has_instance_of { };
             ^~~~~~~~~~~~~~~~~~~~~
   In file included from R_Model.cpp:23:
   In file included from fdaPDE/fdaPDE/models.h:20:
   In file included from fdaPDE/fdaPDE/models/model_base.h:22:
   In file included from fdaPDE/fdaPDE/core/fdaPDE/pde.h:20:
   In file included from fdaPDE/fdaPDE/core/fdaPDE/pde/pde.h:29:
   fdaPDE/fdaPDE/core/fdaPDE/pde/differential_operators.h:48:27: error: default initialization of an object of const type 'const bool'
       static constexpr bool value = has_instance_of<dT, decltype(std::declval<E>().get_operator_type())>::value;
                             ^
                                   = false

Problem seems related to some apple-clang aspects which are ignored when compiling with gcc.

Compiler details:

─  installing source package ‘fdaPDE2’ ...
   ** using staged installation
   ** libs
   using C++ compiler: ‘Apple clang version 15.0.0 (clang-1500.0.40.1)’
   using C++17
   using SDK: ‘MacOSX14.0.sdk’

Add support for standardized and well-known input data format (stop using `matrix` everywhere!)

fdaPDE must be able to support many different data format as input, well established in the R language and scientific community. Is quiet annoying to input data in low-level matrix or array data formats. This is true for statistical data, but also for the domain geometry (this is a critical aspect which must be fixed sooner or later).

This issue wants to keep a list of all data format we should (or wish) support to enhance the fdaPDE usage. Each iter reports the data format, its supporting R package and possibly some specific documentation:

`optimizer = "bfgs"` causes segfault in GCV lambda selection

When using BFGS as optimization method, the R wrapper crashes with cause 'memory not mapped'

MWE

data("unit_square", package = "fdaPDE2")
unit_square <- Mesh(unit_square)
df <- ## some data...

model <- SRPDE(y ~ f, domain = unit_square, data = df)
## fit with BFGS optimization
model$fit(lambda = gcv(
    optimizer = "bfgs",
    lambda = 1e-4,
    step = 1e-6
))

The problem is releated to the R wrapper, as performing a BFGS optimization of the GCV from the C++ layer does not cause any segfault.

You can reproduce the test gcv_srpde_newton_test, laplacian_nonparametric_samplingatnodes_newton_fd_exact with BFGS in place of Netwon, and obtain the correct result using a wolfe line search approach for the adaptive step.

auto GCV = model.gcv<ExactEDF>();
GCV.set_step(4e-08);
// optimize GCV
BFGS<fdapde::Dynamic> opt(10, 0.05, 1);
DVector<double> pt = SVector<1>(6.25e-06);
opt.optimize(GCV, pt, WolfeLineSearch());

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.