Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Discussions
- :
- How to get the spline fit curve name?

Topic Options

- Start Article
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

How to get the spline fit curve name?

May 7, 2017 9:19 PM
(1061 views)

Hi,

Is there a way to get the spline fit curve name (i.e, if we group the fitting by a certain column).

I searched and the only way I found how to reference a curve is by its index number.

E.g.

```
obj = Bivariate(Y( :Weight ), X( :Height ), Fit Line);
obj << (Curve[1] << Line Width ( 2 ));
```

I thought I could get away with this by using this code where I just create a list from grouping column.

```
groupcol=Column(dt, "Group Col Name");
Summarize( A = by( groupcol ) );
B = groupcol << get property( value ordering );
If( Is Empty( B ),
GroupList = A,
GroupList = B
);
```

Hence, GroupList[1] would refer to Curve[1], GroupList[2] would refer to Curve[2], and so on..

However, I saw one problem with this. If GroupList[2] has too few points so that a spline fit cannot be done, Curve[2] will actually belong to GroupList[3]! So I realized this isn't really the way to do it.

Therefore, here are my questions:

1. Supposed I create a script that does spline fit by a certain grouping column (e.g. a column which contains "Red", "Blue", "Green", "Yellow"), is there a way to know the ff:

1.1 How many spline fits were drawn?

1.2 Which spline fit belongs to which group? (I.e, does Curve[2] belongs to "Blue" or to "Green" or "Yellow")?

Thank you.

2 REPLIES 2

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: How to get the spline fit curve name?

Here is one way to get the Curve Numbers, and which Fit they go with

```
Names Default To Here( 1 );
// Read in some sample data
dt = Open( "$SAMPLE_DATA\semiconductor capability.jmp" );
// Run the bivariate and create the Fit line for each of the sites
biv = bivariate( y( :npn1 ), x( :pnp1 ), Groupby( :site ), Fit line );
// The Outline Box for the fit can be read
TheTitle = Report( biv )[Outline Box( 2 )] << get title;
Show( TheTitle );
// Here is a little bit of code that can get the list of values for the Linear Fit, and
// get the curve number
AllTitles = CurveNumber = {};
i = 2;
FitNum = 0;
While( Try( Report( biv )[Outline Box( i )] << get title, "" ) != "",
If(
Word( 1, Report( biv )[Outline Box( i )] << get title ) == "Linear" & Word(
2,
Report( biv )[Outline Box( i )] << get title
) == "Fit",
FitNum = FitNum + 1;
AllTitles[FitNum] = Word( 3, Report( biv )[Outline Box( i )] << get title );
CurveNumber[FitNum] = FitNum;
);
i = i + 1;
);
```

Jim

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: How to get the spline fit curve name?

Thanks Jim. I tried to tweak it a bit to show all the variables and apply it to sample data Candy Bars.jmp.

```
Names Default To Here( 1 );
// Read in some sample data
dt = Current Data Table();
// Run the bivariate and create the Fit line for each of the sites
biv = bivariate( y( :Total fat g ), x( :Calories ), Groupby( :Brand ), Fit line );
// The Outline Box for the fit can be read
TheTitle = Report( biv )[Outline Box( 2 )] << get title;
Show( TheTitle );
// Here is a little bit of code that can get the list of values for the Linear Fit, and
// get the curve number
AllTitles = CurveNumber = {};
i = 2;
FitNum = 0;
While( Try( Report( biv )[Outline Box( i )] << get title, "" ) != "",
If(
Word( 1, Report( biv )[Outline Box( i )] << get title ) == "Linear" & Word(
2,
Report( biv )[Outline Box( i )] << get title
) == "Fit",
FitNum = FitNum + 1;
Show (FitNum);
AllTitles[FitNum] = Word( 3, Report( biv )[Outline Box( i )] << get title );
Show (AllTitles[FitNum]);
CurveNumber[FitNum] = FitNum;
Show(CurveNumber[FitNum]);
);
i = i + 1;
);
```

I get this output:

```
/*:
TheTitle = "Linear Fit Brand==\!"Adams & Brooks\!"";
FitNum = 1;
AllTitles[FitNum] = "Brand==\!"Adams";
CurveNumber[FitNum] = 1;
FitNum = 2;
AllTitles[FitNum] = "Brand==\!"Annabelle\!"";
CurveNumber[FitNum] = 2;
FitNum = 3;
AllTitles[FitNum] = "Brand==\!"Bit-O-Honey\!"";
CurveNumber[FitNum] = 3;
FitNum = 4;
AllTitles[FitNum] = "Brand==\!"Brown";
CurveNumber[FitNum] = 4;
FitNum = 5;
AllTitles[FitNum] = "Brand==\!"Charms\!"";
CurveNumber[FitNum] = 5;
FitNum = 6;
AllTitles[FitNum] = "Brand==\!"Hershey\!"";
CurveNumber[FitNum] = 6;
FitNum = 7;
AllTitles[FitNum] = "Brand==\!"Just";
CurveNumber[FitNum] = 7;
FitNum = 8;
AllTitles[FitNum] = "Brand==\!"Leaf\!"";
CurveNumber[FitNum] = 8;
FitNum = 9;
AllTitles[FitNum] = "Brand==\!"M&M/Mars\!"";
CurveNumber[FitNum] = 9;
FitNum = 10;
AllTitles[FitNum] = "Brand==\!"Myerson\!"";
CurveNumber[FitNum] = 10;
FitNum = 11;
AllTitles[FitNum] = "Brand==\!"Nabisco\!"";
CurveNumber[FitNum] = 11;
FitNum = 12;
AllTitles[FitNum] = "Brand==\!"Nestle\!"";
CurveNumber[FitNum] = 12;
FitNum = 13;
AllTitles[FitNum] = "Brand==\!"Pearson\!"";
CurveNumber[FitNum] = 13;
FitNum = 14;
AllTitles[FitNum] = "Brand==\!"Sherwood\!"";
CurveNumber[FitNum] = 14;
FitNum = 15;
AllTitles[FitNum] = "Brand==\!"Standard\!"";
CurveNumber[FitNum] = 15;
FitNum = 16;
AllTitles[FitNum] = "Brand==\!"Tobler\!"";
CurveNumber[FitNum] = 16;
FitNum = 17;
AllTitles[FitNum] = "Brand==\!"Tootsie\!"";
CurveNumber[FitNum] = 17;
FitNum = 18;
AllTitles[FitNum] = "Brand==\!"Weider\!"";
CurveNumber[FitNum] = 18;
```

If you noticed, the script cuts the name if it encounters a space. E.g. "Adams & Brooks" becomes "Adams", while "Brown & Haley" becomes "Brown"But I will also try tweaking this. Also, I am thinking of doing the spline fit on a per group basis as work around as well. Thanks again for the help.