Hi all,

I posted a question recently here, but I think that it included a little too much detail, so I am trying to rephrase the question.

Suppose there is a farmer who has an apple orchard and he wants to know how many apples are being stolen by the squirrels. He places a box under each tree (pretend the box covers all the ground underneath the apple tree) that the squirrels can’t get into. He visits N apple trees for i days and counts (1) the number of apples left on the tree and (2) the number of apples in the box. However, there would be error on his counts of the apples in the trees, but we assume that he accurately counts the apples in the box.

I am trying to get started on modeling this, but not sure how to do it. It seems like a state space model with a poisson distribution on the apples. Any help on getting started would be appreciated.

The data would look something like this:

tree day apples(Tree) box

tree_1 1 97 21

tree_1 2 76 24

tree_1 3 75 15

tree_1 4 57 14

tree_1 5 48 12

tree_2 1 93 21

…

tree_10 4 57 10

tree_10 5 46 7

Here is the code I used the generate the data:

```
numTrees = 10
apples_start = rpois(numTrees,100) # number of apples at day 1
trees = paste(rep("tree",numTrees),as.character(1:numTrees),sep="_")
days = 1:5
i = 1 # counter
data = data.frame(Tree = character(),day = numeric(),applesTrue = numeric(),applesObs = numeric(),applesFallen=numeric())
for (apples in apples_start){
applesTrue = apples # start at the same place
tree = trees[i]
print(apples)
Fallen = c()
totalApplesTrue = apples
totalApples = rpois(1,apples)
for (day in days) {
tmpFallen= rbinom(1,apples[length(apples)],.2)
if (day == 1){
totalApplesTrue = append(totalApplesTrue,applesTrue - tmpFallen)
totalApples = append(totalApples,rpois(1,(apples-tmpFallen)))}
if (day != 1 && day != days[length(days)]) {
totalApples = append(totalApples,rpois(1,(apples-tmpFallen)) )## add observer error
totalApplesTrue = append(totalApplesTrue,applesTrue - tmpFallen)
}
Fallen = append(Fallen,tmpFallen)
apples = apples - tmpFallen
applesTrue = apples
}
tmpdat = data.frame(rep(tree,max(days)),days,totalApplesTrue,totalApples,Fallen)
data = rbind(data, tmpdat)
i = i+1
}
```

The data set looks like this:

tree days totalApplesTrue totalApples Fallen

tree_1 1 105 93 22

tree_1 2 83 86 19

tree_1 3 64 58 12

tree_1 4 52 50 12

tree_1 5 40 38 6

tree_2 1 98 76 12

So here, the farmer puts down the box at day 0 and checks at day 1. 22 apples have fallen out of a ‘true’ number of 105. However, he miscounts and gets 93. The next day, he counts 19 apples in the box and 86 on the tree. The true number is 83 (105 - 22).