loading

Logout succeed

Logout succeed. See you again!

ebook img

Package 'rFSA' PDF

pages15 Pages
release year2016
file size0.09 MB
languageEnglish

Preview Package 'rFSA'

Package ‘rFSA’ October14,2022 Type Package Title FeasibleSolutionAlgorithmforFindingBestSubsetsand Interactions Version 0.9.6 Date 2020-06-10 Description Assistsinstatisticalmodelbuildingtofindoptimalandsemi-optimalhigherorderinteractions andbestsubsets.Usesthelm(),glm(),andotherRfunctionstofitmodelsgeneratedfromafeasible solutionalgorithm.DiscussedinSubsetSelectioninRegression,AMiller(2002).Ap- pliedandexplained forleastmedianofsquaresinHawkins(1993)<doi:10.1016/0167-9473(93)90246- P>.Thefeasiblesolution algorithmcomesupwithmodelformsofaspecifictypethatcanhavefixedvariables,higherorder interactionsandtheirlowerorderterms. License GPL-2 LazyData TRUE Imports parallel,methods,tibble,rPref,tidyr,hash RoxygenNote 7.1.0 NeedsCompilation no Author JoshuaLambert[aut,cre], LiyuGong[aut], CorrineElliott[aut], SarahJanse[ctb] Maintainer JoshuaLambert<[email protected]> Repository CRAN Date/Publication 2020-06-1020:20:03UTC R topics documented: adj.r.squared . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 apress . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1 2 adj.r.squared bdist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 fitmodels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 fitted.FSA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 FSA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 int.p.val . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 list.criterion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 max_abs_resid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 nextswap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 pFSA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 plot.FSA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 predict.FSA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 print.FSA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 QICu.geeglm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 r.squared . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 rmse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 summary.FSA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 swaps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 twFSA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 which.max.na . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 which.min.na . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Index 18 adj.r.squared AnrFSACriterionFunction. Description rFSACriterionFunctiontocomputeAdjustedR-Squared. Usage adj.r.squared(model, name = "Adj R Squared") Arguments model lmorglmfittobepassed. name passedtoprint.FSA apress 3 apress AnrFSACriterionFunction. Description rFSACriterionFunctiontoAllen’sPressStatistic. Usage apress(model, name = "PRESS") Arguments model lmorglmfittobepassed. name passedtoprint.FSA bdist AnrFSACriterionFunction. Description rFSACriterionFunctiontocomputetheBhattacharyyadistance. Usage bdist(model, name = "B Distance") Arguments model lmorglmfittobepassed. name passedtoprint.FSA Examples #To use Bhattacharyya Distance and FSA the response must be binary, and you must #be considering searching for two way continuous interactions. data(mtcars) fit<-FSA(formula = "am~gear*hp",data = mtcars, fitfunc = glm,family="binomial",m = 2,cores=1, interactions = TRUE,criterion = bdist,minmax = "max") 4 fitted.FSA fitmodels ModelfittingfunctionforFSAsolutions Description ModelfittingfunctionforFSAsolutions Usage fitmodels(object, ...) Arguments object FSAobjecttoconstructmodelson. ... otherparameterspassedtolmorglm. Seehelp(lm)orhelp(glm)forotherpo- tentialarguements. Value listofFSAmodelsthathavebeenfitted. Examples #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,save_solutions=FALSE,cores=1) fitmodels(fit) fitted.FSA FittedValuesforFSAsolutions Description FittedValuesforFSAsolutions Usage ## S3 method for class 'FSA' fitted(object, ...) Arguments object FSAobjecttogetfittedvaluesfrom. ... other parameters passed to fitmodels or fitted function. See help(fitmodels) or help(fitted)forassistance. FSA 5 Value listoffittedvaluesfromeachFSAmodel. Examples #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,save_solutions=FALSE,cores=1) fitted(fit) FSA FSA:FeasibleSolutionAlgorithm Description A function using a Feasible Solution Algorithm to find a set of feasible solutions for a statistical model of a specific form that could include mth-order interactions (Note that these solutions are optimalinthesensethatnooneswaptoanyofthevariableswillincreasethecriterionfunction.) Usage FSA( formula, data, fitfunc = lm, fixvar = NULL, quad = FALSE, m = 2, numrs = 1, cores = 1, interactions = T, criterion = AIC, minmax = "min", checkfeas = NULL, var4int = NULL, min.nonmissing = 1, return.models = FALSE, fix.formula = NULL, ... ) lmFSA(...) glmFSA(...) 6 FSA Arguments formula anobjectofclass"formula"(oronethatcanbecoercedtothatclass):asymbolic descriptionofthemodeltobefitted. data adataframe,listorenvironment(orobjectcoerciblebyas.data.frametoadata frame)containingthevariablesinthemodel. fitfunc themethodthatshouldbeusedtofitthemodel. ForExample: lm,glm,orother methodsthatrelyonformula,data,andotherinputs. fixvar variable(s) to fix in the model. Usually a covariate that should always be in- cluded(Example: Age,Sex). Willstillconsideritwithinteractions. Defaultis NULL. quad Includequadratictermsornot. Logical. m orderoftermstoinclude. IfinteractionsissettoTRUEthenmistheorderof interactionstobeconsidered. ForSubsetselection(interaction=F),misthesize ofthesubsettoexamine. Defaultsto2. numrs numberofrandomstartstoperform. cores numberofcorestousewhilerunning. Note: Windowscanonlyuse1core. See mclapplyfordetails.IffunctiondetectsaWindowsuseritwillautomaticallyset cores=1. interactions whethertoincludeinteractionsinmodel. DefaultstoTRUE. criterion whichcriterionfunctiontoeithermaximizeorminimize. Forlinearmodelsone 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(InteractionP-value),AIC,BIC. minmax whethertominimizeormaximizethecriterionfunction checkfeas vectorofvariablesthatcouldbeafeasiblesolution.Thesevariableswillbeused asthelastrandomstart. var4int specification of which variables to check for marginal feasiblilty. Default is NULL min.nonmissing thecombinationofpredictorswillbeignoredunlessthismanyofobservations arenotmissing return.models bool value to specify whether return all the fitted models which have been checked fix.formula ... ... otherargumentspassedtofitfunc. Value matrixofresults Functions • FSA:findbestsetofvariablesforstatisticalmodels • lmFSA:aliasforFSA(fitfunc=lm,...) • glmFSA:aliasforFSA(fitfunc=glm,...) int.p.val 7 Examples N <- 10 #number of obs P <- 100 #number of variables data <- data.frame(matrix(rnorm(N*(P+1)), nrow = N, ncol = P+1)) sln <- FSA(formula = "X101~1", data = data, cores = 1, m = 2, interactions = FALSE, criterion = AIC, minmax = "min", numrs = 10) sln int.p.val AnrFSACriterionFunction. Description rFSA Criterion Function to compute Liklihood Ratio Test Statistics p-value for the largest order interationterm. Usage int.p.val(model, name = "Interaction P-Value") Arguments model lmorglmfittobepassed. name passedtoprint.FSA list.criterion ListallincludedCriteriafunctionforlmFSAandglmFSA. Description ListallincludedCriteriafunctionforlmFSAandglmFSA. Usage list.criterion() Value listoffunctionsandwhetherlmFSAorglmFSAworkwiththosefunctions. Examples list.criterion() 8 nextswap max_abs_resid Returnmaximumabsoluteresidualfromamodel Description Returnmaximumabsoluteresidualfromamodel Usage max_abs_resid(model) Arguments model modelobj nextswap Variablestoincludeinthe>1ststepofanmthorderinteractionmodel determinedfromtheFeasibleSoutionAlorithm. Description Findstheswapsavailablegivenacurrentpositiongivenpreviouspicks. Usage nextswap(curpos, n, prevpos, quad) Arguments curpos Avectoroflengthgreaterthan2ofwhatcurrentexplantoryvarialbesarebeing usedinthemodel. n Thenumberofexplanatoryvariablesinavailabletoswap. prevpos Avectorofpreviousbestspots quad Whethertoincludequadraticterms. ie(x1*x1)aspotentialswaps. Value amatrixwiththepossibleformsbycolumn. pFSA 9 pFSA pFSA:ParetoFeasibleSolutionAlgorithm Description AfunctionusingaFeasibleSolutionAlgorithmtoestimateasetofmodelswhichareonthePareto frontiersforchosencriteria Usage pFSA( numFronts = 2, pselExpr = NULL, plot.it = TRUE, formula, data, fitfunc = lm, fixvar = NULL, quad = FALSE, m = 2, numrs = 1, cores = 1, interactions = T, criterion = AIC, minmax = "min", checkfeas = NULL, var4int = NULL, min.nonmissing = 1, return.models = FALSE, fix.formula = NULL, ... ) Arguments numFronts integernumberofestimatedfrontierstoreturn pselExpr expressionusedbyfunctionpseltoestimateparetofrontiers. help(psel). plot.it TRUE/FALSEforwhethertoplottheparetofrontiers formula anobjectofclass"formula"(oronethatcanbecoercedtothatclass):asymbolic descriptionofthemodeltobefitted. data adataframe,listorenvironment(orobjectcoerciblebyas.data.frametoadata frame)containingthevariablesinthemodel. fitfunc themethodthatshouldbeusedtofitthemodel. ForExample: lm,glm,orother methodsthatrelyonformula,data,andotherinputs. 10 pFSA fixvar variable(s) to fix in the model. Usually a covariate that should always be in- cluded(Example: Age,Sex). Willstillconsideritwithinteractions. Defaultis NULL. quad Includequadratictermsornot. Logical. m orderoftermstoinclude. IfinteractionsissettoTRUEthenmistheorderof interactionstobeconsidered. ForSubsetselection(interaction=F),misthesize ofthesubsettoexamine. Defaultsto2. numrs numberofrandomstartstoperform. cores numberofcorestousewhilerunning. Note: Windowscanonlyuse1core. See mclapplyfordetails.IffunctiondetectsaWindowsuseritwillautomaticallyset cores=1. interactions whethertoincludeinteractionsinmodel. DefaultstoTRUE. criterion whichcriterionfunctiontoeithermaximizeorminimize. Forlinearmodelsone 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(InteractionP-value),AIC,BIC. minmax whethertominimizeormaximizethecriterionfunction checkfeas vectorofvariablesthatcouldbeafeasiblesolution.Thesevariableswillbeused asthelastrandomstart. var4int specification of which variables to check for marginal feasiblilty. Default is NULL min.nonmissing thecombinationofpredictorswillbeignoredunlessthismanyofobservations arenotmissing return.models bool value to specify whether return all the fitted models which have been checked fix.formula ... ... seeargumentstakenbyfunctionFSAorotherfunctions. help(FSA). Value list of a matrix of all models obtained from FSA (fits) and their criteria. Also a matrix of the estimatedfrontiersthatwererequested. TheKeycolumninfits, andpboundreferstothecolumn number of the variables contined in the model fit. For instance, Key="42,96" would refer to the modelwhichcontainsthevariableinthe42ndcolumnand96thcolumnofthedesignateddataset. Examples N <- 1000 #number of obs P <- 100 #number of variables data <- data.frame(matrix(rnorm(N*(P+1)), nrow = N, ncol = P+1)) sln <- pFSA(formula = "X101~1", data = data, m = 2, criterion = c(max_abs_resid,r.squared), minmax = c("min","max"),numrs = 10,numFronts = 2, pselExpr =rPref::low(max_abs_resid)*rPref::high(r.squared),plot.it = TRUE)

See more

The list of books you might like