Displaying 2 results from an estimated 2 matches for "termmean".
Did you mean:
termmeans
2009 Apr 16
0
manipulating data via the factors of a term in a lm()
...ct, given the *name* of a term, which will
always be
a character string representing
a factor ("A") or an interaction of two or more factors ("A:B", "A:B:C",
...). I'd
prefer not to have to require() additional packages if possible. The
functions I need
are
[1] termMeans(mod, term): Find the (possibly vector) response means for
a model term, specified by a string, "A", "A:B", ...
[2] dataIndices(mod, term): Find indices of the observations in the data
corresponding to the combination of levels in the term
Here is a small example to illustrat...
2007 Aug 28
0
help with aggregate(): tables of means for terms in an mlm
....0 4.798 8.100 0.2475 9.8575
11.970
Top:60-90 3.893 0.05775 1.4300 97.0 5.268 8.928 0.4250 9.2900
11.030
>
Here is the current version of a function that doesn't work, because I
can't supply the factor names to aggregate in the proper way.
Can someone help me make it work?
termMeans.mlm <- function( object, term ) {
resp<- model.response(model.frame(object))
terms <- term.names(soils.mod)
terms <- terms[terms != "(Intercept)"]
factors <- strsplit(term, ":")
# browser()
means <- aggregate(resp, factors, mean)
#...