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>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
On Aug 5, 2010, at 6: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 >> > > 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.The group mean is correctly calculated.> > I compile the R 2.11.1 in the Fedora 13. > Should i download a library?That would not appear to be necessary: > x= 1:100 > y=1:100 > lm(y~x) Call: lm(formula = y ~ x) Coefficients: (Intercept) x -5.684e-14 1.000e+00> Some configure options are missing during the installation? or is a > bug?Not sure. To determine that you would need to read the help page very carefully and determine whether putting such raw expressions into a location where formulas were generally used actually is allowed. A bit of experimentation shows that it is probably the rhs logic (as was also suggested by the warning message) where the issue arises. > lm (seq(1:100)~., data=list(a=1:100)) Call: lm(formula = seq(1:100) ~ ., data = list(a = 1:100)) Coefficients: (Intercept) a -5.684e-14 1.000e+00 Read the help page for formula and note the section regarding the I() function: > lm(seq(1:100)~I(seq(1:100)) ) Call: lm(formula = seq(1:100) ~ I(seq(1:100))) Coefficients: (Intercept) I(seq(1:100)) -5.684e-14 1.000e+00> Thanks in advance > Giuseppe AmatulliDavid Winsemius, MD West Hartford, CT
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.
Possibly Parallel Threads
- confidence / prediction ellipse
- Basic question: why does a scatter plot of a variable against itself works like this?
- how to assess the significance of regression between a set of response and predictor variables
- Ranked predictor and response variable analysis
- "model.response" error