# lmFSA: rFSA: Feasible Solution Algorithm (FSA) for Linear Models In jmsuk0587/rFSA: Feasible Solution Algorithm for Finding Best Subsets and Interactions

## Description

A function using a Feasible Solution Algorithm to find a set of feasible solutions for a linear model of a specific form that could include mth-order interactions (Note that these solutions are optimal in the sense that no one swap to any of the variables will increase the criterion function.)

## Usage

 ```1 2 3``` ```lmFSA(formula, data, fixvar = NULL, quad = FALSE, m = 2, numrs = 1, cores = 1, interactions = TRUE, criterion = r.squared, minmax = "max", checkfeas = NULL, ...) ```

## Arguments

 `formula` an object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted. See help(lm) for details. `data` a data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model. `fixvar` a variable to fix in the model. Usually a covariate that should always be included (Example: Age, Sex). Will still consider it with interactions. Default is NULL. `quad` to include quadratic terms or not. `m` order of terms to potentially include. If interactions is set to TRUE then m is the order of interactions to be considered. Defaults to 2. For Subset selection (interaction=F), m is the size of the subset to examine. Default is 2. `numrs` number of random starts to perform. `cores` number of cores to use while running. Note: Windows can only use 1 core. See mclapply for details. If function detects a Windows user it will automatically set cores=1. `interactions` T or F for whether to include interactions in model. Defaults to FALSE. `criterion` which criterion function to either maximize or minimize. For linear models one can use: r.squared, adj.r.squared, cv5.lmFSA (5 Fold Cross Validation error), cv10.lmFSA (10 Fold Cross Validation error), apress (Allen's Press Statistic), int.p.val (Interaction P-value), AIC, BIC. `minmax` whether to minimize or maximize the criterion function `checkfeas` A vector of a potential feasible solution `...` arguments to be passed to the lm function

## Details

PLEASE NOTE: make sure categorical variables are factors or characters otherwise answers will not reflect the variable being treated as a continuous variable.

## Value

returns a list of solutions and table of unique solutions. \$solutions is a matrix of fixed terms, start position, feasible solution, criterion function value (p-value of interaction), and number of swaps to solution. \$table is a matrix of the unique feasible solutions and how many times they occured out of the number of random starts chosen. It also returns any warning messages with these solutions in the last column. \$efficiency is text comparing how many models you ran during your FSA search compared to how many you would have done with exhaustive search. Note: The FSA algorithm takes additional time to run on top of the model checks that were done during the algorithm. This additional time is approximately 15

## Examples

 ```1 2 3 4 5 6 7``` ```#use mtcars package see help(mtcars) data(mtcars) colnames(mtcars) fit<-lmFSA(formula="mpg~hp+wt",data=mtcars,fixvar="hp", quad=FALSE,m=2,numrs=10,cores=1) print(fit) #print formulas of fitted models summary(fit) #review ```

jmsuk0587/rFSA documentation built on July 7, 2017, 2:23 a.m.