示例#1
0
        public Model(MeasureList measures, bool outcomeIsLogNormallyDistributed, McmcParameters mcmcParams)
        {
            OelStdz  = new OelStandardizer(this);
            Measures = measures;

            this.ClassName = this.GetType().Name;
            if (mcmcParams == null)
            {
                mcmcParams = new McmcParameters(); // default values
                this.Messages.AddWarning("Mcmc parameters were undefined, using default values", this.ClassName);
            }

            this.Messages.Add(measures.Error);
            this.Messages.Add(mcmcParams.Error);
            this.NIter         = mcmcParams.NIter;
            this.NBurnin       = mcmcParams.NBurnin;
            this.NThin         = mcmcParams.NThin;
            this.MonitorBurnin = mcmcParams.MonitorBurnin;
            this.OutcomeIsLogNormallyDistributed = outcomeIsLogNormallyDistributed;
            if (this.OutcomeIsLogNormallyDistributed)
            {
                OelStdz.StandardizeObservations();
            }
            this.Data = new DataSummary(measures, this.OutcomeIsLogNormallyDistributed);
            this.ME   = measures.ME;
            this.OEL  = measures.OEL;
        }
示例#2
0
        public SEGUninformativeModel(MeasureList measures, UninformativeModelParameters specificParams, McmcParameters mcmcParams = null)
            : base(measures, specificParams.LogNormalDstrn, /*new Range(specificParams.MuLower, specificParams.MuUpper, specificParams.InitMu),*/ mcmcParams)
        {
            this.MuLower = specificParams.MuLower;
            this.MuUpper = specificParams.MuUpper;
            this.SDRange = specificParams.SDRange;
            this.InitMu  = specificParams.InitMu;
            this.InitSD  = specificParams.InitSD;
            this.Result  = new ModelResult(this, "mu", "sd");
            bool testSD = double.IsNaN(this.InitSD) || (this.InitSD == 0);

            if (Tools.IsND(this.InitMu) || testSD)
            {
                InitialValues initVals = WebExpoFunctions3.DefaultInits(this.Data, this.OutcomeIsLogNormallyDistributed, Tools.Combine(this.MuLower, this.MuUpper), this.SDRange, includeCensoredData: false);
                if (Tools.IsND(this.InitMu))
                {
                    this.InitMu = initVals.Mu;
                }

                if (testSD)
                {
                    this.InitSD = initVals.SigmaWithin;
                }
            }

            if (this.ME.ThroughCV)
            {
                this.Result.Chains.Add("cv");
            }
        }// end constructor
示例#3
0
        public SEGInformedVarModel(MeasureList measures, SEGInformedVarModelParameters specificParams, McmcParameters mcmcParams = null, PastDataSummary pastDataSummary = null)
            : base(measures, specificParams.LogNormalDstrn, mcmcParams)
        {
            this.PastData = pastDataSummary == null ? PastDataSummary.EmptyObject : pastDataSummary;

            this.Messages.Add(this.PastData.Messages);
            this.LogSigmaMu   = specificParams.LogSigmaMu;
            this.LogSigmaPrec = specificParams.LogSigmaPrec;
            this.InitSigma    = specificParams.InitSigma;
            this.MuLower      = specificParams.MuLower;
            this.MuUpper      = specificParams.MuUpper;
            this.InitMu       = specificParams.InitMu;
            this.Result       = new ModelResult(this, "mu", "sd");

            if (this.ME.ThroughCV)
            {
                this.Result.Chains.Add("cv");
            }
        }// end constructor
示例#4
0
        public BetweenWorkerModel(MeasureList measures, AbstractBWModelParameters specificParams, McmcParameters mcmcParams = null)
            : base(measures, specificParams.LogNormalDstrn, mcmcParams)
        {
            this.Result = new ModelResult(this, "muOverall", "sigmaWithin", "sigmaBetween");
            if (!measures.IsWorkerInfoComplete)
            {
                this.Messages.AddError("Incomplete worker information.", this.ClassName);
            }

            if (this.Data.MEAny)
            {
                if (this.Data.METhroughSD && !MeasurementErrorSupport.MESD)
                {
                    this.Messages.AddError("No support for METhrougSD.", this.ClassName);
                }
                else if (this.Data.METhroughCV && !MeasurementErrorSupport.me_CV)
                {
                    this.Messages.AddError("No support for METhrougCV.", this.ClassName);
                }
            }

            if (this.Messages.Level == Message.Severity.Error)
            {
                return;
            }

            this.UseUniformPriorOnSds = specificParams.UseUniformPriorOnSds;
            if (this.UseUniformPriorOnSds)
            {
                this.SigmaBetweenRange = Tools.Copy(((BWModelParameters_UniformPriorOnSDs)specificParams).SigmaBetweenRange);
                this.SigmaWithinRange  = ((BWModelParameters_UniformPriorOnSDs)specificParams).SigmaWithinRange;
            }
            else
            {
                this.LogSigmaBetweenMu   = ((BWModelParameters)specificParams).LogSigmaBetweenMu;
                this.LogSigmaBetweenPrec = ((BWModelParameters)specificParams).LogSigmaBetweenPrec;
                this.LogSigmaWithinMu    = ((BWModelParameters)specificParams).LogSigmaWithinMu;
                this.LogSigmaWithinPrec  = ((BWModelParameters)specificParams).LogSigmaWithinPrec;
            }

            //4 paramètres communs aux 2 formes que prend le modèle.
            this.MuOverallLower  = specificParams.MuOverallLower;
            this.MuOverallUpper  = specificParams.MuOverallUpper;
            this.InitMuOverall   = specificParams.InitMuOverall;
            this.InitSigmaWithin = specificParams.InitSigmaWithin;

            this.MuOverallRange = Tools.Combine(this.MuOverallLower, this.MuOverallUpper);
            this.Result.AddWorkerMuChains(Data.WorkersByTag.Values);

            if (!Data.AnyCensored && UseUniformPriorOnSds)
            {
                //
                //# If there is no variation observed within subjects,
                //# then we require a non-null lower bound for sigma.within
                //
                if (SigmaWithinRange[0] == 0)
                {
                    bool problem = (Data.NWorkers == Data.N); //il devrait donc y avoir plus d'une mesure pour au moins un travailleur
                    if (!problem)
                    {
                        problem = true;
                        foreach (KeyValuePair <Worker, List <Measure> > kv in Data.MeasuresByWorker)
                        {
                            if (kv.Value.Count <= 1)
                            {
                                continue;
                            }
                            //at least two measures
                            double vari = kv.Value.Select(x => x.A).Variance();
                            if (double.IsNaN(vari) || (vari == 0))
                            {
                                continue;
                            }
                            else
                            {
                                problem = false;
                                break;
                            }
                        } //foreach
                    }

                    if (problem)
                    {
                        this.Messages.AddError("Lower bound for SigmaWithinRange must be > 0 due to observed null within-subjects variance.", this.ClassName);
                        return;
                    }
                }
            }

            if (specificParams.GetType() == typeof(BWModelParameters))// && (Tools.IsND(this.InitMuOverall) || Tools.IsND(this.InitSigmaWithin)))
            {
                InitialValues initValues = specificParams.DefaultInits(this.Data, includeCensoredData: false);

                if (Tools.IsND(this.InitMuOverall))
                {
                    this.InitMuOverall = initValues.Mu;
                }

                if (Tools.IsND(this.InitSigmaWithin))
                {
                    this.InitSigmaWithin = initValues.SigmaWithin;
                }

                this.NormalizedY = initValues.NormalizedY.ToArray();
            }
        }