[R] linear model with similar response predictor
Erik Iverson
eriki at ccbr.umn.edu
Thu Aug 5 15:25:44 CEST 2010
On 08/05/2010 05:50 AM, Giuseppe Amatulli wrote:
> Hi,
> can somebody tell me why R is not able to calculate a linear model
> written in this way?
>
>> lm (seq(1:100)~seq(1:100))
>
> Call:
> lm(formula = seq(1:100) ~ seq(1:100))
>
> Coefficients:
> (Intercept)
> 50.5
>
> Warning messages:
> 1: In model.matrix.default(mt, mf, contrasts) :
> the response appeared on the right-hand side and was dropped
> 2: In model.matrix.default(mt, mf, contrasts) :
> problem with term 1 in model.matrix: no columns are assigned
>>
Essentially, I believe it's because you're using the same syntax on the
LHS and RHS of the formula.
Try this, (and 'seq' is redundant in your example):
x <- 1:100
y <- 1:100
lm(y ~ x)
Call:
lm(formula = y ~ x)
Coefficients:
(Intercept) x
-1.121e-14 1.000e+00
>
> Seems that is not able to dealing with similar number and so with very
> small numbers for calculating the coefficients. Moreover also
> Intercepts is wrong it should be equal to 0.
>
> I compile the R 2.11.1 in the Fedora 13.
> Should i download a library?
> Some configure options are missing during the installation? or is a bug?
> Thanks in advance
> Giuseppe Amatulli
>
> ______________________________________________
> 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.
More information about the R-help
mailing list