Hi,
I have some code I run interactively through the R interpreter and it works
fine. I then run it as a script with Rscript and I get an error. The error
is coming when Rscript builds a model matrix.
Here is the Rscript code :
#!/usr/lib/R/bin/Rscript --verbose
require(MASS)
options(contrasts = c("contr.treatment", "contr.poly"))
....
form <- as.formula(paste(ef.var, form, sep="~"))
cat("The propensity score formula\n")
form
#####
## Calculate the fitted values
fv <- glm(form, family=binomial(link="logit"),
data=df1)$fitted.values
Output from Rscript with the error:
running
'/usr/lib/R/bin/R --slave --no-restore --file=./matchingModel --args
mmtest'
...
'data.frame': 5000 obs. of 8 variables:
$ id : int 1 2 3 4 5 6 7 8 9 10 ...
$ y : num -0.148 1.139 -1.164 -1.13 -0.365 ...
$ C.1 : num 0.2603 0.328 0.6848 0.3909 0.0184 ...
$ C.2 : num 0.64403 0.7233 0.00284 0.42691 0.90681 ...
$ C.24: Factor w/ 4 levels
"a","b","c","d": 3 4 4 2 2 3 1 2 1 4 ...
$ C.5 : num 0.8702 0.6947 0.4795 0.2511 0.0725 ...
$ C.60: num 0.5083 0.8354 0.3339 0.0445 0.2292 ...
$ ev : num 0 0 0 0 0 0 0 0 0 0 ...
The number of unique values in each column:
id y C.1 C.2 C.24 C.5 C.60 ev
5000 5000 5000 5000 4 5000 5000 2
The number of levels in each factor column:
id y C.1 C.2 C.24 C.5 C.60 ev
0 0 0 0 4 0 0 0
The formula
ev ~ C.2 + C.24 + C.5 + C.60
Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") :
could not find function "is"
Calls: glm ... model.matrix -> model.matrix.default -> contrasts<-
The version of R I am using is:
R version 2.10.1 (2009-12-14)
The version of Rscript I am using is
R scripting front-end version 49838
I am running R on x86_64 Linux (kernel 2.6.24-25)
Thank you for your help.
OS
[[alternative HTML version deleted]]