R/ZIBP_Geoffroy.R
, R/marZIBP_Geoffroy.R
summary.marZIBPGeoffroy.Rd
This function obtains the summary table for objects of class marZIBPGeoffroy.
Returns the summary table.
# Example 1 ---------------------------------------------------------------
l1 <- 3
l2 <- 4
l0 <- 1.5
psi <- 0.20
set.seed(12345678)
data1 <- rZIBP_Geoffroy(n=500, l1=l1, l2=l2, l0=l0, psi=psi)
data1 <- as.data.frame(data1)
# To fit the model
mod1 <- NULL
mod1 <- marZIBP_Geoffroy(mu1.fo=X1~1,
mu2.fo=X2~1,
psi.fo=~1,
data=data1)
# To obtain the usual summary table
summary(mod1)
#> ---------------------------------------------------------------
#> Fixed effects for log(mu1)
#> ---------------------------------------------------------------
#> Estimate Std. Error z value Pr(>|z|)
#> (Intercept) 1.326544 0.031135 42.606 < 2.2e-16 ***
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> ---------------------------------------------------------------
#> Fixed effects for log(mu2)
#> ---------------------------------------------------------------
#> Estimate Std. Error z value Pr(>|z|)
#> (Intercept) 1.502743 0.029727 50.552 < 2.2e-16 ***
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> ---------------------------------------------------------------
#> Fixed effects for logit(psi)
#> ---------------------------------------------------------------
#> Estimate Std. Error z value Pr(>|z|)
#> (Intercept) -1.51725 0.11649 -13.025 < 2.2e-16 ***
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> ---------------------------------------------------------------
#> Estimation for l0
#> ---------------------------------------------------------------
#> Estimate Std. Error z value Pr(>|z|)
#> (Intercept) 1.35003 0.23462 5.7542 8.706e-09 ***
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> ---------------------------------------------------------------
# To explore the estimations of l1, l2, mu and p
# To obtain E(Y1)=v1 and E(Y2)=v2
mod1$fitted.mu1[1]
#> [1] 3.768
mod1$fitted.mu2[1]
#> [1] 4.494
# To compare sample means with v1 and v2
colMeans(data1)
#> X1 X2
#> 3.768 4.494
# To obtain l0 and psi
mod1$fitted.l0
#> [1] 1.350031
mod1$fitted.psi[1]
#> [1] 0.1798666
# To obtain l1 and l2
mod1$fitted.l1[1]
#> [1] 3.244343
mod1$fitted.l2[1]
#> [1] 4.129565
# Example 2 ---------------------------------------------------------------
gen_data_ZIBP_Geoffroy <- function(n=100) {
# To generate the covariates
x1 <- runif(n=n)
x2 <- runif(n=n)
# To generate the means
mu1 <- exp(1 + 1.3 * x1)
mu2 <- exp(1 + 2.1 * x2)
# To generate the psi
logit_inv <- function(x) exp(x) / (1+exp(x))
psi <- logit_inv(-2.4 + 2.1 * x2)
# The third lambda
l0 <- 1
# To obtain lambdas
l1 <- mu1 / (1-psi) - l0
l2 <- mu2 / (1-psi) - l0
# To generate Y1 and Y2
y <- NULL
for (i in 1:n)
y <- rbind(y, rZIBP_Geoffroy(n=1, l1=l1[i], l2=l2[i],
l0=l0, psi=psi[i]))
# To create the dataset
dataset <- data.frame(y1=y[,1], y2=y[,2],
x1=x1, x2=x2,
mu1=mu1, mu2=mu2,
l0=l0, psi=psi,
l1=l1, l2=l2)
return(dataset)
}
set.seed(12)
data2 <- gen_data_ZIBP_Geoffroy(n=300)
head(data2, n=8)
#> y1 y2 x1 x2 mu1 mu2 l0 psi l1
#> 1 1 8 0.06936092 0.5996109 2.974777 9.575261 1 0.2421704 2.925391
#> 2 8 27 0.81777520 0.8306384 7.870391 15.554356 1 0.3417154 10.955909
#> 3 0 0 0.94262173 0.7396654 9.257261 12.849403 1 0.3001250 12.227021
#> 4 7 8 0.26938188 0.5644036 3.858183 8.892849 1 0.2288612 4.003228
#> 5 4 4 0.16934812 0.3643197 3.387705 5.841989 1 0.1631563 3.048193
#> 6 0 0 0.03389562 0.9902194 2.840739 21.746671 1 0.4205443 3.902427
#> 7 5 4 0.17878500 0.3031845 3.429521 5.138122 1 0.1463760 3.017601
#> 8 6 18 0.64166537 0.7065033 6.259905 11.985013 1 0.2857036 7.763736
#> l2
#> 1 11.635111
#> 2 22.628618
#> 3 17.359569
#> 4 10.532100
#> 5 5.980980
#> 6 36.529482
#> 7 5.019186
#> 8 15.778768
mod2 <- NULL
mod2 <- marZIBP_Geoffroy(mu1.fo=y1~x1,
mu2.fo=y2~x2,
psi.fo=~x2,
data=data2)
summary(mod2)
#> ---------------------------------------------------------------
#> Fixed effects for log(mu1)
#> ---------------------------------------------------------------
#> Estimate Std. Error z value Pr(>|z|)
#> (Intercept) 0.994025 0.065509 15.174 < 2.2e-16 ***
#> x1 1.261572 0.089517 14.093 < 2.2e-16 ***
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> ---------------------------------------------------------------
#> Fixed effects for log(mu2)
#> ---------------------------------------------------------------
#> Estimate Std. Error z value Pr(>|z|)
#> (Intercept) 1.025758 0.060641 16.915 < 2.2e-16 ***
#> x2 2.070244 0.097812 21.166 < 2.2e-16 ***
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> ---------------------------------------------------------------
#> Fixed effects for logit(psi)
#> ---------------------------------------------------------------
#> Estimate Std. Error z value Pr(>|z|)
#> (Intercept) -2.68273 0.27843 -9.6353 < 2.2e-16 ***
#> x2 2.44568 0.32549 7.5139 5.739e-14 ***
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> ---------------------------------------------------------------
#> Estimation for l0
#> ---------------------------------------------------------------
#> Estimate Std. Error z value Pr(>|z|)
#> (Intercept) 1.09401 0.39189 2.7916 0.005245 **
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> ---------------------------------------------------------------