R/subtyper.R
rowwise_linear_variable_adjustments.Rd
Trains linear models on a given dataframe row by row and applies the learned parameters to perform subject-specific adjustment to other variables.
rowwise_linear_variable_adjustments(
tempNM,
trainvalues,
varstoadjust,
poly_order = 1,
post_fix = "_pred",
verbose = FALSE
)
The input dataframe containing the data to be processed.
A vector of target values corresponding to the predictor variables. this should be a vector of values with column names in tempNM representing the predictor variables.
A vector of column names in tempNM representing the variables to be predicted.
An integer specifying the polynomial order to be used in the fit. Defaults to 1.
an extension to add to the modified variable name - can be an empty string
boolean
A dataframe with the predicted values added as new columns. The new columns are named by appending post_fix to the original column names specified in varstoadjust.
This function loops through each row in the dataframe, trains a linear model using trainvalues, and applies the model to predict the values for the specified variables. It handles both simple (one predictor) and multiple predictor cases, adapting the modeling approach accordingly and allows for both linear and polynomial adjustment.
The function uses a simple linear model for prediction, which may not be suitable for complex relationships between variables. It assumes that the input dataframe has the same structure and column names as expected, and does not perform any error checking or handling. Therefore, it may fail if the input data is not properly formatted or if there are missing values.