dm 'log;clear;output;clear'; options ps=512 ls=105 nocenter nodate nonumber nolabel FORMCHAR="|----|+|---+=|-/\<>*"; ODS listing; ods graphics on; ods html close; ODS HTML style=minimal body='Battleship Weight.html'; ******************************************************; *** EXST700x Lab: Regression Example ***; *** Weight of Royual Navy line-of-battle ships ***; *** All ships are first rate 3-deck battleships ***; *** built between 1620 and 1839 ***: *** - - - - - - - - - - - - - - - - - - - - - - - -************; *** Source: Lavery, Brian, The Ship of the Line Volume I, ***; *** pub Conway Maritime Press, 1983 ***; *** In http://en.wikipedia.org/wiki/File:Weight_Growth_of_ ***; *** RN_First_Rate_Line-of-Battle_Ships_1630-1875.svg ***; ***************************************************************; TITLE1 'Simple linear Regression Example (SLR)'; DATA ONE; LENGTH name $ 21; INFILE "Battleship Weight.csv" missover DSD dlm="," firstobs=2; TITLE2 'Change in weight of sail powered battle ships from 1637 to 1833'; INPUT Launched Tonnage Name $ ; LABEL Name = 'Name of the ship' Launched = 'Year of launch' Tonnage = 'Weight in tons'; datalines; ; RUN; *PROC PRINT DATA=ONE; TITLE2 'Data for Battleship weights'; RUN; proc plot data=one; plot Tonnage*Launched; TITLE3 'Raw data scatterplot'; options ps=52 ls=111 ; run; options ps=512 ls=99; PROC REG DATA=ONE LINEPRINTER; TITLE3 'Regression with confidence limits'; MODEL Tonnage = Launched / clb CLI CLM P R; ID Launched; SlopeTest:TEST Launched = 6.2; OUTPUT OUT=NEXT P=Predicted R=Resid STUDENT=student rstudent=rstudent lcl=lcl lclm=lclm ucl=ucl uclm=uclm; RUN; OPTIONS PS=45; TITLE4 'Plots of raw data & residuals'; PLOT PREDICTED.*Launched='P' Tonnage*Launched='O' / OVERLAY; PLOT RESIDUAL.*Launched='E'; RUN; QUIT; proc plot data=next; plot rstudent * Launched = name / vref = -2.030 0 +2.030; TITLE4 'Deleted standardized residuals with 95% interval'; options ps=52 ls=111 ; run; options ps=512 ls=99; proc print data=next; TITLE4 'Listing of output from PROC REG'; var Launched Tonnage Predicted Resid student rstudent lcl ucl lclm uclm; run; PROC UNIVARIATE DATA=NEXT NORMAL PLOT; VAR Resid; TITLE4 'Residual analysis with PROC UNIVARIATE'; ods exclude BasicMeasures ExtremeObs ExtremeValues Modes MissingValues Quantiles TestsForLocation; histogram Length / normal; RUN; ods html close; run; quit;