As shown in the reproducible example below, I used the RStudio function haven() 
to read a Stata .dta file, and then tried to do some fitting with the resulting 
data.frame.  This produced an error from my fitting function rqss() in the 
package quantreg.  After a bit of frustrated cursing, I converted the 
data.frame, D, to a matrix A, and thence back to a data.frame B, and tried 
again, which worked as expected.  The conversion removed the attributes of D.  
My question is:  why were the attributes inhibiting the fitting?

In accordance with the usual R-help etiquette I first tried to contact the 
maintainer of the haven package, i.e. RStudio, which elicited the response: 
"since the error is occurring outside RStudio we’re not responsible, so try 
Stack Overflow".  This is pretty much what I would have expected from the 
capitalist running dogs they are.  Admittedly, the error is probably due to 
some unforeseen infelicity in my rqss() coding, but it does seem odd that 
attributes could have such a drastic  effect.  I would be most grateful for any 
insight the R commune might offer.

#require(haven) # for reading dta file
#Ddta <- read_dta(“foo.dta")
#D <- with(Ddta, data.frame(y = access_merg, x = meannets_allhh, z = meanhh))
#save(D, file = "D.Rda")
con <- url("http://www.econ.uiuc.edu/~roger/research/data/D.Rda";)
load(con)

# If I purge the Stata attributes in D:
A <- as.matrix(D)
B <- as.data.frame(A)

# This works:
with(D,plot(x, y, cex = .5, col = "grey"))
taus <- 1:4/5
require(quantreg)
for(i in 1:length(taus)){
    f <- rqss(y ~ qss(x, constraint = "I", lambda = 1), tau = taus[i], data = B)
    plot(f, add = TRUE, col = i)
}
# However, the same code with data = D, does not.  Why?
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to