Problem with script compiling

2 posts / 0 new
Last post
daveisme
Offline
Joined: 09/19/2011
Problem with script compiling

Hi guys
I'm new at R language and I have a script compiling problem.

I'm trying to compile this script:

###
model_logistic
{
for (i in 1:N)
{Y[i]~ dbin(theta[i], 1)
logit(theta[i] <- beta.0+beta.1*X[i]}
}

beta.0 ~ dnorm(0, 0.0001)
beta.1 ~ dnorm(0, 0.0001)

or <-exp(beta.1)
}
###

by typing:
> source("question2bis_code.R")

But it gives me this error:

Error in source("question2bis_code.R") :
question2bis_code.R:7:45: unexpected '}'
{Y[i]~ dbin(theta[i], 1)
logit(theta[i] <- beta.0+beta.1*X[i]}

Why do I get this?
Why this error?

Thanx




ProgrammingR offers two ways for you to stay up to date. To be notified when new articles and book reviews are posted, subscribe to the general ProgrammingR RSS feed by clicking here. To be notified when new R-based job listings are posted, click here.

bryan
Offline
Joined: 01/15/2009

Hi daveisme,

What exactly are you trying to do? You usually don't have to compile code in R. Are you just trying to create and include a function? If so, you probably want something more like this in your included code:


model_logistic <- function {
beta.0 ~ dnorm(0, 0.0001)
beta.1 ~ dnorm(0, 0.0001)
for (i in 1:N) {
Y[i]~ dbin(theta[i], 1)
logit(theta[i] <- beta.0+beta.1*X[i]
}
or <-exp(beta.1)
}

This is just an approximation based on a guess at your goal, but it should help you make some progress.

Login or register to post comments