CHAPTER14. CONDITIONINGANDPLOTTINGTHREEORMOREVARIABLES
153
·
Cansummarizeresponsevariableusingmultiplestatistics(e.g.,mean
andmedian)
·
Ifspecifya
fun
functionthatcandealspeciallywithmatrices,youcan
summarizemultiple–columnresponsevariables
·
Createsspecialobjectsandhasspecialmethodsforpresentingthem
print
methodforprintingatableinASCIItextformat
plot
methodforplottingtheresult(notavailablefor
method=’cross’
– L
A
T
E
X method fortypesetting the table, , allowing g the use ofmultiple
fonts,charactersizes,subscripts,superscripts,bold,etc.
·
Don’tplottheresultsof
summary.formula
usingoneofthetrellisfunc-
tions.
summarize
·
Similarpurposeas
aggregate
butwithsomedifferences
·
Willsummarizeonlyasingleresponsevariablebutthe
FUN
functioncan
summarizeitwithmanystatistics
·
Cancomputemultiplequantilesorupperandlowerlimitsforerrorbars
·
Will notconvertnumeric stratifiers to factors, so output is suitable for
summarizingdatafor
xyplot
or
xYplot
whenthestratificationvariable
needstobeonthe
x
–axis
·
Onlydoescross–classification
·
CreatesanordinarydataframesuitableforanyuseinS-P
LUS
,especially
forpassingasa
data
argumenttotrellisgraphicsfunctions
And paste pdf to powerpoint - application Library tool:C# Create PDF from PowerPoint Library to convert pptx, ppt to PDF in C#.net, ASP.NET MVC, WinForms, WPF
Online C# Tutorial for Creating PDF from Microsoft PowerPoint Presentation
www.rasteredge.com
And paste pdf to powerpoint - application Library tool:VB.NET Create PDF from PowerPoint Library to convert pptx, ppt to PDF in vb.net, ASP.NET MVC, WinForms, WPF
VB.NET Tutorial for Export PDF file from Microsoft Office PowerPoint
www.rasteredge.com
CHAPTER14. CONDITIONINGANDPLOTTINGTHREEORMOREVARIABLES
154
·
CanalsoeasilyusetheGUItographthisdataframe
method=function
with
xYplot
: Automatically y aggregates data to be plotted
whencentraltendencyandupperandlowerbandsareofinterest.
application Library tool:C# PDF Page Extract Library: copy, paste, cut PDF pages in C#.net
C#.NET PDF Library - Copy and Paste PDF Pages in C#.NET. Easy to C#.NET Sample Code: Copy and Paste PDF Pages Using C#.NET. C# programming
www.rasteredge.com
application Library tool:VB.NET PDF Page Extract Library: copy, paste, cut PDF pages in vb.
Page: Extract, Copy, Paste PDF Pages. |. Home ›› XDoc.PDF ›› VB.NET PDF: Copy and Paste PDF Page. VB.NET DLLs: Extract, Copy and Paste PDF Page.
www.rasteredge.com
Chapter15
NonparametricTrendLines
C18-9,168-79,AH11.3
·
Continuous
X
,continuousorbinary
Y
·
Nonparametric smootheronlyassumes thatthe shape oftherelationship
between
X
and
Y
issmooth
·
Asmootherislikeamovingaveragebutbetter
– Movingaverageisamovingflatlineapproximation
– Movingaverageshaveproblemsintheleftandrighttails
·
Bestall-purposesmoother:
loess
·
Iscalledascatterplotsmootherormovingweightedlinearregression
·
Byhavingmovingslopeandintercept,withoverlappingwindows,thesmooth
curveismoreaccurateandhasnoproblemsinleftandrighttails
155
application Library tool:VB.NET PDF Image Extract Library: Select, copy, paste PDF images
VB.NET PDF - Extract Image from PDF Document in VB.NET. Support PDF Image Extraction from a Page, a Region on a Page, and PDF Document in VB.NET Project.
www.rasteredge.com
application Library tool:C# PDF Image Extract Library: Select, copy, paste PDF images in C#
PDF ›› C# PDF: Extract PDF Image. How to C#: Extract Image from PDF Document. Support PDF Image Extraction from a Page, a Region on a Page, and PDF Document.
www.rasteredge.com
CHAPTER15. NONPARAMETRICTRENDLINES
156
·
loess
can handle binaryresponsevariableifyouturnoffoutlierrejection
(i.e.,tellthealgorithmtodonoextraiterations)
·
BasicS-P
LUS
functionfor
loess
smoothingis
lowess
:
plot(age, sysbp)
lines(lowess(age, sysbp))
·
Tousemorethantwovariablesusethefunctioncalled
loess
whichusesthe
statisticalformulalanguage
·
Hmisc
plsmo
functionplots
loess
or“supersmoother”(
supsmu
)estimates
withseveraloptionsincludingautomaticstratificationonadiscretevariable
plsmo(age, sysbp, , group=sex, datadensity=T) # # 2 2 curves s with rug g plots
·
Exampleusing
titanic3
datasetfromWebsite
attach(titanic3)
plsmo(age, survived, group=interaction(pclass,sex),
datadensity=T)
# Figure e 15.1
dev.off()
interaction(a,b)
createsanew
factor
variablecontainingthecross-classifications
ofthetwoconstituentvariables
·
plsmo
automaticallyturnsoutlierrejectionoffifthe
y
variableshasonlytwo
uniquevalues
·
plsmo
automaticallylabelscurvesbylevelsofthe
group
variable
a
·
Youcanuse
plsmo
asa
panel
functionto
xyplot
:
a
Notethat
group
isnotplural,whichisinconsistentwiththeTrellis
groups
variableusedforsuperposition.
application Library tool:C# PDF copy, paste image Library: copy, paste, cut PDF images in
C#.NET PDF SDK - Copy, Paste, Cut PDF Image in C#.NET. C# Guide C#.NET Demo Code: Copy and Paste Image in PDF Page in C#.NET. This C#
www.rasteredge.com
application Library tool:VB.NET PDF copy, paste image library: copy, paste, cut PDF images
VB.NET PDF - Copy, Paste, Cut PDF Image in VB.NET. using RasterEdge.Imaging.Basic; using RasterEdge.XDoc.PDF; VB.NET: Copy and Paste Image in PDF Page.
www.rasteredge.com
CHAPTER15. NONPARAMETRICTRENDLINES
157
age
survived
0
20
40
60
80
0.0
0.2
0.4
0.6
0.8
1.0
1st.female
2nd.female
3rd.female
1st.male
2nd.male
3rd.male
Figure 15.1:
loess
smoothed estimatesofthe probability ofsurvivingtheTitanic asafunction of
passengerage,sex,andticketclass
xyplot(sysbp ∼ ∼ age e | | race, , groups=sex, , panel=panel.plsmo)
·
OtherwaystogettrendlinesusingTrellisaregiveninSection14.7.3
application Library tool:VB.NET PDF Library SDK to view, edit, convert, process PDF file
to: create a new PDF file and load PDF from other file formats; merge, append, and split PDF files; insert, delete, move, rotate, copy and paste PDF file page.
www.rasteredge.com
application Library tool:C# PDF Library SDK to view, edit, convert, process PDF file for C#
to: create a new PDF file and load PDF from other file formats; merge, append, and split PDF files; insert, delete, move, rotate, copy and paste PDF file page.
www.rasteredge.com
Chapter16
ReproducibleAnalysis,FileandScript
Management
16.1 FileManagement
·
Organizetheuserareaonyourcomputerhierarchically
·
Usemanysubdirectories
·
Examplemajorsubdirectories:
bin
:localexecutables
data
:universaldataincludingteachingandexampledatasets
doc
:documentsnotrelatingtoanalyses
– subdirectoriesmightinclude
letters, papers, , proposals, , references,
reports, reviews, , seminars, , talks, teaching
,eachwithmanysub-
directories
projects
:project-specificdirectories
– subdirectoriesmightcorrespondtocourses,grants,contracts,depart-
ments
R
:genericfunctionsspecifictoR
158
CHAPTER16. REPRODUCIBLEANALYSIS,FILEANDSCRIPTMANAGEMENT
159
S
:genericfunctionsforS-P
LUS
andR
tmp
:temporaryfilestobepurgedmonthly
·
Terminalsubdirectorieshaveallthefilesassociatedwithaprojectorsubpro-
ject,e.g.
– S,SAS,andotherscripts
– Datafileswhennotstoredcentrally
– Finalanalysisfiles
– Analysisoutputlistings
– Graphicsfiles
– Sourcefilesforfunctionsneededforonlytheprojectinquestion
– Reportdocuments
– Historylog ordiary that chronologicallydocuments updates to source
dataandanalysiscode,mainfindings,andreasonsforchangesinthe
analysisplan
·
Separatingfilesbysoftwaretheyareassociatedwith(e.g.,havingseparate
directoriesforScode,SAScode,Worddocuments,etc.)doesnotworkwell
16.2 ScriptManagementandReproducibleAnalyses
AH13
·
Storinganalysiscodeinascriptallowsanalysestobereproducedasneeded
inbatchmodewhendataarecorrectedorotherwiseupdatedorwhencom-
putingsoftwareisimproved
CHAPTER16. REPRODUCIBLEANALYSIS,FILEANDSCRIPTMANAGEMENT
160
·
Scriptsalsoprovidedetaileddocumentationonexactlyhowanalyseswere
done
a
·
Documentcodebyliberaluseofcomments
·
Analysesgenerallyrequiremultipleapproachesandchangesinthechoice
ofstatisticalmodelsastheanalystbetterunderstandstheprojectandthe
data
·
Someanalystsstorescriptsforeachnewanalysisinaseparatefile
·
Whentheanalystreturns tothe projectafterasignificanttime lapse, the
sequencingofanalysisstepsisdifficulttoreconstruct
·
Themultiple-scriptapproachisextremelyhardtofollowwhenanewanalyst
takesuptheproject
·
Ingeneralitisbesttohaveonemainanalysisscriptthatcontainsexplicit
detours
·
Ifyouneedtoreliablyrollbacksourcefilestoreproduceanolderanalysis
useaversioncontrolsystemsuchas
CVS
(
http://www.gnu.org/software/
cvs
)
·
Oftenusefultocodesothatunneededstepsarenotexecutedeachtimethe
scriptisrun
·
Easeofdoingthisdependsonstatisticalcomputingpackageused
·
SAShasno“IFstatements”thatcancontroltheflowofentireprocedures
a
Itisusefultoputscriptsonawebsiteforreferencebyreadersofreportsandmanuscripts.
CHAPTER16. REPRODUCIBLEANALYSIS,FILEANDSCRIPTMANAGEMENT
161
– commentoutblocksofcodenotneedingtobere-run(willhavetoun-
commentthemtorunagainthough)
– usethe macro facility’s
%IF %THEN
statements to conditionallyexecute
sectionsofcode;thisjustdoestextexpansion/suppressionandisnot
data-sensitive
·
TheSlanguageisfully“live”sothat
if
statementscanbeusedinallcontexts
andtheycanbedata-sensitive,e.g.
n ← ← nrow(mydata)
if(n < < 20) print(mydata) ) else survplot(survfit(Surv(d.time,death)))
Inthisexample,ifthesamplesizeis
<20
thedatasetismerelylisted.When
thedataareupdatedandthesamplesizeissufficient,aKaplan-Meiersur-
vivalcurvewillbeplotted.
·
Onegoodwaytowritescriptswithmultiplecomponentsistosetupvariables
atthetopofthescriptcontrollingwhatcurrentlyneedstobeexecuted,e.g.
create ← ← F F # # analysis s file already y created
fitmod ← ← F F # # model already y fitted
valmod ← ← T T # # need to o validate e model
if(create) {
df ← ← sas.get(...)
df.desc describe(df)
ddist ← datadist(df)
}
if(fitmod) {
fit ← ← lrm(death h ∼ ∼ age*sex, x=T, y=T)
print(fit)
print(anova(fit))
}
if(valmod) {
val ← ← validate(fit)
print(val)
}
Thisisespeciallyusefulforprocessinglargedatasetswhereeachsteptakes
significantexecutiontime.
CHAPTER16. REPRODUCIBLEANALYSIS,FILEANDSCRIPTMANAGEMENT
162
·
Disadvantages:
– mustexplicitly
print
objectsbecausecodeissurroundedby
{ }
– resultingoutputlistingfilewillcontainonlyoutputfromrecentlyruncode
sections
·
TheHmisclibrary’s
do
functionsolvestheseproblemsbyoutputtingresults
andgraphicstoseparatefiles
AH13.2
16.3 ReproducibleResearch
·
Projectsrequiremultipleprogrammingandwritingsteps
b
:
– create/updateprimarydatabase(e.g.,usingSQL)
– create/updateextractionsfromprimarydatabase(e.g.,usingSASorS
tomergedatatables)
– create/updateSanalysisfiles
– obtainscalarcomputedvalues
c
, tabular,andgraphicsoutputonlatest
data
– assemblenewcomputedvalues,tables,andgraphicsintoareport
– recompilethereportintoafinaloutputformatsuchas
PDF
·
Themoreofthesestepsthatcanbeautomatedthemoreefficientanderror-
freetheanalysisbecomes
b
See
http://hesweb1.med.virginia.edu/biostat/s/LiveDoc.html
formoreinformation.
c
Forexample,asingle
P
-valueforaprimaryhypothesis.
Documents you may be interested
Documents you may be interested