# [R] problem w/ lm() ?

Francisco Cribari cribari at de.ufpe.br
Wed Jan 13 16:37:37 CET 1999

Does this help? Thanks a lot. Best, FC.

R : Copyright 1998, The R Development Core Team
Version 0.63.1 Beta (Dec 5, 1998)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type    "?license" or "?licence" for distribution details.

R is a collaborative project with many contributors.
Type    "?contributors" for a list.

Type    "demo()" for some demos, "help()" for on-line help, or
"help.start()" for a HTML browser interface to help.
Type    "q()" to quit R.

[Previously saved workspace restored]

> ls()
character(0)
> data(women)
> names(women)
[1] "height" "weight"
> women
height weight
1      58    115
2      59    117
3      60    120
4      61    123
5      62    126
6      63    129
7      64    132
8      65    135
9      66    139
10     67    142
11     68    146
12     69    150
13     70    154
14     71    159
15     72    164
> hw.sum <- summary(lm(weight ~ height, data = women)) # avoids printing
> hw.sum # I believe this provokes the error

Call:
lm(formula = weight ~ height, data = women)

Residuals:
Min      1Q  Median      3Q     Max
-1.7333 -1.1333 -0.3833  0.7417  3.1167

Coefficients:
Error: binary operator applied to invalid types
> traceback()
[1] "print.coefmat(x\$coef, digits = digits, signif.stars = signif.stars,
"
[2] "    ...)"

[3] "print.summary.lm(structure(list(call = lm(formula = weight ~ "

[4] "    height, data = women), terms = weight ~ height, residuals =
structure(c(2.416667, "
[5] "0.9666667, 0.5166667, 0.06666667, -0.3833333, -0.8333333, -
1.283333, "
[6] "-1.733333, -1.183333, -1.633333, -1.083333, -0.5333333, 0.01666667,
"
[7] "1.566667, 3.116667), .Names = c(\"1\", \"2\", \"3\", \"4\", \"5\",
\"6\", "
[8] "\"7\", \"8\", \"9\", \"10\", \"11\", \"12\", \"13\", \"14\",
\"15\")), coefficients = structure(c(-87.51667, "
[9] "3.45, 5.936944, 0.0911365, -14.74103, 37.85531, 1.711082e-009, "

[10] "1.088019e-014), .Dim = c(2, 4), .Dimnames = list(c(\"(Intercept)\",
"
[11] "\"height\"), c(\"Estimate\", \"Std. Error\", \"t value\",
\"Pr(>|t|)\"))), "
[12] "    sigma = 1.525005, df = c(2, 13, 2), r.squared = 0.9910098, "

[13] "    adj.r.squared = 0.9903183, fstatistic = structure(c(1433.024, "

[14] "    1, 13), .Names = c(\"value\", \"numdf\", \"dendf\")),
cov.unscaled = structure(c(15.15595, "
[15] "    -0.2321429, -0.2321429, 0.003571429), .Dim = c(2, 2), .Dimnames
= list("
[16] "        c(\"(Intercept)\", \"height\"), c(\"(Intercept)\",
\"height\""
[17] "        )))), .Names = c(\"call\", \"terms\", \"residuals\",
\"coefficients\", "
[18] "\"sigma\", \"df\", \"r.squared\", \"adj.r.squared\",
\"fstatistic\", \"cov.unscaled\""
[19] "), class = \"summary.lm\"))"

> print.default(hw.sum)
\$call
lm(formula = weight ~ height, data = women)

\$terms
weight ~ height
attr(,"variables")
list(weight, height)
attr(,"factors")
height
weight      0
height      1
attr(,"term.labels")
[1] "height"
attr(,"order")
[1] 1
attr(,"intercept")
[1] 1
attr(,"response")
[1] 1

\$residuals
1           2           3           4           5           6
7
2.41666667  0.96666667  0.51666667  0.06666667 -0.38333333 -0.83333333 -
1.28333333
8           9          10          11          12          13
14
-1.73333333 -1.18333333 -1.63333333 -1.08333333 -0.53333333  0.01666667
1.56666667
15
3.11666667

\$coefficients
Estimate Std. Error   t value     Pr(>|t|)
(Intercept) -87.51667  5.9369440 -14.741031.711082e-009
height        3.45000  0.0911365  37.855311.088019e-014

\$sigma
[1] 1.525005

\$df
[1]  2 13  2

\$r.squared
[1] 0.9910098

\$adj.r.squared
[1] 0.9903183

\$fstatistic
value    numdf    dendf
1433.024    1.000   13.000

\$cov.unscaled
(Intercept)       height
(Intercept)  15.1559524 -0.232142857
height       -0.2321429  0.003571429

attr(,"class")
[1] "summary.lm"
> debug(print.summary.lm)
> hw.sum
debugging in: print.summary.lm(structure(list(call = lm(formula = weight
~
height, data = women), terms = weight ~ height, residuals =
structure(c(2.416667,
0.9666667, 0.5166667, 0.06666667, -0.3833333, -0.8333333, -1.283333,
-1.733333, -1.183333, -1.633333, -1.083333, -0.5333333, 0.01666667,
1.566667, 3.116667), .Names = c("1", "2", "3", "4", "5", "6",
"7", "8", "9", "10", "11", "12", "13", "14", "15")), coefficients =
structure(c(-87.51667,
3.45, 5.936944, 0.0911365, -14.74103, 37.85531, 1.711082e-009,
1.088019e-014), .Dim = c(2, 4), .Dimnames = list(c("(Intercept)",
"height"), c("Estimate", "Std. Error", "t value", "Pr(>|t|)"))),
sigma = 1.525005, df = c(2, 13, 2), r.squared = 0.9910098,
adj.r.squared = 0.9903183, fstatistic = structure(c(1433.024,
1, 13), .Names = c("value", "numdf", "dendf")), cov.unscaled =
structure(c(15.15595,
-0.2321429, -0.2321429, 0.003571429), .Dim = c(2, 2), .Dimnames =
list(
c("(Intercept)", "height"), c("(Intercept)", "height"
)))), .Names = c("call", "terms", "residuals", "coefficients",
"sigma", "df", "r.squared", "adj.r.squared", "fstatistic", "cov.unscaled"
), class = "summary.lm"))
debug: #S: ' ' instead of '\n'
cat("\nCall:\n")
Browse[1]>

On 13 Jan 99, at 18:51, Peter Dalgaard BSA wrote:

> "Francisco Cribari" <cribari at de.ufpe.br> writes:
>
> > Any thoughts on the following? Am I missing something? [I am running R
> > for Windows 0.63.1 on a Win NT 4.0 (workstation, sevice pack #4) box.]
> > Thanks. FC.
> ...
> > > data(women)
> > > names(women)
> > [1] "height" "weight"
> > > summary(lm(weight ~ height, data = women))
> >
> > Call:
> > lm(formula = weight ~ height, data = women)
> >
> > Residuals:
> >     Min      1Q  Median      3Q     Max
> > -1.7333 -1.1333 -0.3833  0.7417  3.1167
> >
> > Coefficients:
> > Error: binary operator applied to invalid types
>
> This works on Unix 0.63.1, so no, you're not missing anything. Unless you
> have something important redefined when you load your workspace.
>
> To help debugging in, perhaps you could try something like:
>
> hw.sum <- summary(lm(weight ~ height, data = women)) # avoids printing
> hw.sum # I believe this provokes the error traceback()
> print.default(hw.sum) debug(print.summary.lm) hw.sum
>
>
> --
>    O__  ---- Peter Dalgaard             Blegdamsvej 3
>   c/ /'_ --- Dept. of Biostatistics     2200 Cph. N
>  (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
> ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
>

________________________________________________________________________

Francisco Cribari-Neto               voice: +55-81-2718420
Departamento de Estatistica          fax:   +55-81-2718422
Universidade Federal de Pernambuco   e-mail: cribari at de.ufpe.br
Recife/PE, 50740-540, Brazil         http://www.de.ufpe.br/~cribari/

Eat well, exercise, and die anyway.
________________________________________________________________________

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

More information about the R-help mailing list