Anamika Chaudhuri
2008-Dec-08 03:46 UTC
[R] Reading txt file in R to run Random Intercept Model
I am using a random intercept model with SITEID as random and NAUSEA as outcome. Thanks. Anamika I tried using a dataset without missing values and changed my model statement accordingly but still get the same error. Follwoing in an excerpt.> anal.data <- read.table("nausea.txt", header=T, sep="\t") > list(names(anal.data))[[1]] [1] "SITEID" "NAUSEA"> #anal.data <- read.csv("simuldat.csv", header=T) > attach(anal.data)The following object(s) are masked from anal.data ( position 3 ) : NAUSEA SITEID The following object(s) are masked from anal.data ( position 4 ) : NAUSEA SITEID> data.bugs <-list("NAUSEA"=NAUSEA,"SITEID"=SITEID,"n.samples"=n.samples,"n.sites"=n.sites,"n.params"=n.params)> bugsData(data.bugs, fileName = "nauseadata.txt") > inits.bugs <- list("alpha"=rep(0,n.sites), "tau"=1) > bugsInits(list(inits.bugs), fileName = "nauseainit.txt") > modelCheck("nausea_random.txt") # check model filemodel is syntactically correct> modelData("nauseadata.txt") # read data fileexpected variable name error pos 98349 *MODEL* model { for (i in 1:n.samples) {NAUSEA[i] ~ dbin(p[i],1) logit(p[i]) <- alpha[SITEID[i]]} #for(k in 1:n.params) #{b[k]~ dnorm(0.0,tau)} for (j in 1:n.sites) {alpha[j]~dnorm(0.0,1.0E-10)} tau ~ dgamma(0.001,0.001) } *Dataset:* SITEID NAUSEA 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 0 1 0 1 0 1 1 -Anamika [[alternative HTML version deleted]]
>>> "Anamika Chaudhuri" <canamika at gmail.com> 08/12/2008 03:46:34 >>> >I am using a random intercept model with SITEID as random and NAUSEAas>outcome.Hardly surprising ;-) More seriously, your data set fragment had only one level for SITEID. I assume there were actually more levels? S ******************************************************************* This email and any attachments are confidential. Any use...{{dropped:8}}