Example #1
0
        /// <summary>
        /// performs an addition / subtraction or pass thru rule
        /// </summary>
        /// <returns>object</returns>
        public override object Execute()
        {
            object result = null;

            if (!this.HasRun)
            {
                // prepare IAnalysisStatisticContext information to be sent to the
                // KMSurvival
                IAnalysisStatistic KMSurvival = null;

                // connection string
                // 1 term / column name
                // 1 dependent variable /column name
                // tablname

                Dictionary <string, string> setProperties = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
                if (this.Context.CurrentRead == null)
                {
                    setProperties.Add("TableName", "");
                }
                else
                {
                    setProperties.Add("TableName", this.Context.CurrentRead.Identifier);
                }
                setProperties.Add("CommandText", this.commandText);
                Dictionary <string, string> inputVariableList = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);

                setProperties.Add("BLabels", "Yes;No;Missing"); // TODO: Replace Yes, No, Missing with global vars

                //ToDo: Move calls to inputVariableList.Add up into applicable function above: Rule_KMSurv or SetOption
                //
                inputVariableList.Add("time_variable", time_variable);
                inputVariableList.Add("group_variable", group_variable);

                //inputVariableList.Add("time_function", time_function);
                inputVariableList.Add("censor_variable", censor_variable);
                inputVariableList.Add("uncensored_value", uncensored_value);
                inputVariableList.Add("time_unit", time_unit);

                inputVariableList.Add("out_table", out_table);
                inputVariableList.Add("graph_type", graph_type);
                inputVariableList.Add("weight_variable", weight_variable);


                IDataSource DataSource = this.Context.GetDefaultIDataSource();

                AnalysisStatisticExecuteHost statisticHost = new AnalysisStatisticExecuteHost(this.Context, setProperties, DataSource, inputVariableList, this.Context.CurrentSelect.ToString(), this.Context.AnalysisInterpreterHost);

                KMSurvival = this.Context.GetStatistic("KaplanMeierSurvival", statisticHost);
                KMSurvival.Execute();
                this.HasRun = true;
            }

            return(result);
        }
        /// <summary>
        /// performs execution of the Match command
        /// </summary>
        /// <returns>object</returns>
        public override object Execute()
        {
            object result = null;

            if (!this.HasRun)
            {
                //Configuration config = Configuration.GetNewInstance();
                Dictionary <string, string> setProperties = this.Context.GetGlobalSettingProperties();
                if (Stratvar != null)
                {
                    inputVariableList.Add("Stratavar", Stratvar);
                }

                if (!string.IsNullOrEmpty(OutTable))
                {
                    inputVariableList.Add("OutTable", OutTable);
                }

                if (!string.IsNullOrEmpty(WeightVar))
                {
                    inputVariableList.Add("WeightVar", WeightVar);
                }
                inputVariableList.Add("commandText", commandText);
                if (!string.IsNullOrEmpty(PSUVar))
                {
                    inputVariableList.Add("PSUVar", PSUVar);
                }
                if (this.Context.CurrentRead == null)
                {
                    inputVariableList.Add("TableName", "");
                }
                else
                {
                    inputVariableList.Add("TableName", this.Context.CurrentRead.Identifier);
                }

                EpiInfo.Plugin.IDataSource   DataSource    = this.Context.GetDefaultIDataSource();
                AnalysisStatisticExecuteHost statisticHost = new AnalysisStatisticExecuteHost(this.Context, setProperties, DataSource, inputVariableList, this.Context.CurrentSelect.ToString(), this.Context.AnalysisInterpreterHost);

                string resultcount = "<p>Match command NOT yet implemented</p>";
                Dictionary <string, string> args = new Dictionary <string, string>();
                args.Add("COMMANDNAME", CommandNames.DELETE);
                args.Add("COMMANDTEXT", this.commandText.Trim());
                args.Add("TABLENAME", this.Context.CurrentRead.Identifier);
                args.Add("HTMLRESULTS", resultcount);
                this.Context.AnalysisCheckCodeInterface.Display(args);
                this.HasRun = true;
            }
            return(result);
        }
Example #3
0
        /// <summary>
        /// performs execution of the Freq(uency) command
        /// </summary>
        /// <returns>object</returns>
        public override object Execute()
        {
            object result = null;

            if (!this.HasRun)
            {
                this.Context.AddConfigSettings(this.SetOptions);

                Dictionary<string, string> setProperties = this.Context.GetGlobalSettingProperties();
                Dictionary<string, string> inputVariableList = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
                //bool isExceptionList = false;

                this.Context.ExpandGroupVariables(this.IdentifierList, ref isExceptionList);

                StringBuilder sb = new StringBuilder();
                foreach (string s in IdentifierList)
                {
                    sb.Append(s);
                    sb.Append(",");
                }
                sb.Length = sb.Length - 1;

                inputVariableList.Add("IdentifierList", sb.ToString());

                if (StratvarList != null)
                {
                    sb.Length = 0;

                    foreach (string s in StratvarList)
                    {
                        sb.Append(s);
                        sb.Append(",");
                    }
                    sb.Length = sb.Length - 1;

                    inputVariableList.Add("StratvarList", sb.ToString());
                }

                inputVariableList.Add("OutTable", OutTable);
                inputVariableList.Add("WeightVar", WeightVar);
                inputVariableList.Add("commandText", commandText);
                inputVariableList.Add("PSUVar", PSUVar);
                if (this.Context.CurrentRead == null)
                {
                    inputVariableList.Add("TableName", "");
                }
                else
                {
                    inputVariableList.Add("TableName", this.Context.CurrentRead.Identifier);
                }

                EpiInfo.Plugin.IDataSource DataSource = this.Context.GetDefaultIDataSource();

               // Context.DataTableRefreshNeeded = true;

                AnalysisStatisticExecuteHost statisticHost = new AnalysisStatisticExecuteHost(this.Context, setProperties, DataSource, inputVariableList, this.Context.CurrentSelect.ToString(), this.Context.AnalysisInterpreterHost);

                if (string.IsNullOrEmpty(this.PSUVar))
                {
                    this.FrequencyStatistic = this.Context.GetStatistic("Frequency", statisticHost);
                }
                else
                {
                    this.FrequencyStatistic = this.Context.GetStatistic("ComplexSampleTables", statisticHost);
                }

                this.FrequencyStatistic.Execute();
                this.FrequencyStatistic = null;
                this.HasRun = true;
            }

            return result;
        }
Example #4
0
        public override object Execute()
        {
            object result = null;

            if (!this.HasRun)
            {
                //Configuration config = Configuration.GetNewInstance();


                Dictionary <string, string> setProperties = this.Context.GetGlobalSettingProperties();
                List <string> ExposureVariableList        = new List <string>();
                ExposureVariableList.Add(this.Exposure);

                bool isExceptionList = false;
                this.Context.ExpandGroupVariables(ExposureVariableList, ref isExceptionList);


                foreach (string EXPOSURE_VARIABLE in ExposureVariableList)
                {
                    inputVariableList = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);

                    inputVariableList.Add("EXPOSURE_VARIABLE", EXPOSURE_VARIABLE);
                    inputVariableList.Add("OUTCOME_VARIABLE", this.Outcome);

                    if (this.Stratvar != null)
                    {
                        StringBuilder temp = new StringBuilder();
                        foreach (string s in Stratvar)
                        {
                            temp.Append(s);
                            temp.Append(',');
                        }
                        if (temp.Length > 0)
                        {
                            temp.Length = temp.Length - 1;
                        }
                        inputVariableList.Add("STRATAVAR", temp.ToString());
                    }

                    if (!string.IsNullOrEmpty(OutTable))
                    {
                        inputVariableList.Add("OutTable", OutTable);
                    }

                    if (!string.IsNullOrEmpty(WeightVar))
                    {
                        inputVariableList.Add("WeightVar", WeightVar);
                    }
                    if (!tablesShowStatistics)
                    {
                        inputVariableList.Add("STATISTICS", "NONE");
                    }
                    inputVariableList.Add("commandText", commandText);
                    if (!string.IsNullOrEmpty(PSUVar))
                    {
                        inputVariableList.Add("PSUVar", PSUVar);
                    }
                    if (this.Context.CurrentRead == null)
                    {
                        inputVariableList.Add("TableName", "");
                    }
                    else
                    {
                        inputVariableList.Add("TableName", this.Context.CurrentRead.Identifier);
                    }

                    EpiInfo.Plugin.IDataSource DataSource = this.Context.GetDefaultIDataSource();

                    AnalysisStatisticExecuteHost statisticHost = new AnalysisStatisticExecuteHost(this.Context, setProperties, DataSource, inputVariableList, this.Context.CurrentSelect.ToString(), this.Context.AnalysisInterpreterHost);

                    if (!inputVariableList.ContainsKey("PSUVAR"))
                    {
                        this.TablesStatistic = this.Context.GetStatistic("Tables", statisticHost);
                    }
                    else
                    {
                        this.TablesStatistic = this.Context.GetStatistic("ComplexSampleTables", statisticHost);
                    }

                    this.TablesStatistic.Execute();

                    this.TablesStatistic = null;
                }

                this.HasRun = true;
            }

            return(result);
        }
Example #5
0
        public override object Execute()
        {
            object result = null;

            if (false == hasRun)
            {
                IAnalysisStatistic summarizePlugin = null;
                Dictionary<string, string> setProperties = Context.GetGlobalSettingProperties();
                Dictionary<string, string> inputVariableList = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
                StringBuilder stringBuilder = new StringBuilder();

                foreach (string aggregate in aggregateList)
                {
                    stringBuilder.Append(aggregate);
                    stringBuilder.Append(",");
                }

                stringBuilder.Length = stringBuilder.Length - 1;

                inputVariableList.Add("AggregateList", stringBuilder.ToString());
                stringBuilder.Length = 0;
                bool HasAggregateElements = false;

                foreach (KeyValuePair<string, string> aggregatePair in aggregateElement)
                {
                    stringBuilder.Append(aggregatePair.Key);
                    stringBuilder.Append("=");
                    stringBuilder.Append(aggregatePair.Value);
                    stringBuilder.Append(",");
                    HasAggregateElements = true;
                }

                if (HasAggregateElements)
                {
                    stringBuilder.Length = stringBuilder.Length - 1;
                }

                inputVariableList.Add("AggregateElementList", stringBuilder.ToString());

                if (strataVariableList.Count > 0)
                {
                    stringBuilder.Length = 0;

                    foreach (string strataVariable in strataVariableList)
                    {
                        stringBuilder.Append(strataVariable);
                        stringBuilder.Append(",");
                    }

                    stringBuilder.Length = stringBuilder.Length - 1;
                    inputVariableList.Add("StratvarList", stringBuilder.ToString());
                }

                if (participatingVariableList.Count > 0)
                {
                    stringBuilder.Length = 0;

                    foreach (string participatingVariable in participatingVariableList)
                    {
                        stringBuilder.Append(participatingVariable);
                        stringBuilder.Append(",");
                    }

                    stringBuilder.Length = stringBuilder.Length - 1;
                    inputVariableList.Add("ParticipatingVariableList", stringBuilder.ToString());
                }

                inputVariableList.Add("OutTable", outTableName);
                inputVariableList.Add("WeightVar", weightVariable);
                inputVariableList.Add("commandText", commandText);

                if (Context.CurrentRead == null)
                {
                    inputVariableList.Add("TableName", "");
                }
                else
                {
                    inputVariableList.Add("TableName", Context.CurrentRead.Identifier);
                }

                EpiInfo.Plugin.IDataSource DataSource = Context.GetDefaultIDataSource();
                AnalysisStatisticExecuteHost statisticHost = new AnalysisStatisticExecuteHost(Context, setProperties, DataSource, inputVariableList, Context.CurrentSelect.ToString(), Context.AnalysisInterpreterHost);
                summarizePlugin = Context.GetStatistic("Summarize", statisticHost);
                summarizePlugin.Execute();
                summarizePlugin = null;

                hasRun = true;
            }
            return result;
        }
Example #6
0
        /// <summary>
        /// performs execution of the Freq(uency) command
        /// </summary>
        /// <returns>object</returns>
        public override object Execute()
        {
            object result = null;

            if (!this.HasRun)
            {
                this.Context.AddConfigSettings(this.SetOptions);

                Dictionary <string, string> setProperties     = this.Context.GetGlobalSettingProperties();
                Dictionary <string, string> inputVariableList = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
                //bool isExceptionList = false;

                this.Context.ExpandGroupVariables(this.IdentifierList, ref isExceptionList);

                StringBuilder sb = new StringBuilder();
                foreach (string s in IdentifierList)
                {
                    sb.Append(s);
                    sb.Append(",");
                }
                sb.Length = sb.Length - 1;

                inputVariableList.Add("IdentifierList", sb.ToString());

                if (StratvarList != null)
                {
                    sb.Length = 0;

                    foreach (string s in StratvarList)
                    {
                        sb.Append(s);
                        sb.Append(",");
                    }
                    sb.Length = sb.Length - 1;

                    inputVariableList.Add("StratvarList", sb.ToString());
                }

                inputVariableList.Add("OutTable", OutTable);
                inputVariableList.Add("WeightVar", WeightVar);
                inputVariableList.Add("commandText", commandText);
                inputVariableList.Add("PSUVar", PSUVar);
                if (this.Context.CurrentRead == null)
                {
                    inputVariableList.Add("TableName", "");
                }
                else
                {
                    inputVariableList.Add("TableName", this.Context.CurrentRead.Identifier);
                }

                EpiInfo.Plugin.IDataSource DataSource = this.Context.GetDefaultIDataSource();

                // Context.DataTableRefreshNeeded = true;

                AnalysisStatisticExecuteHost statisticHost = new AnalysisStatisticExecuteHost(this.Context, setProperties, DataSource, inputVariableList, this.Context.CurrentSelect.ToString(), this.Context.AnalysisInterpreterHost);

                if (string.IsNullOrEmpty(this.PSUVar))
                {
                    this.FrequencyStatistic = this.Context.GetStatistic("Frequency", statisticHost);
                }
                else
                {
                    this.FrequencyStatistic = this.Context.GetStatistic("ComplexSampleTables", statisticHost);
                }

                this.FrequencyStatistic.Execute();
                this.FrequencyStatistic = null;
                this.HasRun             = true;
            }

            return(result);
        }
Example #7
0
        /// <summary>
        /// performs an addition / subtraction or pass thru rule
        /// </summary>
        /// <returns>object</returns>
        public override object Execute()
        {
            object result = null;

            if (!this.HasRun)
            {
                // prepare IAnalysisStatisticContext information to be sent to the
                // CoxPH
                IAnalysisStatistic CoxPH = null;

                // connection string
                // 1 term / column name
                // 1 dependent variable /column name
                // tablname

                Dictionary<string, string> setProperties = this.Context.GetGlobalSettingProperties();
                if (this.Context.CurrentRead == null)
                {
                    setProperties.Add("TableName", "");
                }
                else
                {
                    setProperties.Add("TableName", this.Context.CurrentRead.Identifier);
                }
                setProperties.Add("CommandText", this.commandText);
                Dictionary<string, string> inputVariableList = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

                inputVariableList.Add("time_variable", time_variable);
                StringBuilder sb = new StringBuilder();
                foreach (string s in this.CovariateList)
                {
                    sb.Append(s);
                    sb.Append(",");
                }
                if (sb.Length > 0)
                {
                    sb.Length = sb.Length - 1;
                }
                inputVariableList.Add("CovariateList", sb.ToString());
                sb.Length = 0;
                foreach (string s in this.DiscreteList)
                {
                    sb.Append(s);
                    sb.Append(",");
                }
                if (this.DiscreteList.Count > 0)
                {
                    sb.Length = sb.Length - 1;
                }

                inputVariableList.Add("DiscreteList", sb.ToString());
                inputVariableList.Add("time_function", time_function);
                inputVariableList.Add("censor_variable", censor_variable);
                inputVariableList.Add("censor_value", censor_value);
                inputVariableList.Add("time_unit", time_unit);

                inputVariableList.Add("out_table", out_table);
                inputVariableList.Add("graph_type", graph_type);
                inputVariableList.Add("weightvar", weightvar);

                sb.Length = 0;

                foreach (string s in StrataVarList)
                {
                    sb.Append(s);
                    sb.Append(",");
                }
                if (sb.Length > 0)
                {
                    sb.Length = sb.Length - 1;
                }
                inputVariableList.Add("StrataVarList", sb.ToString());

                sb.Length = 0;
                foreach (string s in GraphVariableList)
                {
                    sb.Append(s);
                    sb.Append(",");
                }
                if (sb.Length > 0)
                {
                    sb.Length = sb.Length - 1;
                }
                inputVariableList.Add("GraphVariableList", sb.ToString());

                IDataSource DataSource = this.Context.GetDefaultIDataSource();

                AnalysisStatisticExecuteHost statisticHost = new AnalysisStatisticExecuteHost(this.Context, setProperties, DataSource, inputVariableList, this.Context.CurrentSelect.ToString(), this.Context.AnalysisInterpreterHost);

                CoxPH = this.Context.GetStatistic("CoxProportionalHazards", statisticHost);
                CoxPH.Execute();
                this.HasRun = true;
            }

            return result;
        }
Example #8
0
        /// <summary>
        /// performs execution of the MEANS command
        /// </summary>
        /// <returns>object</returns>
        public override object Execute()
        {
            object result = null;

            if (!this.HasRun)
            {

                Dictionary<string, string> setProperties = this.Context.GetGlobalSettingProperties();

                List<string> NumericVariableList = new List<string>();
                NumericVariableList.Add(this.Numeric_Variable);

                bool isExceptionList = false;
                this.Context.ExpandGroupVariables(NumericVariableList, ref isExceptionList);

                foreach (string Numeric_Variable in NumericVariableList)
                {
                    inputVariableList = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

                    inputVariableList.Add("Numeric_Variable", Numeric_Variable);
                    inputVariableList.Add("Cross_Tabulation_Variable", this.Cross_Tabulation_Variable);

                    this.Context.ExpandGroupVariables(this.StratvarList, ref isExceptionList);

                    if (this.StratvarList != null && this.StratvarList.Count > 0)
                    {
                        StringBuilder sb = new StringBuilder();

                        foreach (string s in this.StratvarList)
                        {
                            sb.Append(s);
                            sb.Append(",");
                        }
                        sb.Length = sb.Length - 1;

                        inputVariableList.Add("StratvarList", sb.ToString());
                    }

                    if (!string.IsNullOrEmpty(OutTable))
                    {
                        inputVariableList.Add("OutTable", OutTable);
                    }

                    if (!string.IsNullOrEmpty(WeightVar))
                    {
                        inputVariableList.Add("WeightVar", WeightVar);
                    }
                    inputVariableList.Add("commandText", commandText);
                    if (!string.IsNullOrEmpty(PSUVar))
                    {
                        inputVariableList.Add("PSUVar", PSUVar);
                    }
                    if (this.Context.CurrentRead == null)
                    {
                        inputVariableList.Add("TableName", "");
                    }
                    else
                    {
                        inputVariableList.Add("TableName", this.Context.CurrentRead.Identifier);
                    }

                    if (this.ColumnSize != null)
                    {
                        inputVariableList.Add("ColumnSize", this.ColumnSize);
                    }

                    if (this.NoWrap != null)
                    {
                        inputVariableList.Add("NoWrap", this.NoWrap);
                    }

                    EpiInfo.Plugin.IDataSource DataSource = this.Context.GetDefaultIDataSource();

                    AnalysisStatisticExecuteHost statisticHost = new AnalysisStatisticExecuteHost(this.Context, setProperties, DataSource, inputVariableList, this.Context.CurrentSelect.ToString(), this.Context.AnalysisInterpreterHost);

                    if (string.IsNullOrEmpty(this.PSUVar))
                    {
                        this.MeansStatistic = this.Context.GetStatistic("Means", statisticHost);
                    }
                    else
                    {
                        this.MeansStatistic = this.Context.GetStatistic("ComplexSampleMeans", statisticHost);
                    }

                    this.MeansStatistic.Execute();

                    this.MeansStatistic = null;
                }
                this.HasRun = true;
            }

            return result;
        }
        /// <summary>
        /// performs an addition / subtraction or pass thru rule
        /// </summary>
        /// <returns>object</returns>
        public override object Execute()
        {
            object result = null;

            if (!this.HasRun)
            {
                IAnalysisStatistic LogisticRegress = null;

                //View view = null;

                //if (Context.CurrentProject != null)
                //{
                //    view = Context.CurrentProject.GetViewByName(Context.CurrentRead.Identifier);
                //}

                // connection string
                // 1 term / column name
                // 1 dependent variable /column name
                // tablname

                Dictionary <string, string> setProperties = this.Context.GetGlobalSettingProperties();
                if (this.Context.CurrentRead == null)
                {
                    setProperties.Add("TableName", "");
                }
                else
                {
                    setProperties.Add("TableName", this.Context.CurrentRead.Identifier);
                }
                setProperties.Add("CommandText", this.commandText);
                Dictionary <string, string> inputVariableList = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
                inputVariableList.Add(this.Identifier, "DependVar");

                if (this.nointercept == false)
                {
                    setProperties.Add("Intercept", "true");
                    inputVariableList.Add("true", "Intercept");
                }
                else
                {
                    setProperties.Add("Intercept", "false");
                    inputVariableList.Add("false", "Intercept");
                }

                if (!string.IsNullOrEmpty(this.pvalue))
                {
                    double p       = 0.95;
                    bool   success = Double.TryParse(this.pvalue.Replace("%", string.Empty), out p);
                    if (success)
                    {
                        setProperties.Add("P", p.ToString());
                        inputVariableList.Add(p.ToString(), "P");
                    }
                }

                // Make sure dummy vars aren't split up either!
                if (this.TermList.Contains("(") || this.TermList.Contains(")"))
                {
                    this.TermList = this.TermList.Replace("( ", "(");
                    this.TermList = this.TermList.Replace(" )", ")");
                }

                string[] terms;
                // Make sure each interaction term isn't split up!
                this.TermList = this.TermList.Replace(" *", "*");
                this.TermList = this.TermList.Replace("* ", "*");
                terms         = this.TermList.Split(' ');

                foreach (string s in terms)
                {
                    if (!s.Contains("*"))
                    {
                        if ((s.Contains("(") && s.Contains(")")))// || (view != null && view.Fields.Contains(s) && view.Fields[s] is Epi.Fields.YesNoField))
                        {
                            inputVariableList.Add(s.Replace("(", string.Empty).Replace(")", string.Empty), "Discrete");
                        }
                        else
                        {
                            inputVariableList.Add(s, "Unsorted");
                        }
                    }
                    else
                    {
                        inputVariableList.Add(s, "Term");
                    }
                }

                if (!string.IsNullOrEmpty(this.WeightVar))
                {
                    // Make sure our weight variable isn't a term or the dependent variable. This shouldn't occur through the UI, but the user can still type something like this in manually
                    if (inputVariableList.ContainsKey(this.WeightVar))
                    {
                        Dictionary <string, string> args = new Dictionary <string, string>();
                        args.Add("COMMANDNAME", CommandNames.LOGISTIC);
                        args.Add("COMMANDTEXT", commandText.Trim());
                        args.Add("HTMLRESULTS", "<br clear=\"all\" /><p align=\"left\"><b><tlt>Weight variable cannot be a term or dependent variable</tlt></b></p>");

                        this.Context.AnalysisCheckCodeInterface.Display(args);

                        return(result);
                    }
                    inputVariableList.Add(this.WeightVar, "WeightVar");
                }

                if (!string.IsNullOrEmpty(this.MatchVar))
                {
                    // Make sure our weight variable isn't a term or the dependent variable. This shouldn't occur through the UI, but the user can still type something like this in manually
                    if (inputVariableList.ContainsKey(this.MatchVar))
                    {
                        Dictionary <string, string> args = new Dictionary <string, string>();
                        args.Add("COMMANDNAME", CommandNames.LOGISTIC);
                        args.Add("COMMANDTEXT", commandText.Trim());
                        args.Add("HTMLRESULTS", "<br clear=\"all\" /><p align=\"left\"><b><tlt>Match variable cannot be a term or dependent variable</tlt></b></p>");

                        this.Context.AnalysisCheckCodeInterface.Display(args);

                        return(result);
                    }
                    inputVariableList.Add(this.MatchVar, "MatchVar");
                }

                IDataSource DataSource = this.Context.GetDefaultIDataSource();

                AnalysisStatisticExecuteHost statisticHost = new AnalysisStatisticExecuteHost(this.Context, setProperties, DataSource, inputVariableList, this.Context.CurrentSelect.ToString(), this.Context.AnalysisInterpreterHost);

                LogisticRegress = this.Context.GetStatistic("LogisticRegression", statisticHost);
                LogisticRegress.Execute();

                this.HasRun = true;
            }

            return(result);
        }
        public override object Execute()
        {
            object result = null;

            if (false == hasRun)
            {
                IAnalysisStatistic          summarizePlugin   = null;
                Dictionary <string, string> setProperties     = Context.GetGlobalSettingProperties();
                Dictionary <string, string> inputVariableList = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
                StringBuilder stringBuilder = new StringBuilder();

                foreach (string aggregate in aggregateList)
                {
                    stringBuilder.Append(aggregate);
                    stringBuilder.Append(",");
                }

                stringBuilder.Length = stringBuilder.Length - 1;

                inputVariableList.Add("AggregateList", stringBuilder.ToString());
                stringBuilder.Length = 0;
                bool HasAggregateElements = false;

                foreach (KeyValuePair <string, string> aggregatePair in aggregateElement)
                {
                    stringBuilder.Append(aggregatePair.Key);
                    stringBuilder.Append("=");
                    stringBuilder.Append(aggregatePair.Value);
                    stringBuilder.Append(",");
                    HasAggregateElements = true;
                }

                if (HasAggregateElements)
                {
                    stringBuilder.Length = stringBuilder.Length - 1;
                }

                inputVariableList.Add("AggregateElementList", stringBuilder.ToString());

                if (strataVariableList.Count > 0)
                {
                    stringBuilder.Length = 0;

                    foreach (string strataVariable in strataVariableList)
                    {
                        stringBuilder.Append(strataVariable);
                        stringBuilder.Append(",");
                    }

                    stringBuilder.Length = stringBuilder.Length - 1;
                    inputVariableList.Add("StratvarList", stringBuilder.ToString());
                }

                if (participatingVariableList.Count > 0)
                {
                    stringBuilder.Length = 0;

                    foreach (string participatingVariable in participatingVariableList)
                    {
                        stringBuilder.Append(participatingVariable);
                        stringBuilder.Append(",");
                    }

                    stringBuilder.Length = stringBuilder.Length - 1;
                    inputVariableList.Add("ParticipatingVariableList", stringBuilder.ToString());
                }

                inputVariableList.Add("OutTable", outTableName);
                inputVariableList.Add("WeightVar", weightVariable);
                inputVariableList.Add("commandText", commandText);

                if (Context.CurrentRead == null)
                {
                    inputVariableList.Add("TableName", "");
                }
                else
                {
                    inputVariableList.Add("TableName", Context.CurrentRead.Identifier);
                }

                EpiInfo.Plugin.IDataSource   DataSource    = Context.GetDefaultIDataSource();
                AnalysisStatisticExecuteHost statisticHost = new AnalysisStatisticExecuteHost(Context, setProperties, DataSource, inputVariableList, Context.CurrentSelect.ToString(), Context.AnalysisInterpreterHost);
                summarizePlugin = Context.GetStatistic("Summarize", statisticHost);
                summarizePlugin.Execute();
                summarizePlugin = null;

                hasRun = true;
            }
            return(result);
        }
Example #11
0
        public override object Execute()
        {
            object result = null;

            if (!this.HasRun)
            {
                //Configuration config = Configuration.GetNewInstance();

                Dictionary<string, string> setProperties = this.Context.GetGlobalSettingProperties();
                List<string> ExposureVariableList = new List<string>();
                ExposureVariableList.Add(this.Exposure);

                bool isExceptionList = false;
                this.Context.ExpandGroupVariables(ExposureVariableList, ref isExceptionList);

                foreach (string EXPOSURE_VARIABLE in ExposureVariableList)
                {
                    inputVariableList = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

                    inputVariableList.Add("EXPOSURE_VARIABLE", EXPOSURE_VARIABLE);
                    inputVariableList.Add("OUTCOME_VARIABLE", this.Outcome);

                    if (this.Stratvar != null)
                    {
                        StringBuilder temp = new StringBuilder();
                        foreach (string s in Stratvar)
                        {
                            temp.Append(s);
                            temp.Append(',');
                        }
                        if (temp.Length > 0)
                        {
                            temp.Length = temp.Length - 1;
                        }
                        inputVariableList.Add("STRATAVAR", temp.ToString());
                    }

                    if (!string.IsNullOrEmpty(OutTable))
                    {
                        inputVariableList.Add("OutTable", OutTable);
                    }

                    if (!string.IsNullOrEmpty(WeightVar))
                    {
                        inputVariableList.Add("WeightVar", WeightVar);
                    }
                    inputVariableList.Add("commandText", commandText);
                    if (!string.IsNullOrEmpty(PSUVar))
                    {
                        inputVariableList.Add("PSUVar", PSUVar);
                    }
                    if (this.Context.CurrentRead == null)
                    {
                        inputVariableList.Add("TableName", "");
                    }
                    else
                    {
                        inputVariableList.Add("TableName", this.Context.CurrentRead.Identifier);
                    }

                    EpiInfo.Plugin.IDataSource DataSource = this.Context.GetDefaultIDataSource();

                    AnalysisStatisticExecuteHost statisticHost = new AnalysisStatisticExecuteHost(this.Context, setProperties, DataSource, inputVariableList, this.Context.CurrentSelect.ToString(), this.Context.AnalysisInterpreterHost);

                    if (!inputVariableList.ContainsKey("PSUVAR"))
                    {
                        this.TablesStatistic = this.Context.GetStatistic("Tables", statisticHost);
                    }
                    else
                    {
                        this.TablesStatistic = this.Context.GetStatistic("ComplexSampleTables", statisticHost);
                    }

                    this.TablesStatistic.Execute();

                    this.TablesStatistic = null;
                }

                this.HasRun = true;
            }

            return result;
        }
        /// <summary>
        /// performs an addition / subtraction or pass thru rule
        /// </summary>
        /// <returns>object</returns>
        public override object Execute()
        {
            object result = null;

            if (!this.HasRun)
            {
                IAnalysisStatistic LogisticRegress = null;

                //View view = null;

                //if (Context.CurrentProject != null)
                //{
                //    view = Context.CurrentProject.GetViewByName(Context.CurrentRead.Identifier);
                //}

                // connection string
                // 1 term / column name
                // 1 dependent variable /column name
                // tablname

                Dictionary<string, string> setProperties = this.Context.GetGlobalSettingProperties();
                if (this.Context.CurrentRead == null)
                {
                    setProperties.Add("TableName", "");
                }
                else
                {
                    setProperties.Add("TableName", this.Context.CurrentRead.Identifier);
                }
                setProperties.Add("CommandText", this.commandText);
                Dictionary<string, string> inputVariableList = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
                inputVariableList.Add(this.Identifier, "DependVar");

                if (this.nointercept == false)
                {
                    setProperties.Add("Intercept", "true");
                    inputVariableList.Add("true", "Intercept");
                }
                else
                {
                    setProperties.Add("Intercept", "false");
                    inputVariableList.Add("false", "Intercept");
                }

                if (!string.IsNullOrEmpty(this.pvalue))
                {
                    double p = 0.95;
                    bool success = Double.TryParse(this.pvalue.Replace("%", string.Empty), out p);
                    if (success)
                    {
                        setProperties.Add("P", p.ToString());
                        inputVariableList.Add(p.ToString(), "P");
                    }
                }

                // Make sure dummy vars aren't split up either!
                if (this.TermList.Contains("(") || this.TermList.Contains(")"))
                {
                    this.TermList = this.TermList.Replace("( ", "(");
                    this.TermList = this.TermList.Replace(" )", ")");
                }

                string[] terms;
                // Make sure each interaction term isn't split up!
                this.TermList = this.TermList.Replace(" *", "*");
                this.TermList = this.TermList.Replace("* ", "*");
                terms = this.TermList.Split(' ');

                foreach (string s in terms)
                {
                    if (!s.Contains("*"))
                    {
                        if ((s.Contains("(") && s.Contains(")")))// || (view != null && view.Fields.Contains(s) && view.Fields[s] is Epi.Fields.YesNoField))
                        {
                            inputVariableList.Add(s.Replace("(", string.Empty).Replace(")", string.Empty), "Discrete");
                        }
                        else
                        {
                            inputVariableList.Add(s, "Unsorted");
                        }
                    }
                    else
                    {
                        inputVariableList.Add(s, "Term");
                    }
                }

                if (!string.IsNullOrEmpty(this.WeightVar))
                {
                    // Make sure our weight variable isn't a term or the dependent variable. This shouldn't occur through the UI, but the user can still type something like this in manually
                    if (inputVariableList.ContainsKey(this.WeightVar))
                    {
                        Dictionary<string, string> args = new Dictionary<string, string>();
                        args.Add("COMMANDNAME", CommandNames.LOGISTIC);
                        args.Add("COMMANDTEXT", commandText.Trim());
                        args.Add("HTMLRESULTS", "<br clear=\"all\" /><p align=\"left\"><b><tlt>Weight variable cannot be a term or dependent variable</tlt></b></p>");

                        this.Context.AnalysisCheckCodeInterface.Display(args);

                        return result;
                    }
                    inputVariableList.Add(this.WeightVar, "WeightVar");
                }

                if (!string.IsNullOrEmpty(this.MatchVar))
                {
                    // Make sure our weight variable isn't a term or the dependent variable. This shouldn't occur through the UI, but the user can still type something like this in manually
                    if (inputVariableList.ContainsKey(this.MatchVar))
                    {
                        Dictionary<string, string> args = new Dictionary<string, string>();
                        args.Add("COMMANDNAME", CommandNames.LOGISTIC);
                        args.Add("COMMANDTEXT", commandText.Trim());
                        args.Add("HTMLRESULTS", "<br clear=\"all\" /><p align=\"left\"><b><tlt>Match variable cannot be a term or dependent variable</tlt></b></p>");

                        this.Context.AnalysisCheckCodeInterface.Display(args);

                        return result;
                    }
                    inputVariableList.Add(this.MatchVar, "MatchVar");
                }

                IDataSource DataSource = this.Context.GetDefaultIDataSource();

                AnalysisStatisticExecuteHost statisticHost = new AnalysisStatisticExecuteHost(this.Context, setProperties, DataSource, inputVariableList, this.Context.CurrentSelect.ToString(), this.Context.AnalysisInterpreterHost);

                LogisticRegress = this.Context.GetStatistic("LogisticRegression", statisticHost);
                LogisticRegress.Execute();

                this.HasRun = true;
            }

            return result;
        }
Example #13
0
        /// <summary>
        /// performs execution of the MEANS command
        /// </summary>
        /// <returns>object</returns>
        public override object Execute()
        {
            object result = null;

            if (!this.HasRun)
            {
                Dictionary <string, string> setProperties = this.Context.GetGlobalSettingProperties();

                List <string> NumericVariableList = new List <string>();
                NumericVariableList.Add(this.Numeric_Variable);

                bool isExceptionList = false;
                this.Context.ExpandGroupVariables(NumericVariableList, ref isExceptionList);


                foreach (string Numeric_Variable in NumericVariableList)
                {
                    inputVariableList = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);

                    inputVariableList.Add("Numeric_Variable", Numeric_Variable);
                    inputVariableList.Add("Cross_Tabulation_Variable", this.Cross_Tabulation_Variable);


                    this.Context.ExpandGroupVariables(this.StratvarList, ref isExceptionList);

                    if (this.StratvarList != null && this.StratvarList.Count > 0)
                    {
                        StringBuilder sb = new StringBuilder();

                        foreach (string s in this.StratvarList)
                        {
                            sb.Append(s);
                            sb.Append(",");
                        }
                        sb.Length = sb.Length - 1;

                        inputVariableList.Add("StratvarList", sb.ToString());
                    }

                    if (!string.IsNullOrEmpty(OutTable))
                    {
                        inputVariableList.Add("OutTable", OutTable);
                    }

                    if (!string.IsNullOrEmpty(WeightVar))
                    {
                        inputVariableList.Add("WeightVar", WeightVar);
                    }
                    inputVariableList.Add("commandText", commandText);
                    if (!string.IsNullOrEmpty(PSUVar))
                    {
                        inputVariableList.Add("PSUVar", PSUVar);
                    }
                    if (this.Context.CurrentRead == null)
                    {
                        inputVariableList.Add("TableName", "");
                    }
                    else
                    {
                        inputVariableList.Add("TableName", this.Context.CurrentRead.Identifier);
                    }

                    if (this.ColumnSize != null)
                    {
                        inputVariableList.Add("ColumnSize", this.ColumnSize);
                    }

                    if (this.NoWrap != null)
                    {
                        inputVariableList.Add("NoWrap", this.NoWrap);
                    }

                    EpiInfo.Plugin.IDataSource DataSource = this.Context.GetDefaultIDataSource();

                    AnalysisStatisticExecuteHost statisticHost = new AnalysisStatisticExecuteHost(this.Context, setProperties, DataSource, inputVariableList, this.Context.CurrentSelect.ToString(), this.Context.AnalysisInterpreterHost);

                    if (string.IsNullOrEmpty(this.PSUVar))
                    {
                        this.MeansStatistic = this.Context.GetStatistic("Means", statisticHost);
                    }
                    else
                    {
                        this.MeansStatistic = this.Context.GetStatistic("ComplexSampleMeans", statisticHost);
                    }

                    this.MeansStatistic.Execute();

                    this.MeansStatistic = null;
                }
                this.HasRun = true;
            }

            return(result);
        }
Example #14
0
        /// <summary>
        /// performs an addition / subtraction or pass thru rule
        /// </summary>
        /// <returns>object</returns>
        public override object Execute()
        {
            object result = null;

            if (!this.HasRun)
            {
                // Create the AnalysisStatisticExecuteHost analysisStatisticExecuteHost = null;
                // Create dynamic reference to the Linear Regression assembly
                // call the LinearRegress.ProcessData(IAnalysisStatisticExecuteHost AnalysisStatisticExecuteHost);
                // method
                IAnalysisStatistic LinearRegress = null;

                // connection string
                // 1 term / column name
                // 1 dependent variable /column name
                // tablname

                Dictionary <string, string> setProperties = this.Context.GetGlobalSettingProperties();
                if (this.Context.CurrentRead == null)
                {
                    setProperties.Add("TableName", "");
                }
                else
                {
                    setProperties.Add("TableName", this.Context.CurrentRead.Identifier);
                }

                setProperties.Add("CommandText", this.commandText);
                Dictionary <string, string> inputVariableList = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
                inputVariableList.Add(this.Identifier, "DependVar");
                bool containsDummyVariables = false;

                if (this.nointercept == false)
                {
                    setProperties.Add("Intercept", "true");
                }
                else
                {
                    setProperties.Add("Intercept", "false");
                }

                if (!string.IsNullOrEmpty(this.pvalue))
                {
                    double p       = 0.95;
                    bool   success = Double.TryParse(this.pvalue.Replace("%", string.Empty), out p);
                    if (success)
                    {
                        setProperties.Add("P", p.ToString());
                    }
                }

                Configuration config = Configuration.GetNewInstance();

                setProperties.Add("BLabels", config.Settings.RepresentationOfYes + ";" + config.Settings.RepresentationOfNo + ";" + config.Settings.RepresentationOfMissing); // TODO: Replace Yes, No, Missing with global vars

                //// Make sure dummy vars aren't split up either!
                //if(this.TermList.Contains("(") || this.TermList.Contains(")"))
                //{
                //    this.TermList = this.TermList.Replace("( ", "(");
                //    this.TermList = this.TermList.Replace(" )", ")");
                //    containsDummyVariables = true;
                //}

                //string[] terms;
                //// Make sure each interaction term isn't split up!
                //this.TermList = this.TermList.Replace(" *", "*");
                //this.TermList = this.TermList.Replace("* ", "*");
                //terms = this.TermList.Split(' ');

                //foreach (string s in terms)
                //{


                //    if (!s.Contains("*") && s.Contains("(") && s.Contains(")"))
                //    {
                //        // dummy variables (discrete terms) get added to the terms list, but this is handled in the regression code
                //        inputVariableList.Add(s.Replace("(", string.Empty).Replace(")", string.Empty), "Discrete");
                //    }
                //    else if (s.Contains("*"))
                //    {
                //        inputVariableList.Add(s, "Term");
                //    }
                //    else
                //    {
                //        inputVariableList.Add(s, "Unsorted");
                //    }
                //}

                foreach (string s in TermList)
                {
                    if (!s.Contains("*") && s.Contains("(") && s.Contains(")"))
                    {
                        // dummy variables (discrete terms) get added to the terms list, but this is handled in the regression code
                        inputVariableList.Add(s.Replace("(", string.Empty).Replace(")", string.Empty), "Discrete");
                    }
                    else if (s.Contains("*"))
                    {
                        inputVariableList.Add(s, "Term");
                    }
                    else
                    {
                        inputVariableList.Add(s, "Unsorted");
                    }
                }

                if (!string.IsNullOrEmpty(this.WeightVar))
                {
                    // Make sure our weight variable isn't a term or the dependent variable. This shouldn't occur through the UI, but the user can still type something like this in manually
                    if (inputVariableList.ContainsKey(this.WeightVar))
                    {
                        Dictionary <string, string> args = new Dictionary <string, string>();
                        args.Add("COMMANDNAME", CommandNames.REGRESS);
                        args.Add("COMMANDTEXT", commandText.Trim());
                        args.Add("HTMLRESULTS", "<br clear=\"all\" /><p align=\"left\"><b><tlt>Weight variable cannot be a term or dependent variable</tlt></b></p>");

                        this.Context.AnalysisCheckCodeInterface.Display(args);

                        return(result);
                    }
                    inputVariableList.Add(this.WeightVar, "WeightVar");
                }

                IDataSource DataSource = this.Context.GetDefaultIDataSource();

                AnalysisStatisticExecuteHost statisticHost = new AnalysisStatisticExecuteHost(this.Context, setProperties, DataSource, inputVariableList, this.Context.CurrentSelect.ToString(), this.Context.AnalysisInterpreterHost);

                LinearRegress = this.Context.GetStatistic("LinearRegression", statisticHost);
                LinearRegress.Execute();
                this.HasRun = true;
            }

            return(result);
        }
Example #15
0
        /// <summary>
        /// performs an addition / subtraction or pass thru rule
        /// </summary>
        /// <returns>object</returns>
        public override object Execute()
        {
            object result = null;

            if (!this.HasRun)
            {
                // prepare IAnalysisStatisticContext information to be sent to the
                // KMSurvival
                IAnalysisStatistic KMSurvival = null;

                // connection string
                // 1 term / column name
                // 1 dependent variable /column name
                // tablname

                Dictionary<string, string> setProperties = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
                if (this.Context.CurrentRead == null)
                {
                    setProperties.Add("TableName", "");
                }
                else
                {
                    setProperties.Add("TableName", this.Context.CurrentRead.Identifier);
                }
                setProperties.Add("CommandText", this.commandText);
                Dictionary<string, string> inputVariableList = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

                setProperties.Add("BLabels", "Yes;No;Missing"); // TODO: Replace Yes, No, Missing with global vars

                //ToDo: Move calls to inputVariableList.Add up into applicable function above: Rule_KMSurv or SetOption
                //
                inputVariableList.Add("time_variable", time_variable);
                inputVariableList.Add("group_variable", group_variable);

                //inputVariableList.Add("time_function", time_function);
                inputVariableList.Add("censor_variable", censor_variable);
                inputVariableList.Add("uncensored_value", uncensored_value);
                inputVariableList.Add("time_unit", time_unit);

                inputVariableList.Add("out_table", out_table);
                inputVariableList.Add("graph_type", graph_type);
                inputVariableList.Add("weight_variable", weight_variable);

                IDataSource DataSource = this.Context.GetDefaultIDataSource();

                AnalysisStatisticExecuteHost statisticHost = new AnalysisStatisticExecuteHost(this.Context, setProperties, DataSource, inputVariableList, this.Context.CurrentSelect.ToString(), this.Context.AnalysisInterpreterHost);

                KMSurvival = this.Context.GetStatistic("KaplanMeierSurvival", statisticHost);
                KMSurvival.Execute();
                this.HasRun = true;
            }

            return result;
        }
        public override object Execute()
        {
            object result = null;

            if (!this.HasRun)
            {
                Dictionary <string, string> setProperties = this.Context.GetGlobalSettingProperties();

                if (!string.IsNullOrEmpty(_commandText))
                {
                    inputVariableList.Add("Command_Text", _commandText);
                }
                if (!string.IsNullOrEmpty(_independentVariableList))
                {
                    inputVariableList.Add("Independent_Variable_List", _independentVariableList.Trim(','));
                }
                if (!string.IsNullOrEmpty(_graphCrossTab))
                {
                    inputVariableList.Add("Cross_Tabulation_Variable", _graphCrossTab);
                }
                if (!string.IsNullOrEmpty(_strataVar))
                {
                    inputVariableList.Add("StrataVar", _strataVar);
                }
                if (!string.IsNullOrEmpty(_graphType))
                {
                    inputVariableList.Add("Graph_Type", _graphType);
                }
                if (!string.IsNullOrEmpty(_graphTitle))
                {
                    inputVariableList.Add("Graph_Title", _graphTitle);
                }
                if (!string.IsNullOrEmpty(_graphXAxisLabel))
                {
                    inputVariableList.Add("Graph_Independent_Value_Axis_Label", _graphXAxisLabel);
                }
                if (!string.IsNullOrEmpty(_graphYAxisLabel))
                {
                    inputVariableList.Add("Graph_Dependent_Value_Axis_Label", _graphYAxisLabel);
                }
                if (!string.IsNullOrEmpty(_weightVar))
                {
                    inputVariableList.Add("Weight_Variable", _weightVar);
                }
                if (!string.IsNullOrEmpty(_aggregateFunction))
                {
                    inputVariableList.Add("Aggregate_Function", _aggregateFunction);
                }
                if (!string.IsNullOrEmpty(_graphDateFormat))
                {
                    inputVariableList.Add("Date_Format", _graphDateFormat);
                }

                if (!string.IsNullOrEmpty(_graphInterval))
                {
                    inputVariableList.Add("Interval", _graphInterval);
                }
                if (!string.IsNullOrEmpty(_graphIntervalUnits))
                {
                    inputVariableList.Add("Interval_Units", _graphIntervalUnits);
                }
                if (!string.IsNullOrEmpty(_graphStartFrom))
                {
                    inputVariableList.Add("Start_From", _graphStartFrom);
                }

                EpiInfo.Plugin.IDataSource DataSource = this.Context.GetDefaultIDataSource();

                AnalysisStatisticExecuteHost statisticHost = new AnalysisStatisticExecuteHost(this.Context, setProperties, DataSource, inputVariableList, this.Context.CurrentSelect.ToString(), this.Context.AnalysisInterpreterHost);

                this.GraphStatistic = this.Context.GetStatistic("Graph", statisticHost);
                this.GraphStatistic.Execute();
                this.GraphStatistic = null;
                this.HasRun         = true;
            }
            return(result);
        }
Example #17
0
        public override object Execute()
        {
            object result = null;

            if (!this.HasRun)
            {

                Dictionary<string, string> setProperties = this.Context.GetGlobalSettingProperties();

                if (!string.IsNullOrEmpty(_commandText)) inputVariableList.Add("Command_Text", _commandText);
                if (!string.IsNullOrEmpty(_independentVariableList)) inputVariableList.Add("Independent_Variable_List", _independentVariableList.Trim(','));
                if (!string.IsNullOrEmpty(_graphCrossTab)) inputVariableList.Add("Cross_Tabulation_Variable", _graphCrossTab);
                if (!string.IsNullOrEmpty(_strataVar)) inputVariableList.Add("StrataVar", _strataVar);
                if (!string.IsNullOrEmpty(_graphType)) inputVariableList.Add("Graph_Type", _graphType);
                if (!string.IsNullOrEmpty(_graphTitle)) inputVariableList.Add("Graph_Title", _graphTitle);
                if (!string.IsNullOrEmpty(_graphXAxisLabel)) inputVariableList.Add("Graph_Independent_Value_Axis_Label", _graphXAxisLabel);
                if (!string.IsNullOrEmpty(_graphYAxisLabel)) inputVariableList.Add("Graph_Dependent_Value_Axis_Label", _graphYAxisLabel);
                if (!string.IsNullOrEmpty(_weightVar)) inputVariableList.Add("Weight_Variable", _weightVar);
                if (!string.IsNullOrEmpty(_aggregateFunction)) inputVariableList.Add("Aggregate_Function", _aggregateFunction);
                if (!string.IsNullOrEmpty(_graphDateFormat)) inputVariableList.Add("Date_Format", _graphDateFormat);

                if (!string.IsNullOrEmpty(_graphInterval)) inputVariableList.Add("Interval", _graphInterval);
                if (!string.IsNullOrEmpty(_graphIntervalUnits)) inputVariableList.Add("Interval_Units", _graphIntervalUnits);
                if (!string.IsNullOrEmpty(_graphStartFrom)) inputVariableList.Add("Start_From", _graphStartFrom);

                EpiInfo.Plugin.IDataSource DataSource = this.Context.GetDefaultIDataSource();

                AnalysisStatisticExecuteHost statisticHost = new AnalysisStatisticExecuteHost(this.Context, setProperties, DataSource, inputVariableList, this.Context.CurrentSelect.ToString(), this.Context.AnalysisInterpreterHost);

                this.GraphStatistic = this.Context.GetStatistic("Graph", statisticHost);
                this.GraphStatistic.Execute();
                this.GraphStatistic = null;
                this.HasRun = true;
            }
            return result;
        }
        /// <summary>
        /// performs an addition / subtraction or pass thru rule
        /// </summary>
        /// <returns>object</returns>
        public override object Execute()
        {
            object result = null;

            if (!this.HasRun)
            {
                // prepare IAnalysisStatisticContext information to be sent to the
                // CoxPH
                IAnalysisStatistic CoxPH = null;

                // connection string
                // 1 term / column name
                // 1 dependent variable /column name
                // tablname

                Dictionary <string, string> setProperties = this.Context.GetGlobalSettingProperties();
                if (this.Context.CurrentRead == null)
                {
                    setProperties.Add("TableName", "");
                }
                else
                {
                    setProperties.Add("TableName", this.Context.CurrentRead.Identifier);
                }
                setProperties.Add("CommandText", this.commandText);
                Dictionary <string, string> inputVariableList = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);

                inputVariableList.Add("time_variable", time_variable);
                StringBuilder sb = new StringBuilder();
                foreach (string s in this.CovariateList)
                {
                    sb.Append(s);
                    sb.Append(",");
                }
                if (sb.Length > 0)
                {
                    sb.Length = sb.Length - 1;
                }
                inputVariableList.Add("CovariateList", sb.ToString());
                sb.Length = 0;
                foreach (string s in this.DiscreteList)
                {
                    sb.Append(s);
                    sb.Append(",");
                }
                if (this.DiscreteList.Count > 0)
                {
                    sb.Length = sb.Length - 1;
                }

                inputVariableList.Add("DiscreteList", sb.ToString());
                inputVariableList.Add("time_function", time_function);
                inputVariableList.Add("censor_variable", censor_variable);
                inputVariableList.Add("censor_value", censor_value);
                inputVariableList.Add("time_unit", time_unit);

                inputVariableList.Add("out_table", out_table);
                inputVariableList.Add("graph_type", graph_type);
                inputVariableList.Add("weightvar", weightvar);

                sb.Length = 0;

                foreach (string s in StrataVarList)
                {
                    sb.Append(s);
                    sb.Append(",");
                }
                if (sb.Length > 0)
                {
                    sb.Length = sb.Length - 1;
                }
                inputVariableList.Add("StrataVarList", sb.ToString());

                sb.Length = 0;
                foreach (string s in GraphVariableList)
                {
                    sb.Append(s);
                    sb.Append(",");
                }
                if (sb.Length > 0)
                {
                    sb.Length = sb.Length - 1;
                }
                inputVariableList.Add("GraphVariableList", sb.ToString());

                IDataSource DataSource = this.Context.GetDefaultIDataSource();

                AnalysisStatisticExecuteHost statisticHost = new AnalysisStatisticExecuteHost(this.Context, setProperties, DataSource, inputVariableList, this.Context.CurrentSelect.ToString(), this.Context.AnalysisInterpreterHost);

                CoxPH = this.Context.GetStatistic("CoxProportionalHazards", statisticHost);
                CoxPH.Execute();
                this.HasRun = true;
            }

            return(result);
        }
        /// <summary>
        /// performs an addition / subtraction or pass thru rule
        /// </summary>
        /// <returns>object</returns>
        public override object Execute()
        {
            object result = null;

            if (!this.HasRun)
            {
                // Create the AnalysisStatisticExecuteHost analysisStatisticExecuteHost = null;
                // Create dynamic reference to the Linear Regression assembly
                // call the LinearRegress.ProcessData(IAnalysisStatisticExecuteHost AnalysisStatisticExecuteHost);
                // method
                IAnalysisStatistic LinearRegress = null;

                // connection string
                // 1 term / column name
                // 1 dependent variable /column name
                // tablname

                Dictionary<string, string> setProperties = this.Context.GetGlobalSettingProperties();
                if (this.Context.CurrentRead == null)
                {
                    setProperties.Add("TableName", "");
                }
                else
                {
                    setProperties.Add("TableName", this.Context.CurrentRead.Identifier);
                }

                setProperties.Add("CommandText", this.commandText);
                Dictionary<string, string> inputVariableList = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
                inputVariableList.Add(this.Identifier, "DependVar");
                bool containsDummyVariables = false;

                if (this.nointercept == false)
                {
                    setProperties.Add("Intercept", "true");
                }
                else
                {
                    setProperties.Add("Intercept", "false");
                }

                if (!string.IsNullOrEmpty(this.pvalue))
                {
                    double p = 0.95;
                    bool success = Double.TryParse(this.pvalue.Replace("%", string.Empty), out p);
                    if (success)
                    {
                        setProperties.Add("P", p.ToString());
                    }
                }

                Configuration config = Configuration.GetNewInstance();

                setProperties.Add("BLabels", config.Settings.RepresentationOfYes + ";" + config.Settings.RepresentationOfNo + ";" + config.Settings.RepresentationOfMissing); // TODO: Replace Yes, No, Missing with global vars

                //// Make sure dummy vars aren't split up either!
                //if(this.TermList.Contains("(") || this.TermList.Contains(")"))
                //{
                //    this.TermList = this.TermList.Replace("( ", "(");
                //    this.TermList = this.TermList.Replace(" )", ")");
                //    containsDummyVariables = true;
                //}

                //string[] terms;
                //// Make sure each interaction term isn't split up!
                //this.TermList = this.TermList.Replace(" *", "*");
                //this.TermList = this.TermList.Replace("* ", "*");
                //terms = this.TermList.Split(' ');

                //foreach (string s in terms)
                //{

                //    if (!s.Contains("*") && s.Contains("(") && s.Contains(")"))
                //    {
                //        // dummy variables (discrete terms) get added to the terms list, but this is handled in the regression code
                //        inputVariableList.Add(s.Replace("(", string.Empty).Replace(")", string.Empty), "Discrete");
                //    }
                //    else if (s.Contains("*"))
                //    {
                //        inputVariableList.Add(s, "Term");
                //    }
                //    else
                //    {
                //        inputVariableList.Add(s, "Unsorted");
                //    }
                //}

                foreach (string s in TermList)
                {
                    if (!s.Contains("*") && s.Contains("(") && s.Contains(")"))
                    {
                        // dummy variables (discrete terms) get added to the terms list, but this is handled in the regression code
                        inputVariableList.Add(s.Replace("(", string.Empty).Replace(")", string.Empty), "Discrete");
                    }
                    else if (s.Contains("*"))
                    {
                        inputVariableList.Add(s, "Term");
                    }
                    else
                    {
                        inputVariableList.Add(s, "Unsorted");
                    }
                }

                if (!string.IsNullOrEmpty(this.WeightVar))
                {
                    // Make sure our weight variable isn't a term or the dependent variable. This shouldn't occur through the UI, but the user can still type something like this in manually
                    if (inputVariableList.ContainsKey(this.WeightVar))
                    {
                        Dictionary<string, string> args = new Dictionary<string, string>();
                        args.Add("COMMANDNAME", CommandNames.REGRESS);
                        args.Add("COMMANDTEXT", commandText.Trim());
                        args.Add("HTMLRESULTS", "<br clear=\"all\" /><p align=\"left\"><b><tlt>Weight variable cannot be a term or dependent variable</tlt></b></p>");

                        this.Context.AnalysisCheckCodeInterface.Display(args);

                        return result;
                    }
                    inputVariableList.Add(this.WeightVar, "WeightVar");
                }

                IDataSource DataSource = this.Context.GetDefaultIDataSource();

                AnalysisStatisticExecuteHost statisticHost = new AnalysisStatisticExecuteHost(this.Context, setProperties, DataSource, inputVariableList, this.Context.CurrentSelect.ToString(), this.Context.AnalysisInterpreterHost);

                LinearRegress = this.Context.GetStatistic("LinearRegression", statisticHost);
                LinearRegress.Execute();
                this.HasRun = true;
            }

            return result;
        }