Hello fellow R-users, I’m stuck with something i think is pretty stupid, but i can’t find out where i’m wrong, and it’s turning me crazy! I am doing a very simple linear regression with Northing/Easting data, then I plot the data as well as the regression line :> plot(x=Dataset$EASTING,y=Dataset$NORTHING)> fit <- lm(formula = NORTHING ~ EASTING,data = Dataset)> abline(fit) > fitCall: lm(formula = NORTHING ~ EASTING, data Dataset) Coefficients: (Intercept) EASTING 5.376e+05 4.692e-02 Later on, when I use the command “abline” with the coefficient provided by “summary(fit)”, the line is not the same as abline(fit) ! To summarize, those two lines are different:> abline(fit) >abline(5.376e+05, 4.692e-02) The “b” coefficients appear equal, but the intercepts are different. Where am I missing something? L Thanks [[alternative HTML version deleted]]
You don't provide a reproducible example, but my first guess is that the print method is rounding what appears on the screen, so you aren't actually using the slope and intercept. See ?print.default and the digits argument under ?options for more. Why do you need to copy and paste the coefficients? Just to check your understanding? Sarah On Thursday, December 13, 2012, Robert U wrote:> Hello fellow > R-users, > > I’m stuck > with something i think is pretty stupid, but i can’t find out where i’m > wrong, > and it’s turning me crazy! > > I am doing > a very simple linear regression with Northing/Easting data, then I plot the > data as well as the regression line : > > > plot(x=Dataset$EASTING, > y=Dataset$NORTHING) > > fit <- lm(formula = NORTHING ~ EASTING, > data = Dataset) > > abline(fit) > > fit > > Call: > lm(formula = NORTHING ~ EASTING, data > Dataset) > > Coefficients: > (Intercept) EASTING > 5.376e+05 4.692e-02 > > Later on, when I use the > command “abline” with the coefficient provided by “summary(fit)”, the line > is > not the same as abline(fit) ! > > To summarize, > those two lines are different: > > > abline(fit) > > > abline(5.376e+05, 4.692e-02) > > The “b” coefficients > appear equal, but the intercepts are different. > > Where am I missing > something? L > > Thanks > [[alternative HTML version deleted]] > >-- Sarah Goslee http://www.stringpage.com http://www.sarahgoslee.com http://www.functionaldiversity.org [[alternative HTML version deleted]]
Easting and northing data uses numbers requiring more digits than R's default of 7. In all the years I've used R, the only time I've needed to adjust the default digits is with easting and northing data. Try something like options(digits = 11) HTH On Thu, 13-Dec-2012 at 03:22PM +0000, Robert U wrote: |> Hello fellow |> R-users, |> ?? |> I???m stuck |> with something i think is pretty stupid, but i can???t find out where i???m wrong, |> and it???s turning me crazy! |> ?? |> I am doing |> a very simple linear regression with Northing/Easting data, then I plot the |> data as well as the regression line : |> ?? |> > plot(x=Dataset$EASTING, |> y=Dataset$NORTHING) |> > fit <- lm(formula = NORTHING ~ EASTING, |> data = Dataset) |> > abline(fit) |> > fit |> ?? |> Call: |> lm(formula = NORTHING ~ EASTING, data |> Dataset) |> ?? |> Coefficients: |> (Intercept)?????????? EASTING?? |> ?? 5.376e+05?????? 4.692e-02?? |> ?? |> Later on, when I use the |> command ???abline??? with the coefficient provided by ???summary(fit)???, the line is |> not the same as abline(fit) ! |> ?? |> To summarize, |> those two lines are different: |> ?? |> > abline(fit) |> > |> abline(5.376e+05, 4.692e-02) |> ?? |> The ???b??? coefficients |> appear equal, but the intercepts are different. |> ?? |> Where am I missing |> something? L |> ?? |> Thanks |> [[alternative HTML version deleted]] |> |> ______________________________________________ |> 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. -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___ Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_ Average minds discuss events (:_~*~_:) Small minds discuss people (_)-(_) ..... Eleanor Roosevelt ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.