Skip to content
Prev 2461 / 398506 Next

basic question about lm summaries

On Thu, 22 Apr 1999, andy bernat wrote:

            
You need to find out where that error message is coming from, by 
traceback(). The documentation for the function giving the error
probably mentions n.

I won't try to solve the problem (you need to send us an example to
reproduce), but I will try to help make using R easier.

-- use  lm(CRIME ~ INCOME + HOUSING, data=data). That is easier to read
   (it would be even easier without the capitals) and ensures that the
   variables are searched for in `data', which I hope is a data frame (but
   lists work too, I believe).

-- Don't ever call methods unless you mean to do something very unusual. Do
   summary(lm(CRIME ~ INCOME + HOUSING, data=data))

-- Unless you really need them, avoid assignments as arguments. They are
   hard to read and easy to miss when skimming code. In other words, use

   lm.d1 <- lm(data$CRIME~data$INCOME+data$HOUSING)
   summary(lm.d1)

-- Try the opposite convention, d1.lm. Names with a system name . something 
   are normally either methods or helper functions.  And surely it is the
   data that is important here, not lm.

-- Avoid names like `data'.  One guess as to the root of your problem is
   that another object named `data' (other than the one you meant) is 
   being found. Now, some analysis suggests that is unlikely, but if the 
   data frame had been called `UScrime' I would have had no analysis to do.