Dear all,

I studied in tank prey fish behavior. Using the design described below 
(and R code), I want to test the effects of both habitat and predator 
(and interaction) on prey fish's vertical distribution, which was 
recorded (with repeated measures) as a categorical variable.

I found that package mlogit might fit to my need but I don't know how to 
specify my complex design in the formulae (which of my variables are 
individual- or alternative-specific?) If this package is the good one, I 
would be glad you help me in formulating my full model. If it is not, 
any suggestion would be appreciate.

Design:

Factor Habitat (Hab): fixed, 3 levels

Factor Predator (Pre): fixed, 2 levels (abscence vs presence)

Factor subject (Sub): random, nested in Hab X Pre, 4 levels (hence a 
total of 24 subjects)

Data collection using repeated measures.

I observed each subject during a 130 min trial but I collected data only 
during 3 periods (10 min long separated each other by 50min) --> Factor 
period (Per): 3 levels, from 0min to 10min (after trial start), from 
60min to 70min, and from 120 to 130min.

Within each period, I recorded subject's positions 21 times (every 
30sec). I consider these observations as independent because 30 sec is 
large enough so that fish go back-and forth several time in the tank. 
--> Postition (Pos) was a categorical variable with 8 levels. Levels are 
in reality ordered but I don't need to consider them as such. However, I 
would like to compare them 2 by 2, which is more useful as regard to my 
ecological hypotheses).

To test putative differences in vertical distribution between habitat 
and predator treatments, I thought to use mixed linear modeling with as 
response variable the number of time(Nobs) each position was observed 
(out of 21 observations for a given combinations of Hab, Pre, Sub and 
Per). However, the 8 values of Nobs for a given period are not 
independent, by definition (ad up to 21). Hence, I cannot use linear 
modeling and dig in the way of model multinomial. However, I appreciate 
the boxplot (run R code) as graphical representation and would be able 
to assign letters for pairwise comparisons of positions within a 
treatment, and also of treatments within a position level.


I hope I have been clear and I thank you in advance,

Best regards,

Pierre THIRIET

Université de Nice

########################### here is R code for exemplifying the 
structure of my data set.

#factorial design

hab=c("h1","h2","h3")

pre=c("a","p")

sub=c("s1","s2","s3","s4")

per=c("p1","P2","p3")

tim=paste("t",1:21,sep="")

mydata=expand.grid(tim=tim,per=per,sub=sub,pre=pre,hab=hab)

#random generation of the response variable,with an effect of factor pre 
(by adding a vector of probability weights)

require(plyr)

posl=paste("z",1:8,sep="")

mydata$pos=factor(NA,levels=posl)

n=length(mydata$pos[pre=="a"])

mydata$pos[mydata$pre=="a"]=replicate(n,sample(posl,1,prob=c(0.05,0.05,0.05,0.4,0.3,0.05,0.05,0.05)))#strong 
preference for z3 and z4

mydata$pos[mydata$pre=="p"]=replicate(n,sample(posl,1,prob=c(0.3,0.4,0.05,0.05,0.05,0.05,0.05,0.05)))#strong 
preference for z1 and z2

summary(mydata)

# number of time (out of 21) each position was observed, given hab, pre, 
sub and per

mydata2=ddply(mydata,.(hab,pre,sub,per,pos),summarize,nobs=length(pos),.drop=F)

mydata2[,1:5]=catcolwise(function(x)as.factor(x))(mydata2)

summary(mydata2)

# boxplot of frequencies of occpupancy

require(ggplot2)

ggplot(mydata2)+geom_boxplot(aes(pos,I(100*nobs/21)))+facet_grid(pre~hab)


	[[alternative HTML version deleted]]

