0
我是一些代謝縮放模型的參數化指數擬合。我已經在lmer中完成了這個工作,沒有問題,使用了記錄的依賴變量和獨立變量。但是,我現在想要包含與因變量不一定成指數關係的其他參數。因此,我轉向nlme(lme4 :: nlmer似乎不處理固定效果),但我沒有太多的經驗。提前道歉爲新手的錯誤。nlme中的因素:backsolve錯誤中的奇異點
隨着下面的代碼,我收到以下錯誤。我猜,這事做的「現場」的因素被錯誤識別:
Error in nlme.formula(dep ~ scaling_fun(alpha, beta, ind, site), data = scale_df, :
Singularity in backsolve at level 0, block 1
當我適合不涉及「網站」一個簡單的功能,該模型似乎正常工作。
任何想法將不勝感激!
感謝, 艾莉
# dput for data
# copy from http://pastebin.com/WNHhi2kZ (too large to include here)
> head(scale_df)
dep ind spp site
2 0.28069471 -0.0322841 157 A
3 -0.69719050 -1.2568901 183 A
4 0.29252012 0.1592420 246 A
5 0.72030740 -0.3282789 154 A
6 -0.08601891 0.3623756 110 A
7 0.30793594 0.2230840 154 A
scaling_fun <- function(alpha, beta, ind, site) {
return(beta + ind^alpha + site*(ind^alpha))
}
# results in singularity in backsolve error
nlme(dep ~ trait_scaling_fun(alpha, beta, ind, site),
data = scale_df,
fixed = list(alpha + beta + site ~ 1), random = alpha ~ 1|spp,
start = list(fixed = c(0.7, 0, 1)))
##############################
# simpler function converges #
##############################
scaling_fun <- function(alpha, beta, ind) {
return(beta + ind^alpha)
}
nlme(dep ~ scaling_fun(alpha, beta, ind),
data = scale_df,
fixed = list(alpha + beta ~ 1), random = alpha ~ 1|spp,
start = list(fixed = c(0.7, 0)))
謝謝羅蘭 - 這很有道理。我對以下數學公式感興趣: D =(β_1+β_site+β_spp)•I ^(α_1+α_site+α_spp), 其中β_1是大平均β項,β_site是每站點偏差從這意味着,並且β_spp是一個隨機項(對於α是相同的)。爲此,我編碼網站的偏差(總和爲零)對比[例如對比(site)= contr.sum(levels(site))]。使用您的scaling_fun,我運行nlme: fixed = list(alpha + beta_site),random = alpha + beta〜1 | spp。 然後,我將α(截距)解釋爲α_1和β(截距)作爲β_1。你同意嗎? –
順便說一句,我其實對每站點偏差的價值感興趣,因此,我將它們編碼爲固定效果。 –
你知道你也可以提取隨機效應,而不僅僅是固定係數? – Roland