On Tue, 2006-10-24 at 11:54 -0400, Stanfield, Les (MNR) wrote: > I hope you can help me. I am new to "R" and am working through the > example of quantile regression analysis in the paper by Roger Koenker > (quantile regression in R: a Vignette. I got to page 6 and in trying to > execute the following code I received the error below. I have searched > on the web and while I have found similar error messages, I have not > been able to ascertain the root cause. Any assistance would be > appreciated. Basically, is this a bug in the program or in the coding, > or does this function not work in the versions that I have downloaded. > I have downloaded: R 2.4.0 and quantreg 4.0.1 and SparseM. Am I missing > something? > > > > > xx <- x -mean(x) > > > fit1 <- summary(rq(y ~ xx, tau = 2:98/100)) > > Error in model.frame(formula, rownames, variables, varnames, extras, > extranames, : > > variable lengths differ (found for 'xx')
The error is indicating that the number of elements in 'y' is not the same as in 'xx': > y <- rnorm(50) > xx <- rnorm(49) > lm(y ~ xx) Error in model.frame(formula, rownames, variables, varnames, extras, extranames, : variable lengths differ (found for 'xx') Thus, check the nature of 'y' and 'xx': > str(y) num [1:50] -0.902 1.002 -1.064 2.630 2.193 ... > str(xx) num [1:49] 1.590 -2.354 0.166 0.332 -0.547 ... And that should reveal the source of the error. HTH, Marc Schwartz ______________________________________________ R-help@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 and provide commented, minimal, self-contained, reproducible code.