The error you had in your program was because of the na.action in the
function call. If you specify the parameter you need to give it a function
such as na.omit or na.fail
There would be a second error if you fixed this because you are including an
intercept and the gee function will automatically fit an intercept also,
this will lead to to columns being the exact same in the design matrix.
The following code should get you where you want to be.
eta <- rnorm(100)
Si <- runif(100, min=0, max=11)
lny <- 10+2*Si-Si^2+eta
id <- (1:100)
conc <- rep(1,100)
Si2 <- Si^2
geedat <- data.frame(Si=Si,Si2=Si2,lny=lny,id=id)
lnyhat <- gee(lny ~ Si - Si2, id=id, data=geedat)
lnyhat <- gee(lny ~ conc+Si - Si2 -1, id=id, data=geedat)
-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of anafava at uiuc.edu
Sent: Wednesday, August 18, 2004 14:54 PM
To: r-help at stat.math.ethz.ch
Subject: [R] Gee
I am trying to learn the gee function in R. So I try to
generate some data and use this function. I have the
following lines:
######################################## Gee
# Generating lny=10+2*Si-Si^2+eta
# eta ~ N(0,1)
# Si ~ U(0,11)
eta <- vector(mode="numeric",100)
eta <- rnorm(100)
Si <- vector(mode="numeric",100)
Si <- runif(100, min=0, max=11)
lny <- vector(mode="numeric",100)
lny <- 10+2*Si-Si^2+eta
id <- vector(mode="numeric",100)
id <- (1:100)
cons <- vector(mode="numeric",100)
for(i in 1:100) {
cons[i] <- 1
}
Si2 <- vector(mode="numeric",100)
for(j in 1:100) {
Si2[j] <- Si[j]^2
}
geedat <- data.frame(Si=Si,Si2=Si2,lny=lny,id=id,cons=cons)
lnyhat <- gee(lny~cons+Si-Si2, id=id, data=geedat, na.action)
And I received the following error message:
[1] "Beginning Cgee S-function, @(#) geeformula.q 4.13
98/01/27"
Error in "[.data.frame"(structure(list(lny = c
(9.92388214744737, 2.54332321404939, :
invalid subscript type
I don't know what I am doing wrong. May someone help me?
Thanks
Ana
______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html