>我有以下数据,我想比较第 28 天和第 83 天之间value
变量的平均值:
library(lme4)
#> Loading required package: Matrix
library(lmerTest)
#>
#> Attaching package: 'lmerTest'
#> The following object is masked from 'package:lme4':
#>
#> lmer
#> The following object is masked from 'package:stats':
#>
#> step
df <- structure(list(experience_sep = c(
"DM", "DA", "DM", "DA", "DM",
"DA"
), day = c(55, 110, 55, 110, 55, 110), day_factor = c(
55,
110, 55, 110, 55, 110
), day_julian = c(
55, 110, 55, 110, 55,
110
), day_true = c(28, 83, 28, 83, 28, 83), culture = c(
1L, 1L,
2L, 2L, 3L, 3L
), value = c(
758453.333333333, 575133.333333333,
684160, 656933.333333333, 816840, 734700
)), row.names = c(
NA,
-6L
), class = c("data.frame"))
df
#> experience_sep day day_factor day_julian day_true culture value
#> 1 DM 55 55 55 28 1 758453.3
#> 2 DA 110 110 110 83 1 575133.3
#> 3 DM 55 55 55 28 2 684160.0
#> 4 DA 110 110 110 83 2 656933.3
#> 5 DM 55 55 55 28 3 816840.0
#> 6 DA 110 110 110 83 3 734700.0
因为经验涉及伪复制(culture
(,我正在考虑使用混合模型,如下所示:
lmerTest::lmer(value ~ factor(day_true) + (1|culture), data = df)
#> Warning in as_lmerModLT(model, devfun): Model may not have converged with 1
#> eigenvalue close to zero: 2.6e-09
#> Linear mixed model fit by REML ['lmerModLmerTest']
#> Formula: value ~ factor(day_true) + (1 | culture)
#> Data: df
#> REML criterion at convergence: 102.7974
#> Random effects:
#> Groups Name Std.Dev.
#> culture (Intercept) 47535
#> Residual 55990
#> Number of obs: 6, groups: culture, 3
#> Fixed Effects:
#> (Intercept) factor(day_true)83
#> 753151 -97562
但是,我收到此错误,我找不到问题。是因为我的积分很少(每组 n = 3(吗?
创建于 2019-02-05 由 reprex 软件包 (v0.2.1(
我知道
我参加这个派对有点晚了,但我在标准化响应变量(值(后运行了这个模型,它工作得很好。当模型中的变量比其他变量大几个数量级时,可能会导致数值问题。这是代码。
df$value.st<-(df$value-mean(df$value))/(sd(df$value))
mod<-lmer(value.st ~ factor(day_true) + (1|culture), data=df)
mod
Linear mixed model fit by REML ['lmerMod']
Formula: value.st ~ factor(day_true) + (1 | culture)
Data: df
REML criterion at convergence: 12.0241
Random effects:
Groups Name Std.Dev.
culture (Intercept) 0.5613
Residual 0.6612
Number of obs: 6, groups: culture, 3
Fixed Effects:
(Intercept) factor(day_true)83
0.5761 -1.1521
祝你好运!