如何使用 R 中的 nlmer 函数拟合具有随机效应的 Michaelis-Menten 模型?

问题描述 投票:0回答:1

我们希望将 Michaelis-Menten 函数拟合到数据集,其中“CTIR”是响应变量(对应于饲喂率),“FL”是自变量(对应于食物水平),“Tank”是随机变量具有两个级别 1 和 2 的效果。到目前为止,我们的代码改编自 (https://stats.stackexchange.com/questions/101154/how-to-fit-a-michaelis-menten-function-with-使用 nlme-packa 的随机效果))。

该模型应该允许我们获得斜率和截距的 p 值,以及 R2 和 AIC 值。模型的数据可以在这里找到:https://dalu-my.sharepoint.com/:x:/g/personal/ek717816_dal_ca/EaDPOacdHvdOhAU-lOjNuQUByIgWKepuYBkd2WthxPXc7g?e=9JyWkQ

# Load required library
library(lme4)

#Load data
tirsfl <- read.csv("TIR.FL.csv", header=TRUE, sep=",") 
names(tirsfl)

#Michaelis-Menten model (TIR vs. FL)
michaelis_menten_model <- function(FL, maxTIR, FoodK) #Write the MM function
  {maxTIR * (FL / (FL + FoodK))}

# Fit the model using nlmer
fit <- nlmer(TIR ~ michaelis_menten_model(FL, maxTIR, FoodK) + (1 | Tank), #Fit the model
             data = tirsfl,
             start = c(maxTIR = max(tirsfl$TIR), FoodK = median(tirsfl$FL)))
summary(fit)

运行 nlmer 后,我们收到以下错误代码:

eval(form[[2]]) 中的错误:未找到对象“TIR”

如何修复?

r lme4
1个回答
0
投票

我在这里尝试了一些东西,这有效吗

fit <- nls(TIR ~ Vm*FL / (K+FL), data = tirsfl, start = list(Vm = max(tirsfl$TIR), K = median(tirsfl$FL)))
summary(fit)

Formula: TIR ~ Vm * FL/(K + FL)

Parameters:
    Estimate Std. Error t value Pr(>|t|)    
Vm 1.289e+00  8.573e-02  15.039   <2e-16 ***
K  2.499e+03  1.489e+03   1.678   0.0984 .  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.3852 on 61 degrees of freedom

Number of iterations to convergence: 6 
Achieved convergence tolerance: 5.304e-06
© www.soinside.com 2019 - 2024. All rights reserved.