[R] interacting variables in a formulae in R

Ista Zahn istazahn at gmail.com
Thu Jul 16 15:47:14 CEST 2009


Hi Peter,

> --------- Forwarded message ----------
> From: Peter Schmidtke <pschmidtke at mmb.pcb.ub.es>
> To: r-help at r-project.org
> Date: Wed, 15 Jul 2009 12:27:17 +0200
> Subject: [R] interacting variables in a formulae in R
> Dear R Mailing Subscribers,
>
> I just have a question of how R handles interacting variables in model
> creation using glm for instance.
>
> if I write :
>
> >>
> model=glm(solution~descriptor1+descriptor2+descriptor3,family=binomial(link="logit"))
>
> I should end up with coefficients for a logistic model that I can introduce
> easily in the mathematical form of such a model (weighted sum of these
> descriptors).
>
> But how do I have to interpret what R does with interacting terms, like
> this? :
>
> >>
> model=glm(solution~descriptor1:descriptor2+descriptor3,family=binomial(link="logit"))
>
> What does R with the numerical values of descriptor1 and 2 in order to fit
> the data? How I can rewrite the model in a mathematical form?
>

Take a look at

?contrasts

and

?model.matrix

At least I think that's what you're after...

-Ista
> Thanks in advance.
>
> Best regards.
> --
>
> Peter Schmidtke
>
> ----------------------
> PhD Student at the Molecular Modeling and Bioinformatics Group
> Dep. Physical Chemistry
> Faculty of Pharmacy
> University of Barcelona




More information about the R-help mailing list