r - Accounting for temporal correlation in GLMM -


i trying account autocorrelation in glmm. response variable boolean, represents presence , absence of en event in life cycle of set of bee nests. trying predict probability of such event set of numerical variables describing state of each nest. thefore, used binomial distribution in generalized model nest random effect (using glmer()). however, events autocorrelated, pretty horrible pattern in residuals. if using gaussian distribution in errors without random effects, estimate correlation parameters using correlation structure gls(), not gonna work in case. have been looking ways include autocorrelation in glmm, don't seem right. found data set can transformed using function ts() , diff() allow model include predictor, previous values of response. works linear model lm(), making residuals nicer.

basket.1<-subset(basket,select=c(nest,day,number_cells,provitioning_cells,closed_cells,                              reopened_cells,eclosed_cells,pollen)) basket.ts<-ts(as.matrix.data.frame(basket.1),start=1,frequency=9) m.basket.ts1<-lm(pollen~provitioning_cells+reopened_cells+closed_cells             +eclosed_cells+day,data=diff(basket.ts,differences=2))` 

however, neither lmer() nor glm() accept output of functions. problem seems the trasformation makes values negative, , glm()does not accept negative values binomial model (which makes sense). have read possible account autocorrelations glm(), improvement,but cannot make work. read glmmpql() can include correlation structures.that model runs, not improve patterns in residuals. still seem autocorrelated.

m.basket.glmm1<-glmmpql(pollen~provitioning_cells+reopened_cells+closed_cells             +eclosed_cells+day,random=~1|nest,family=binomial,correlation=corar1(form=~day),             data=basket) 

i tried different correlation structures , none of them seems work.

finally, tried dyn package, supposed allow regression functions handles time series. once again, function not run values produced transformation.

m.bas.glm.dyn1<-dyn$glm(pollen~provitioning_cells+reopened_cells+closed_cells                     +eclosed_cells+day,family=poisson,data = diff(basket.ts,differences=3)) 

to summarize, need run glmm temporal correlations, cannot find way this. highly appreciate help.

cheers!!!

can give reproducible example? in principle shouldn't hard lag values 'by hand', e.g.

basket.1 <- subset(basket,select=c(nest,day,number_cells,                              provitioning_cells,closed_cells,                              reopened_cells,eclosed_cells,pollen)) n <- nrow(basket.1) basket.2 <- transform(basket.1,pollen.lag1=c(pollen[2:n],na),                       pollen.lag2=c(pollen[3:n],rep(na,2)))  library("lme4") m.basket.glmm1 <- glmer(pollen~provitioning_cells+                    reopened_cells+ closed_cells+                     eclosed_cells+day+pollen.lag1+pollen.lag2+                     (1|nest),                    family=binomial,data=basket.2) 

depending on size of data set, if day numeric rather factor might want (day|nest) instead of (1|nest) ...


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -