[ADMB Users] glmmadmb problems
Daniel Moreno Fernández
danielmorenofdez at gmail.com
Thu Nov 21 01:18:10 PST 2013
Hi all,
My name is Daniel Moreno. I am working in forest regeneration and I am
trying to explain the factors which involves the regeneration in a
experiment composed by transects, plots and subplots. I have count data and
I would like to fit a negative binomial with a log link function. Below,
you can see the structure of the full data (excuse me for the Spanish code):
str(todonava)
'data.frame': 170 obs. of 41 variables:
$ COD : int 9 10 11 12 13 14 15 16 17 18 ...
$ Subplot : Factor w/ 170 levels "1C5-3-1","1C5-3-2",..: 1 2 3 4 5
6 7 8 9 10 ...
$ Plot : Factor w/ 43 levels "1C5-3","1C5-4",..: 1 1 1 1 2 2 2 2
3 3 ...
$ Transecto : Factor w/ 5 levels "1C5","2A5","2B5",..: 1 1 1 1 1 1 1
1 1 1 ...
$ Seedlings : int 9 59 5 92 8 11 4 4 22 33 ...
$ isf : num 0.852 0.848 0.855 0.862 0.82 ...
$ dsf : num 0.812 0.785 0.807 0.835 0.812 ...
$ gsf : num 0.817 0.793 0.813 0.838 0.813 ...
$ altitud : int 1730 1730 1730 1730 1730 1730 1730 1730 1730 1730
...
$ pendgrados : num 14 11 12 16 16 15 15 17 19 11 ...
$ pend100 : num 25 20 22 29 29 27 28 32 35 20 ...
$ numfoto : int 9 10 11 12 13 14 15 16 17 18 ...
$ ph : num 4.67 4.67 4.67 4.67 8.45 8.45 8.45 8.45 4.76 4.76
...
$ conductividad : num 0.08 0.08 0.08 0.08 0.2 0.2 0.2 0.2 0.08 0.08 ...
$ arena : num 71 71 71 71 58 ...
$ limo : num 11 11 11 11 12.6 ...
$ arcilla : num 18.4 18.4 18.4 18.4 29.4 ...
$ MO : num 13.9 13.9 13.9 13.9 17.4 ...
$ potasio : int 134 134 134 134 182 182 182 182 180 180 ...
$ fosforo : num 11.5 11.5 11.5 11.5 13.5 13.5 13.5 13.5 8.8 8.8 ...
Some variables contains NA values (e.g. fosforo (fosforo=phosphorus)).
Below, it is possible to read my R code (to fit the best model and avoid
overparametization I use a stepwise model selection) and some Errors:
> todo2<-glmmadmb(Seedlings~Transecto + fosforo + (1|Plot), na.omit,
data=todonava, zeroInflation=FALSE, family="nbinom", link="log")
Error in II[, ii] = II[, ii] + REmat$codes[[i]] :
number of items to replace is not a multiple of replacement length
In addition: Warning messages:
1: In glmmadmb(Seedlings ~ Transecto + fosforo + (1 | Plot), data =
todonava, :
NAs removed in constructing fixed-effect model frame: you should probably
remove them manually, e.g. with na.omit()
2: In II[, ii] + REmat$codes[[i]] :
longer object length is not a multiple of shorter object length
It could be a NA problem. Then, I removed NA values:
navana<-na.omit(todonava)
str(navana)
'data.frame': 0 obs. of 41 variables:
$ COD : int
$ Subplot : Factor w/ 170 levels "1C5-3-1","1C5-3-2",..:
$ Plot : Factor w/ 43 levels "1C5-3","1C5-4",..:
$ Transecto : Factor w/ 5 levels "1C5","2A5","2B5",..:
$ Seedlings : int
$ isf : num
$ dsf : num
$ gsf : num
$ altitud : int
$ pendgrados : num
$ pend100 : num
$ numfoto : int
$ ph : num
$ conductividad : num
$ arena : num
$ limo : num
$ arcilla : num
$ MO : num
$ potasio : int
$ fosforo : num
$ magnesio : num
$ calcio : num
$ sodio : num
$ texturaISSS : Factor w/ 5 levels " arcillo arenoso",..:
$ F25 : logi
$ lnca : num
$ lnconductividad: num
$ lnfosforo : num
$ gsfcuadrado : num
$ lnMg : num
$ lnpotasio : num
$ raizpotasio : num
$ lnsodio : num
$ ipot : num
$ ifn : num
$ trees : int
$ stump : int
$ perctrees : num
$ percstumps : num
$ pedre : num
$ Lnpedre : num
- attr(*, "na.action")=Class 'omit' Named int [1:170] 1 2 3 4 5 6 7 8 9
10 ...
.. ..- attr(*, "names")= chr [1:170] "1" "2" "3" "4" ...
Then, I run again the model with the new data frame:
> todo3<-glmmadmb(Seedlings~Transecto + fosforo + (1|Plot), na.omit,
data=navana, zeroInflation=FALSE, family="nbinom", link="log")
Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
contrasts can be applied only to factors with 2 or more levels
I am new with R (till now, I worked with SAS). Could you help me to solve
this problems)
Thanks you all,
Daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.admb-project.org/pipermail/users/attachments/20131121/d936e504/attachment.html>
More information about the Users
mailing list