Quantcast
Channel: Active questions tagged lm - Stack Overflow
Viewing all articles
Browse latest Browse all 105

Error when trying to produce a residual panel plot using a polynom in an lm

$
0
0

I think I've encountered a bug when plotting diagnostic plots for models made with lm() including a poly() term using ggResidPanel::resid_panel().

df <- data.frame(x=rnorm(100),                 y=rnorm(100))limo <- lm(y~poly(x, degree=2, raw=T), data=df)summary(limo)resid_panel(limo) ### this is where the error isError in [<-.data.frame`(`*tmp*`, , i, value = c("poly(x, degree = 2): 0.95", :   replacement has 200 rows, data has 100

I initially thought this could have something to do with the specifications of the poly function, e.g., the orthogonalization of the the linear and polynomial terms, but have exhausted all of the settings in the poly() function.

I do not know how the poly() function "names" the terms, but am now thinking that there is some bugginess, which is why the error thinks that there are 200 rows for x when there only should be 100.

Any pointers, alternatives to poly() or corrections to poly would be highly appreciated.


Viewing all articles
Browse latest Browse all 105

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>