<?xml version="1.0"?>
<OriginStorage Label="" Display="652"><XFname NodeID="11" Label="Name" DataID="300">phm_Cox</XFname><xFdescription NodeID="11" Label="Description" DataID="310">&amp;Cox Model Estimator:Perform a Cox Proportional Hazards Model analysis</xFdescription><attachTo NodeID="13" Label="Attach to Origin Object" Combo="None|Auto|Column|Sheet/Layer|Book/Graph" DataID="320" Show="0">1</attachTo><author NodeID="11" Label="Author" DataID="314"></author><AutoDependent NodeID="10" Label="Auto Compile Dependent Files" DataID="451">1</AutoDependent><UsageCtxt NodeID="268435456" Label="Usage Context" DataID="329"><LabTalk NodeID="10" Label="Labtalk" DataID="357">1</LabTalk><WksSel NodeID="10" Label="Worksheet Selection" DataID="350">0.</WksSel><GrObj NodeID="268435456" Label="Graphic Object Events" DataID="330" Use="0"><InitAnchors NodeID="10" Label="Initialization" DataID="339">1.</InitAnchors><Move NodeID="10" Label="Move" DataID="331">1.</Move><Moving NodeID="10" Label="Moving" DataID="332">0.</Moving><Resize NodeID="10" Label="Resize" DataID="333">0.</Resize><Resizing NodeID="10" Label="Resizing" DataID="334">0.</Resizing><Delete NodeID="10" Label="Delete" DataID="335">0.</Delete><Select NodeID="10" Label="Select" DataID="336">0.</Select><Unselect NodeID="10" Label="Unselect" DataID="337">0.</Unselect><BtnClick NodeID="10" Label="Button Click" DataID="338">0.</BtnClick><Rotate NodeID="10" Label="Rotate" DataID="340">0.</Rotate><Rotating NodeID="10" Label="Rotating" DataID="341">0.</Rotating><Skew NodeID="10" Label="Skew" DataID="342">0.</Skew><Skewing NodeID="10" Label="Skewing" DataID="343">0.</Skewing><EditEv NodeID="10" Label="Edit" DataID="344">0.</EditEv><Editing NodeID="10" Label="Editing" DataID="345">0.</Editing><NewSelection NodeID="10" Label="New Selection" DataID="346">0.</NewSelection><DeletePart NodeID="10" Label="Delete Part" DataID="347">0.</DeletePart><Keyboard NodeID="10" Label="Keyboard" DataID="348">0.</Keyboard><ObjType NodeID="13" Label="Type" Combo="Rect|Line" DataID="349">0.</ObjType></GrObj><Theme NodeID="268435456" Label="Theme" DataID="386"><UseInDialog NodeID="10" Label="Support Saving Themes in Dialog" DataID="372">1.</UseInDialog><ShowInMenu NodeID="10" Label="Show Themes as Popups in Menu" DataID="352">1</ShowInMenu><SaveInBook NodeID="10" Label="Support Saving to Book" DataID="387">0.</SaveInBook><SaveInSheet NodeID="10" Label="Support Saving to Sheet" DataID="388">0.</SaveInSheet></Theme><mainmenu NodeID="268435456" Label="Menus" DataID="365" Use="1" BranchCombo="None|Main Menus|Context Menus|Both|Context Menus 1|Context Menus 2|Context Menus 3|Context Menus 4"><AddAsTool NodeID="10" Label="Add As Tool" DataID="366">0.</AddAsTool><ClassOp NodeID="10" Label="Class Operation" DataID="367">0.</ClassOp><GetN NodeID="13" Label="Auto GetN Dialog" Combo="None|Simple GetNBox|GetNGraphBox with Preview|GetNImageBox|Wizard|Custom" DataID="371">1</GetN><CustomDialog NodeID="11" Label="Custom Dialog Function" DataID="395" Show="0"></CustomDialog><DlgFromMenu NodeID="10" Label="Open Dialog from Menu for Option Index" DataID="374">1.</DlgFromMenu><checkMenu NodeID="10" Label="Check Menu" DataID="470">0.</checkMenu></mainmenu><windows NodeID="268435456" Label="Windows" DataID="450" Use="1"><graph NodeID="10" Label="Graph" DataID="368">0.</graph><worksheet NodeID="10" Label="Worksheet" DataID="369">1</worksheet><matrix NodeID="10" Label="Matrix" DataID="370">0.</matrix><report NodeID="10" Label="Report" DataID="360">0.</report><none NodeID="10" Label="Layout" DataID="359">0.</none><none NodeID="10" Label="None" DataID="361">0.</none></windows></UsageCtxt><outTree NodeID="10" Label="Generate LabTalk Tree upon execution" DataID="373">0</outTree><askOutResultsLog NodeID="10" Label="Add Checkbox to Auto GetN Dialog about Results Log Output" DataID="393">1</askOutResultsLog><outResultsLog NodeID="13" Label="Output to Results Log upon execution" Combo="None|All|Report Tree|First Input|First Output|All Outputs|All Except Trees" DataID="394">2</outResultsLog><customButtons NodeID="11" Label="GetN Dialog Custom Buttons" DataID="391"></customButtons><syntax NodeID="41" Label="Command Line Usage" DataID="305" MultilineEditExpShrink="1" DispFormat="33554432" RowHeightRange="2-18">1. phm_Cox irng:=(1,2,3,4) censor:=0
2. phm_Cox irng:=(1,2,3,4) censor:=0 cov:=1
3. phm_Cox irng:=(1,2,3,4) censor:=0 corr:=1</syntax><vars NodeID="268435456" Label="Variables" Branch="1"><v1 _XFUNCTION_VAR="1" RepeatID="1"><name NodeID="11" Label="Name" DataID="10">irng</name><description NodeID="11" Label="Label" DataID="20" Show="0"></description><io NodeID="13" Label="Input/Output" Combo="Input|Output|Input/Output" DataID="30">0</io><type NodeID="11" Label="Data Type" Combo="double|string|int|vector|vector&lt;string&gt;|vector&lt;complex&gt;|Range|XYRange|XYRangeComplex|XYZRange|matrix|ButtonInfo|LineInfo|TextInfo|EventInfo|MarkerInfo|RectInfo|Column|MatrixObject|Image|DataPlot|Page|GraphPage|WorksheetPage|MatrixPage|GraphLayer|Worksheet|MatrixLayer|TreeNode|FileLink|ReportTree|ReportData|GraphPageBase|Layer" DataID="40">Range</type><valdata NodeID="57" Label="Data" DataID="50"></valdata><comboString NodeID="11" Label="Control" DataID="70">Time Range|Censor Range|Covariate Range</comboString><context NodeID="268435456" Label="Context" DataID="71"></context><optionString NodeID="11" Label="Option String" DataID="69">I:0x00000004</optionString><suggestedValues NodeID="11" Label="Suggested Values" DataID="405"></suggestedValues><themeID NodeID="14" Label="Theme ID" DataID="35">0.</themeID><help NodeID="268435456" Label="English Help" DataID="410" RepeatID="256"><description NodeID="11" Label="Display Name" DataID="408"></description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8">Specify data range for analysis, including time data range, censor data range and covariate data range.
Time data range
 Specify time data column
Censor data range
 Specify censor data column
Covariate data range
 Specify covariate data column</remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3">data range</hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407"></comboDescription></help><helpj NodeID="268435456" Label="Japanese Help" DataID="410" RepeatID="512"><description NodeID="11" Label="Display Name" DataID="408" CdPg="932"></description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8" CdPg="932">時間データ範囲、打ち切りデータ範囲、共分散データ範囲を含む分析するデータ範囲を指定します。
時間データ範囲
 時間データ列を指定します。
打ち切りデータ範囲
 打ち切りデータ列を指定します。
共分散データ範囲
 共分散データ列を指定します。</remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3" CdPg="932">データ範囲</hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407" CdPg="932"></comboDescription></helpj><helpg NodeID="268435456" Label="German Help" DataID="410" RepeatID="768"><description NodeID="11" Label="Display Name" DataID="408" CdPg="1252"></description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8" CdPg="1252">Bestimmen des Datenbereichs zur Analyse, einschließlich Zeitdatenbereich, Zensordatenbereich und Kovariate Datenbereich.
Zeitdatenbereich
 Bestimmen der Zeitdatenspalte
Zensordatenbereich
 Bestimmen der Zensordatenspalte
Kovariate Datenbereich
 Bestimmen der Datenspalte für Kovariate</remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3" CdPg="1252">Datenbereich</hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407" CdPg="1252"></comboDescription></helpg><helpc NodeID="268435456" Label="Chinese Help" DataID="410" RepeatID="1024"><description NodeID="11" Label="Display Name" DataID="408" CdPg="936"></description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8" CdPg="936"></remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3" CdPg="936"></hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407" CdPg="936"></comboDescription></helpc></v1><v2 _XFUNCTION_VAR="1" RepeatID="2"><name NodeID="11" Label="Name" DataID="10">censor</name><description NodeID="11" Label="Label" DataID="20" Show="0">Censoring Value(s)</description><io NodeID="13" Label="Input/Output" Combo="Input|Output|Input/Output" DataID="30">0</io><type NodeID="11" Label="Data Type" Combo="double|string|int|vector|vector&lt;string&gt;|vector&lt;complex&gt;|Range|XYRange|XYRangeComplex|XYZRange|matrix|ButtonInfo|LineInfo|TextInfo|EventInfo|MarkerInfo|RectInfo|Column|MatrixObject|Image|DataPlot|Page|GraphPage|WorksheetPage|MatrixPage|GraphLayer|Worksheet|MatrixLayer|TreeNode|FileLink|ReportTree|ReportData|GraphPageBase|Layer" DataID="40">vector</type><valdata NodeID="35" Label="Data" DataID="50" _DROP_DOWN_BUTTON_ID="2112|1"></valdata><comboString NodeID="11" Label="Control" DataID="70">|0|1</comboString><context NodeID="268435456" Label="Context" DataID="71"></context><optionString NodeID="11" Label="Option String" DataID="69">T:1</optionString><suggestedValues NodeID="11" Label="Suggested Values" DataID="405"></suggestedValues><themeID NodeID="14" Label="Theme ID" DataID="35">0.</themeID><help NodeID="268435456" Label="English Help" DataID="410" RepeatID="256"><description NodeID="11" Label="Display Name" DataID="408">Censoring Value(s)</description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8"><![CDATA[Specify the censor subject value, which identifies which time values in the observation data set are censored. ]]></remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3">Censor subject value</hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407"></comboDescription></help><helpj NodeID="268435456" Label="Japanese Help" DataID="410" RepeatID="512"><description NodeID="11" Label="Display Name" DataID="408" CdPg="932">打ち切り値</description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8" CdPg="932"><![CDATA[観測データセットにある時間がが打ち切られたと識別する打ち切り対象の値を指定します。 ]]></remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3" CdPg="932">打ち切り対象の値</hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407" CdPg="932"></comboDescription></helpj><helpg NodeID="268435456" Label="German Help" DataID="410" RepeatID="768"><description NodeID="11" Label="Display Name" DataID="408" CdPg="1252">Zensierungswert(e)</description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8" CdPg="1252"><![CDATA[Bestimmen des Zensorsubjektwerts, welcher identifiziert welche Zeitwerte im Beobachtungsdatensatz zensiert werden. ]]></remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3" CdPg="1252">Zensorsubjektwert</hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407" CdPg="1252"></comboDescription></helpg><helpc NodeID="268435456" Label="Chinese Help" DataID="410" RepeatID="1024"><description NodeID="11" Label="Display Name" DataID="408" CdPg="936"></description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8" CdPg="936"></remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3" CdPg="936"></hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407" CdPg="936"></comboDescription></helpc></v2><v3 _XFUNCTION_VAR="1" RepeatID="3"><name NodeID="11" Label="Name" DataID="10">summary</name><description NodeID="11" Label="Label" DataID="20" Show="0">Event and Censor Values Summary</description><io NodeID="13" Label="Input/Output" Combo="Input|Output|Input/Output" DataID="30">0.</io><type NodeID="11" Label="Data Type" Combo="double|string|int|vector|vector&lt;string&gt;|vector&lt;complex&gt;|Range|XYRange|XYRangeComplex|XYZRange|matrix|ButtonInfo|LineInfo|TextInfo|EventInfo|MarkerInfo|RectInfo|Column|MatrixObject|Image|DataPlot|Page|GraphPage|WorksheetPage|MatrixPage|GraphLayer|Worksheet|MatrixLayer|TreeNode|FileLink|ReportTree|ReportData|GraphPageBase|Layer" DataID="40">int</type><valdata NodeID="13" Label="Data" DataID="50" Combo="" Enable="1">1</valdata><comboString NodeID="11" Label="Control" DataID="70">0|1</comboString><context NodeID="268435456" Label="Context" DataID="71"></context><optionString NodeID="11" Label="Option String" DataID="69">G:-#3</optionString><suggestedValues NodeID="11" Label="Suggested Values" DataID="405"></suggestedValues><themeID NodeID="14" Label="Theme ID" DataID="35">0.</themeID><help NodeID="268435456" Label="English Help" DataID="410" RepeatID="256"><description NodeID="11" Label="Display Name" DataID="408">Event and Censor Values Summary</description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8">Check box for output the summary of event and censored value result.</remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3">Summary of event and censored value.</hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407"></comboDescription></help><helpj NodeID="268435456" Label="Japanese Help" DataID="410" RepeatID="512"><description NodeID="11" Label="Display Name" DataID="408" CdPg="932">イベントと打ち切り値のサマリー</description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8" CdPg="932">イベントと打ち切り値の結果のサマリーを出力するチェックボックス</remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3" CdPg="932">イベントと打ち切り値のサマリー</hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407" CdPg="932"></comboDescription></helpj><helpg NodeID="268435456" Label="German Help" DataID="410" RepeatID="768"><description NodeID="11" Label="Display Name" DataID="408" CdPg="1252">Ereignis- und Zensorwertezusammenfassung</description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8" CdPg="1252">Auswahlfeld zur Ausgabe der Zusammenfassung der Ergebnisse von Ereignis- und zensierten Werten.</remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3" CdPg="1252">Zusammenfassung von Ereignis- und zensierten Werten</hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407" CdPg="1252"></comboDescription></helpg><helpc NodeID="268435456" Label="Chinese Help" DataID="410" RepeatID="1024"><description NodeID="11" Label="Display Name" DataID="408" CdPg="936"></description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8" CdPg="936"></remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3" CdPg="936"></hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407" CdPg="936"></comboDescription></helpc></v3><v4 _XFUNCTION_VAR="1" RepeatID="4"><name NodeID="11" Label="Name" DataID="10">cov</name><description NodeID="11" Label="Label" DataID="20" Show="0">Covariance Matrix</description><io NodeID="13" Label="Input/Output" Combo="Input|Output|Input/Output" DataID="30">0.</io><type NodeID="11" Label="Data Type" Combo="double|string|int|vector|vector&lt;string&gt;|vector&lt;complex&gt;|Range|XYRange|XYRangeComplex|XYZRange|matrix|ButtonInfo|LineInfo|TextInfo|EventInfo|MarkerInfo|RectInfo|Column|MatrixObject|Image|DataPlot|Page|GraphPage|WorksheetPage|MatrixPage|GraphLayer|Worksheet|MatrixLayer|TreeNode|FileLink|ReportTree|ReportData|GraphPageBase|Layer" DataID="40">int</type><valdata NodeID="13" Label="Data" DataID="50" Combo="" Enable="1">0</valdata><comboString NodeID="11" Label="Control" DataID="70">0|1</comboString><context NodeID="268435456" Label="Context" DataID="71"></context><optionString NodeID="11" Label="Option String" DataID="69"></optionString><suggestedValues NodeID="11" Label="Suggested Values" DataID="405"></suggestedValues><themeID NodeID="14" Label="Theme ID" DataID="35">0.</themeID><help NodeID="268435456" Label="English Help" DataID="410" RepeatID="256"><description NodeID="11" Label="Display Name" DataID="408">Covariance Matrix</description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8">Specify whether output the covariance matrix or not.</remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3">Covariance matrix</hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407"></comboDescription></help><helpj NodeID="268435456" Label="Japanese Help" DataID="410" RepeatID="512"><description NodeID="11" Label="Display Name" DataID="408" CdPg="932">共分散行列</description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8" CdPg="932">共分散行列を出力するかどうかを指定します。</remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3" CdPg="932">共分散行列</hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407" CdPg="932"></comboDescription></helpj><helpg NodeID="268435456" Label="German Help" DataID="410" RepeatID="768"><description NodeID="11" Label="Display Name" DataID="408" CdPg="1252">Kovarianzmatrix</description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8" CdPg="1252">Bestimmen, ob die Kovarianzmatrix ausgegeben werden soll oder nicht.</remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3" CdPg="1252">Kovarianzmatrix</hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407" CdPg="1252"></comboDescription></helpg><helpc NodeID="268435456" Label="Chinese Help" DataID="410" RepeatID="1024"><description NodeID="11" Label="Display Name" DataID="408" CdPg="936"></description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8" CdPg="936"></remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3" CdPg="936"></hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407" CdPg="936"></comboDescription></helpc></v4><v5 _XFUNCTION_VAR="1" RepeatID="5"><name NodeID="11" Label="Name" DataID="10">corr</name><description NodeID="11" Label="Label" DataID="20" Show="0">Correlation Matrix</description><io NodeID="13" Label="Input/Output" Combo="Input|Output|Input/Output" DataID="30">0.</io><type NodeID="11" Label="Data Type" Combo="double|string|int|vector|vector&lt;string&gt;|vector&lt;complex&gt;|Range|XYRange|XYRangeComplex|XYZRange|matrix|ButtonInfo|LineInfo|TextInfo|EventInfo|MarkerInfo|RectInfo|Column|MatrixObject|Image|DataPlot|Page|GraphPage|WorksheetPage|MatrixPage|GraphLayer|Worksheet|MatrixLayer|TreeNode|FileLink|ReportTree|ReportData|GraphPageBase|Layer" DataID="40">int</type><valdata NodeID="13" Label="Data" DataID="50" Combo="" Enable="1">0</valdata><comboString NodeID="11" Label="Control" DataID="70">0|1</comboString><context NodeID="268435456" Label="Context" DataID="71"></context><optionString NodeID="11" Label="Option String" DataID="69">G:</optionString><suggestedValues NodeID="11" Label="Suggested Values" DataID="405"></suggestedValues><themeID NodeID="14" Label="Theme ID" DataID="35">0.</themeID><help NodeID="268435456" Label="English Help" DataID="410" RepeatID="256"><description NodeID="11" Label="Display Name" DataID="408">Correlation Matrix</description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8">Specify whether output the correlation matrix or not.</remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3">Correlation matrix</hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407"></comboDescription></help><helpj NodeID="268435456" Label="Japanese Help" DataID="410" RepeatID="512"><description NodeID="11" Label="Display Name" DataID="408" CdPg="932">相関行列</description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8" CdPg="932">相関行列を出力するかどうかを指定します。</remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3" CdPg="932">相関行列</hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407" CdPg="932"></comboDescription></helpj><helpg NodeID="268435456" Label="German Help" DataID="410" RepeatID="768"><description NodeID="11" Label="Display Name" DataID="408" CdPg="1252">Korrelationsmatrix</description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8" CdPg="1252">Bestimmen, ob die Korrelationsmatrix ausgegeben werden soll oder nicht.</remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3" CdPg="1252">Korrelationsmatrix</hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407" CdPg="1252"></comboDescription></helpg><helpc NodeID="268435456" Label="Chinese Help" DataID="410" RepeatID="1024"><description NodeID="11" Label="Display Name" DataID="408" CdPg="936"></description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8" CdPg="936"></remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3" CdPg="936"></hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407" CdPg="936"></comboDescription></helpc></v5><v6 _XFUNCTION_VAR="1" RepeatID="6"><name NodeID="11" Label="Name" DataID="10">sf</name><description NodeID="11" Label="Label" DataID="20" Show="0">Survival</description><io NodeID="13" Label="Input/Output" Combo="Input|Output|Input/Output" DataID="30">0.</io><type NodeID="11" Label="Data Type" Combo="double|string|int|vector|vector&lt;string&gt;|vector&lt;complex&gt;|Range|XYRange|XYRangeComplex|XYZRange|matrix|ButtonInfo|LineInfo|TextInfo|EventInfo|MarkerInfo|RectInfo|Column|MatrixObject|Image|DataPlot|Page|GraphPage|WorksheetPage|MatrixPage|GraphLayer|Worksheet|MatrixLayer|TreeNode|FileLink|ReportTree|ReportData|GraphPageBase|Layer" DataID="40">int</type><valdata NodeID="13" Label="Data" DataID="50" Combo="" Enable="1">0</valdata><comboString NodeID="11" Label="Control" DataID="70">0|1</comboString><context NodeID="268435456" Label="Context" DataID="71"></context><optionString NodeID="11" Label="Option String" DataID="69">G:+Survival Plots</optionString><suggestedValues NodeID="11" Label="Suggested Values" DataID="405"></suggestedValues><themeID NodeID="14" Label="Theme ID" DataID="35">0.</themeID><help NodeID="268435456" Label="English Help" DataID="410" RepeatID="256"><description NodeID="11" Label="Display Name" DataID="408">Survival</description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8"><![CDATA[Specify whether output the survival curve or not.
]]></remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3">Survival plots</hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407"></comboDescription></help><helpj NodeID="268435456" Label="Japanese Help" DataID="410" RepeatID="512"><description NodeID="11" Label="Display Name" DataID="408" CdPg="932">生存グラフ</description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8" CdPg="932"><![CDATA[生存曲線を出力するかどうかを指定します。
]]></remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3" CdPg="932">生存グラフ</hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407" CdPg="932"></comboDescription></helpj><helpg NodeID="268435456" Label="German Help" DataID="410" RepeatID="768"><description NodeID="11" Label="Display Name" DataID="408" CdPg="1252">Überleben</description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8" CdPg="1252"><![CDATA[Bestimmen, ob die Überlebenskurve ausgegeben werden soll oder nicht.
]]></remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3" CdPg="1252">Überlebensdiagramm</hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407" CdPg="1252"></comboDescription></helpg><helpc NodeID="268435456" Label="Chinese Help" DataID="410" RepeatID="1024"><description NodeID="11" Label="Display Name" DataID="408" CdPg="936"></description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8" CdPg="936"></remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3" CdPg="936"></hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407" CdPg="936"></comboDescription></helpc></v6><v7 _XFUNCTION_VAR="1" RepeatID="7"><name NodeID="11" Label="Name" DataID="10">hazard</name><description NodeID="11" Label="Label" DataID="20" Show="0">Hazard</description><io NodeID="13" Label="Input/Output" Combo="Input|Output|Input/Output" DataID="30">0.</io><type NodeID="11" Label="Data Type" Combo="double|string|int|vector|vector&lt;string&gt;|vector&lt;complex&gt;|Range|XYRange|XYRangeComplex|XYZRange|matrix|ButtonInfo|LineInfo|TextInfo|EventInfo|MarkerInfo|RectInfo|Column|MatrixObject|Image|DataPlot|Page|GraphPage|WorksheetPage|MatrixPage|GraphLayer|Worksheet|MatrixLayer|TreeNode|FileLink|ReportTree|ReportData|GraphPageBase|Layer" DataID="40">int</type><valdata NodeID="13" Label="Data" DataID="50" Combo="" Enable="1">0</valdata><comboString NodeID="11" Label="Control" DataID="70">0|1</comboString><context NodeID="268435456" Label="Context" DataID="71"></context><optionString NodeID="11" Label="Option String" DataID="69">G:</optionString><suggestedValues NodeID="11" Label="Suggested Values" DataID="405"></suggestedValues><themeID NodeID="14" Label="Theme ID" DataID="35">0.</themeID><help NodeID="268435456" Label="English Help" DataID="410" RepeatID="256"><description NodeID="11" Label="Display Name" DataID="408">Hazard</description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8">Specify whether output the hazard curve or not.</remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3">Hazard plot</hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407"></comboDescription></help><helpj NodeID="268435456" Label="Japanese Help" DataID="410" RepeatID="512"><description NodeID="11" Label="Display Name" DataID="408" CdPg="932">ハザードグラフ</description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8" CdPg="932">ハザード曲線を出力するかどうかを指定します。</remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3" CdPg="932">ハザードグラフ</hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407" CdPg="932"></comboDescription></helpj><helpg NodeID="268435456" Label="German Help" DataID="410" RepeatID="768"><description NodeID="11" Label="Display Name" DataID="408" CdPg="1252">Hazard</description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8" CdPg="1252">Bestimmen, ob die Hazardkurve ausgegeben werden soll oder nicht.</remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3" CdPg="1252">Hazarddiagramm</hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407" CdPg="1252"></comboDescription></helpg><helpc NodeID="268435456" Label="Chinese Help" DataID="410" RepeatID="1024"><description NodeID="11" Label="Display Name" DataID="408" CdPg="936"></description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8" CdPg="936"></remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3" CdPg="936"></hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407" CdPg="936"></comboDescription></helpc></v7><v8 _XFUNCTION_VAR="1" RepeatID="8"><name NodeID="11" Label="Name" DataID="10">rd</name><description NodeID="11" Label="Label" DataID="20" Show="0">Survival Function</description><io NodeID="13" Label="Input/Output" Combo="Input|Output|Input/Output" DataID="30">1</io><type NodeID="11" Label="Data Type" Combo="double|string|int|vector|vector&lt;string&gt;|vector&lt;complex&gt;|Range|XYRange|XYRangeComplex|XYZRange|matrix|ButtonInfo|LineInfo|TextInfo|EventInfo|MarkerInfo|RectInfo|Column|MatrixObject|Image|DataPlot|Page|GraphPage|WorksheetPage|MatrixPage|GraphLayer|Worksheet|MatrixLayer|TreeNode|FileLink|ReportTree|ReportData|GraphPageBase|Layer" DataID="40">ReportData</type><valdata NodeID="81" Label="Data" DataID="50" _DROP_DOWN_BUTTON_ID="2112|0">&lt;optional&gt;</valdata><comboString NodeID="11" Label="Control" DataID="70"></comboString><context NodeID="268435456" Label="Context" DataID="71"></context><optionString NodeID="11" Label="Option String" DataID="69">G:-Outputs;U:N;P:0;N:sheet:="SurvFunc1"</optionString><suggestedValues NodeID="11" Label="Suggested Values" DataID="405"></suggestedValues><themeID NodeID="14" Label="Theme ID" DataID="35">0.</themeID><help NodeID="268435456" Label="English Help" DataID="410" RepeatID="256"><description NodeID="11" Label="Display Name" DataID="408">Survival Function</description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8">Specify the survival function data destination</remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3">Survival function destination</hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407"></comboDescription></help><helpj NodeID="268435456" Label="Japanese Help" DataID="410" RepeatID="512"><description NodeID="11" Label="Display Name" DataID="408" CdPg="932">生存関数</description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8" CdPg="932">生存関数のデータの出力先を指定します。</remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3" CdPg="932">生存関数の出力先</hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407" CdPg="932"></comboDescription></helpj><helpg NodeID="268435456" Label="German Help" DataID="410" RepeatID="768"><description NodeID="11" Label="Display Name" DataID="408" CdPg="1252">Überlebensfunktion</description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8" CdPg="1252">Bestimmen des Ziels der Überlebensfunktionsdaten</remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3" CdPg="1252">Überlebensfunktionsziel</hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407" CdPg="1252"></comboDescription></helpg><helpc NodeID="268435456" Label="Chinese Help" DataID="410" RepeatID="1024"><description NodeID="11" Label="Display Name" DataID="408" CdPg="936"></description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8" CdPg="936"></remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3" CdPg="936"></hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407" CdPg="936"></comboDescription></helpc></v8><v9 _XFUNCTION_VAR="1" RepeatID="9"><name NodeID="11" Label="Name" DataID="10">rt</name><description NodeID="11" Label="Label" DataID="20" Show="0">Output Report</description><io NodeID="13" Label="Input/Output" Combo="Input|Output|Input/Output" DataID="30">1</io><type NodeID="11" Label="Data Type" Combo="double|string|int|vector|vector&lt;string&gt;|vector&lt;complex&gt;|Range|XYRange|XYRangeComplex|XYZRange|matrix|ButtonInfo|LineInfo|TextInfo|EventInfo|MarkerInfo|RectInfo|Column|MatrixObject|Image|DataPlot|Page|GraphPage|WorksheetPage|MatrixPage|GraphLayer|Worksheet|MatrixLayer|TreeNode|FileLink|ReportTree|ReportData|GraphPageBase|Layer" DataID="40">ReportTree</type><valdata NodeID="81" Label="Data" DataID="50" _DROP_DOWN_BUTTON_ID="2112|0">[&lt;input&gt;]&lt;new&gt;</valdata><comboString NodeID="11" Label="Control" DataID="70"></comboString><context NodeID="268435456" Label="Context" DataID="71"></context><optionString NodeID="11" Label="Option String" DataID="69">G:;U:N;N:sheet:= CoxPHM1;P:0;O:A</optionString><suggestedValues NodeID="11" Label="Suggested Values" DataID="405"></suggestedValues><themeID NodeID="14" Label="Theme ID" DataID="35">0.</themeID><help NodeID="268435456" Label="English Help" DataID="410" RepeatID="256"><description NodeID="11" Label="Display Name" DataID="408">Output Report</description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8">Specify the report worksheet destination</remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3">Report worksheet destination</hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407"></comboDescription></help><helpj NodeID="268435456" Label="Japanese Help" DataID="410" RepeatID="512"><description NodeID="11" Label="Display Name" DataID="408" CdPg="932">出力レポート</description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8" CdPg="932">レポートワークシートの出力先を指定します。</remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3" CdPg="932">レポートワークシートの出力先</hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407" CdPg="932"></comboDescription></helpj><helpg NodeID="268435456" Label="German Help" DataID="410" RepeatID="768"><description NodeID="11" Label="Display Name" DataID="408" CdPg="1252">Ausgabebericht</description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8" CdPg="1252">Bestimmen des Ziels des Berichtsdatenblatts</remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3" CdPg="1252">Berichtsdatenblattziel</hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407" CdPg="1252"></comboDescription></helpg><helpc NodeID="268435456" Label="Chinese Help" DataID="410" RepeatID="1024"><description NodeID="11" Label="Display Name" DataID="408" CdPg="936"></description><remark NodeID="41" Label="Description" DataID="409" RowHeightRange="3-8" CdPg="936"></remark><hint NodeID="41" Label="Auto Complete Hint" DataID="406" RowHeightRange="1-3" CdPg="936"></hint><comboDescription NodeID="47" Label="Option Explanations" DataID="407" CdPg="936"></comboDescription></helpc></v9></vars><modificationLog NodeID="41" Label="Modification Log" DataID="438" MultilineEditExpShrink="1" DispFormat="33554432" RowHeightRange="2-15">Edited. Fay. 13/6. 
5/30/07 Fay. Complete the rest of the document.
6/01/07 Fay. Modify the Command Line Usage part and some details of the Variables part.
7/11/07 Larry. Review document, change some format, and modify two variable label. Done.
7/30/07. Fay. Review document and change some details.
8/15/07. Fay. Review and modify Command Line Usage.</modificationLog><codes NodeID="268435456" Label="Code" DataID="324"><rettype NodeID="11" Label="Return Type" Combo="void|int|double|string|vector" DataID="41">void</rettype><header NodeID="45" Label="Header" DataID="323" MultilineEditExpShrink="1" DispFormat="33554432" RowHeightRange="3-15"><![CDATA[ 
///Nicole 07/05/2007 v8.0655 REMOVE_SPACE_FOR_LOCATION_STRING
#include <GetNBox.h>
#include <stats_utils.h>
#include <report_utils.h>
#include <event_utils.h>
#include <control.h>
#include <o8dlg.h>
///////////////////////////////////////////////////
// Modification log
///Jasmine 08/14/07 QA80-10207 REPORT_SHEET_CHECK_CONFLICT
/// Max 3/7/08 SHOULD_PASS_WHOLE_STRING_OF_LPCSZRDLABEL_FOR_LOCALIZATION
/// Max 3/19/08 SHOULD_NOT_RESET_VARIABLE_VALUE_IN_LT
/// Folger 12/26/08 QA80-12642-P3 v8.0991 CONSISTENT_SHOW_LN_WITH_DOUBLE_QUOTES_IN_REPORT_SHEET
/// Folger 02/20/09 OUTPUT_NODES_SHOULD_BE_DISABLED_IN_CAHNGE_PARAM
/// Kyle 03/02/2009 SHOULD_NOT_CHANGE_OUTPUT_ON_GUI_ON_CHANGE_PARAMETERS
/// Folger 08/26/2010 ORG-920-P2 COX_MODAL_BETTER_HANDLING_OF_OUTPUT_PLOT_AND_REPORT_DATA
///////////////////////////////////////////////////
//put your own support static functions here

#define IDST_COX_LE           0x00000010
#define IDST_COX_PE           0x00000012
#define IDST_COX_COV          0x00000016
#define IDST_COX_CORR         0x00000018
#define IDST_SA_SP            0x11110000


enum
{
	ERR_DIFF_SIZE,
	ERR_COX_MODEL
	
};

static void _get_fit_stats(SAFitStats stSAFitStats, vector &vStats)
{
	vStats.SetSize(4);
	vStats[0] = round(stSAFitStats.Criter, 4);
	vStats[1] = round(stSAFitStats.ChiSq, 4);
	vStats[2] = stSAFitStats.DOF;
	vStats[3] = round(stSAFitStats.Prob, 4);
}


static void _get_analysis_stats(SAParaEstim *psSAParaEstim, int ii, vector &vStats)
{
	vStats.SetSize(6);
	vStats[0] = psSAParaEstim[ii].DOF;
	vStats[1] = round(psSAParaEstim[ii].ParaEst, 4);
	vStats[2] = round(psSAParaEstim[ii].SE, 4);
	vStats[3] = round(psSAParaEstim[ii].ChiSq, 4);
	vStats[4] = round(psSAParaEstim[ii].Prob, 4);
	vStats[5] = round(psSAParaEstim[ii].Hazard, 4);
}

static void _get_cox_estimates(SAEstim stSurvivEstim, vector& vCoxEstim)
{
	vCoxEstim.SetSize(6);
	vCoxEstim[0] = stSurvivEstim.Time;
	vCoxEstim[1] = stSurvivEstim.Status;
	vCoxEstim[2] = stSurvivEstim.Surv;
	vCoxEstim[3] = stSurvivEstim.SD;
	vCoxEstim[4] = stSurvivEstim.Events;
	vCoxEstim[5] = stSurvivEstim.Remain;
	
}


void cox_make_likelihood_analysis(ReportTree& outRT, SAFitStats& stSAFitStats, const bool bConverage)
{
    //////////////////////////////////////////////////////////////////
	// -2 Log Likelihood Estimates
	//////////////////////////////////////////////////////////////////
	ReportTable rtLE = outRT.CreateTable("Likelihood", _L("Analysis of -2 Log Likelihood Estimates"), IDST_COX_LE);
	
	vector<string> vFitStatsLabels(4);
	vFitStatsLabels[0] = _L("-2 Log Likelyhood");
	vFitStatsLabels[1] = _L("Chi-Square");
	vFitStatsLabels[2] = _L("DF");
	vFitStatsLabels[3] = _L("Pr > ChiSq");
	
	vector<string> vstrTagName;
	string strTagName = COX_LIKELIHOOD_ESTIM;
	strTagName.GetTokens(vstrTagName, '|');
	
	vector vFitStats;
	_get_fit_stats(stSAFitStats, vFitStats);
    /// Nicole 07/05/2007 v8.0655 REMOVE_SPACE_FOR_LOCATION_STRING
    //rtLE.AddRow(_L(""), vFitStats, _L(" "), vFitStatsLabels, NULL, make_one_set_ID(IDST_COX_LE, 0));
    rtLE.AddRow("LH", vFitStats, " ", vFitStatsLabels, vstrTagName, make_one_set_ID(IDST_COX_LE, 0));
    /// End REMOVE_SPACE_LOCATION_STRING    if (!bConverage)
	///Sophy 3/30/2009 QA80-13352 SUPPORT_SPECIFY_COLUMN_DESIGNATIONS_IN_REPORT_TABLES
	TreeNode trRow = rtLE.GetNode("LH");
	if ( trRow )
		tree_set_attribute_to_all_nodes(trRow, STR_COL_DESIGNATION_ATTRIB, (string)OKDATAOBJ_DESIGNATION_Y);
	///end SUPPORT_SPECIFY_COLUMN_DESIGNATIONS_IN_REPORT_TABLES

    {
    	string strFootNote = _L("Iteration limit reached without convergence.\nValidity of the model fit is questionable.");
	 	TreeNode trFooter = tree_check_get_node(rtLE, "Footer", IDE_FOOTNOTE_BEGIN, TREE_Footnote, "1"); // just need the TREE_Footnote attribute, value does not matter, so 1 is good
		trFooter.strVal = strFootNote;		
   }
}

void cox_make_parameter_analysis(ReportTree& outRT, SAParaEstim* psSAParaEstim, const vector<string>& vstrCovarLab)
{
	 //////////////////////////////////////////////////////////////////
	// Parameter estimates
	//////////////////////////////////////////////////////////////////
	ReportTable rtPE = outRT.CreateTable("ParamEstim", _L("Analysis of parameter estimates"), IDST_COX_PE);
	
	vector<string> vANAStatsLabels(6);
	vANAStatsLabels[0] = _L("DF");
	vANAStatsLabels[1] = _L("Estimate");
	vANAStatsLabels[2] = _L("Standard Error");
	vANAStatsLabels[3] = _L("Chi-Square");
	vANAStatsLabels[4] = _L("Pr > ChiSq");
	vANAStatsLabels[5] = _L("Hazard Ratio");
	
	vector<string> vstrTagName;
	string strTagName = COX_PARAM_ESTIM;
	strTagName.GetTokens(vstrTagName, '|');
	
	vector vANAStats;
	for(int ii = 0; ii < vstrCovarLab.GetSize(); ii++)
	{
	    _get_analysis_stats(psSAParaEstim, ii, vANAStats);
	    string strRow = "Param" + ftoa(ii+1);
	    rtPE.AddRow(strRow, vANAStats, vstrCovarLab[ii], vANAStatsLabels, vstrTagName, make_one_set_ID(IDST_COX_PE, ii));		
		///Sophy 3/30/2009 QA80-13352 SUPPORT_SPECIFY_COLUMN_DESIGNATIONS_IN_REPORT_TABLES
		TreeNode trRow = rtPE.GetNode(strRow);
		if ( trRow )
		{
			tree_set_attribute_to_all_nodes(trRow, STR_COL_DESIGNATION_ATTRIB, (string)OKDATAOBJ_DESIGNATION_Y);
			if ( trRow.SE )
				trRow.SE.SetAttribute(STR_COL_DESIGNATION_ATTRIB, OKDATAOBJ_DESIGNATION_ERROR);
		}
		///end SUPPORT_SPECIFY_COLUMN_DESIGNATIONS_IN_REPORT_TABLES
	}
}

void cox_get_survival_analysis_data(ReportData& outData, const bool bSF, const bool bHazard, const int& nSizeSAEstm, SAEstim* pSurvivEstim)
{
	vector vSurvivEstims;
	vector vX,vY;
	vX.SetSize(nSizeSAEstm+1);
	vY.SetSize(nSizeSAEstm+1);
	vX[0] = 0;
	vY[0] = 1;
	
	for (int ii = 0; ii < nSizeSAEstm; ii++)
	{
		_get_cox_estimates(pSurvivEstim[ii], vSurvivEstims);
		vX[ii+1] = vSurvivEstims[0];
		vY[ii+1] = vSurvivEstims[2];
	}
	
	vector<string> vstrGroup(1);
	vstrGroup[0] = " ";
	surv_update_report_data(outData, 0.95, vX, vY, NULL ,0, vstrGroup, bSF, bHazard);
}

void cox_make_covars_corre_analysis(ReportTree& outRT, const int& cov, const int& corr, const matrix& mCovars, const matrix& mCorre, const vector<string>& vstrCovarLab)
{
	int ii;
	vector vTemp;
	string strRow;
	
	int nSize = vstrCovarLab.GetSize();
	vector<string> vstrTagName;
	vstrTagName.SetSize(nSize);
	for (ii = 0; ii < nSize; ii++)
	{
		vstrTagName[ii] = "Var"+ftoa(ii+1);
	}
	
	if(cov)
	{
		ReportTable rtCovariance = outRT.CreateTable("Covariance", _L("Estimated Covariance Matrix"), IDST_COX_COV);
		for(ii = 0; ii < nSize; ii++)
		{
			strRow = "Var" + ftoa(ii+1);
	    	mCovars.GetRow(vTemp, ii);
			rtCovariance.AddRow(strRow, vTemp, vstrCovarLab[ii], vstrCovarLab, vstrTagName, make_one_set_ID(IDST_COX_COV, ii));		
			///Sophy 3/30/2009 QA80-13352 SUPPORT_SPECIFY_COLUMN_DESIGNATIONS_IN_REPORT_TABLES
			TreeNode trRow = rtCovariance.GetNode(strRow);
			if ( trRow )
				tree_set_attribute_to_all_nodes(trRow, STR_COL_DESIGNATION_ATTRIB, (string)OKDATAOBJ_DESIGNATION_Y);
			///end SUPPORT_SPECIFY_COLUMN_DESIGNATIONS_IN_REPORT_TABLES
		}
	}
	
	if(corr)
	{
		ReportTable rtCorrelation = outRT.CreateTable("Correlation", _L("Estimated Correlation Matrix"), IDST_COX_CORR);
		for(ii = 0; ii < nSize; ii++)
		{
			strRow = "Var" + ftoa(ii+1);
	    	mCorre.GetRow(vTemp, ii);
			rtCorrelation.AddRow(strRow, vTemp, vstrCovarLab[ii], vstrCovarLab, vstrTagName, make_one_set_ID(IDST_COX_CORR, ii));		
			///Sophy 3/30/2009 QA80-13352 SUPPORT_SPECIFY_COLUMN_DESIGNATIONS_IN_REPORT_TABLES
			TreeNode trRow = rtCorrelation.GetNode(strRow);
			if ( trRow )
				tree_set_attribute_to_all_nodes(trRow, STR_COL_DESIGNATION_ATTRIB, (string)OKDATAOBJ_DESIGNATION_Y);
			///end SUPPORT_SPECIFY_COLUMN_DESIGNATIONS_IN_REPORT_TABLES
		}
	}
}	

//assume all subrange more than or equal to nIndex-th one are covariates
static int _get_covariate(const DataRange& dr, const int nIndex, vector<string> &vstrColNames, matrix &mCovars, int nSize)
{
	int r1, c1, r2, c2;
	Worksheet wksTemp;
	string strRange;

	int nRanges = dr.GetNumRanges() - nIndex;
	int nCovars = 0, nCol = 0;
	for (int kk = 0; kk < nRanges; kk++)
	{
	
		dr.GetRange(kk+nIndex, r1, c1, r2, c2, wksTemp, &strRange);
		int bBegin = nCovars;
		nCovars += c2-c1+1;
		mCovars.SetSize(nSize, nCovars, true);
		vstrColNames.SetSize(nCovars);
		for(int ii=c1, jj=0; ii<=c2; ii++, jj++)
		{
			nCol = bBegin + jj;
			Column col = wksTemp.Columns(ii);
			string strName = col.GetLongName();
			///------ Folger 12/26/08 QA80-12642-P3 v8.0991 CONSISTENT_SHOW_LN_WITH_DOUBLE_QUOTES_IN_REPORT_SHEET
			//strName = strName.IsEmpty()? col.GetName() : strName;
			strName = strName.IsEmpty()? col.GetName() : "\"" + strName + "\"";
			///------ End CONSISTENT_SHOW_LN_WITH_DOUBLE_QUOTES_IN_REPORT_SHEET
			vstrColNames[nCol] = strName;
			vector vCovar = col.GetDataObject();
			//if (vCovar.GetSize()!= nSize)
				//throw(CER_TIME_COVAR_DIFF_SIZE);
			mCovars.SetColumn(vCovar,nCol);
		}
	}
	
	return nCovars;
}

static int cox_check_input(TreeNode& trGetN)
{
	int nErr = sa_check_data(trGetN.irng, SA_COVARIATE);
	if (nErr == CER_NO_ERROR)
		nErr = check_valid_censoring(trGetN);
	
	return nErr;
}
]]></header><code NodeID="45" Label="Expression" DataID="325" MultilineEditExpShrink="1" DispFormat="33554432" RowHeightRange="5-20"><![CDATA[
int nRet = sa_check_data(irng, SA_COVARIATE);
if (CER_NO_ERROR != nRet)
	XF_THROW(nRet);

int ii;
vector vTime, vCensor;
irng.GetData(vTime, 0);
irng.GetData(vCensor, 1);
vector<string> vstrCovarLab;	
matrix mCovars;

int nCovars = _get_covariate(irng, 2, vstrCovarLab, mCovars, vTime.GetSize());

int nMissing;
nRet = trim_nanum_sa(&nMissing, vTime, vCensor, NULL, mCovars);


SASummary	stSASummary;
SAFitStats	stSAFitStats;
SAParaEstim* psSAParaEstim = (SAParaEstim*) malloc (nCovars * sizeof(SAParaEstim));	
int nSizeSAEstm = vTime.GetSize();
SAEstim* pSurvivEstim = (SAEstim*) malloc (nSizeSAEstm * sizeof(SAEstim));
matrix mCov, mCorr;
bool bConverage = true;
nRet =  stats_surviv_cox_model(vTime,vCensor,censor,mCovars,stSASummary,stSAFitStats,
		psSAParaEstim,nCovars,pSurvivEstim,nSizeSAEstm,mCov,mCorr);
if (nRet != STATS_NO_ERROR)
{
	if ( STATS_ERROR_CONVERGENCE_FAIL == nRet )
		bConverage = false;
	else
		XF_THROW_EX(CER_UNKNOWN_ERROR_EX, nRet);
}


LPCSTR lpsczLabel = _L("CoxPHM");
report_tree_create(rt, lpsczLabel, "irng");
if(summary)
{
 		rt_add_sa_summary(rt, stSASummary, censor);
}
	
cox_make_likelihood_analysis(rt, stSAFitStats, bConverage);
cox_make_parameter_analysis(rt, psSAParaEstim, vstrCovarLab);
cox_make_covars_corre_analysis(rt, cov, corr, mCov, mCorr, vstrCovarLab);
cox_get_survival_analysis_data(rd, sf, hazard, nSizeSAEstm, pSurvivEstim);

///Kyle 03/02/2009 SHOULD_NOT_CHANGE_OUTPUT_ON_GUI_ON_CHANGE_PARAMETERS
//if(0 != sf+hazard)
if(0 != sf+hazard && rd)
///End SHOULD_NOT_CHANGE_OUTPUT_ON_GUI_ON_CHANGE_PARAMETERS
{
	rd.ID = IDST_RESULT_CURVES;	
	vector<string> vsLabel;
	vsLabel.SetSize(1);
   	survival_rd_plotting(rd, vsLabel, rt, sf, hazard);
}

free(psSAParaEstim);
free(pSurvivEstim);


]]></code><event1 NodeID="45" Label="Event1" DataID="327" MultilineEditExpShrink="1" DispFormat="33554432" RowHeightRange="5-20" Show="0"><![CDATA[
TreeNode trRange = trGetN.irng;

TreeNode trCensor = trGetN.censor;
if (trRange && trCensor)
	set_censor_list(trRange, trCensor);

///------ Folger 08/26/2010 ORG-920-P2 COX_MODAL_BETTER_HANDLING_OF_OUTPUT_PLOT_AND_REPORT_DATA
/*
///------ Folger 02/20/09 OUTPUT_NODES_SHOULD_BE_DISABLED_IN_CAHNGE_PARAM
//bool bEnabled = (0 != get_plot_number(trGetN));
int		nEnabled = ENABLE;
bool	bIsChangeParam = trGetN.AutoUpdate.GetAttribute(STR_ENABLE_ATTRIB, nEnabled) && nEnabled == DISABLE;
bool	bEnabled = !bIsChangeParam && (0 != get_plot_number(trGetN));
///------ End OUTPUT_NODES_SHOULD_BE_DISABLED_IN_CAHNGE_PARAM

/// Max 3/7/08 SHOULD_PASS_WHOLE_STRING_OF_LPCSZRDLABEL_FOR_LOCALIZATION
//rd_set_optional(nEventID, bOKEnable, lpcszNodeName, trGetN.rd, bEnabled, _L("SurvFunc1"));
/// Max 4/8/08 move to event_utils.h
//string strRDvalue = "[<input>]<new>";
string strRDvalue = STR_DEFAULT_TEXT_FOR_REPORT_DATA_NODE;
//------
okutil_convert_localized_PDS(&strRDvalue);
///Kyle 03/02/2009 SHOULD_NOT_CHANGE_OUTPUT_ON_GUI_ON_CHANGE_PARAMETERS
//tr_set_optional(nEventID, lpcszNodeName, trGetN.rd, bEnabled, strRDvalue);
if(!bIsChangeParam)
	tr_set_optional(nEventID, lpcszNodeName, trGetN.rd, bEnabled, strRDvalue);
///End SHOULD_NOT_CHANGE_OUTPUT_ON_GUI_ON_CHANGE_PARAMETERS
/// END SHOULD_PASS_WHOLE_STRING_OF_LPCSZRDLABEL_FOR_LOCALIZATION
*/
///------ End COX_MODAL_BETTER_HANDLING_OF_OUTPUT_PLOT_AND_REPORT_DATA
tr_set_optional_ex(nEventID, lpcszNodeName, trGetN.rd, xf_event_is_change_param(trGetN), 0 != get_plot_number(trGetN));
trGetN.irng.SetAttribute(STR_ATTRIB_BRANCH, GETNBRANCH_OPEN);	

int nErr = cox_check_input(trGetN);
///Jasmine 08/14/07 QA80-10207 REPORT_SHEET_CHECK_CONFLICT
if (nErr == CER_NO_ERROR && is_same_sheet(trGetN.rd, trGetN.rt))
	nErr = XFERR_REPORT_SHEET_CONFLICT;
///End REPORT_SHEET_CHECK_CONFLICT
if (CER_NO_ERROR != nErr)
{
	bOKEnable = false;
	strErrMsg = nErr;
	if (CER_DATA_TOO_FEW == nErr)
		strErrMsg += ":" + 2;
	
}


return true;
]]></event1><event2 NodeID="45" Label="Event2" DataID="376" MultilineEditExpShrink="1" DispFormat="33554432" RowHeightRange="5-20" Show="0"><![CDATA[
return false;
]]></event2><event3 NodeID="45" Label="Event3" DataID="378" MultilineEditExpShrink="1" DispFormat="33554432" RowHeightRange="5-20" Show="0"><![CDATA[
//------ fisher 11/16/07 ADD_MAP_ID_TO_CHM
if(is_use_origin_chm())
	trGetN.SetAttribute(STR_HELPID_ATTRIB, IDD_XF_phm_Cox);

/// Max 3/19/08 SHOULD_NOT_RESET_VARIABLE_VALUE_IN_LT
// It is the responsibility of users to specify each variable value (<auto> ones are exception) when run from LT
/*
///handle case that user select plot but not specify rd, when run from command
if (nGetNDialog <= 0)
{
	/// Max 3/7/08 LOCALIZE_PREDEFINED_STRING
	//if (!lstrcmp(trGetN.rd.strVal, "<optional>") && get_plot_number(trGetN))
	//{
		//trGetN.rd.strVal = "[<input>]<new name:=SurvFunc1>";
	//}
	if (compare_string_localization(trGetN.rd.strVal, STR_OPTIONAL) && get_plot_number(trGetN))
	{
		string strRDvalue = "[<input>]<new>";
		okutil_convert_localized_PDS(&strRDvalue);
		trGetN.rd.strVal = strRDvalue;
	}
	/// END LOCALIZE_PREDEFINED_STRING
}
*/
/// END SHOULD_NOT_RESET_VARIABLE_VALUE_IN_LT

///Jasmine 08/14/07 QA80-10207 REPORT_SHEET_CHECK_CONFLICT
//if ( (dwCntrl&LTXF_THEME_USED) && nGetNDialog <= 0 )
if (nGetNDialog <= 0 )
{
	//if ( CER_NO_ERROR != cox_check_input(trGetN) )
	int nErr = cox_check_input(trGetN);
	if(CER_NO_ERROR == nErr && is_same_sheet(trGetN.rd, trGetN.rt))
		nErr = XFERR_REPORT_SHEET_CONFLICT;
	if(CER_NO_ERROR != nErr)
	{
		if((dwCntrl&LTXF_THEME_USED))
			nRet = XFEVT_PROCEED_WITH_DLG;
		else
		{
			warning_msg_box(nErr, false, 'E');
			nRet = XFEVT_ABORT;
		}
	}
}
///End REPORT_SHEET_CHECK_CONFLICT

///Kyle 03/02/2009 SHOULD_NOT_CHANGE_OUTPUT_ON_GUI_ON_CHANGE_PARAMETERS
if( nGetNDialog == 0 && (dwCntrl & LTXF_EXECUTE) && 0 == get_plot_number(trGetN) )
	trGetN.rd.strVal = STR_OPTIONAL;
///End SHOULD_NOT_CHANGE_OUTPUT_ON_GUI_ON_CHANGE_PARAMETERS]]></event3><event4 NodeID="45" Label="Event4" DataID="377" MultilineEditExpShrink="1" DispFormat="33554432" RowHeightRange="5-20" Show="0"><![CDATA[return false;]]></event4><GetNEvent NodeID="47" Label="GetNBox Event" DataID="379" Show="0" TypeID="65543" BlobArrElementaryType="8" xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="bin.base64">AA==</GetNEvent></codes><SaveInOpj NodeID="10" Label="Save with Object" DataID="560">0.</SaveInOpj><optargindex NodeID="14" Label="Option Argument Index" DataID="72">0.</optargindex><version NodeID="14" Label="Version" DataID="73">1.</version><category NodeID="11" Label="Primary Category" DataID="74" Show="0">Statistics\Survival Analysis</category><subcategory NodeID="11" Label="Primary Subcategory" DataID="77" Show="0"></subcategory><seccategory1 NodeID="11" Label="Secondary Category" DataID="75" Show="0"></seccategory1><secsubcategory1 NodeID="11" Label="Secondary Subcategory 1" DataID="78" Show="0"></secsubcategory1><seccategory2 NodeID="11" Label="Secondary Category 2" DataID="76" Show="0"></seccategory2><secsubcategory2 NodeID="11" Label="Secondary Subcategory 2" DataID="79" Show="0"></secsubcategory2><module NodeID="11" Label="Module" DataID="80">Pro</module><subGroup NodeID="17" Label="Subgroup Index Within a Category" Combo="-10|-9|-8|-7|-6|-5|-4|-3|-2|-1|0|1|2|3|4|5|6|7|8|9" DataID="82">0.</subGroup><errmsgCount NodeID="14" Label="Number of Error Messages" DataID="412">0.</errmsgCount><helpe NodeID="268435456" Label="English Help" DataID="420" RepeatID="256"><info NodeID="41" Label="Auto Complete Hint" DataID="422" RowHeightRange="2-8">Cox Model Estimator:  Perform a Cox model analysis.</info><summary NodeID="47" Label="Summary" DataID="421" Show="0"><![CDATA[]]></summary><example NodeID="47" Label="Examples" DataID="431" Show="0"><![CDATA[]]></example><ref NodeID="47" Label="References" DataID="432" Show="0"><![CDATA[]]></ref><algorithm NodeID="47" Label="Algorithm" DataID="434" Show="0"><![CDATA[]]></algorithm><parameters NodeID="47" Label="Parameters" DataID="444" Show="0"><![CDATA[]]></parameters><script NodeID="41" Label="LabTalk Script Example" Show="0" DataID="436" RowHeightRange="2-12"></script><errmsgs NodeID="47" Label="Error Messages" DataID="413" Show="0"></errmsgs></helpe><helpj NodeID="268435456" Label="Japanese Help" DataID="420" RepeatID="512"><description NodeID="11" Label="Description" DataID="440" CdPg="932">Cox比例ハザードモデル:Cox比例ハザードモデルの分析を行う。</description><customButtons NodeID="11" Label="GetN Dialog Custom Buttons" DataID="448" CdPg="932"></customButtons><info NodeID="41" Label="Auto Complete Hint" DataID="422" RowHeightRange="2-8" CdPg="932">Cox?????????: Cox??????????????????</info><summary NodeID="47" Label="Summary" DataID="421" Show="0" CdPg="932"><![CDATA[]]></summary><example NodeID="47" Label="Examples" DataID="431" Show="0" CdPg="932"><![CDATA[]]></example><ref NodeID="47" Label="References" DataID="432" Show="0" CdPg="932"><![CDATA[]]></ref><algorithm NodeID="47" Label="Algorithm" DataID="434" Show="0" CdPg="932"><![CDATA[]]></algorithm><parameters NodeID="47" Label="Parameters" DataID="444" Show="0" CdPg="932"><![CDATA[]]></parameters><script NodeID="41" Label="LabTalk Script Example" Show="0" DataID="436" RowHeightRange="2-12" CdPg="932"></script><errmsgs NodeID="47" Label="Error Messages" DataID="413" Show="0" CdPg="932"></errmsgs></helpj><helpg NodeID="268435456" Label="German Help" DataID="420" RepeatID="768"><description NodeID="11" Label="Description" DataID="440" CdPg="1252">Proportionales Hazardmodell, Cox: Ein Proportionales Hazardmodell nach Cox durchführen</description><customButtons NodeID="11" Label="GetN Dialog Custom Buttons" DataID="448" CdPg="1252"></customButtons><info NodeID="41" Label="Auto Complete Hint" DataID="422" RowHeightRange="2-8" CdPg="1252">Proportionales Hazardmodell, Cox: Ein Proportionales Hazardmodell nach Cox durchführen</info><summary NodeID="47" Label="Summary" DataID="421" Show="0" CdPg="1252"><![CDATA[]]></summary><example NodeID="47" Label="Examples" DataID="431" Show="0" CdPg="1252"><![CDATA[]]></example><ref NodeID="47" Label="References" DataID="432" Show="0" CdPg="1252"><![CDATA[]]></ref><algorithm NodeID="47" Label="Algorithm" DataID="434" Show="0" CdPg="1252"><![CDATA[]]></algorithm><parameters NodeID="47" Label="Parameters" DataID="444" Show="0" CdPg="1252"><![CDATA[]]></parameters><script NodeID="41" Label="LabTalk Script Example" Show="0" DataID="436" RowHeightRange="2-12" CdPg="1252"></script><errmsgs NodeID="47" Label="Error Messages" DataID="413" Show="0" CdPg="1252"></errmsgs></helpg><helpc NodeID="268435456" Label="Chinese Help" DataID="420" RepeatID="1024"><description NodeID="11" Label="Description" DataID="440" CdPg="936"></description><customButtons NodeID="11" Label="GetN Dialog Custom Buttons" DataID="448" CdPg="936"></customButtons><info NodeID="41" Label="Auto Complete Hint" DataID="422" RowHeightRange="2-8" CdPg="936"></info><summary NodeID="47" Label="Summary" DataID="421" Show="0" CdPg="936"><![CDATA[]]></summary><example NodeID="47" Label="Examples" DataID="431" Show="0" CdPg="936"><![CDATA[]]></example><ref NodeID="47" Label="References" DataID="432" Show="0" CdPg="936"><![CDATA[]]></ref><algorithm NodeID="47" Label="Algorithm" DataID="434" Show="0" CdPg="936"><![CDATA[]]></algorithm><parameters NodeID="47" Label="Parameters" DataID="444" Show="0" CdPg="936"><![CDATA[]]></parameters><script NodeID="41" Label="LabTalk Script Example" Show="0" DataID="436" RowHeightRange="2-12" CdPg="936"></script><errmsgs NodeID="47" Label="Error Messages" DataID="413" Show="0" CdPg="936"></errmsgs></helpc><SkipHiddenInDlg NodeID="10" Label="Skip hidden in dialog" DataID="295">0.</SkipHiddenInDlg><ClearMsg NodeID="10" Label="Auto Clear Error Message in dialog" DataID="296">1.</ClearMsg><KeepBtnStatus NodeID="10" Label="Keep Button Status for Event Handler" DataID="298">0.</KeepBtnStatus><SptApplyUndoButtonSts NodeID="10" Label="Control Apply and Undo button by User" DataID="294">0.</SptApplyUndoButtonSts><PreviewButton NodeID="10" Label="Show Preview Button" DataID="299">0.</PreviewButton><AutoApplyChkbox NodeID="10" Label="Show Auto Apply CheckBox" DataID="290">1.</AutoApplyChkbox><SkipHelpDoc NodeID="10" Label="Skip Help Document Processing" DataID="297">0.</SkipHelpDoc><SupportFolderLastUsed NodeID="10" Label="Support Folder Last Used Theme" DataID="291">0.</SupportFolderLastUsed><NotCloseOnEnterKey NodeID="10" Label="Do not Close Dialog upon Enter Key" DataID="292">0.</NotCloseOnEnterKey><seeAlso NodeID="11" Label="See Also" DataID="430"></seeAlso><relatedXF NodeID="11" Label="Related X-Functions" DataID="442">kaplanmeier, weibullfit</relatedXF></OriginStorage>
