I'm trying to plot the Worm plot residuals on a model fitted using the gamlss
function from the gamlss
package. The interest graph looks like the one below:
首先,下面是参考使用的计算例程wormplot_gg
函数从childsds
然而,使用上述函数表达的结果与上面所示的示例不同,该示例应用于 R 中包含的数据集。
library(ggplot2)
library(gamlss)
library(childsds)
head(Orange)
Dados <- Orange
Model <- gamlss(circumference~age, family=NO,data=Dados); Model
wp(Model)
wormplot_gg(m = Model)
以下是通过wp
函数在gamlss
包裹。
最后,我们通过以下方法获得了结果wormplot_gg
函数从childsds
包裹。然而,正如已经描述的那样,这个并没有以我感兴趣的方式呈现,即第一个图形的视觉结构。
使用 qqplotrhttps://aloy.github.io/qqplotr/index.html https://aloy.github.io/qqplotr/index.html与detrend=True
option
library(qqplotr)
set.seed(1)
df <- data.frame(z=rnorm(50))
ggplot(df, aes(sample=z)) +
stat_qq_point(detrend = T) +
stat_qq_band(detrend = T, color='black', fill=NA, size=0.5)
你还可以添加geom_hline(yintercept = 0)
edit:在将其与 gamlss 模型一起使用的情况下,首先必须从模型中提取随机残差,对于 gamlss 来说,只需使用以下函数即可完成residuals
,所以你可以这样做,例如df <- data.frame(z=residuals(Model))
然后继续其余的代码
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)