r - General linear mixed-effect (glmer) heteroscedasticity modelling -
my variables measured on randomized block subsampling design treatments 23 accesion. have 3 complete blocks , 6 samples per block. example dataframe has 4 response variables (lh, ren, ftt, dfr), accesion (treatment), bloque (block number) , plot (that variable accounting subsampling). head of data is:
plot accesion bloque lh ren ftt dfr 1 221 22 1 20.6 1127 23 88 2 221 22 1 20.5 1638 20 88 3 221 22 1 24.5 1319 16 88 4 221 22 1 21.4 960 17 88 5 221 22 1 25.7 1469 18 88 6 221 22 1 25.8 1658 21 88 so, data non-normal , heteroscedastic of 100 response variables after types of transformations (log, boxcox, power, etc). of variables show chi-squared or poisson-like distribution different variance each accesion.

so far i've beeng working on running generalized linear model-effect poisson using glmer() on ftt response variable. using code:
fttglme = glmer(ftt ~ accesion + bloque + (1|plot), data = lyc, family=poisson(link="identity")) the residuals non-normal according shapiro.test(). that, assume, because of heteroscedasticity observed in residuals. boxplot of residuals accesion, shows difference of variances:

the heteroscedasticity expected between plant populations, know can modelled inside glme. code should add, have investigated already, is:
vf <- varident(form=~accesion) fttglme = glmer(ftt ~ accesion + bloque + (1|plot), data = lyc, family=poisson(link="identity"), weights = vf) i want different variances account each accesion category. keep getting error:
error in model.frame.default(data = lyc, weights = varident(form = ~accesion), : variable lengths differ (found '(weights)')
does know how account differences of variance between accesions inside glmer()?
any other suggestions analyze data welcome.
i've solved issue. in glmer() weights argument correspond vector of same length original. model heteroscedaticity generated variance dataframe:
var<-aggregate(lyc[,6],by=list(lyc$accesion), var) colnames(var)<-c("accesion", "var") that yields dataframe treatment/variance, head of is:
accesion var 1 22 4.369281 2 23 16.251634 3 24 13.911765 4 25 15.404412 5 26 15.895833 6 27 44.838095 then create new dataframe merging both dataframes
lyc2<-merge(var, lyc, by="accesion") and saw doing wrong 1 time, needed use inverse variance, in order correct variance.
lyc2$var<-(1/lyc2$var) after data steps, run code:
fttglme = glmer(ftt ~ accesion + bloque + (1|plot), data = lyc2, family=poisson(link="log"), weights = lyc2$var) that fixes variance issue:

Comments
Post a Comment