Performs k-fold resampling to estimate averaged coefficients for linear regression. The coefficients are averaged across k different subsets of the data to provide more stable estimates. For small samples (n < 100), returns a standard linear model instead.
subsample_lm(text, data, weights, k = 10)
An object of class 'lm' with averaged coefficients from k-fold resampling. For small samples, returns a standard lm object.
A character string or formula specifying the model to be fitted
A data frame containing the variables in the model
Optional numeric vector of weights. If NULL, unweighted regression is performed
Integer specifying the number of resampling folds (default = 10)
The function splits the data into k subsets, fits a linear model on k-1 subsets, and stores the coefficients. This process is repeated k times, and the final coefficients are averaged across all iterations to provide more stable estimates.