[R-br] Regressão espacial com variavel transformada log normal

Elias T. Krainski eliaskrainski em yahoo.com.br
Quarta Junho 10 13:23:51 BRT 2015


Como os dados são contínuos seria necessário considerar uma distribuição 
contínua com mistura Bernoulli, veja uma proposta aqui:
http://jupiter.est.ufmg.br/~posgrad/mestrado/dissertacao_mestrado_zaida%20_quiroz.pdf
e um exemplo no script abaixo:

## hurdle model for zero-gamma (zero inflation and continuous outcome)
require(INLA)

### rainfall data from Parana' state in Brazil
data(PRprec)

### analize data from one location
PRprec[301,1:3]
y <- as.matrix(PRprec[,-(1:3)])[301,]

summary(y)

plot.ts(y)
if (TRUE)
     dev.off()

### organize the dataset to build a model for
### smoothing the rainfall amount over the year
### accounting for a smoothed zero probability as well
n <- length(y)
dat <- list(resp=cbind(
                 c((y>0)+0, rep(NA,n)),
                 c(rep(NA,n), ifelse(y>0,y,NA))),
             t0=c(1:n, rep(NA,n)),
             t1=c(rep(NA,n), 1:n))

### two choices to smooth the rainfall amount
form1 <- resp ~ 0 +
     f(t0, model='rw2', cyclic=TRUE) +
         f(inla.group(t1, n=73), model='rw1', cyclic=TRUE)
form2 <- resp ~ 0 +
     f(t0, model='rw2', cyclic=TRUE) +
         f(t1, model='rw2', cyclic=TRUE)
inla.setOption(scale.model=TRUE)

res1 <- inla(form1, family=c('binomial', 'gamma'), data=dat)
res2 <- inla(form2, family=c('binomial', 'gamma'), data=dat)

day <- seq(ISOdate(2011,1,1), ISOdate(2011,12,31), 24*3600)
par(mfrow=c(2,1), mar=c(3,3,1,1), mgp=c(2,1,0))
plot(day, y>0)
for (j in 4:6) {
     lines(day, 1/(1+exp(-res1$summary.ran$t0[,j])), lty=2)
     lines(day, 1/(1+exp(-res2$summary.ran$t0[,j])), lty=2, col=2)
}
plot(day, y, type='l')
for (j in 4:6) {
     lines(day[seq(3,n,5)], exp(res1$summary.ran[[2]][,j]), lty=2)
     lines(day, exp(res2$summary.ran[[2]][,j]), lty=2, col=2)
}


Elias


Mais detalhes sobre a lista de discussão R-br