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
- :
- Slope Calculation and Compilation for Multiple Cas...

Topic Options

- 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

Aug 4, 2017 10:00 AM
(1299 views)

Hi,

I know that the topic of linear slope calculation has been discussed before but I could not find an efficient way to create a tabulated output of Slopes for a set of Cases (i.e. Patients) for which I have varying numbers of obervations as a function of time.

Here is a screen shot of the data (mock; the actual file is attached):

Following the advice of previous discussions in this board, I used the Fit Y by X (Change in Measure by Time) using Patient_ID as By variable, and plotting a linear fit with intercept constrains to 0:

Ouput: 5 analyses identical to the one below:

Where I'm stuck is how to collect the Estimate of the Slope into a new table that would look like:

Patient_ID | Slope |

AAA | m1 |

BBB | m2 |

CCC | m3 |

DDD | m4 |

EEE | m5 |

Any suggestion would be welcome: I'm not attached to the original data format or the analysis method.

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions

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

Aug 4, 2017 10:42 AM
(2582 views)

Solution

You discovered the **By** role group the data for separate regression analysis. (I hope that you know to press and hold the Ctrl key before clicking the red triangle and selecting the Fit Line command!) Now right-click on the Parameter Estimates table and select Make Combined Data Table.

Learn it once, use it forever!

6 REPLIES

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

Aug 4, 2017 10:30 AM
(1295 views)

This code will do the trick. The "secret" is to look at the underlying tree structure of the output, converted to a report.

```
dt = data table("SLOPE_Calculation_mock_data");
bv = dt << Bivariate(
Y( :Change in Measure ),
X( :Time ),
Fit Line( {Line Color( {213, 72, 87} )} ),
By( :Patient_ID )
);
// Figure out how many patients there are
dtab = dt << Tabulate(
Show Control Panel( 0 ),
Add Table( Row Table( Grouping Columns( :Patient_ID ) ) ),
invisible
);
pdt = dtab << Make Into Data Table;
np = nrows(pdt);
patient_list = pdt:Patient_ID << get values;
dtab << close window;
pdt << new column("Slope", numeric, continuous);
bvrep = bv << report;
//bvrep << show tree structure; // Used to get underlying structure
for (i = 1, i <= np, i++,
parameter_estimates = bvrep[i][numbercolbox(7)] << get;
one_slope = parameter_estimates[2];
pdt:Slope[i] = one_slope;
);
```

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

Aug 4, 2017 10:44 AM
(1291 views)

Hi,

Thanks for your quick reply: it is what I was looking for with the exception that the "retrieval" of the parameter_estimate from the multi plot report does not work because the NumberColBox (7) only works for the first plot, the following plots have their corresponding NumberColBox 23, 37 and so on.

I'm not sure how to iterate through the NumberColBox call.

Any thoughts?

Thanks

TS

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

Aug 4, 2017 11:19 AM
(1280 views)

A script could extract the estimates, too, using several different techniques. The common iteration approach becomes cumbersome due to the By groups but can be straight-forward, if only brute force. A more elegant solution would use a single XPath query on the report display tree to retrieve all of thee slopes as a vector. I don't have time right now to research the exact syntax but it would be easy, details aside. Something like this:

`plat << XPath( "//NumberColBox[NumberColBoxHeader=\!"Estimate\!"]" ) << Get( 2 );`

Learn it once, use it forever!

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

Aug 4, 2017 11:30 AM
(1278 views)

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

Aug 4, 2017 10:42 AM
(2583 views)

You discovered the **By** role group the data for separate regression analysis. (I hope that you know to press and hold the Ctrl key before clicking the red triangle and selecting the Fit Line command!) Now right-click on the Parameter Estimates table and select Make Combined Data Table.

Learn it once, use it forever!

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

Aug 4, 2017 10:45 AM
(1289 views)