I would like estimate Best Linear Unbiased Estimates. I have data like this.
set.seed(1234)
data1 <- data.frame (entry=rep(1:20, 3), repl = rep(1:3, each=20),
yld = rnorm(60)+50)
require(nlme)
data1$entry <- as.factor (data1$entry)
data1$repl <- as.factor (data1$repl)
# with intercept
fm1 <- lme(yld ~ entry, random = ~ 1|repl, data=data1 )
fixed.effects(fm1)
(Intercept) entry2 entry3 entry4 entry5 entry6 entry7 entry8 entry9 entry10
50.12550625 -0.55280604 -0.19599669 -0.84775000 -0.54515146 -0.76239402 -0.49460706 -1.06626407 -0.49331238 -0.89978504
entry11 entry12 entry13 entry14 entry15 entry16 entry17 entry18 entry19 entry20
-0.51914838 -0.81085806 -0.99036743 -0.60942666 -0.40280922 -0.36378922 -0.47325014 -1.13402026 0.03264178 0.13853678
You can see I did not get fixed effect of first level of the variable. If I remove the intercept term it gives me fixed effect for first level of the entry variable.
# without intercept
fm2 <- lme(yld ~ -1 + entry, random = ~ 1|repl, data=data1 )
fixed.effects(fm2)
entry1 entry2 entry3 entry4 entry5 entry6 entry7 entry8 entry9 entry10 entry11 entry12 entry13
50.12551 49.57270 49.92951 49.27776 49.58035 49.36311 49.63090 49.05924 49.63219 49.22572 49.60636 49.31465 49.13514
entry14 entry15 entry16 entry17 entry18 entry19 entry20
49.51608 49.72270 49.76172 49.65226 48.99149 50.15815 50.26404
But I do not think my case is intercept is 0 case. So I want to fit the first model with intercept still get the fixed effects. Am I missing something little?
lsmeans
. $\endgroup$lsmeans()
function in thelsmeans
package. I will add this to my answer. $\endgroup$