/
Overviewperspscatter3dScatterplot3d Overviewperspscatter3dScatterplot3d

Overviewperspscatter3dScatterplot3d - PDF document

giovanna-bartolotta
giovanna-bartolotta . @giovanna-bartolotta
Follow
369 views
Uploaded On 2016-07-10

Overviewperspscatter3dScatterplot3d - PPT Presentation

rockchalkOutline 1 Overview 2 persp 3 scatter3d 4 Scatterplot3d 5 rockchalk mcGraph plotPlane DescriptiveKU Overviewperspscatter3dScatterplot3d rockchalkOutline 1 Overview 2 persp 3 scatter3d 4 Scat ID: 398770

rockchalkOutline 1 Overview 2 persp 3 scatter3d 4 Scatterplot3d 5 rockchalk mcGraph plotPlane DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkOutline 1 Overview 2 persp 3 scatter3d 4 Scat

Share:

Link:

Embed:

Download Presentation from below link

Download Pdf The PPT/PDF document "Overviewperspscatter3dScatterplot3d" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Overviewperspscatter3dScatterplot3d rockchalkOutline 1 Overview 2 persp 3 scatter3d 4 Scatterplot3d 5 rockchalk mcGraph plotPlane DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkOutline 1 Overview 2 persp 3 scatter3d 4 Scatterplot3d 5 rockchalk mcGraph plotPlane DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkKindsof3dPlot Static\drawonthescreen,likeRplot" persp:intheRbasegraphics cloudinlatticepackage scatterplot3d scatter3d:byJohnFoxforthecarpackage,usesOpenGL(computer3dprogramminglibrary) interactiveandeasytogetstarted canbeaccessedfromFox'sRcmdrpackageinterface naloutputnotaslikelytobe\publishable" DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkHere'swhatweusuallywantthe3dPlotFor Showthe\cloud"ofpointsscatteredinspace Showthe\predictedplane"ofa ttedregressionmodel perspcandothesethings,althoughitissomewhattoughtograspat rst Whykeeptrying:perspisinthebaseofR,soifsomethingiswrongwithit,itislikelysomebodywillknowhowto xit. Ifyoushowupinr-helpaskingabout3Dplotting,manyfolkstherewillsuggestyoulearnpersp,sincemostotherroutinesdrawuponitsconcepts. DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkOutline 1 Overview 2 persp 3 scatter3d 4 Scatterplot3d 5 rockchalk mcGraph plotPlane DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkperspisthePlacetoStart Thekeythingtounderstand:ifyourvariablesarex1,x2(theinputs),andz(theoutput),perspdoesnot\want"yourvariableslikethis persp(x1,x2,z) persprequires\plottingsequences"forx1andforx2.Thesearenotobservedvalues,butrathersequencesfromtheminimumscoretothemaximum. For\realdata,"x1,forexample,gettherange,thenmakeasequence: x1r range(x1) x1seq seq(x1r[1],x1r[2],length.out=30) ##orusetherockchalkshort-cut x1seq plotSeq(x1,length.out=30) DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkCreateSomeDataforaRegression... x10.205600.085382.4080.0179* x20.208550.044734.6621e�05** * ��� Signif.codes:0'***'0.001'**'0.01'*'0.05'. '0.1''1 Residualstandarderror:0.942on97degreesof freedom MultipleR2:0.2082,AdjustedR2:0.1919 F�statistic:12.76on2and97DF,p�value:1 .207e�05 DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkCreatethepredictorsequences x1r range(dat$x1) x1seq seq(x1r[1],x1r[2],length=30) x2r range(dat$x2) x2seq seq(x2r[1],x2r[2],length=30) DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkCreatethezmatrix z outer(x1seq,x2seq,function(a,b)predict(m1 ,newdata=data.frame(x1=a,x2=b))) DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkManyOpportunitiesforBeauti cation xlim,ylim,zlimplaysameroleasinordinaryRplots xlab,ylab,zlabsame thetaandphicontroltheviewingangle. thetamovestheviewingangleleftandright phimovesitupanddown. Example,this\raises"one'sviewingangle(anegativevaluewouldlowerit) persp(x=x1seq,y=x2seq,z=z,phi=40) Example,this\rotates"one'sviewingangletotheleft persp(x=x1seq,y=x2seq,z=z,theta=�20) DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalk persp(x=x1seq,y=x2seq,z =z,zlim=c(�3,3),theta =40) persp(x=x1seq,y=x2seq,z =z,zlim=c(�3,3),theta =40,phi=�20) DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkOutline 1 Overview 2 persp 3 scatter3d 4 Scatterplot3d 5 rockchalk mcGraph plotPlane DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkAskForanOrdinaryandaSmoothedRegressionSurface scatter3d(yx1+x2,data=dat,fit=c("linear"," additive")) rgl.snapshot(filename="scat3.png",fmt="png") DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkEvaluation scatter3dmakesitveryeasytogetstarted TheGUIinRcmdrmakesiteveneasier! Greatforquick&dirtydataexploration Disadvantages Outputqualitynotsuitableforpresentation(labelsnot\sharp") pngonlyworkableoutputformatatcurrenttime(othersgenerateHUGE les) DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkscatterplot3d:QuiteaBitlikeplot DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkscatterplot3d:QuiteaBitlikeplot DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkAddaplanefroma ttedmodel! library(scatterplot3d) s3d scatterplot3d(dat,type="p",color=" blue",angle=55,pch=16,main=" scatterplot3d") s3d$plane3d(m1) Notes3disthe3dplotobject,itistoldtodrawplanecorrespondingtomodelm1 That\internalizes"the\translateto3dcoordinates"worksthatpersprequiredustodoexplicitly suppliesfunction\xyz.convert"whenexplicittranslationfrom3dto2disrequired(inplacingtextorlines) DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkAddResidualLines:QuiteaBitLikeUsingpersp s3d scatterplot3d(dat,type="p",color=" blue",angle=55,pch=16,main=" scatterplot3d") s3d$plane3d(m1,lty="dotted",lwd=0.7) obser2d s3d$xyz.convert(dat$x1,dat$x2,dat$y) pred2d s3d$xyz.convert(dat$x1,dat$x2,fitted( m1)) segments(obser2d$x,obser2d$y,pred2d$x,pred2d$y, lty=4) DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkscatterplot3d DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkThe rststepistheemptybox x1 x2 seq(�10,10,length=51) dens matrix(dmvnorm(expand.grid(x1,x2),sigma =rbind(c(3,2),c(2,3))),ncol=length(x1)) s3d scatterplot3d(x1,x2,seq(min(dens),max( dens),length=length(x1)),type="n",grid =FALSE,angle=70,zlab=expression(f(x[1], x[2])),xlab=expression(x[1]),ylab= expression(x[2]),main="Bivariatenormal distribution")Note:type="n",justlike2Dplotfunction DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkDrawthelinesfromOneEndtotheOther for(iinlength(x1):1)f s3d$points3d(rep(x1[i],length(x2)),x2,dens[ i,],type="l") g inEnglish:foreachvalueofx1,drawalinefrom\fronttoback"thattracesoutthedensityat(x1,x2). Theforloopgoestoeachvalueofx1 for(iinlength(x1):1)f... insertspointsfromlowestx2tohighestx2andconnectsthembyaline s3d$points3d(...type=l) DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkLinesinOneDirection DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkUseR'stextfunctionwithplotmathtoWriteEquation text(s3d$xyz.convert(�1,10,0.07),labels=expression(f(x)==frac (1,sqrt((2*pi)^n*phantom(".")*det(Sigma[X])))*phantom( ".")*exp*fbgroup("(",�scriptstyle(frac(1,2)*phantom(" ."))* (x�mu)^T*Sigma[X]^�1*(x�mu),")")g)) ###fix.insert{}aroundSigma[X]==...## text(s3d$xyz.convert(1.5,10,0.05),labels=expression("with"* phantom("m")*mu==bgroup("(",atop(0,0),")")*phantom("." )*","*phantom(0)*fSigma[X]==bgroup("(",atop(3* phantom(0)*2,2*phantom(0)*3),")")g))The rstoneistheprobabilitydensityfunction(PDF)ThesecondoneistheExpectedValueandVariancematrix DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkUsePlotmath DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkDepictingMulticollinearity:My rst3dfunctions mcGraph1(x1,x2,y):Createsan\emptybox"showingthefootprintofthe(x1,x2)pairsinthebottomofthedisplay. mcGraph2(x1,x2,y,rescaley=0.5):Showspoints\risingabove"footprint mcGraph3(x1,x2,y): tsaregressionofyonx1andx2,andplotsit.Includesoptionalinteractionterm. DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkmcGraph1 Novaluesdrawnyetfordependentvariable Pleasenoticedispersioninthex1-x2plane mod1 mcGraph1(dat$x1,dat$x2,dat$y,theta=�30, phi=8) DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkmcGraphusesrescaleyargument Thetruerelationshipisyi=:2x1i+:2x2i+ei;eiN(0;72) x1;x2=0:1 mod mcGraph2(dat$x1,dat$x2,dat$y,rescaley= 0.1,theta=�30) DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkStepuprescaleybitbybit,itsalmostamovie! Thetruerelationshipisyi=:2x1i+:2x2i+ei;eiN(0;72) mod mcGraph2(dat$x1,dat$x2,dat$y,rescaley= 0.3,theta=�30) DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkStepuprescaleybitbybit,itsalmostamovie! Thetruerelationshipisyi=:2x1i+:2x2i+ei;eiN(0;72) mod mcGraph2(dat$x1,dat$x2,dat$y,rescaley= 0.4,theta=�30) DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkStepuprescaleybitbybit,itsalmostamovie! Thetruerelationshipisyi=:2x1i+:2x2i+ei;eiN(0;72) mod mcGraph2(dat$x1,dat$x2,dat$y,rescaley= 0.5,theta=�30) DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkStepuprescaleybitbybit,itsalmostamovie! Thetruerelationshipisyi=:2x1i+:2x2i+ei;eiN(0;72) mod mcGraph2(dat$x1,dat$x2,dat$y,rescaley= 0.7,theta=�30) DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkStepuprescaleybitbybit,itsalmostamovie! Thetruerelationshipisyi=:2x1i+:2x2i+ei;eiN(0;72) mod mcGraph2(dat$x1,dat$x2,dat$y,rescaley= 0.80,theta=�30) DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkStepuprescaleybitbybit,itsalmostamovie! Thetruerelationshipisyi=:2x1i+:2x2i+ei;eiN(0;72) mod mcGraph2(dat$x1,dat$x2,dat$y,rescaley= 1.0,theta=�30) DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkCanSpintheCloud(JustShowingO ) mod mcGraph2(dat$x1,dat$x2,dat$y,rescaley= 1.0,theta=20) DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkCanSpintheCloud(JustShowingO ) mod mcGraph2(dat$x1,dat$x2,dat$y,rescaley= 1.0,theta=40) DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkCanSpintheCloud(JustShowingO ) mod mcGraph2(dat$x1,dat$x2,dat$y,rescaley= 1.0,theta=80) DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkRegressionPlaneSitsNicelyintheDataCloud M1Estimate(S.E.) (Intercept)-0.678(4.345)x10.18*(0.066)x20.229*(0.069) N100RMSE6.717R20.194adjR20.178 p0:05 mod1 mcGraph3(dat$x1,dat$x2,dat$y,theta= �30) DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkSevereCollinearity:r(x1,x2)=0.9 Nearlylineardispersioninthex1-x2plane mod2 mcGraph1(dat2$x1,dat2$x2,dat2$y,theta =20,phi=8) DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkCloudIsMorelikeDataTube mod mcGraph2( dat2$x1,dat2$ x2,dat2$y, theta=�30) DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkFitInteractionlm(yx1*x2) M1Estimate(S.E.) (Intercept)4.997(17.977)x10.324(0.394)x2-0.058(0.4)x1:x20.001(0.007) N100RMSE7.199R20.166adjR20.14 p0:05 mod mcGraph3(dat2$x1,dat2$x2,dat2$y, interaction=TRUE,theta=�30) DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkNextStep:PlotanyFittedRegression AftermcGraphworked,Iwasencouraged(becauseIcould llupawholelectureonmulticollinearity) ButthemcGraphinterfacewastoolimiting hadtospecifyandprovidevariables couldnotworkwithlargerregressionmodels DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkplotPlane:choosex1andx2 plotPlane(m1, plotx1="x1", plotx2="x2" ,theta=�40, npp=8,llwd =0.105, drawArrows= TRUE,ticktype ="detailed") DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkNextStep:VisualizationofFactorPredictors Supposex2isacategoricalvariable. Shouldn'tforcethattoanumericscaleand3Dplotwithanordinaryplane,shouldwe? latticepackagetoolscandrawoneplotperlevelofthefactor(maybethat'sbest) ButI'vewrestledtryingto ndamoreinformativeview DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkGroup1 DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkGroups1-4 DescriptiveK.U. Overviewperspscatter3dScatterplot3d rockchalkConclusion Ifyoucan\sketch"whatyouwantwithapencil,youcanprobablygetRtodrawyouagoodexample. Search(AGGRESSIVELY)forworkingexamplecodefromproblemslikeyours.Accumulatethemwheneveryou ndthem. Ifyouwantaquickviewofaregressionmodel{eitherlinearornotlinear{I'dsuggestplotPlane DescriptiveK.U.

Related Contents


Next Show more