[R] create loops in the explanatory variables using lm
david.emmerth at ieu.uzh.ch
Thu Sep 29 14:11:37 CEST 2011
thanks for the answer
I guess I was a bit unclear about the nature of my data
the species terms are columns in the data frame, and they are coded 0/1, depending whether the species is present in a plot or not.
No I want to repeatedly fit the linear model with all the species presence absence term in a hierarchical model, so that every species is in the first place, after the richness term once. I hope this is possible with data like this.
thanks a lot
Am 29.09.2011 um 11:57 schrieb Petr PIKAL:
> Well, are those names (Acer_davidii, ...) columns in data frame? If not
> and you want them as factors of species you shall reformat your input so
> as you get data frame with columns mortality, richness, species,
> community. Column species shall have your plant species names in each
> respective row.
> Your lm call shall be
> lm(sqrt(mortality)~richness+species+community, data=your.data.frame)
> see then
> ?relevel for setting reference level of your factor.
>> Hi everyone
>> I am new to the list and read all the instructions, hope i get it right.
>> I have the following linear model:
>> Where everything from Acer_davidii to Schima_superba are plant species.
>> Since the order of the plant species matters in my case, I want to
>> repeatedly fit the model so that every species is in the first place,
>> is after the richness term, once.
>> I am looking for a way so that I don't have to do this by hand. I
>> checked combn with as.formula and paste, but I couldn't get it right.
>> I'd be very grateful for any help.
>> [[alternative HTML version deleted]]
>> R-help at r-project.org mailing list
>> PLEASE do read the posting guide
>> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help