Learn R Programming

refund (version 0.1-40)

Regression with Functional Data

Description

Methods for regression for functional data, including function-on-scalar, scalar-on-function, and function-on-function regression. Some of the functions are applicable to image data.

Copy Link

Version

Install

install.packages('refund')

Monthly Downloads

5,505

Version

0.1-40

License

GPL (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Julia Wrobel

Last Published

March 21st, 2026

Functions in refund (0.1-40)

amc

Additive model with constraints
bayes_fosr

Bayesian Function-on-scalar regression
build_cl2_working_standard

Build CL2 working representation for standard single-LP families
build_cluster_id

Build cluster ID vector from pffr metadata
af

Construct an FGAM regression term
build_cl2_working_gaulss

Build CL2 working representation for gaulss family
build_coef_axes

Build coordinate axes for coefficient results
af_old

Construct an FGAM regression term
center_ff_beta

Center beta(s,t) surface for ff identifiability
build_mgcv_data

Build the mgcv data frame from pffr components
ccb.fpc

Corrected confidence bands using functional principal components
center_concurrent_covariate

Center concurrent functional covariate column-wise
compute_coef_se

Compute standard errors for coefficient extraction
build_limits_function

Convert limits argument to a function
cd4

Observed CD4 cell counts
coef_safe_range

Safely compute range for coef.pffr
compute_concurrent_effect

Compute concurrent functional effect: Xc(t) * beta_c(t)
build_coef_linear_map

Build linear map used for smooth-term uncertainty calculations
cmdscale_lanczos

Faster multi-dimensional scaling
coef.pffr

Get estimated coefficients from a pffr fit
build_mgcv_formula

Build the final mgcv formula from transformed terms
compute_smooth_effect

Compute smooth varying coefficient effect
compute_linear_effect

Compute linear varying coefficient effect
compute_integration_windows

Compute integration window bounds from a boolean mask
center_functional_covariate

Center functional covariate column-wise
content

The CONTENT child growth study
create.prep.func

Construct a function for preprocessing functional predictors
coef_get_predictions

Compute predictions for coefficient extraction
f_sum

Sum computation 1
compute_intercept

Compute functional intercept
coefficients.pfr

Extract coefficient functions from a fitted pfr-object
center_smooth_effect

Center effect matrix column-wise for smooth term identifiability
compute_ci_critical

Compute critical value for pointwise/simultaneous intervals
concurrent_presets

Concurrent functional effect presets
expand_windows_to_maxwidth

Expand windows to uniform width
const_presets

Constant-over-t effect presets for c() terms
.smooth.spec

Basis constructor for PEER terms
compute_gaulss_scores

Compute per-observation scores for gaulss family
create_shortlabels

Create short labels for pffr terms at model fit time
coef_make_data_grid

Generate evaluation grid for smooth term
compute_integration_weights

Compute integration weights for ff/sff terms
f_trace

Trace computation
fgam

Functional Generalized Additive Models
ensure_grid_axis_attributes

Ensure evaluation grid has axis attributes used by coef extraction
draw_coef_perturbations

Draw coefficient perturbations for simultaneous intervals
finalize_grid_by_var

Add by-variable column to grid if needed
coefboot.pffr

Simple bootstrap CIs for pffr (deprecated)
compute_const_effect

Compute constant-over-t effect
ffpc

Construct a PC-based function-on-function regression term
ffpcplot

Plot PC-based function-on-function regression terms
compute_ff_effect

Compute function-on-function effect
expand.call

Return call with all possible arguments
f_sum4

Sum computation 2
f_sum2

Sum computation 2
eval_bs

Evaluate B-spline at new points using stored specification
fbps

Sandwich smoother for matrix data
ff

Construct a function-on-function regression term
ff_presets

Function-on-function effect presets
fpca.face

Functional principal component analysis with fast covariance estimation
fosr.vs

Function-on Scalar Regression with variable selection
fpca.sc

Functional principal components analysis by smoothed covariance
fosr

Function-on-scalar regression
fpca.ssvd

Smoothed FPCA via iterative penalized rank one SVDs.
fosr.perm

Permutation testing for function-on-scalar regression
fpca.lfda

Longitudinal Functional Data Analysis using FPCA
fpca2s

Functional principal component analysis by a two-stage method
fpc

Construct a FPC regression term
fosr2s

Two-step function-on-scalar regression
generate_scalar_covariate

Generate scalar covariate
fpcr

Functional principal component regression
gam_sandwich_cluster

Cluster-robust sandwich covariance estimator
generate_functional_covariate

Generate functional covariate
gen_random_1d

Generate 1D random function from P-spline prior
gen_random_2d

Generate 2D random surface from tensor P-spline prior
gasoline

Octane numbers and NIR spectra of gasoline
gam_sandwich_cluster_cl2

Cluster-robust CL2 sandwich covariance estimator
getTF

Get recognized transformation function
get_default_effect

Get default effect specification for a term type
gibbs_mult_wish

Multilevel FoSR using a Gibbs sampler and Wishart prior
get_smooth_label_from_term

Get smooth label from a term string
gibbs_cs_fpca

Cross-sectional FoSR using a Gibbs sampler and FPCA
lf.vd

Construct a VDFR regression term
gibbs_cs_wish

Cross-sectional FoSR using a Gibbs sampler and Wishart prior
gibbs_mult_fpca

Multilevel FoSR using a Gibbs sampler and FPCA
lf_old

Construct an FLM regression term
intercept_presets

Intercept presets for mu(t)
make_random_2d_fn

Create 2D random surface function from P-spline prior
lf

Construct an FLM regression term
make_random_truth_generator

Create random truth generator with P-spline prior
linear_presets

Linear varying coefficient presets
make_bs_spec

Create B-spline specification for evaluation at new points
lofocv

Leave-one-function-out cross-validation
gls_cs

Cross-sectional FoSR using GLS
lpeer

Longitudinal Functional Models with Structured Penalties
lpfr

Longitudinal penalized functional regression
mfpca.face

Multilevel functional principal components analysis with fast covariance estimation
model.matrix.pffr

Obtain model matrix for a pffr fit
mfpca.sc

Multilevel functional principal components analysis by smoothed covariance
pffr-formula

Modular Formula Parsing for pffr
ols_cs

Cross-sectional FoSR using GLS
pco_predict_preprocess

Make predictions using pco basis terms
peer

Construct a PEER regression term in a pfr formula
parse_pffr_model_formula

Parse a pffr model formula and classify terms
pffr-core

Core Modular Functions for pffr
parse_pffr_formula

Parse a pffr-style formula
pcre

pffr-constructor for functional principal component-based functional random intercepts.
peer_old

Functional Models with Structured Penalties
pffrSim_legacy

Legacy pffr_simulate implementation
pffr

Penalized flexible functional regression
parse_single_term

Parse a single term string
pffrSim_formula

Generate data from formula specification
pffr_build_call

Build and configure the mgcv call
pffr.check

Some diagnostics for a fitted pffr model (deprecated)
pffrSim

Simulate example data for pffr (deprecated)
pffr_build_ar_start

Build AR.start indicator for AR(1) errors
pffr_attach_metadata

Attach pffr metadata to model
pffr_build_label_map

Build the label map from terms to smooth labels
pffrGLS

Penalized function-on-function regression with non-i.i.d. residuals (deprecated)
pffr_expand_variables

Expand variables to formula environment for smooth/parametric terms
pffr_coefboot

Simple bootstrap CIs for pffr
pffr_process_ff_terms

Process ff/sff terms and assign to formula environment
pffr_process_ffpc_terms

Process ffpc terms and return formula strings
pffr_configure_algorithm

Select and configure algorithm
pffr_build_metadata

Build the pffr metadata list
pffr_gls

Penalized function-on-function regression with non-i.i.d. residuals (deprecated)
pffr_get_dimensions

Detect data dimensions for pffr
pffr_validate_dots

Validate pffr arguments and process dots
pffr_check

Some diagnostics for a fitted pffr model
pfr_old

Penalized Functional Regression (old version)
pfr

Penalized Functional Regression
pffr_setup_yind_dense

Setup y-index for dense data
pffr_validate_ydata

Validate sparse data format
pffr_setup_response

Setup response and indices for formula environment
pffr_simulate

Simulate example data for pffr
pffr_setup_yind_sparse

Setup y-index for sparse data
pffr_process_pcre_terms

Process pcre terms and return formula strings
pffr_qq

QQ plots for pffr model residuals
plot.pffr

Plot a pffr fit
plot.peer

Plotting of estimated regression functions obtained through peer()
plot.fpcr

Default plotting for functional principal component regression output
pffr_prepare

Prepare data, formula, and call for pffr()
predict.fgam

Prediction from a fitted FGAM model
plot.lpeer

Plotting of estimated regression functions obtained through lpeer()
predict.fbps

Prediction for fast bivariate P-spline (fbps)
plot.fosr.vs

Plot for Function-on Scalar Regression with variable selection
pfr_plot.gam

Local version of plot.gam
quadWeights

Compute quadrature weights
plot.fosr

Default plotting of function-on-scalar regression objects
predict.pffr

Prediction for penalized function-on-function regression
predict.fosr.vs

Prediction for Function-on Scalar Regression with variable selection
predict.fosr

Prediction from a fitted bayes_fosr model
predict.pfr

Prediction from a fitted pfr model
qq.pffr

QQ plots for pffr model residuals (deprecated)
print.summary.pffr

Print method for summary of a pffr fit
residuals.pffr

Obtain residuals and fitted values for a pffr models
plot.pfr

Plot a pfr object
re

Random effects constructor for fgam
rlrt.pfr

Likelihood Ratio Test and Restricted Likelihood Ratio Test for inference of functional predictors
pwcv

Pointwise cross-validation for function-on-scalar regression
resolve_effect

Resolve an effect specification to a coefficient function/matrix
resolve_eval_grid_for_term

Resolve optional fixed evaluation grid for one smooth term
sample_pspline_coef_1d

Sample coefficients from 1D P-spline prior
sff

Construct a smooth function-on-function regression term
shift_and_shorten_matrix

Extract row-wise windows from a matrix
scenario_to_formula

Scenario-to-formula mapping for backward compatibility
smooth.construct.fpc.smooth.spec

Basis constructor for FPC terms
smooth.construct.pco.smooth.spec

Principal coordinate ridge regression
simpson_weights

Compute Simpson integration weights
sample_pspline_coef_2d

Sample coefficients from 2D tensor P-spline prior
simplify_term_label

Simplify a term label for display
smooth.construct.pss.smooth.spec

P-spline constructor with modified 'shrinkage' penalty
smooth_presets

Smooth effect presets for s() terms
smooth.construct.pi.smooth.spec

Parametric Interaction basis constructor
smooth.construct.pcre.smooth.spec

mgcv-style constructor for PC-basis functional random effects
vb_cs_wish

Cross-sectional FoSR using Variational Bayes and Wishart prior
summary.pfr

Summary for a pfr fit
simulate_from_family

Simulate response from a GLM family
smooth.construct.dt.smooth.spec

Domain Transformation basis constructor
sym_inv_sqrt

Symmetric matrix inverse square root with eigenvalue floor
vb_mult_fpca

Multilevel FoSR using Variational Bayes and FPCA
vb_cs_fpca

Cross-sectional FoSR using Variational Bayes and FPCA
validate_and_expand_xind

Validate and expand xind to matrix form
transform_intercept_term

Transform intercept term to functional intercept
vis.pfr

Visualization of PFR objects
summary.pffr

Summary for a pffr fit
transform_c_term

Transform c() wrapped terms by removing the wrapper
vis.fgam

Visualization of FGAM objects
vb_mult_wish

Multilevel FoSR using Variational Bayes and Wishart prior
sofa

SOFA (Sequential Organ Failure Assessment) Data
transform_smooth_term

Transform smooth terms (s, te, ti, t2) to include y-index
transform_par_term

Transform parametric terms to varying coefficient terms
PEER.Sim

Simulated longitudinal data with functional predictor and scalar response, and structural information associated with predictor function
DTI2

Diffusion Tensor Imaging: more fractional anisotropy profiles and outcomes
COVID19

The US weekly all-cause mortality and COVID19-associated deaths in 2020
Predict.matrix.pi.smooth

Predict.matrix method for pi basis
Predict.matrix.peer.smooth

mgcv-style constructor for prediction of PEER terms
Predict.matrix.pcre.random.effect

mgcv-style constructor for prediction of PC-basis functional random effects
DTI

Diffusion Tensor Imaging: tract profiles and outcomes
Predict.matrix.dt.smooth

Predict.matrix method for dt basis
Xt_siginv_X

Internal computation function
Predict.matrix.fpc.smooth

mgcv-style constructor for prediction of FPC terms
assemble_cluster_sandwich

Assemble cluster-robust sandwich from score matrix
apply_sandwich_correction

Apply sandwich correction to model covariance matrices