[R] SemiPar/spm question

Chuck White chuckwhite8 at charter.net
Fri Jan 29 20:34:21 CET 2010


Hello -- I posted this question yesterday and for some reason the post seems to be attached to the wrong thread. Also, I extended my test a little and it seems to indicate the problem is with spm. I would appreciate any help. Thanks.

==========================================================
library(plyr)
library(SemiPar)

data <- data.frame(id=c(rep("111",100),rep("222",200)), value=c(rnorm(100,2,1),rnorm(200,10,5)), lhs=c(rnorm(100,2,1),rnorm(200,10,5)))

#this works
d_ply(data, c("id"), function(x) {
    print(lm("lhs~value", data=x))
})

#this works
data111 <- data[data$id=="111",]
print(spm(data111$value ~ f(1:nrow(data111))))

#this does not work
d_ply(data, c("id"), function(x) {
    print(spmx <- spm(x$value ~ f(1:nrow(x))))
})



More information about the R-help mailing list