<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Sequential model mixtures in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Sequential-model-mixtures/m-p/275947#M14558</link>
    <description>&lt;P&gt;Thank you very much, Rick!&lt;/P&gt;</description>
    <pubDate>Wed, 08 Jun 2016 13:11:50 GMT</pubDate>
    <dc:creator>BarryDeCicco</dc:creator>
    <dc:date>2016-06-08T13:11:50Z</dc:date>
    <item>
      <title>Sequential model mixtures</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Sequential-model-mixtures/m-p/275781#M14535</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I'm trying to fit a mixture model (or, with transformations, an piecewise regression) where I assume that there are from 1 to three groups, sequentially along the independent variable. &amp;nbsp; I would love to do this in Proc FMM, but when I tried, it seemed to assume that any point could be in any group (mixed groups). &amp;nbsp;I would like sequential groups.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Has anybody succeeded in doing this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Barry&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 18:54:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Sequential-model-mixtures/m-p/275781#M14535</guid>
      <dc:creator>BarryDeCicco</dc:creator>
      <dc:date>2016-06-07T18:54:49Z</dc:date>
    </item>
    <item>
      <title>Re: Sequential model mixtures</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Sequential-model-mixtures/m-p/275785#M14536</link>
      <description>&lt;P&gt;Please post the code that you are using.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An important consideration in PL models is whether you assume that the cutpoints are known or whether they need to be estimated. Also important is whether the regression model is continuous or discontinuous.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For known cutpoints and a discontinuous model, you can simply discretize the X axis and include a categorical variable that specifies the domain for the model. &amp;nbsp;For example, the following data specifies three domains [0,1], [1,2], and [2,3] with a different model define on each interval. &amp;nbsp;You can use PROC GLM to solve for the parameter estimates on each interval. &amp;nbsp;You can even get a crdue fit plot, although of course GLM doesn't know that the prediction lines should be restricted to the intervals:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
call streaminit(1);
do x = 0 to 1 by 0.1;
   c = 1;
   y = 2 - 3*x + rand("normal");
   output;
end;
do x = 1 to 2 by 0.1;
   c = 2;
   y = -2 + 3*x + rand("normal");
   output;
end;
do x = 2 to 3 by 0.1;
   c = 3;
   y = 0 + x + rand("normal");
   output;
end;
run;

proc glm data=A plots=fitplot;
class c;
model y = c | x / solution;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Jun 2016 19:12:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Sequential-model-mixtures/m-p/275785#M14536</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-06-07T19:12:36Z</dc:date>
    </item>
    <item>
      <title>Re: Sequential model mixtures</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Sequential-model-mixtures/m-p/275814#M14538</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Rick, thanks for a quick response!&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;Here's the code:&lt;BR /&gt;&lt;BR /&gt;proc fmm data=a.transreg gconv=0 plots=all  ;&lt;BR /&gt; model Log_Log = Log_KM / kmax=3 krestart;&lt;BR /&gt; output out=FMM_model pred=mixpred resid=mixresid class=mixcomp;&lt;BR /&gt; ods output ParameterEstimates=FMM_parms ;&lt;BR /&gt; ods output FitStatistics=FMM_FitStatistics;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;When I plot a scatterplot of the actual vs. predicted values, &lt;BR /&gt;with the class variable 'mixcomp' as a group, it's clear that the two groups are intermingled.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 21:44:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Sequential-model-mixtures/m-p/275814#M14538</guid>
      <dc:creator>BarryDeCicco</dc:creator>
      <dc:date>2016-06-07T21:44:47Z</dc:date>
    </item>
    <item>
      <title>Re: Sequential model mixtures</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Sequential-model-mixtures/m-p/275815#M14539</link>
      <description>&lt;P&gt;This system stripped all line breaks!&lt;/P&gt;
Is there any way to fix that?</description>
      <pubDate>Tue, 07 Jun 2016 21:43:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Sequential-model-mixtures/m-p/275815#M14539</guid>
      <dc:creator>BarryDeCicco</dc:creator>
      <dc:date>2016-06-07T21:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: Sequential model mixtures</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Sequential-model-mixtures/m-p/275829#M14540</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11862"&gt;@BarryDeCicco&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;This system stripped all line breaks!&lt;/P&gt;
Is there any way to fix that?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Did you post using the "run" icon box or the {i} box?&lt;/P&gt;
&lt;P&gt;Code from the SAS editor works best if posted using the Run icon box.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 22:46:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Sequential-model-mixtures/m-p/275829#M14540</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-06-07T22:46:58Z</dc:date>
    </item>
    <item>
      <title>Re: Sequential model mixtures</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Sequential-model-mixtures/m-p/275839#M14542</link>
      <description>I did that, and it was all so pretty...... &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Wed, 08 Jun 2016 01:43:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Sequential-model-mixtures/m-p/275839#M14542</guid>
      <dc:creator>BarryDeCicco</dc:creator>
      <dc:date>2016-06-08T01:43:00Z</dc:date>
    </item>
    <item>
      <title>Re: Sequential model mixtures</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Sequential-model-mixtures/m-p/275849#M14544</link>
      <description>&lt;P&gt;I don't know if this is pertinent to your problem. An easy way to fit a piecewise linear model (with fixed breaks) is with proc ROBUSTREG and a spline of degree 1:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc robustreg data=sashelp.fish;
effect spl = spline(length1 / degree=1 knotmethod=list(20));
model weight = spl;
output out=fishPred p=predweight;
run;

proc sort data=fishPred; by length1; run;

proc sgplot data=fishPred;
scatter x=length1 y=weight;
series x=length1 y=predweight;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/3528i41165F438D765EB0/image-size/medium?v=v2&amp;amp;px=-1" border="0" alt="SGPlot5.png" title="SGPlot5.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2016 03:10:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Sequential-model-mixtures/m-p/275849#M14544</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-06-08T03:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: Sequential model mixtures</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Sequential-model-mixtures/m-p/275943#M14557</link>
      <description>&lt;P&gt;To add to PGStats's coments, a spline effect enables you to define&amp;nbsp;piecewise polynomials of any degree. If you put knots at the cutpoints, then you will get a continuous piecewise fit. &amp;nbsp;You can also add additional knots at the cutpoints to achieve a discontinuous fit, as shown in &lt;A href="http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/viewer.htm#statug_transreg_details03.htm" target="_self"&gt;Figure 117.24 (Discontinuous Spline Fit) in the documentation for the TRANSREG procedure.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With regard to the FMM code you posted, I don't think yourcode makes sense. &amp;nbsp;Your code tells SAS to&amp;nbsp;"fit a linear model, then try to find as many as three normal components such that the distribution of the residuals are best described as being a mixture of these&amp;nbsp;component distributions." &amp;nbsp;But that's not the problem you are trying to solve! Instead, you want to fit three separate regression models, each with a different slope and intercept. &amp;nbsp;That requires an class&amp;nbsp;variable that indicates the domain of each PL model.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you use the sample data that I provided earlyier, this syntax works in FMM:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc fmm data=a; 
class c;
model y = x | c; 
output out=FMM_model pred=mixpred class=mixcomp; 
run;

proc sgplot data=FMM_Model;
scatter x=x y=y / group=c;
series  x=x y=mixpred;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Notice, however, that this really isn't a finite mixture model. There is only one component used to model the residual distribution. Therefore you can use GLM or ROBUSTREG or TRANSREG to get the same model.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2016 12:46:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Sequential-model-mixtures/m-p/275943#M14557</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-06-08T12:46:14Z</dc:date>
    </item>
    <item>
      <title>Re: Sequential model mixtures</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Sequential-model-mixtures/m-p/275947#M14558</link>
      <description>&lt;P&gt;Thank you very much, Rick!&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2016 13:11:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Sequential-model-mixtures/m-p/275947#M14558</guid>
      <dc:creator>BarryDeCicco</dc:creator>
      <dc:date>2016-06-08T13:11:50Z</dc:date>
    </item>
  </channel>
</rss>

