In your sample data, the first 9 lines do not have the same number of
elements as the rest. What are they supposed to represent? How do
you intend to read them in and use them?
On Sat, Dec 6, 2008 at 10:42 PM, Anamika Chaudhuri <canamika16 at
yahoo.com> wrote:>
>
>
>
>
>
>
>
> Hi:
>
> I am using the following code to read a data set in txt in R and using the
follwoing model. But it seems to give me an error ' expected variable name
error pos 134022'. Any help is greatly appreciated.
>
> Code:
> anal.data <- read.table("nausea.txt", header=T,
sep="\t")
> list(names(anal.data))
> attach(anal.data)
> n.samples <- dim(anal.data) [1] # number of data points
> n.params <- dim(anal.data)[2] - 2 # number of parameters to estimate
> n.sites <- length(unique(SITEID))
>
> data.bugs <-
list("NAUSEA"=NAUSEA,"SITEID"=SITEID,"BMI"=BMI,
"USUBJID"=USUBJID,"n.samples"=n.samples,"n.sites"=n.sites,"n.params"=n.params)
> bugsData(data.bugs, fileName = "nauseadata.txt")
> inits.bugs <-
list("b"=rep(0,n.params),"alpha"=rep(0,n.sites),
"tau"=1)
> bugsInits(list(inits.bugs), fileName = "nauseainit.txt")
>> modelCheck("nausea_random.txt") # check model file
> model is syntactically correct
>> modelData("nauseadata.txt") # read data
file
> expected variable name error pos 134022
>
> Model statement:
> model
> {
> for (i in 1:n.samples)
> {NAUSEA[i] ~ dbin(p[i],1)
> logit(p[i]) <- alpha[SITEID[i]] + b[1] + b[2]*BMI[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)
> }
>
> Sample Dataset:
> USUBJID SITEID BMI NAUSEA
> 01 0
> 01 0
> 01 0
> 01 0
> 01 0
> 01 0
> 01 0
> 01 0
> 01 0
> 3020101648 01 25.62 0
> 3020101649 01 30.54 0
> 3020101650 01 26.68 1
> 3020101651 01 26.56 0
> 3020101652 01 22.96 0
> 3020101653 01 26.27 0
> 3020101666 01 26.15 1
> 3020101667 01 30.18 0
> 3020101668 01 24.33 0
> 3020101669 01 44.72 1
> 3020101670 01 33.54 1
> 3020101671 01 36.39 1
> 3080101561 01 30.13 1
> 3080101562 01 25.8 1
> 3080101564 01 31.07 1
> 3080101565 01 26.53 0
> 3080101566 01 29.3 0
> 30801 01694 01 28.4 1
> 3080101695 01 26.03 1
> 3080101696 01 27.43 1
> 3080101697 01 31.96 0
> 3080101698 01 28.76 0
> 3080101699 01 28.4 1
> 3080101700 01 29.33 0
> 3080101701 01 36.02 0
> 3080101768 01 31.05 1
>
> Thanks
> Anamika
>
>
>
>
>
> [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem that you are trying to solve?