model2.ChiSq3: model2.ChiSq3

View source: R/PulseWaveform.R

model2.ChiSq3R Documentation

model2.ChiSq3

Description

model2.ChiSq3 calculates a reduced ChiSq (goodness of fit) value for a model generated waveform, when provided with the original waveform being modelled and a set of model parameters. The function can either be applied to calculate the goodness of fit of an individual waveform, or batches of waveforms, and is used to drive the downhill simplex optimisation of model parameters.

Usage

model2.ChiSq3(data, params, debug=FALSE, beats, optional = NULL, beat = NULL, a = NULL, plot = FALSE, renal_param, dias_param, sys_time, w)

Arguments

data

section of ppg time series

params

model parameters

debug

logical, currently redundant

beats

list of number of inputted beats, there beginnings in the time series, and their endings

optional

logical, now redundant

beat

dataframe of model parameters

a

the combined matrix used in the downhill simplex routine (alternative source of parameters)

plot

logical, if set to true plots model generated waveform against original waveform

renal_param

the starting parameter for 1st reflectance peak timing (inputted to prevent drastic deviations from this value)

dias_param

the starting parameter for 2nd reflectance peak timing (inputted to prevent drastic deviations from this value)

sys_time

the starting parameter for systolic peak timing (inputted to prevent drastic deviations from this value)

w

the timing of the 1st derivative peaks on the ppg time series

Value

ts_fit

total reduced ChiSq value summed across all beats inputted

Note

makesimplex3 inputs a single set of parameters (tParam) to test, whereas run.simplex2 inputs a matrix This determines where within beat parameters should be extracted from, hence beat and a are NULL unless otherwise specified.

During the downhill simplex parameter optimization process, movements of parameter values outside of defined contraints will lead to the application of penalties, which model2.ChiSq3 adds to the ChiSq value outputted, driving the optimisation process to occur within constraints. The penalties are proportionate to the degree to which the constraints are exceeded, to prevent mere ignorance of the constraint once violated.

Examples

chiSq[i] <- f(data, params = NULL, optional=NULL,
                  a = result[i, ], beats = beat_vector,
                  renal_param = renal_param,
                  dias_param = dias_param,
                  sys_time = sys_time, w = w)










stw32/PulseWaveform documentation built on Dec. 6, 2022, 2:50 a.m.