Model not running when using lme4 - "Error: unexpected symbol..." message returned

#1
Hi all,

I have been attempting to run the following model in the lme4 package in R.

mod1<-glmer(perc~treatment+region+stage+treatment*stage+region*stage+(tub+aquarium), weights=no start, family=binomial, data=data)

But continue to receive the following error message:

> mod1<-glmer(perc~treatment+region+stage+treatment*stage+region*stage+(tub+aquarium), weights=no start, family=binomial, data=data)
Error: unexpected symbol in "mod1<-glmer(perc~treatment+region+stage+treatment*stage+region*stage+(tub+aquarium), weights=no start"

I have searched the user manual for the package, my supervisor is not proficient in R and thus cannot help me with this and I'm not aware of anyone else who can help me with R errors within the next week.

The unexpected symbol message appears to be specific to the code that is being run and a google search of

'error: unexpected symbol in "mod1<-glmer(perc~treatment+region+stage+treatment*stage+region*stage+(tub+aquarium), weights=no start"'

has not provided me with a similar problem from which I can work out a solution. however
tub and aquarium should be random variables, the others fixed effects (region, stage, treatment) and interactions (treatment*stage) and (region*stage), weights are specified and family=binomial.

I suspect the error only has to do with syntax, but cannot work out where I am going wrong. Any suggestions?

Thanks in advance.

Daniel
 

Jake

Cookie Scientist
#2
Re: Model not running when using lme4 - "Error: unexpected symbol..." message returne

The problem is here:
Code:
weights=no start
In other words, the last piece of syntax that R attempted to process before encountering the error.

Just looking at this piece of code, it is clear that it is not correct syntax. "no start" is not a proper variable name, so I guess you are not trying to pass a variable called "no start" to the weights parameter, because such a variable cannot exist. Maybe you are trying to pass a variable "no" to the weights parameter, but then it's not clear why there is a " start" after this. In short, this piece of code doesn't make sense.
 
#3
Re: Model not running when using lme4 - "Error: unexpected symbol..." message returne

Ah, thank you very much for that. I figured this out myself after a while, but didn't understand why it was a problem. Now I do; R doesn't like spaces in variable names.
 

Jake

Cookie Scientist
#4
Re: Model not running when using lme4 - "Error: unexpected symbol..." message returne

I don't think there are any programming languages that like variable names that contain spaces. Anyway, glad you got it working now.
 
#5
Re: Model not running when using lme4 - "Error: unexpected symbol..." message returne

I use the following R-code:
portfolio.optim(x, mean(x), riskless = FALSE, shorts = FALSE,
rf = 0.0, reslow = NULL, reshigh = NULL, covmat = cov(x), . .)"
Error: unexpected symbol in:
"
rf = 0.0, reslow = NULL, reshigh = NULL, covmat = cov(x), . .)"
I do not see anything wrong. Please advise.

Jan van der Peet