impute: Functional Imputation

View source: R/imputation.R

imputeR Documentation

Functional Imputation

Description

Several basic imputation methods for missing values in functional data formatted as dfts objects.

Usage

impute(
  X,
  method = c("zero", "mean_obs", "median_obs", "mean_data", "median_data", "linear",
    "functional"),
  obs_share_data = FALSE
)

Arguments

X

A dfts object or data which can be automatically converted to that format. See dfts().

method

String to indicate method of imputation.

  • zero: Fill missing values with 0.

  • mean_obs: Fill missing values with the mean of each observation.

  • median_obs: Fill missing values with the median of each observation.

  • mean_data: Fill missing values with the mean of the data at that particular fparam value.

  • median_data: Fill missing values with the median of the data at that particular fparam value.

  • linear: Fill missing values with linear interpolation.

  • functional: Fill missing values with functional interpolation. This is done by fitting the data to basis with the package 'fda'.

obs_share_data

Boolean in linear interpolation that indicates if data should be shared across observations. For example, if the end of observation i related to the start of observation i+1. Default is FALSE, which suggests independence. If true, the distance between the end and start of observations is taken to be the mean average distance of points in fparam.

Value

A dfts object of the data with missing values interpolated.

Examples

temp <- data.frame(
  c(NA, NA, 3:9, NA),
  c(NA, stats::rnorm(2), NA, stats::rnorm(6)),
  stats::rnorm(10),
  c(stats::rnorm(4), rep(NA, 3), stats::rnorm(3)),
  rep(NA, 10),
  c(stats::rnorm(1), rep(NA, 9)),
  c(stats::rnorm(9), NA),
  stats::rnorm(10),
  stats::rnorm(10),
  c(NA, NA, 3:9, NA)
)
impute(temp, method = "mean_obs")
impute(temp, method = "linear", obs_share_data = TRUE)

fChange documentation built on June 21, 2025, 9:08 a.m.