ANOVA in R: Degrees of freedom almost all equal 1 -



ANOVA in R: Degrees of freedom almost all equal 1 -

this honors thesis! advisor doesn't know how utilize r , don't know how utilize else, here am.

i have info set begins this:

> d.weight r n p c d.weight 1 1 0 0 go 45.3 2 2 0 0 go 34.0 3 3 0 0 go 19.1 4 4 0 0 go 26.6 5 5 0 0 go 23.5 6 1 45 0 go 22.1 7 2 45 0 go 15.5 8 3 45 0 go 23.4 9 4 45 0 go 15.8 10 5 45 0 go 42.9 ...

and on.

r rep , there 5 of them (1-5). n nitrogen level, , there 5 (0, 45, 90, 180, 360). p phosphorus level, , there 5 (0, 35, 70, 140, 280). c plant combination, , there 4 (go, gb, lo, lb). d.weight dry weight in grams.

however, when anova wrong degrees of freedom. run anovas on subsets of total set of data, let's analysis wouldn't otherwise, can see of df wrong.

> example.aov=aov(d.weight ~ r+n+p+c, data=d.weight) > summary(example.aov) df sum sq mean sq f value pr(>f) r 1 1158 1158 9.484 0.00226 ** n 1 202 202 1.657 0.19900 p 1 11040 11040 90.408 < 2e-16 *** c 3 41032 13677 112.010 < 2e-16 *** residuals 313 38220 122

so, basically, 1 that's right c factor. because has letters instead of numbers?

i found somewhere if write interaction() each term, right df, don't know if that's right thing overall. example:

> example.aov2=aov(d.weight ~ interaction(r)+interaction(n)+interaction(p)+interaction(c), data=d.weight) > summary(example.aov2) df sum sq mean sq f value pr(>f) interaction(r) 4 7423 1856 19.544 2.51e-14 *** interaction(n) 4 543 136 1.429 0.224 interaction(p) 4 13788 3447 36.301 < 2e-16 *** interaction(c) 3 41032 13677 144.042 < 2e-16 *** residuals 304 28866 95

i tried c factor see if messed anything:

> example.aov3=aov(d.weight ~ c, data=d.weight) > summary(example.aov3) df sum sq mean sq f value pr(>f) c 3 41032 13677 85.38 <2e-16 *** residuals 316 50620 160 > > example.aov4=aov(d.weight ~ interaction(c), data=d.weight) > summary(example.aov4) df sum sq mean sq f value pr(>f) interaction(c) 3 41032 13677 85.38 <2e-16 *** residuals 316 50620 160

and looks same. should adding interaction() everywhere?

thanks help!

r determines whether should treat variables categorical (anova-type analysis) or continuous (regression-type analysis) checking whether numeric or factor variables. simply, can convert predictor (independent) variables factors via

facs <- c("r","n","p") d_weight[facs] <- lapply(d.weight[facs],factor)

if want create auxiliary variables instead of overwriting like

for (varname in facs) { d_weight[[paste0("f",varname)]] <- factor(d_weight[[varname]]) }

there might more compact way should serve ...

r anova

Comments

Popular posts from this blog

c# - ASP.NET MVC Sequence contains no matching element -

java - Parsing XML, skip certain tags -

rest - How to invalidate user session on inactivity in a stateless server? -