# [R] ploting a linear model

Ott Toomet siim at obs.ee
Thu May 16 10:33:52 CEST 2002

```On 15 May 2002, Ernesto Jardim wrote:

|I have the result of a linear model "lm98" and I want to plot it to
|analyse the regression but I'm getting the folowing error message
|
|> lm98<-lm(log(U+1)~Bq+Gi+Lv+Tb+Bq:Gi+Bq:Lv+Bq:Tb+Gi:Lv+Gi:Tb+Lv:Bq)
|> plot(lm98)
|Error in plot.window(xlim, ylim, log, asp, ...) :
|        need finite ylim values
|NaNs produced in: sqrt(1 - hii)

You should try to describe and investigate the problem better.  As you can
see, the problem arises in plot.lm(). Typing plot.lm (note -- without
parentheses) on command prompt, you can find a part of the plotting routine
which include ,,hii'':

hii <- lm.influence(x)\$hat
w <- weights(x)
r.w <- if (is.null(w))
r
else (sqrt(w) * r)[w != 0]
rs <- r.w/(s * sqrt(1 - hii))

?lm.influence says that

Value:
A list containing the following components:
hat: a vector containing the diagonal of the `hat'' matrix.

Hat matrix (at least it is common notion in econometrics) is

H <- X %*% solve( t(X) %*% X) %*% t(X)

Your problem is associated with the fact that any of the diagonal elements
is greater than 1.  This is probably due to numerical problems, caused by
near-singular matrices.

You should carefully look at your data.  Have you checked for
multicollinearity?  Does the results from summary(lm(...)) seem reasonable?
What do say specification tests?

Perhaps it helps

Cheers,

Ott

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

```