[R] multilevel
eeecon
121onto at gmail.com
Fri May 20 21:54:22 CEST 2011
Hi,
My code indicates there may be a bug in multilevel.
I doubt this is actually the case, can anyone tell me what is wrong with my
code?
The data file for this code can be downloaded here:
http://cameron.econ.ucdavis.edu/mmabook/mma15p4gev.asc
Here is the code that generates the bug:
rm(list = ls())
library("multilevel")
#v1
fishing.data <- scan("mn.dat")
fishing.data.array <- array(fishing.data, c(11, 4, 1182))
fishing.data.array <- aperm(fishing.data.array, c(3,2,1))
means <- aggregate(fishing.data.array[,,3:5],
as.data.frame(cbind(fishing.data.array[,1:4,2])), mean)
## Table 1
## > means
## V1 V2 V3 V4 V1 V2 V3 V4 V5 V6
## 1 1 0 0 0 35.69949 35.69949 97.80913 125.00316 0.2791948 0.2190015
## 2 0 1 0 0 30.57133 30.57133 82.42908 109.76335 0.2614444 0.2025348
## 3 0 0 1 0 137.52710 137.52710 41.60681 70.58409 0.2082868 0.1297646
## 4 0 0 0 1 120.64835 120.64835 44.56376 75.09694 0.2519077 0.1595341
## V7 V8 V9 V10 V11 V12
## 1 0.1593985 0.5176090 4.051617 4.051617 4.051617 4.051617
## 2 0.1501489 0.4980798 3.387172 3.387172 3.387172 3.387172
## 3 0.1775411 0.6539167 4.654107 4.654107 4.654107 4.654107
## 4 0.1771628 0.6914998 3.880900 3.880900 3.880900 3.880900
#
## Note V1 and V2 above are the same. This is suspicious.
## In fact (1,V1) from Table 1 should agree with (1,V1) from Table 2 below:
#
#v2
fishing.data <- scan("mn.dat")
dim(fishing.data) <- c(11,1182*4)
fishing.data <- t(fishing.data)
means <- aggregate(fishing.data[,3:5],
as.data.frame(fishing.data[,2]*fishing.data[,6:8]), mean)
## Table 2
## > means
## V1 V2 V3 V1 V2 V3
## 1 0 0 0 95.85924 0.2717639 4.097600
## 2 1 0 0 30.57133 0.2025348 3.387172
## 3 0 1 0 41.60681 0.1775411 4.654107
## 4 0 0 1 75.09694 0.6914998 3.880900
--
View this message in context: http://r.789695.n4.nabble.com/multilevel-tp3539421p3539421.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list