线性模型R的估计变化
我正在使用线性模型R的估计变化,r,statistics,mixed-models,R,Statistics,Mixed Models,我正在使用nlme软件包,用线性混合模型对我的论文进行统计分析。现在我处理了几个方向(西、东、北),R将估算值作为按字母顺序排列的第一个值。但是,我希望估算值是最低值。有人知道怎么做吗?像@BenBolker,我想我知道你在想什么 首先,模拟一些玩具数据 site <- rep(1:3, each=6) orientation <- rep(c("west","east","north"), 6) x <- rnorm(18) x[orientation=="north"] &
nlme
软件包,用线性混合模型对我的论文进行统计分析。现在我处理了几个方向(西、东、北),R将估算值作为按字母顺序排列的第一个值。但是,我希望估算值是最低值。有人知道怎么做吗?像@BenBolker,我想我知道你在想什么
首先,模拟一些玩具数据
site <- rep(1:3, each=6)
orientation <- rep(c("west","east","north"), 6)
x <- rnorm(18)
x[orientation=="north"] <- x[orientation=="north"] + 1
x[orientation=="east"] <- x[orientation=="east"] + 2
df <- data.frame(site, orientation, x)
df
# site orientation x
# 1 1 west 0.9554461
# 2 1 east 4.1742621
# 3 1 north 0.8901404
# 4 1 west -0.5998719
# 5 1 east 1.8279064
# 6 1 north 1.0984336
# 7 2 west 1.1020786
# 8 2 east 2.7994980
# 9 2 north 0.9158762
# 10 2 west 1.2512472
# 11 2 east 0.1200988
# 12 2 north 1.3584406
# 13 3 west 0.6602157
# 14 3 east 0.6226468
# 15 3 north 0.9409308
# 16 3 west -1.8992221
# 17 3 east 2.0386123
# 18 3 north 2.3562818
。。。您希望将west
作为参考标高,而不是east
,因为它的效果最低
一个可能的解决方案是:使用方向变量的因子版本,按照您希望的顺序设置级别
df$orientation1 <- factor(df$orientation, levels=c("west","north","east"))
summary(lme(x~orientation1, random=~1|site, data=df))
# ... again just looking at fixed effects ...
# Value Std.Error DF t-value p-value
# (Intercept) 0.2449823 0.4729373 13 0.5180016 0.6132
# orientation1north 1.0150350 0.6688344 13 1.5176178 0.1530
# orientation1east 1.6855218 0.6688344 13 2.5200884 0.0256
df$orientation1欢迎来到SO。请阅读如何提出一个好问题****所说的“最低值”是指响应变量的期望值最低的方向吗?我有一个想法,知道如何做我认为你想要做的事情,但你应该首先澄清你的问题,请。。。
df$orientation1 <- factor(df$orientation, levels=c("west","north","east"))
summary(lme(x~orientation1, random=~1|site, data=df))
# ... again just looking at fixed effects ...
# Value Std.Error DF t-value p-value
# (Intercept) 0.2449823 0.4729373 13 0.5180016 0.6132
# orientation1north 1.0150350 0.6688344 13 1.5176178 0.1530
# orientation1east 1.6855218 0.6688344 13 2.5200884 0.0256