R - Passing All Variables from [] to [] to a Model Without "~. -X" -
i'm training predictive model (glm - logistic), , want include not of dataframe variables in model. have code looks this:
logmodel = glm(y ~ . -x1 -x2 -x3, data=train, family=binomial) modelprediction <- predict(logmodel, type="response", newdata=test) but getting "factor has new levels" errors - x1-x3 had excluded model. user explained in comment below using [y ~ . -x1]exposes me errors x1, because model expanded y ~ [includedvars + x1] - x1. , apparently, string variables converted factors glm(...type="response"), string variable in general throw "factor has new levels" error. suggestion @ link remove variables train/test datasets entirely. works seems clunky , unideal. "factor has new levels" error variable i'm not using
in sas can select
"all variables between somevar , someothervar in dataset"
with code myvar1 -- someothervar. exist in r? if i've been unable find it. if [y~. -x] exposes errors when running models, i've got think there's cleaner way.
Comments
Post a Comment