[R] SemiPar/spm question

hadley wickham h.wickham at gmail.com
Sat Jan 30 18:04:03 CET 2010


Hi Chuck,

It looks like a scoping bug in spmx to me:

f <- function() {
  x <- data[data$id=="111",]
  print(spm(x$value ~ f(1:nrow(x))))
}
f()

I'd suggest you contact the package maintainer directly.

Hadley

On Fri, Jan 29, 2010 at 1:34 PM, Chuck White <chuckwhite8 at charter.net> wrote:
> 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))))
> })
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
http://had.co.nz/



More information about the R-help mailing list