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.

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)
#> Baselining for each subject and trial. If this is not the intended behaviour you may wish to do this manually.
differences <- create_difference_data(data = base_data, pupil = mean_pupil)
#> Hard minus Easy  -- relevel condition if this is not the intended outcome  
spline_data <- create_functional_data(data = differences, pupil = mean_pupil, basis = 10, order = 4)