Fit a scalar-on-function regression model. Uses refund::pfr under the hood for computations, and stores results in the mxfda object.
run_sofr( mxFDAobject, model_name, formula, family ="gaussian", metric ="uni k", r ="r", value ="fundiff", smooth =FALSE, filter_cols =NULL,..., knots =NULL)
Arguments
mxFDAobject: Dataframe of spatial summary functions from multiplex imaging data, in long format. Can be estimated using the function extract_summary_functions or provided separately.
model_name: character string to give the fit model
formula: Formula to be fed to mgcv in the form of outcome ~ x1 + x2. Does not contain functional predictor. Character valued.
family: Exponential family distribution to be passed to mgcv::gam. Defaults to "gaussian". Select "binomial" for binary outcome.
metric: Name of calculated spatial metric to use
r: Character string, the name of the variable that identifies the function domain (usually a radius for spatial summary functions). Default is "r".
value: Character string, the name of the variable that identifies the spatial summary function values. Default is "fundiff".
smooth: Option to smooth data using FPCA. Defaults to FALSE.
filter_cols: a named vector of factors to filter summary functions to in c(Derived_Column = "Level_to_Filter") format
...: Optional other arguments to be passed to fpca.face
knots: Number of knots for defining spline basis.
Returns
A list which is a linear or additive functional Cox model fit. See mgcv::gam for more details.
Details
Examples
#load ovarian mxFDA objectdata('ovarian_FDA')# run scalar on function regression model with a continuous outcome (age)ovarian_FDA = run_sofr(ovarian_FDA, model_name ="fit_sofr", formula = age~stage, metric ="uni g", r ="r", value ="fundiff")# run scalar on function regression model with a binary outcome (stage)# also known as functional logistic regressionovarian_FDA = run_sofr(ovarian_FDA, model_name ="fit_sofr", formula = stage~age, family ="binomial", metric ="uni g", r ="r", value ="fundiff")