我正在使用混合效果模型,并且由于我的方法的细节
我需要求解下面模型的积分,然后进行图形
获得的估计值。
换句话说,我需要解决以下积分:

其中, di^2
是 var3
在我的模型中, dh
是与混合效果相对应的功能模型。
在有关我插入的问题的文献中,几乎没有作品
为此目的的混合效应模型,绝大多数仅与回归模型一起工作
简单线性。但是,就我的问题而言,有必要使用混合模型。
该模型由:
考虑变量 var2
,在截距中引入了随机效果。
仅考虑模型的固定部分,即是固定效应模型,我执行的解决积分的过程如下:
data: https://drive.google.com/file.com/file.com/file/d/1hfb1hfb1hfb1hfb1opo链接
,但是,我找不到具有可能与我的问题相匹配的变量的内部R数据库。
fitmixedmodel <- lme(log(Var1)~I(exp(Var3/Var4))+
(I((Var5/Var4)^3)),
random = ~1|Var2,
dados, method="REML")
summary(fitmixedmodel)
volume <- dados[dados$Var5 == 0.1,]
fmixedmodel <- function(Var3, Var5, Var4){
(pi/40000)*(Var3^2)*(coefficients(summary(fitmixedmodel))[1] +
coefficients(summary(fitmixedmodel))[2]*I(exp(Var3/Var4)) +
coefficients(summary(fitmixedmodel))[3]*(I((Var5/Var4)^3)))
}
vmixedmodel <- function(Var3, Var5, Var4){
integrate(Vectorize(fmixedmodel), lower = 0.1, upper = Var4, Var3 = Var3, Var4 = Var4)$value
}
mixed.vol <- mapply(FUN = vmixedmodel,
Var5 = as.list(volume$Var5),
Var3 = as.list(volume$Var3),
Var4 = as.list(volume$Var4))
因此,我得到以下图。
但是,请注意,在计算此积分时,我绝不会声明随机效果,也就是说,我仅从固定零件中集成了该功能,并且也不考虑随机部分。我该如何解决这个问题,也就是说,实际上整合了调整后的混合模型方程式?
I am working with mixed effects models and due to the specifics of my methodology
I need to solve the integral of the model below and later make a graph
of the estimates obtained.
In other words, I need to solve the integral below:

where, di^2
is Var3
in my model and dh
is the function that corresponds to the mixed effects model.
In the literature on the problem in which I am inserted, there are few works that have used
of mixed effects models for this purpose, the vast majority work only with regression models
simple linear. However, for my problem it is necessary to use mixed models.
The model is defined by:

where the random effect bi
was introduced in the intercept considering the variable Var2
.
Considering only the fixed part of the model, that is, a fixed effects model, the procedure I performed to solve the integral was as follows:
Data: https://drive.google.com/file/d/1hFb1OPO0jxQw7_u62swnkRXbOH81ygDD/view?usp=sharing
I apologize for hosting the data in a link, however, I couldn't find an internal R database that has variables that might match my problem.
fitmixedmodel <- lme(log(Var1)~I(exp(Var3/Var4))+
(I((Var5/Var4)^3)),
random = ~1|Var2,
dados, method="REML")
summary(fitmixedmodel)
volume <- dados[dados$Var5 == 0.1,]
fmixedmodel <- function(Var3, Var5, Var4){
(pi/40000)*(Var3^2)*(coefficients(summary(fitmixedmodel))[1] +
coefficients(summary(fitmixedmodel))[2]*I(exp(Var3/Var4)) +
coefficients(summary(fitmixedmodel))[3]*(I((Var5/Var4)^3)))
}
vmixedmodel <- function(Var3, Var5, Var4){
integrate(Vectorize(fmixedmodel), lower = 0.1, upper = Var4, Var3 = Var3, Var4 = Var4)$value
}
mixed.vol <- mapply(FUN = vmixedmodel,
Var5 = as.list(volume$Var5),
Var3 = as.list(volume$Var3),
Var4 = as.list(volume$Var4))
And so I get the following graph.

However, notice that in the calculation of this integral at no point do I declare the random effect, that is, I am integrating the function only from the fixed part and not taking into account the random part either. How could I solve this problem, that is, actually integrate the adjusted mixed model equation?
发布评论
评论(1)
我将您的数据集下载为Data.csv。我必须进行一些格式以使其在本地机器上工作:
我重写了一些代码,以便我可以复制您的图形 -
这是您的代码,并具有一些较小的格式更改:
因此,此时我能够复制您的图形。
我最初认为有两个选择随机拦截。一种是“整合它们”,这将涉及随机截距的方差和双重积分。但是事实证明,对于线性回归,这种边缘化不会改变结果。为了向我们证明这一点,请查看以下代码,这些代码遇到了拟合双重积分以集成遵循正常(0,0,0.1691067^2)分布的随机拦截
b
。因为相对于b
的积分本身可以隔离b
,而e [b] = 0,因此此方法与OP方法没有实质性不同。第二种方法是插入估计的随机拦截值,就像
var4
和var3
中的OP方法插入值一样。要追求这一途径,我们首先创建volume_ri
,它与卷
数据集相同,但具有b的估计值:然后我们基本上我们可以使用OP代码来适应此信息
b
在适当的情况下作为参数或价值:以下是旧问题,在评论中回答
旧问题:
我的关注/混乱是我评论的行,您的意思是
var5 = var5 = var5
- 您是否介意仔细检查一下。并给我回答的评论吗?另外,关于考虑随机截距的另一个问题:
您是否要在所有随机拦截值
或
上集成,您是否想插入混合模型拟合中每个唯一的VAR2的随机截距估计?
I downloaded your dataset as Data.csv. I had to do some formatting to get it to work on my local machine:
I rewrote the code a little bit so I could reproduce your graphic --
Here's your code with some minor formatting changes:
So at this point I was able to reproduce your graphic.
I initially thought there were two options for incorporating random intercepts. One is to "integrate them out" which would involve the variance of the random intercepts and a double integral. But it turns out for linear regression this type of marginalization doesn't change the outcome. To prove this to ourselves, look at the following code that goes through the trouble of fitting a double integral to integrate out the random intercept
b
that follows a Normal(0, 0.1691067^2) distribution. Because the integral with respect tob
can just isolateb
by itself and the E[b] = 0, this approach is not materially different than the OP approach.The second approach is plugging in the estimated random intercept value, much like how the OP approach plugs in values for
Var4
andVar3
. To pursue this avenue, we first createvolume_ri
which is the same as thevolume
dataset but has the estimate values of b:And then basically we adust the OP code to accommodate this
b
as an argument or value where appropriate:Below are old questions that are answered in comments
Old questions:
My concern/confusion is the line where I comment DID YOU MEAN
Var5 = Var5
-- would you mind double checking that. and leaving me a comment with the answer?Also, a separate question regarding accounting for the random intercept:
do you want to integrate over all random intercept values
or
do you want to plug in the random intercept estimate for each unique Var2 from the mixed model fit?