[R] predict.lm(...,type="terms") question

David Winsemius dwinsemius at comcast.net
Thu Aug 30 05:57:25 CEST 2012


On Aug 29, 2012, at 4:08 PM, John Thaden wrote:

> Draper & Smith sections (3.2, 9.6) address prediction interval  
> issues, but
> I'm also concerned with the linear fit itself. The Model II regression
> literature

Citations?

> makes it abundantly clear that OLS regression of x on y
> frequently yields a different line than of y on x. The example below  
> is not
> so extreme, but those given e.g. by Ludbrook, J. (2012)

...  to a source that does not require a fee of US$30?


> certainly are. Rui
> notes the logical problem of imputing an unknown x using a calibration
> curve where the x values are without error. Regression x on y  
> doesn't help
> that.  But on a practical level, I definitely recall (years ago) using
> predict.lm and newdata to predict x terms. I wish I remembered how.

You may be thinking of "orthogonal regression" or or "Deming  
regression" or one of its many other names. There is abundant code in  
the (free) archives regarding this topic. Please do be clear about  
what you really do desire. If you think there is a correct answer to  
your problem in a particular case, then by all means ... post that.  
Just saying predict)lm)...)) is not right,  is not sufficient.

-- 
David
>
>
> require(stats)
> #Make an illustrative data set
> set.seed(seed = 1111)
> dta <- data.frame(
>    area = c(
>        rnorm(6, mean = 4875, sd = 400),
>        rnorm(6, mean = 8172, sd = 800),
>        rnorm(6, mean = 18065, sd = 1200),
>        rnorm(6, mean = 34555, sd = 2000)),
>    concn = rep(c(25, 50, 125, 250), each = 6))
> model <- lm(area ~ concn, data = dta)
> inv.model <- lm(concn ~ area, data = dta)
> plot(area ~ concn, data = dta)
> abline(model)
> inv.new = cbind.data.frame(area = c(1600, 34000))
> inv.pred <- predict(inv.model, newdata = inv.new)
> lines(x = inv.pred, y = unlist(inv.new), col = "red")
>
> _____________________________
> Ludbrook, J. (2012). "A primer for biomedical scientists on how to  
> execute
> Model II linear regression analysis." Clinical and Experimental
> Pharmacology and Physiology 39(4): 329-335.
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.

David Winsemius, MD
Alameda, CA, USA




More information about the R-help mailing list