Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
利用R中的glm函数对我的数据应用对数正态分布_R_Modeling_Glm_Lme4 - Fatal编程技术网

利用R中的glm函数对我的数据应用对数正态分布

利用R中的glm函数对我的数据应用对数正态分布,r,modeling,glm,lme4,R,Modeling,Glm,Lme4,我想在我的数据上实现一个具有特定分布类型的混合效应模型。下面是一个名为“a”的数据示例: 首先,我看到什么分布最适合我的数据: # gamma distribution fit_g <- fitdist(magnitudedata$FirstSteeringTime, "gamma") # log normal distribution - can only be used on positive values (any zeros and it will fail) fit_ln

我想在我的数据上实现一个具有特定分布类型的混合效应模型。下面是一个名为“a”的数据示例:

首先,我看到什么分布最适合我的数据:


# gamma distribution
fit_g  <- fitdist(magnitudedata$FirstSteeringTime, "gamma")

# log normal distribution - can only be used on positive values (any zeros and it will fail)
fit_ln <- fitdist(magnitudedata$FirstSteeringTime, "lnorm")

# weibull distribution
fit_w <- fitdist(magnitudedata$FirstSteeringTime, "weibull")

par(mfrow=c(2,2))
plot.legend <- c("Weibull", "gamma", "lognormal")
denscomp(list(fit_w, fit_g, fit_ln), legendtext = plot.legend)
cdfcomp (list(fit_w, fit_g, fit_ln), legendtext = plot.legend)
qqcomp  (list(fit_w, fit_g, fit_ln), legendtext = plot.legend)
ppcomp  (list(fit_w, fit_g, fit_ln), legendtext = plot.legend)


#伽马分布

可能重复:@MrFlick谢谢你!

# gamma distribution
fit_g  <- fitdist(magnitudedata$FirstSteeringTime, "gamma")

# log normal distribution - can only be used on positive values (any zeros and it will fail)
fit_ln <- fitdist(magnitudedata$FirstSteeringTime, "lnorm")

# weibull distribution
fit_w <- fitdist(magnitudedata$FirstSteeringTime, "weibull")

par(mfrow=c(2,2))
plot.legend <- c("Weibull", "gamma", "lognormal")
denscomp(list(fit_w, fit_g, fit_ln), legendtext = plot.legend)
cdfcomp (list(fit_w, fit_g, fit_ln), legendtext = plot.legend)
qqcomp  (list(fit_w, fit_g, fit_ln), legendtext = plot.legend)
ppcomp  (list(fit_w, fit_g, fit_ln), legendtext = plot.legend)


# model 3 - applying gamma distribution
m3 <- glmer(FirstSteeringTime ~ error_rate + (1 + error_rate | pNum), family = Gamma, data = a)