gnumeric r16887 - in trunk: . component po src src/dialogs src/tools
- From: guelzow svn gnome org
- To: svn-commits-list gnome org
- Subject: gnumeric r16887 - in trunk: . component po src src/dialogs src/tools
- Date: Thu, 16 Oct 2008 06:25:42 +0000 (UTC)
Author: guelzow
Date: Thu Oct 16 06:25:42 2008
New Revision: 16887
URL: http://svn.gnome.org/viewvc/gnumeric?rev=16887&view=rev
Log:
2008-10-16 Andreas J. Guelzow <aguelzow pyrshep ca>
* component/Gnumeric-embed.xml.in: added Kaplan-Meier tool menu item
* src/GNOME_Gnumeric-gtk.xml.in: ditto
* src/HILDON_Gnumeric-gtk.xml.in: ditto
* src/wbc-gtk-actions.c: added ToolsKaplanMeier
2008-10-16 Andreas J. Guelzow <aguelzow pyrshep ca>
* POTFILES.in: added src/tools/analysis-kaplan-meier.c and
src/dialogs/dialog-analysis-tool-kaplan-meier.c
2008-10-16 Andreas J. Guelzow <aguelzow pyrshep ca>
* kaplan-meier.glade: new
* dialog-analysis-tool-kaplan-meier.c: new
* Makefile.am: add kaplan-meier.glade and
dialog-analysis-tool-kaplan-meier.c
* help.h (GNUMERIC_HELP_LINK_KAPLAN_MEIER): new
* dialogs.h (dialog_kaplan_meier_tool): new
* dialog-analysis-tools.c: rename analysis_tools_data_ftest_t
to analysis_tools_data_generic_b_t throughout
2008-10-16 Andreas J. Guelzow <aguelzow pyrshep ca>
* analysis-kaplan-meier.c: new
* analysis-kaplan-meier.h: new
* Makefile.am: add analysis-kaplan-meier.[ch]
* analysis-tools.h: rename analysis_tools_data_ftest_t to
analysis_tools_data_generic_b_t throughout
(analysis_tool_generic_b_clean): new
* analysis-tools.c: rename analysis_tools_data_ftest_t to
analysis_tools_data_generic_b_t throughout
(analysis_tool_ftest_clean): rename to analysis_tool_generic_b_clean
and remove unused first argument, change all callers
Added:
trunk/src/dialogs/dialog-analysis-tool-kaplan-meier.c
trunk/src/dialogs/kaplan-meier.glade
trunk/src/tools/analysis-kaplan-meier.c
trunk/src/tools/analysis-kaplan-meier.h
Modified:
trunk/ChangeLog
trunk/NEWS
trunk/component/Gnumeric-embed.xml.in
trunk/po/ChangeLog
trunk/po/POTFILES.in
trunk/src/GNOME_Gnumeric-gtk.xml.in
trunk/src/HILDON_Gnumeric-gtk.xml.in
trunk/src/dialogs/ChangeLog
trunk/src/dialogs/Makefile.am
trunk/src/dialogs/dialog-analysis-tools.c
trunk/src/dialogs/dialogs.h
trunk/src/dialogs/help.h
trunk/src/tools/ChangeLog
trunk/src/tools/Makefile.am
trunk/src/tools/analysis-tools.c
trunk/src/tools/analysis-tools.h
trunk/src/wbc-gtk-actions.c
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Thu Oct 16 06:25:42 2008
@@ -26,6 +26,7 @@
* Fix minor bugs. [#554818] [#553342]
* Update some of the analysis tools documentation.
* Add non-numeric frequency tables tool. [#134166]
+ * Add basic Kaplan-Meier Estimates Tool. [#453765]
Jean:
* Fix printing of rotated text. [#539734]
Modified: trunk/component/Gnumeric-embed.xml.in
==============================================================================
--- trunk/component/Gnumeric-embed.xml.in (original)
+++ trunk/component/Gnumeric-embed.xml.in Thu Oct 16 06:25:42 2008
@@ -169,10 +169,11 @@
<menuitem action="ToolsAverage"/>
</menu>
<menuitem action="ToolsFourier"/>
- <menu name="ToolForecast" action="MenuToolFrequencies">
+ <menu name="ToolFrequencies" action="MenuToolFrequencies">
<menuitem action="ToolsFrequency"/>
<menuitem action="ToolsHistogram"/>
</menu>
+ <menuitem action="ToolsKaplanMeier"/>
<menuitem action="ToolsRanking"/>
<menuitem action="ToolsRegression"/>
<menuitem action="ToolsSampling"/>
Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in (original)
+++ trunk/po/POTFILES.in Thu Oct 16 06:25:42 2008
@@ -142,6 +142,7 @@
src/dialogs/dialog-about.c
src/dialogs/dialog-advanced-filter.c
src/dialogs/dialog-analysis-tool-frequency.c
+src/dialogs/dialog-analysis-tool-kaplan-meier.c
src/dialogs/dialog-analysis-tools.c
src/dialogs/dialog-autocorrect.c
src/dialogs/dialog-autofilter.c
@@ -298,6 +299,7 @@
src/tools/analysis-exp-smoothing.c
src/tools/analysis-frequency.c
src/tools/analysis-histogram.c
+src/tools/analysis-kaplan-meier.c
src/tools/analysis-tools.c
src/tools/dao.c
src/tools/data-shuffling.c
Modified: trunk/src/GNOME_Gnumeric-gtk.xml.in
==============================================================================
--- trunk/src/GNOME_Gnumeric-gtk.xml.in (original)
+++ trunk/src/GNOME_Gnumeric-gtk.xml.in Thu Oct 16 06:25:42 2008
@@ -177,6 +177,7 @@
<menuitem action="ToolsFrequency"/>
<menuitem action="ToolsHistogram"/>
</menu>
+ <menuitem action="ToolsKaplanMeier"/>
<menuitem action="ToolsRanking"/>
<menuitem action="ToolsRegression"/>
<menuitem action="ToolsSampling"/>
Modified: trunk/src/HILDON_Gnumeric-gtk.xml.in
==============================================================================
--- trunk/src/HILDON_Gnumeric-gtk.xml.in (original)
+++ trunk/src/HILDON_Gnumeric-gtk.xml.in Thu Oct 16 06:25:42 2008
@@ -182,7 +182,8 @@
<menuitem action="ToolsFrequency"/>
<menuitem action="ToolsHistogram"/>
</menu>
- <menuitem action="ToolsRanking"/>
+ <menuitem action="ToolsKaplanMeier"/>
+ <menuitem action="ToolsRanking"/>
<menuitem action="ToolsRegression"/>
<menuitem action="ToolsSampling"/>
<menu name="ToolTTest" action="MenuToolTTest">
Modified: trunk/src/dialogs/Makefile.am
==============================================================================
--- trunk/src/dialogs/Makefile.am (original)
+++ trunk/src/dialogs/Makefile.am Thu Oct 16 06:25:42 2008
@@ -27,6 +27,7 @@
dialog-advanced-filter.c \
dialog-analysis-tools.c \
dialog-analysis-tool-frequency.c \
+ dialog-analysis-tool-kaplan-meier.c \
dialog-autocorrect.c \
dialog-autofilter.c \
dialog-autoformat.c \
@@ -125,6 +126,7 @@
histogram.glade \
hyperlink.glade \
insert-cells.glade \
+ kaplan-meier.glade \
mean-tests.glade \
merge.glade \
moving-averages.glade \
Added: trunk/src/dialogs/dialog-analysis-tool-kaplan-meier.c
==============================================================================
--- (empty file)
+++ trunk/src/dialogs/dialog-analysis-tool-kaplan-meier.c Thu Oct 16 06:25:42 2008
@@ -0,0 +1,337 @@
+/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * dialog-analysis-tool-kaplan-meier.c:
+ *
+ * Authors:
+ * Andreas J. Guelzow <aguelzow taliesin ca>
+ *
+ * (C) Copyright 2008 by Andreas J. Guelzow <aguelzow pyrshep ca>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <gnumeric-config.h>
+#include <glib/gi18n-lib.h>
+#include <gnumeric.h>
+#include "dialogs.h"
+#include "analysis-kaplan-meier.h"
+#include "analysis-tools.h"
+
+#include <workbook.h>
+#include <workbook-control.h>
+#include <wbc-gtk.h>
+#include <workbook-view.h>
+#include <gui-util.h>
+#include <parse-util.h>
+#include <gnm-format.h>
+#include <tool-dialogs.h>
+#include <dao-gui-utils.h>
+#include <sheet.h>
+#include <expr.h>
+#include <number-match.h>
+#include <ranges.h>
+#include <selection.h>
+#include <value.h>
+#include <commands.h>
+#include "help.h"
+
+#include <widgets/gnm-dao.h>
+#include <widgets/gnumeric-expr-entry.h>
+
+#include <glade/glade.h>
+#include <string.h>
+#include <gtk/gtktable.h>
+#include <gtk/gtktogglebutton.h>
+#include <gtk/gtkspinbutton.h>
+#include <gtk/gtklabel.h>
+
+#define KAPLAN_MEIER_KEY "analysistools-kaplan-meier-dialog"
+
+typedef struct {
+ GenericToolState base;
+ GtkWidget *censorship_button;
+ GtkWidget *censorship_button_zero;
+ GtkWidget *censorship_button_one;
+ GtkWidget *graph_button;
+ GtkWidget *tick_button;
+ GtkWidget *std_error_button;
+} KaplanMeierToolState;
+
+static char const * const censor_mark_group[] = {
+ "censor-button-0",
+ "censor-button-1",
+ NULL
+};
+
+/**
+ * kaplan_meier_tool_update_sensitivity_cb:
+ * @dummy:
+ * @state:
+ *
+ * Update the dialog widgets sensitivity
+ **/
+static void
+kaplan_meier_tool_update_sensitivity_cb (G_GNUC_UNUSED GtkWidget *dummy,
+ KaplanMeierToolState *state)
+{
+ gboolean censorship;
+ GnmValue *input_range;
+ GnmValue *input_range_2 = NULL;
+ int height, width;
+
+
+ input_range = gnm_expr_entry_parse_as_value
+ (GNM_EXPR_ENTRY (state->base.input_entry), state->base.sheet);
+ if (input_range == NULL) {
+ gtk_label_set_text (GTK_LABEL (state->base.warning),
+ _("The time column is not valid."));
+ gtk_widget_set_sensitive (state->base.ok_button, FALSE);
+ return;
+ }
+
+ height = input_range->v_range.cell.b.row - input_range->v_range.cell.a.row;
+ width = input_range->v_range.cell.b.col - input_range->v_range.cell.a.col;
+
+ value_release (input_range);
+
+ if (width != 0) {
+ gtk_label_set_text (GTK_LABEL (state->base.warning),
+ _("The time column should be part of a single column."));
+ gtk_widget_set_sensitive (state->base.ok_button, FALSE);
+ return;
+ }
+
+ censorship = gtk_toggle_button_get_active (
+ GTK_TOGGLE_BUTTON (state->censorship_button));
+ if (censorship) {
+ input_range_2 = gnm_expr_entry_parse_as_value
+ (GNM_EXPR_ENTRY (state->base.input_entry_2), state->base.sheet);
+ if (input_range_2 == NULL) {
+ gtk_label_set_text (GTK_LABEL (state->base.warning),
+ _("The censorship column is not valid."));
+ gtk_widget_set_sensitive (state->base.ok_button, FALSE);
+ return;
+ }
+
+ if (input_range_2->v_range.cell.b.col != input_range_2->v_range.cell.a.col) {
+ gtk_label_set_text (GTK_LABEL (state->base.warning),
+ _("The censorship column should be part of a single column."));
+ gtk_widget_set_sensitive (state->base.ok_button, FALSE);
+ value_release (input_range_2);
+ return;
+ }
+ if (input_range_2->v_range.cell.b.row - input_range_2->v_range.cell.a.row != height) {
+ gtk_label_set_text (GTK_LABEL (state->base.warning),
+ _("The censorship and time columns should have the same height."));
+ gtk_widget_set_sensitive (state->base.ok_button, FALSE);
+ value_release (input_range_2);
+ return;
+ }
+
+ value_release (input_range_2);
+ }
+
+ if (!gnm_dao_is_ready (GNM_DAO (state->base.gdao))) {
+ gtk_label_set_text (GTK_LABEL (state->base.warning),
+ _("The output specification "
+ "is invalid."));
+ gtk_widget_set_sensitive (state->base.ok_button, FALSE);
+ return;
+ }
+
+ gtk_label_set_text (GTK_LABEL (state->base.warning), "");
+ gtk_widget_set_sensitive (state->base.ok_button, TRUE);
+
+ return;
+}
+
+/**
+ * kaplan_meier_tool_ok_clicked_cb:
+ * @button:
+ * @state:
+ *
+ * Retrieve the information from the dialog and call the kaplan_meier_tool.
+ * Note that we assume that the ok_button is only active if the entry fields
+ * contain sensible data.
+ **/
+static void
+kaplan_meier_tool_ok_clicked_cb (G_GNUC_UNUSED GtkWidget *button,
+ KaplanMeierToolState *state)
+{
+ data_analysis_output_t *dao;
+ analysis_tools_data_kaplan_meier_t *data;
+
+ data = g_new0 (analysis_tools_data_kaplan_meier_t, 1);
+ dao = parse_output ((GenericToolState *)state, NULL);
+
+
+ data->base.wbc = WORKBOOK_CONTROL (state->base.wbcg);
+
+ if (state->base.warning_dialog != NULL)
+ gtk_widget_destroy (state->base.warning_dialog);
+
+ data->base.range_1 = gnm_expr_entry_parse_as_value
+ (GNM_EXPR_ENTRY (state->base.input_entry), state->base.sheet);
+
+ data->censored = gtk_toggle_button_get_active (
+ GTK_TOGGLE_BUTTON (state->censorship_button));
+
+ if (data->censored)
+ data->base.range_2 = gnm_expr_entry_parse_as_value
+ (GNM_EXPR_ENTRY (state->base.input_entry_2), state->base.sheet);
+ else
+ data->base.range_2 = NULL;
+
+ data->censor_mark = gnumeric_glade_group_value (state->base.gui,
+ censor_mark_group);
+ data->chart = gtk_toggle_button_get_active (
+ GTK_TOGGLE_BUTTON (state->graph_button));
+ data->ticks = gtk_toggle_button_get_active (
+ GTK_TOGGLE_BUTTON (state->tick_button));
+ data->std_err = gtk_toggle_button_get_active (
+ GTK_TOGGLE_BUTTON (state->std_error_button));
+
+ if (!cmd_analysis_tool (WORKBOOK_CONTROL (state->base.wbcg), state->base.sheet,
+ dao, data, analysis_tool_kaplan_meier_engine))
+ gtk_widget_destroy (state->base.dialog);
+
+ return;
+}
+
+/**
+ * kaplan_meier_tool_set_graph:
+ * @widget:
+ * @focus_widget:
+ * @state:
+ *
+ *
+ **/
+static gboolean
+kaplan_meier_tool_set_graph_cb (G_GNUC_UNUSED GtkWidget *dummy,
+ KaplanMeierToolState *state)
+{
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (state->graph_button), TRUE);
+ kaplan_meier_tool_update_sensitivity_cb (NULL, state);
+ return FALSE;
+}
+
+/**
+ * kaplan_meier_tool_set_censorship:
+ * @widget:
+ * @event:
+ * @state:
+ *
+ **/
+static gboolean
+kaplan_meier_tool_set_censorship_cb (G_GNUC_UNUSED GtkWidget *widget,
+ G_GNUC_UNUSED GdkEventFocus *event,
+ KaplanMeierToolState *state)
+{
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (state->censorship_button), TRUE);
+ return FALSE;
+}
+static gboolean
+kaplan_meier_tool_set_censor_cb (G_GNUC_UNUSED GtkWidget *dummy,
+ KaplanMeierToolState *state)
+{
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (state->censorship_button), TRUE);
+
+ return FALSE;
+}
+
+/**
+ * dialog_kaplan_meier_tool:
+ * @wbcg:
+ * @sheet:
+ *
+ * Show the dialog (guru).
+ *
+ **/
+int
+dialog_kaplan_meier_tool (WBCGtk *wbcg, Sheet *sheet)
+{
+ KaplanMeierToolState *state;
+
+ if (wbcg == NULL) {
+ return 1;
+ }
+
+
+ /* Only pop up one copy per workbook */
+ if (gnumeric_dialog_raise_if_exists (wbcg, KAPLAN_MEIER_KEY))
+ return 0;
+
+ state = g_new0 (KaplanMeierToolState, 1);
+
+ if (dialog_tool_init (&state->base, wbcg, sheet,
+ GNUMERIC_HELP_LINK_KAPLAN_MEIER,
+ "kaplan-meier.glade", "KaplanMeier",
+ _("Could not create the Kaplan Meier Tool dialog."),
+ KAPLAN_MEIER_KEY,
+ G_CALLBACK (kaplan_meier_tool_ok_clicked_cb), NULL,
+ G_CALLBACK (kaplan_meier_tool_update_sensitivity_cb),
+ 0))
+ return 0;
+
+
+
+ state->censorship_button = GTK_WIDGET (glade_xml_get_widget
+ (state->base.gui,
+ "censor-button"));
+ state->censorship_button_zero = GTK_WIDGET (glade_xml_get_widget
+ (state->base.gui,
+ "censor-button-0"));
+ state->censorship_button_one = GTK_WIDGET (glade_xml_get_widget
+ (state->base.gui,
+ "censor-button-1"));
+ state->graph_button = GTK_WIDGET (glade_xml_get_widget
+ (state->base.gui,
+ "graph-button"));
+ state->tick_button = GTK_WIDGET (glade_xml_get_widget
+ (state->base.gui,
+ "tick-button"));
+ state->std_error_button = GTK_WIDGET (glade_xml_get_widget
+ (state->base.gui,
+ "std-error-button"));
+ g_signal_connect_after (G_OBJECT (state->censorship_button),
+ "toggled",
+ G_CALLBACK (kaplan_meier_tool_update_sensitivity_cb), state);
+ g_signal_connect_after (G_OBJECT (state->graph_button),
+ "toggled",
+ G_CALLBACK (kaplan_meier_tool_update_sensitivity_cb), state);
+ g_signal_connect_after (G_OBJECT (state->std_error_button),
+ "toggled",
+ G_CALLBACK (kaplan_meier_tool_update_sensitivity_cb), state);
+ g_signal_connect_after (G_OBJECT (state->tick_button),
+ "toggled",
+ G_CALLBACK (kaplan_meier_tool_set_graph_cb), state);
+ g_signal_connect_after (G_OBJECT (state->censorship_button_zero),
+ "toggled",
+ G_CALLBACK (kaplan_meier_tool_set_censor_cb), state);
+ g_signal_connect_after (G_OBJECT (state->censorship_button_one),
+ "toggled",
+ G_CALLBACK (kaplan_meier_tool_set_censor_cb), state);
+ g_signal_connect (G_OBJECT
+ (gnm_expr_entry_get_entry (
+ GNM_EXPR_ENTRY (state->base.input_entry_2))),
+ "focus-in-event",
+ G_CALLBACK (kaplan_meier_tool_set_censorship_cb), state);
+
+ gnm_dao_set_put (GNM_DAO (state->base.gdao), TRUE, TRUE);
+ kaplan_meier_tool_update_sensitivity_cb (NULL, state);
+ tool_load_selection ((GenericToolState *)state, TRUE);
+
+ return 0;
+}
Modified: trunk/src/dialogs/dialog-analysis-tools.c
==============================================================================
--- trunk/src/dialogs/dialog-analysis-tools.c (original)
+++ trunk/src/dialogs/dialog-analysis-tools.c Thu Oct 16 06:25:42 2008
@@ -1641,12 +1641,12 @@
FTestToolState *state)
{
data_analysis_output_t *dao;
- analysis_tools_data_ftest_t *data;
+ analysis_tools_data_generic_b_t *data;
GtkWidget *w;
gint err;
- data = g_new0 (analysis_tools_data_ftest_t, 1);
+ data = g_new0 (analysis_tools_data_generic_b_t, 1);
dao = parse_output ((GenericToolState *)state, NULL);
data->wbc = WORKBOOK_CONTROL (state->base.wbcg);
Modified: trunk/src/dialogs/dialogs.h
==============================================================================
--- trunk/src/dialogs/dialogs.h (original)
+++ trunk/src/dialogs/dialogs.h Thu Oct 16 06:25:42 2008
@@ -88,6 +88,7 @@
int dialog_anova_two_factor_tool (WBCGtk *wbcg, Sheet *sheet);
int dialog_histogram_tool (WBCGtk *wbcg, Sheet *sheet);
int dialog_frequency_tool (WBCGtk *wbcg, Sheet *sheet);
+int dialog_kaplan_meier_tool (WBCGtk *wbcg, Sheet *sheet);
typedef enum {
TTEST_PAIRED = 1,
Modified: trunk/src/dialogs/help.h
==============================================================================
--- trunk/src/dialogs/help.h (original)
+++ trunk/src/dialogs/help.h Thu Oct 16 06:25:42 2008
@@ -149,6 +149,9 @@
/* dialog-analysis-tool-frequency.c */
#define GNUMERIC_HELP_LINK_FREQUENCY "sect-analysis-statistical"
+/* dialog-analysis-tool-kaplan-meier.c */
+#define GNUMERIC_HELP_LINK_KAPLAN_MEIER "sect-analysis-statistical"
+
/* dialog-consolidate.c */
#define GNUMERIC_HELP_LINK_CONSOLIDATE ""
Added: trunk/src/dialogs/kaplan-meier.glade
==============================================================================
--- (empty file)
+++ trunk/src/dialogs/kaplan-meier.glade Thu Oct 16 06:25:42 2008
@@ -0,0 +1,312 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--*- mode: xml -*-->
+<glade-interface>
+ <widget class="GtkDialog" id="KaplanMeier">
+ <property name="border_width">6</property>
+ <property name="title" translatable="yes">Histogram</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+ <property name="has_separator">False</property>
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="vbox1">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <widget class="GtkNotebook" id="notebook1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="border_width">5</property>
+ <child>
+ <widget class="GtkVBox" id="vbox5">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkTable" id="input-table">
+ <property name="visible">True</property>
+ <property name="border_width">12</property>
+ <property name="n_rows">5</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">12</property>
+ <property name="row_spacing">2</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="var1-label">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="xpad">5</property>
+ <property name="label" translatable="yes">Time column:</property>
+ <property name="use_underline">True</property>
+ <property name="justify">GTK_JUSTIFY_RIGHT</property>
+ </widget>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="var2-label">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="xpad">25</property>
+ <property name="label" translatable="yes">Censor column:</property>
+ <property name="use_underline">True</property>
+ <property name="justify">GTK_JUSTIFY_RIGHT</property>
+ </widget>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkCheckButton" id="censor-button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Permit censorship</property>
+ <property name="response_id">0</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkRadioButton" id="censor-button-0">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Censored are marked by 0</property>
+ <property name="response_id">0</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="right_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="x_padding">50</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkRadioButton" id="censor-button-1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Censored are marked by 1</property>
+ <property name="response_id">0</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">censor-button-0</property>
+ </widget>
+ <packing>
+ <property name="right_attach">2</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="x_padding">50</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Input</property>
+ <property name="use_underline">True</property>
+ <property name="justify">GTK_JUSTIFY_CENTER</property>
+ </widget>
+ <packing>
+ <property name="type">tab</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkVBox" id="vbox4">
+ <property name="visible">True</property>
+ <property name="border_width">12</property>
+ <child>
+ <widget class="GtkTable" id="table1">
+ <property name="visible">True</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">25</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <widget class="GtkCheckButton" id="graph-button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Show graph </property>
+ <property name="response_id">0</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="right_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkCheckButton" id="tick-button">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Include censorship ticks</property>
+ <property name="response_id">0</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkCheckButton" id="std-error-button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Show standard errors</property>
+ <property name="response_id">0</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">O_ptions</property>
+ <property name="use_markup">True</property>
+ <property name="use_underline">True</property>
+ <property name="justify">GTK_JUSTIFY_CENTER</property>
+ </widget>
+ <packing>
+ <property name="type">tab</property>
+ <property name="position">1</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="dao">
+ <property name="visible">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Output</property>
+ <property name="use_underline">True</property>
+ <property name="justify">GTK_JUSTIFY_CENTER</property>
+ </widget>
+ <packing>
+ <property name="type">tab</property>
+ <property name="position">2</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="warnings">
+ <property name="visible">True</property>
+ <property name="wrap">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="hbuttonbox1">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+ <child>
+ <widget class="GtkButton" id="helpbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="label">gtk-help</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">0</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkButton" id="cancelbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="label">gtk-cancel</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">0</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="okbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="label">gtk-ok</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">0</property>
+ </widget>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+</glade-interface>
Modified: trunk/src/tools/Makefile.am
==============================================================================
--- trunk/src/tools/Makefile.am (original)
+++ trunk/src/tools/Makefile.am Thu Oct 16 06:25:42 2008
@@ -25,6 +25,8 @@
analysis-frequency.h \
analysis-histogram.c \
analysis-histogram.h \
+ analysis-kaplan-meier.c \
+ analysis-kaplan-meier.h \
analysis-tools.c \
analysis-tools.h \
random-generator.c \
Added: trunk/src/tools/analysis-kaplan-meier.c
==============================================================================
--- (empty file)
+++ trunk/src/tools/analysis-kaplan-meier.c Thu Oct 16 06:25:42 2008
@@ -0,0 +1,329 @@
+/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * analysis-kaplan-meier.c:
+ *
+ *
+ * Author:
+ * Andreas J. Guelzow <aguelzow pyrshep ca>
+ *
+ * (C) Copyright 2008 by Andreas J. Guelzow <aguelzow pyrshep ca>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <gnumeric-config.h>
+#include <glib/gi18n-lib.h>
+#include "gnumeric.h"
+#include "analysis-kaplan-meier.h"
+#include "analysis-tools.h"
+#include "value.h"
+#include "ranges.h"
+#include "expr.h"
+#include "func.h"
+#include "numbers.h"
+#include "sheet-object-graph.h"
+#include <goffice/graph/gog-graph.h>
+#include <goffice/graph/gog-object.h>
+#include <goffice/graph/gog-chart.h>
+#include <goffice/graph/gog-plot.h>
+#include <goffice/graph/gog-series.h>
+#include <goffice/graph/gog-style.h>
+#include <goffice/graph/gog-styled-object.h>
+#include <goffice/utils/go-glib-extras.h>
+#include <goffice/utils/go-marker.h>
+
+static gboolean
+analysis_tool_kaplan_meier_engine_run (data_analysis_output_t *dao,
+ analysis_tools_data_kaplan_meier_t *info)
+{
+ int rows, row;
+
+ GnmExpr const *expr_data;
+ GnmExpr const *expr_censor;
+ GnmExpr const *expr_small;
+ GnmExpr const *expr_time;
+ GnmExpr const *expr_at_risk;
+ GnmExpr const *expr_deaths;
+ GnmExpr const *expr_prob_zero;
+ GnmExpr const *expr_prob;
+ GnmExpr const *expr_std_err = NULL;
+
+ GnmFunc *fd_if;
+ GnmFunc *fd_iserror;
+ GnmFunc *fd_small;
+ GnmFunc *fd_sum;
+ GnmFunc *fd_sqrt = NULL;
+
+ fd_small = gnm_func_lookup ("SMALL", NULL);
+ gnm_func_ref (fd_small);
+ fd_if = gnm_func_lookup ("IF", NULL);
+ gnm_func_ref (fd_if);
+ fd_iserror = gnm_func_lookup ("ISERROR", NULL);
+ gnm_func_ref (fd_iserror);
+ fd_sum = gnm_func_lookup ("SUM", NULL);
+ gnm_func_ref (fd_sum);
+
+ if (info->std_err) {
+ fd_sqrt = gnm_func_lookup ("SQRT", NULL);
+ gnm_func_ref (fd_sqrt);
+ }
+
+ rows = info->base.range_1->v_range.cell.b.row
+ - info->base.range_1->v_range.cell.a.row + 1;
+
+ dao_set_italic (dao, 0, 0, 0, 0);
+ dao_set_cell (dao, 0, 0, _("Kaplan-Meier"));
+
+ dao_set_italic (dao, 0, 1, 3, 1);
+ set_cell_text_row (dao, 0, 1,
+ "/Time"
+ "/At Risk"
+ "/Deaths"
+ "/Probability");
+ if (info->std_err) {
+ dao_set_italic (dao, 4, 1, 4, 1);
+ dao_set_cell (dao, 4, 1, "Standard Error");
+ }
+
+ expr_data = gnm_expr_new_constant (value_dup (info->base.range_1));
+
+ expr_at_risk = gnm_expr_new_funcall3
+ (fd_if,
+ gnm_expr_new_binary (make_cellref (-1, 0),
+ GNM_EXPR_OP_EQUAL,
+ gnm_expr_new_constant (value_new_string (""))),
+ gnm_expr_new_constant (value_new_string ("")),
+ gnm_expr_new_funcall1 (fd_sum,
+ gnm_expr_new_funcall3
+ (fd_if,
+ gnm_expr_new_binary
+ (gnm_expr_copy (expr_data),
+ GNM_EXPR_OP_LT,
+ make_cellref (-1, 0)),
+ gnm_expr_new_constant (value_new_int (0)),
+ gnm_expr_new_constant (value_new_int (1)))));
+
+ if (info->censored) {
+ expr_censor = gnm_expr_new_constant (value_dup (info->base.range_2));
+ expr_deaths = gnm_expr_new_funcall3
+ (fd_if,
+ gnm_expr_new_binary (make_cellref (-1, 0),
+ GNM_EXPR_OP_EQUAL,
+ gnm_expr_new_constant (value_new_string (""))),
+ gnm_expr_new_constant (value_new_string ("")),
+ gnm_expr_new_funcall1 (fd_sum,
+ gnm_expr_new_binary
+ (gnm_expr_new_funcall3
+ (fd_if,
+ gnm_expr_new_binary
+ (gnm_expr_copy (expr_data),
+ GNM_EXPR_OP_EQUAL,
+ make_cellref (-2, 0)),
+ gnm_expr_new_constant (value_new_int (1)),
+ gnm_expr_new_constant (value_new_int (0))),
+ GNM_EXPR_OP_MULT,
+ gnm_expr_new_funcall3
+ (fd_if,
+ gnm_expr_new_binary
+ (expr_censor,
+ GNM_EXPR_OP_EQUAL,
+ gnm_expr_new_constant (value_new_int (info->censor_mark))),
+ gnm_expr_new_constant (value_new_int (0)),
+ gnm_expr_new_constant (value_new_int (1))))));
+ } else
+ expr_deaths = gnm_expr_new_funcall3
+ (fd_if,
+ gnm_expr_new_binary (make_cellref (-1, 0),
+ GNM_EXPR_OP_EQUAL,
+ gnm_expr_new_constant (value_new_string (""))),
+ gnm_expr_new_constant (value_new_string ("")),
+ gnm_expr_new_funcall1 (fd_sum,
+ gnm_expr_new_funcall3
+ (fd_if,
+ gnm_expr_new_binary
+ (gnm_expr_copy (expr_data),
+ GNM_EXPR_OP_EQUAL,
+ make_cellref (-2, 0)),
+ gnm_expr_new_constant (value_new_int (1)),
+ gnm_expr_new_constant (value_new_int (0)))));
+
+ expr_small = gnm_expr_new_funcall2 (fd_small,
+ gnm_expr_new_funcall3
+ (fd_if,
+ gnm_expr_new_binary
+ (gnm_expr_copy (expr_data),
+ GNM_EXPR_OP_GT,
+ make_cellref (0, -1)),
+ expr_data,
+ gnm_expr_new_constant (value_new_string ("N/A"))),
+ gnm_expr_new_constant (value_new_int (1)));
+ expr_time = gnm_expr_new_funcall3 (fd_if,
+ gnm_expr_new_funcall1 (fd_iserror,
+ gnm_expr_copy (expr_small)),
+ gnm_expr_new_constant (value_new_string ("")),
+ expr_small);
+
+ expr_prob_zero = gnm_expr_new_binary (gnm_expr_new_binary (make_cellref (-2, 0),
+ GNM_EXPR_OP_SUB,
+ make_cellref (-1, 0)),
+ GNM_EXPR_OP_DIV,
+ make_cellref (-2, 0));
+ expr_prob = gnm_expr_new_funcall3 (fd_if,
+ gnm_expr_new_binary
+ (make_cellref (-1, 0),
+ GNM_EXPR_OP_EQUAL,
+ gnm_expr_new_constant (value_new_string (""))),
+ gnm_expr_new_constant (value_new_string ("")),
+ gnm_expr_new_binary (gnm_expr_copy (expr_prob_zero),
+ GNM_EXPR_OP_MULT,
+ make_cellref (0, -1)));
+
+ if (info->std_err) {
+ expr_std_err = gnm_expr_new_funcall3 (fd_if,
+ gnm_expr_new_binary
+ (make_cellref (-1, 0),
+ GNM_EXPR_OP_EQUAL,
+ gnm_expr_new_constant (value_new_string (""))),
+ gnm_expr_new_constant (value_new_string ("")),
+ gnm_expr_new_binary (make_cellref (-1, 0),
+ GNM_EXPR_OP_MULT,
+ gnm_expr_new_funcall1
+ (fd_sqrt,
+ gnm_expr_new_binary
+ (gnm_expr_new_binary
+ (gnm_expr_new_constant (value_new_int (1)),
+ GNM_EXPR_OP_SUB,
+ make_cellref (-1, 0)),
+ GNM_EXPR_OP_DIV,
+ make_cellref (-3, 0)))));
+
+ dao_set_format (dao, 4, 2, 4, rows + 1, "0.0000");
+ dao_set_cell_expr (dao, 4, 2, gnm_expr_copy (expr_std_err));
+ }
+
+ dao_set_format (dao, 3, 2, 3, rows + 1, "0.00%");
+
+ dao_set_cell_int (dao, 0, 2, 0);
+ dao_set_cell_array_expr (dao, 1, 2, gnm_expr_copy (expr_at_risk));
+ dao_set_cell_array_expr (dao, 2, 2, gnm_expr_copy (expr_deaths));
+ dao_set_cell_expr (dao, 3, 2, expr_prob_zero);
+
+ for (row = 1; row < rows; row++) {
+ dao_set_cell_array_expr (dao, 0, 2+row, gnm_expr_copy (expr_time));
+ dao_set_cell_array_expr (dao, 1, 2+row, gnm_expr_copy (expr_at_risk));
+ dao_set_cell_array_expr (dao, 2, 2+row, gnm_expr_copy (expr_deaths));
+ dao_set_cell_array_expr (dao, 3, 2+row, gnm_expr_copy (expr_prob));
+ if (info->std_err)
+ dao_set_cell_expr (dao, 4, 2+row, gnm_expr_copy (expr_std_err));
+ }
+
+ gnm_expr_free (expr_time);
+ gnm_expr_free (expr_at_risk);
+ gnm_expr_free (expr_deaths);
+ gnm_expr_free (expr_prob);
+ if (expr_std_err != NULL)
+ gnm_expr_free (expr_std_err);
+
+ gnm_func_unref (fd_small);
+ gnm_func_unref (fd_if);
+ gnm_func_unref (fd_iserror);
+ gnm_func_unref (fd_sum);
+ if (fd_sqrt != NULL)
+ gnm_func_unref (fd_sqrt);
+
+ /* Create Chart if requested */
+ if (info->chart) {
+ SheetObject *so;
+ GogGraph *graph;
+ GogChart *chart;
+ GogPlot *plot;
+ GogSeries *series;
+ GOData *times;
+ GOData *probabilities;
+ GogStyle *style;
+
+ graph = g_object_new (GOG_GRAPH_TYPE, NULL);
+ chart = GOG_CHART (gog_object_add_by_name (
+ GOG_OBJECT (graph), "Chart", NULL));
+
+ plot = gog_plot_new_by_name ("GogXYPlot");
+ go_object_set_property (G_OBJECT (plot), "interpolation",
+ "Default interpolation", "step-start",
+ NULL, NULL);
+
+ gog_object_add_by_name (GOG_OBJECT (chart),
+ "Plot", GOG_OBJECT (plot));
+
+ times = dao_go_data_vector (dao, 0, 2, 0, 1+rows);
+ probabilities = dao_go_data_vector (dao, 3, 2, 3, 1+rows);
+
+ series = gog_plot_new_series (plot);
+ gog_series_set_dim (series, 0, times, NULL);
+ gog_series_set_dim (series, 1, probabilities, NULL);
+
+ style = gog_styled_object_get_style (GOG_STYLED_OBJECT (series));
+ style->marker.auto_shape = FALSE;
+ go_marker_set_shape (style->marker.mark, GO_MARKER_NONE);
+ gog_styled_object_set_style (GOG_STYLED_OBJECT (series), style);
+
+ so = sheet_object_graph_new (graph);
+ g_object_unref (graph);
+
+ dao_set_sheet_object (dao, 0, 1, so);
+ }
+
+ dao_redraw_respan (dao);
+
+ return FALSE;
+}
+
+
+gboolean
+analysis_tool_kaplan_meier_engine (data_analysis_output_t *dao, gpointer specs,
+ analysis_tool_engine_t selector, gpointer result)
+{
+ analysis_tools_data_kaplan_meier_t *info = specs;
+
+ switch (selector) {
+ case TOOL_ENGINE_UPDATE_DESCRIPTOR:
+ return (dao_command_descriptor (dao,
+ _("Kaplan-Meier (%s)"),
+ result)
+ == NULL);
+ case TOOL_ENGINE_UPDATE_DAO:
+ dao_adjust (dao, info->std_err ? 5 : 4,
+ info->base.range_1->v_range.cell.b.row
+ - info->base.range_1->v_range.cell.a.row + 3);
+ return FALSE;
+ case TOOL_ENGINE_CLEAN_UP:
+ return analysis_tool_generic_b_clean (specs);
+ case TOOL_ENGINE_LAST_VALIDITY_CHECK:
+ return FALSE;
+ case TOOL_ENGINE_PREPARE_OUTPUT_RANGE:
+ dao_prepare_output (NULL, dao, _("Kaplan-Meier Estimates"));
+ return FALSE;
+ case TOOL_ENGINE_FORMAT_OUTPUT_RANGE:
+ return dao_format_output (dao, _("Kaplan-Meier Estimates"));
+ case TOOL_ENGINE_PERFORM_CALC:
+ default:
+ return analysis_tool_kaplan_meier_engine_run (dao, specs);
+ }
+ return TRUE;
+}
+
+
+
+
Added: trunk/src/tools/analysis-kaplan-meier.h
==============================================================================
--- (empty file)
+++ trunk/src/tools/analysis-kaplan-meier.h Thu Oct 16 06:25:42 2008
@@ -0,0 +1,61 @@
+/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * analysis-kaplan-meier.h:
+ *
+ * Author:
+ * Andreas J. Guelzow <aguelzow pyrshep ca>
+ *
+ * (C) Copyright 2008 by Andreas J. Guelzow <aguelzow pyrshep ca>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+#ifndef ANALYSIS_KAPLAN_MEIER_H
+#define ANALYSIS_KAPLAN_MEIER_H
+
+#include "gnumeric.h"
+#include "numbers.h"
+#include "dao.h"
+#include "tools.h"
+#include "analysis-tools.h"
+
+
+/* typedef struct { */
+/* analysis_tools_error_code_t err; */
+/* WorkbookControl *wbc; */
+/* GnmValue *range_1; */
+/* GnmValue *range_2; */
+/* gboolean labels; */
+/* gnm_float alpha; */
+/* } analysis_tools_data_ftest_t; */
+
+
+typedef struct {
+ analysis_tools_data_generic_b_t base;
+ gboolean censored;
+ int censor_mark;
+ gboolean chart;
+ gboolean ticks;
+ gboolean std_err;
+} analysis_tools_data_kaplan_meier_t;
+
+gboolean analysis_tool_kaplan_meier_engine (data_analysis_output_t *dao,
+ gpointer specs,
+ analysis_tool_engine_t selector,
+ gpointer result);
+
+#endif
Modified: trunk/src/tools/analysis-tools.c
==============================================================================
--- trunk/src/tools/analysis-tools.c (original)
+++ trunk/src/tools/analysis-tools.c Thu Oct 16 06:25:42 2008
@@ -689,11 +689,10 @@
return FALSE;
}
-static gboolean
-analysis_tool_ftest_clean (G_GNUC_UNUSED data_analysis_output_t *dao,
- gpointer specs)
+gboolean
+analysis_tool_generic_b_clean (gpointer specs)
{
- analysis_tools_data_ftest_t *info = specs;
+ analysis_tools_data_generic_b_t *info = specs;
value_release (info->range_1);
info->range_1 = NULL;
@@ -1725,7 +1724,7 @@
dao_adjust (dao, 3, 11);
return FALSE;
case TOOL_ENGINE_CLEAN_UP:
- return analysis_tool_ftest_clean (dao, specs);
+ return analysis_tool_generic_b_clean (specs);
case TOOL_ENGINE_LAST_VALIDITY_CHECK:
return FALSE;
case TOOL_ENGINE_PREPARE_OUTPUT_RANGE:
@@ -2017,7 +2016,7 @@
dao_adjust (dao, 3, 14);
return FALSE;
case TOOL_ENGINE_CLEAN_UP:
- return analysis_tool_ftest_clean (dao, specs);
+ return analysis_tool_generic_b_clean (specs);
case TOOL_ENGINE_LAST_VALIDITY_CHECK:
return FALSE;
case TOOL_ENGINE_PREPARE_OUTPUT_RANGE:
@@ -2317,7 +2316,7 @@
dao_adjust (dao, 3, 13);
return FALSE;
case TOOL_ENGINE_CLEAN_UP:
- return analysis_tool_ftest_clean (dao, specs);
+ return analysis_tool_generic_b_clean (specs);
case TOOL_ENGINE_LAST_VALIDITY_CHECK:
return FALSE;
case TOOL_ENGINE_PREPARE_OUTPUT_RANGE:
@@ -2610,7 +2609,7 @@
dao_adjust (dao, 3, 12);
return FALSE;
case TOOL_ENGINE_CLEAN_UP:
- return analysis_tool_ftest_clean (dao, specs);
+ return analysis_tool_generic_b_clean (specs);
case TOOL_ENGINE_LAST_VALIDITY_CHECK:
return FALSE;
case TOOL_ENGINE_PREPARE_OUTPUT_RANGE:
@@ -2638,7 +2637,7 @@
*/
static gboolean
analysis_tool_ftest_engine_run (data_analysis_output_t *dao,
- analysis_tools_data_ftest_t *info)
+ analysis_tools_data_generic_b_t *info)
{
GnmValue *val_1 = value_dup (info->range_1);
GnmValue *val_2 = value_dup (info->range_2);
@@ -2899,7 +2898,7 @@
dao_adjust (dao, 3, 12);
return FALSE;
case TOOL_ENGINE_CLEAN_UP:
- return analysis_tool_ftest_clean (dao, specs);
+ return analysis_tool_generic_b_clean (specs);
case TOOL_ENGINE_LAST_VALIDITY_CHECK:
return FALSE;
case TOOL_ENGINE_PREPARE_OUTPUT_RANGE:
@@ -3402,7 +3401,7 @@
return FALSE;
}
case TOOL_ENGINE_CLEAN_UP:
- return analysis_tool_ftest_clean (dao, specs);
+ return analysis_tool_generic_b_clean (specs);
case TOOL_ENGINE_LAST_VALIDITY_CHECK:
return FALSE;
case TOOL_ENGINE_PREPARE_OUTPUT_RANGE:
Modified: trunk/src/tools/analysis-tools.h
==============================================================================
--- trunk/src/tools/analysis-tools.h (original)
+++ trunk/src/tools/analysis-tools.h Thu Oct 16 06:25:42 2008
@@ -160,7 +160,7 @@
GnmValue *range_2;
gboolean labels;
gnm_float alpha;
-} analysis_tools_data_ftest_t;
+} analysis_tools_data_generic_b_t;
gboolean analysis_tool_ftest_engine (data_analysis_output_t *dao, gpointer specs,
analysis_tool_engine_t selector, gpointer result);
@@ -168,7 +168,7 @@
/**************** Regression ********************/
typedef struct {
- analysis_tools_data_ftest_t base;
+ analysis_tools_data_generic_b_t base;
gint intercept;
group_by_t group_by;
} analysis_tools_data_regression_t;
@@ -178,7 +178,7 @@
/*********************** TTest paired *****************/
typedef struct {
- analysis_tools_data_ftest_t base;
+ analysis_tools_data_generic_b_t base;
gnm_float mean_diff;
gnm_float var1;
gnm_float var2;
@@ -233,6 +233,7 @@
/* Functions also needed elsewhere. */
gboolean analysis_tool_generic_clean (gpointer specs);
+gboolean analysis_tool_generic_b_clean (gpointer specs);
int analysis_tool_calc_length (analysis_tools_data_generic_t *info);
Modified: trunk/src/wbc-gtk-actions.c
==============================================================================
--- trunk/src/wbc-gtk-actions.c (original)
+++ trunk/src/wbc-gtk-actions.c Thu Oct 16 06:25:42 2008
@@ -730,6 +730,7 @@
static GNM_ACTION_DEF (cb_tools_fourier) { dialog_fourier_tool (wbcg, wbcg_cur_sheet (wbcg)); }
static GNM_ACTION_DEF (cb_tools_frequency) { dialog_frequency_tool (wbcg, wbcg_cur_sheet (wbcg)); }
static GNM_ACTION_DEF (cb_tools_histogram) { dialog_histogram_tool (wbcg, wbcg_cur_sheet (wbcg)); }
+static GNM_ACTION_DEF (cb_tools_kaplan_meier) { dialog_kaplan_meier_tool (wbcg, wbcg_cur_sheet (wbcg)); }
static GNM_ACTION_DEF (cb_tools_ranking) { dialog_ranking_tool (wbcg, wbcg_cur_sheet (wbcg)); }
static GNM_ACTION_DEF (cb_tools_regression) { dialog_regression_tool (wbcg, wbcg_cur_sheet (wbcg)); }
static GNM_ACTION_DEF (cb_tools_sampling) { dialog_sampling_tool (wbcg, wbcg_cur_sheet (wbcg)); }
@@ -2000,6 +2001,9 @@
{ "ToolsFTest", NULL, N_("_Two Variances: FTest..."),
NULL, N_("Comparing two population variances"),
G_CALLBACK (cb_tools_ftest) },
+ { "ToolsKaplanMeier", NULL, N_("_Kaplan-Meier Estimates..."),
+ NULL, N_("Creation of Kaplan-Meier Survival Curves"),
+ G_CALLBACK (cb_tools_kaplan_meier) },
/* Data */
{ "DataSort", GTK_STOCK_SORT_ASCENDING, N_("_Sort..."),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]