I'm looking for a function to do that in R. I know how to write that function. Just don't want to reinvent something.
Solved – term for min + (max – min) / 2
r
Related Solutions
This sounds like just a stacked bar chart. I don't see how you handle the situation when the "contribution" made by a predictor and its coefficient is negative. But you might get something like the not very elegant but workable below. It returns warnings for when it is trying to plot something negative. Perhaps in your case this doesn't happen.
The code uses ggplot2 0.8.9 - I think melt() changes in the latest implementation but I don't have it installed at work:
library(ggplot2)
X1 <- rnorm(100)
X2 <- rnorm(100,5,3)
Y <- 4 + 5*X1 + 3*X2 + rnorm(100)
mod <- lm(Y ~ X1 + X2)
tmp <- data.frame(t(coef(mod) * t(cbind(1, X1, X2))))
names(tmp) <- c("Intercept", "X1", "X2")
qplot(x=as.factor(1:100), fill=variable, weight=value, geom="bar", data=melt(tmp)) +
geom_point(aes(x=1:100, y=predict(mod))
Your treatment
variable represents the interaction between condition
and sp
, so putting treatment
and sp
in the model is redundant. Since the difficulties you're having are with the fixed-effect model, you can diagnose/debug more simply by working with lm()
until you can have a workable model. I would try
fit1 <- lm(cells1~condition*sp,data=suc)
(which is equivalent to a response of ~condition+sp+condition:sp
), check that all the parameters are estimated, and then move on to the mixed model.
Using attach()
is often a bad idea.
I don't know what cont
is.
Your random effect term should probably (?) be 1|Sample/replica
(i.e. replica nested within Sample). You may need to consider a random-slopes model, although it could be too difficult to fit.
Best Answer
min + (max - min) / 2 = (min + max) / 2
It's called the mid-range. I don't know of an existing function in R.