[R] Plotting of the lm

Gavin Simpson gavin.simpson at ucl.ac.uk
Tue Sep 23 11:41:35 CEST 2003


Try this:

plot(x, y)
abline(lm(y ~ x)) #plots the fitted line

or this if you need the model results elsewhere:

mod.lm <- lm(y ~ x)   # store the model
plot(x, y)            # plot the data
abline(mod.lm)        # plot the fitted line

see ?plot.lm and ?abline

HTH

Gav

Melissa_Kuang at jltgroup.com wrote:

> Hi,
> 
> I would like to enquire if by typing plot (lm(y~x)) would this show me the
> plot of the fitted line? I tried this function previously but I was only
> able to get the last 4 plots starting with Residuals vs fitted. 
> 
> Thank You.
> 
> Melissa
> 
> 
> ************************************************************
> JLT Risk Solutions Ltd
> 6 Crutched Friars, London EC3N 2PH. Co Reg No 1536540
> Tel: (44) (0)20 7528 4000   Fax: (44) (0)20 7528 4500
> http://www.jltgroup.com
> Lloyd's Broker.  Regulated by the General Insurance
> Standards Council
> ------------------------------------------------------------
> The content of this e-mail (including any attachments) as 
> received may not be the same as sent. If you consider that 
> the content is material to the formation or performance of 
> a contract or you are otherwise relying upon its accuracy, 
> you should consider requesting a copy be sent by facsimile 
> or normal mail.  The information in this e-mail is 
> confidential and may be legally privileged. If you are not 
> the intended recipient, please notify the sender immediately 
> and then delete this e-mail entirely - you must not retain, 
> copy, distribute or use this e-mail for any purpose or 
> disclose any of its content to others.
> 
> Opinions, conclusions and other information in this e-mail 
> that do not relate to the official business of JLT Risk 
> Solutions Ltd shall be understood as neither given nor 
> endorsed by it.  Please note we intercept and monitor 
> incoming / outgoing e-mail and therefore you should neither 
> expect nor intend any e-mail to be private in nature.
> 
> We have checked this e-mail for viruses and other harmful 
> components and believe but not guarantee it virus-free prior 
> to leaving our computer system.  However, you should satisfy 
> yourself that it is free from harmful components, as we do 
> not accept responsibility for any loss or damage it may 
> cause to your computer systems.
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 
> 

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Gavin Simpson                     [T] +44 (0)20 7679 5522
ENSIS Research Fellow             [F] +44 (0)20 7679 7565
ENSIS Ltd. & ECRC                 [E] gavin.simpson at ucl.ac.uk
UCL Department of Geography       [W] http://www.ucl.ac.uk/~ucfagls/cv/
26 Bedford Way                    [W] http://www.ucl.ac.uk/~ucfagls/
London.  WC1H 0AP.
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%




More information about the R-help mailing list