diff --git a/docs/cap04_resultados-e-discussao.Rnw b/docs/cap04_resultados-e-discussao.Rnw index 43d5c27eb87b2c0c26caab1c66b0d9c2a2d56111..89a3cd78ed0f4508b0d000b15a52257ac8f3c181 100644 --- a/docs/cap04_resultados-e-discussao.Rnw +++ b/docs/cap04_resultados-e-discussao.Rnw @@ -2307,6 +2307,44 @@ fonte("Fonte: Elaborado pelo autor.") @ +<<varspred-nematodes, include=FALSE>>= + +##------------------------------------------- +## Obtendo os efeitos aleatórios +ranefP <- ranef(m2PM)$cult[, 1] +ranefC <- mixedcmp.ranef(m2CM) +ranef.all <- rbind( + data.frame(model = "PM", ranef = ranefP), + data.frame(model = "CM", ranef = ranefC)) + +##------------------------------------------- +## Valores preditos +pred <- with( + nematodes, + expand.grid(off = seq(min(off), max(off), length.out = 20), + cult = levels(cult)) + ) +X <- model.matrix(~log(off), data = pred) + +## Pelo Poisson Mixed +aux <- predict(m2PM, newdata = pred, type = "link") +predPM <- data.frame(pred, y = exp(aux), model = "MP") +muPM <- data.frame(pred, mu = exp(X %*% fixef(m2PM)), model = "MP") + +## Pelo COM-Poisson Mixed +aux <- predict(m2CM, newdata = pred, type = "link") +predCM <- data.frame(pred, y = calc_mean_cmp(aux, phi = m2CM@coef[1]), + model = "MC") +muCM <- data.frame(pred, mu = calc_mean_cmp(X %*% m2CM@coef[-(1:2)], + phi = m2CM@coef[1]), + model = "MC") + +## Agrupa as predições +pred.all <- rbind(predPM, predCM) +mu.all <- rbind(muPM, muCM) + +@ + Conforme já observado anteriormente, no modelo COM-Poisson misto os parâmetros $\phi$, da distribuição considerada para a variável de contagem condicional aos efeitos aleatórios e as covariáveis e $\sigma$, @@ -2338,14 +2376,6 @@ levam ao mesmo resultado. <<pred-nematodes, fig.height=4.2, fig.width=7.4, fig.cap="Perfis de verossimilhança dos parâmetros estimados no modelo COM-Poisson Misto.">>= -##------------------------------------------- -## Obtendo os efeitos aleatórios -ranefP <- ranef(m2PM)$cult[, 1] -ranefC <- mixedcmp.ranef(m2CM) -ranef.all <- rbind( - data.frame(model = "PM", ranef = ranefP), - data.frame(model = "CM", ranef = ranefC)) - xy1 <- densityplot( ~ranef, groups = model, auto.key = list( @@ -2358,32 +2388,6 @@ xy1 <- densityplot( grid = TRUE, par.settings = ps.sub) -##------------------------------------------- -## Valores preditos -pred <- with( - nematodes, - expand.grid(off = seq(min(off), max(off), length.out = 20), - cult = levels(cult)) - ) -X <- model.matrix(~log(off), data = pred) - -## Pelo Poisson Mixed -aux <- predict(m2PM, newdata = pred, type = "link") -predPM <- data.frame(pred, y = exp(aux), model = "MP") -muPM <- data.frame(pred, mu = exp(X %*% fixef(m2PM)), model = "MP") - -## Pelo COM-Poisson Mixed -aux <- predict(m2CM, newdata = pred, type = "link") -predCM <- data.frame(pred, y = calc_mean_cmp(aux, phi = m2CM@coef[1]), - model = "MC") -muCM <- data.frame(pred, mu = calc_mean_cmp(X %*% m2CM@coef[-(1:2)], - phi = m2CM@coef[1]), - model = "MC") - -## Agrupa as predições -pred.all <- rbind(predPM, predCM) -mu.all <- rbind(muPM, muCM) - key <- list( column = 1, lines = list(lty = c(1, 2), lwd = c(3, 1)),