create_functional_data: Makes a functional data with splines from a...

View source: R/functional_data.R

create_functional_dataR Documentation

Makes a functional data with splines from a Pupil_difference_data dataframe.

Description

This function turns difference data into fitted splines in order to carry out functional data analysis. Under the hood this passes basis and order to fda::Data2fd, and fda::create.bspline.basis, and is mandatory before running run_functional_t_test. It is recommended to read the documentation for package fda for further information.

Usage

create_functional_data(data, pupil, basis, order)

Arguments

data

a Pupil_difference_data dataframe

pupil

Column name indicating pupil data to fit

basis

Integer specifying number of basis functions to create a b-spline basis

order

Integer specifying order of b-splines (one higher than the degree)

Value

A Pupil_difference_data dataframe fitted with b-splines.

See Also

fda package

Examples

Sdata <- make_pupillometryr_data(data = pupil_data,
                               subject = ID,
                               trial = Trial,
                               time = Time,
                               condition = Type)
regressed_data <- regress_data(data = Sdata, pupil1 = RPupil, pupil2 = LPupil)
mean_data <- calculate_mean_pupil_size(data = regressed_data, pupil1 = RPupil, pupil2 = LPupil)
base_data <- baseline_data(data = mean_data, pupil = mean_pupil, start = 0, stop = 100)
differences <- create_difference_data(data = base_data, pupil = mean_pupil)
spline_data <- create_functional_data(data = differences, pupil = mean_pupil, basis = 10, order = 4)


samhforbes/PupillometryR documentation built on Sept. 25, 2023, 10:19 a.m.