[R] Glmnet Logistic Variable Questions
Ben Bolker
bbolker at gmail.com
Tue Oct 25 18:16:12 CEST 2011
Bert Gunter <gunter.berton <at> gene.com> writes:
>
> If I understand you correctly, it sounds like you need to do some reading.
>
> ?lm and ?formula tell you how to specify linear models for glm or glmnet.
> However, if you do not have sufficient statistical background, It probably
> will be incomprehensible, in which case you should consult your local
> statistician.
>
> For glmnet, go to the linked references given in the Help file.There is no
> such thing as AIC for these models, as they are penalized fits (with users
> choosing the penalization tradeoff). Again, consult your local statistician
Let me second Bert's concern, but in the meantime, if what you
want are *all two-way interactions among variables, you can follow
this example:
> d <- data.frame(y=runif(100),x1=runif(100),x2=runif(100),x3=runif(100))
> gg <- lm(y~(.)^2,data=d)
> names(coef(gg))
[1] "(Intercept)" "x1" "x2" "x3" "x1:x2"
[6] "x1:x3" "x2:x3"
I have done the example with continuous variables and with lm() here,
but it should generalize easily to (1) a mixture of categorical and
continuous variables and (2) other R modeling functions
More information about the R-help
mailing list