Dear statistics and R experts, I am a new R-user and my statistics is probably more than a bit rusty. So forgive me if the following question is relatively simple. I would like to plot the predicted values from a quantile regression analysis (quantreg v.3.31; R v.1.7.1) so that I can evaluate the fit. My response variable is tree growth (continuous), and my predictor variables are height (continuous), species (factor with 3 levels), and light (ordered factor with 3 levels). I'd like to look at the relationship between growth and height separately for each combination of species and light. I am fitting the model using something like: fit.rq <- rq(growth ~ ht*spp*light, tau = 0.9) Unfortunately, there does not seem to be a predict method for rq objects (unless I am missing something?). I can plot the predicted values by using lines(x, fit), and I can extract the coefficients from fit.rq using fit.rq$coef, creating the correct coefficients for a particular level of spp*light as: intercept <- fit.rq$coef[1,1] + fit.rq$coef[3,1] + ...; slope <- fit.rq$coef[2,1] + fit.rq$coef[5,1] ...) but this seems very slow and awkward to do for each of the 9 levels (not to mention different values of tau). Plus, I would eventually like to do some non-linear fits, and then it will be even worse. I'm sure there must be a way to do this with a matrix of coefficients, if only my poor memory of linear algebra didn't prevent me from seeing it. So, my question is, is there a simple straightforward way to generate the predicted values without having to manually add up all the relevant coefficients for each level? Or, even better, is predict.rq out there somewhere that I haven't found? The help on rq objects does refer to it, but ?predict.rq doesn't turn up anything. Thanks for any help, Matt Landis R. Matthew Landis, Ph.D. Dept. Biology Middlebury College Middlebury VT 05753 tel. 802/443.3484 fax.802/443.2072 [[alternative HTML version deleted]]
Dear statistics and R experts, I'm reposting the following message - I orginally posted it last Friday, and generated exactly no response. I assume it got lost over the weekend (either that or it is just unbelievably obvious!). I would like to plot the predicted values from a quantile regression analysis (quantreg v.3.31; R v.1.7.1) so that I can evaluate the fit. I fit the model using something like: fit.rq <- rq(growth ~ ht*spp*light, tau = 0.9) My response variable is tree growth (continuous), and my predictor variables are height (continuous), species (factor with 3 levels), and light (ordered factor with 3 levels). I'd like to look at the relationship between growth and height separately for each combination of species and light. I would simply use 'predict()' as in lm, but unfortunately, there does not seem to be a predict method for rq objects (unless I am missing something?). I know how to extract coefficients from the rq object, and I've calculated predicted values by simply adding the relevant coefficients for a particular level of spp*light as: intercept <- fit.rq$coef[1,1] + fit.rq$coef[3,1] + ...; slope <- fit.rq$coef[2,1] + fit.rq$coef[5,1] +...) but this is slow and awkward to do for each of the 9 levels (not to mention different values of tau). Plus, I would eventually like to do some non-linear fits, and then it will be even worse. I'm sure there must be a way to do this with a matrix of coefficients, if only my poor memory of linear algebra didn't prevent me from seeing it. Is there a simple straightforward way to generate the predicted values without having to manually add up all the relevant coefficients for each level? Or, even better, is predict.rq out there somewhere that I haven't found? The help on rq objects does refer to it, but ?predict.rq doesn't turn up anything. Thanks for any help, Matt R. Matthew Landis, Ph.D. Dept. Biology Middlebury College Middlebury VT 05753 tel. 802/443.3484 fax.802/443.2072 [[alternative HTML version deleted]]