Reply To: regression on multiple attributes at once

#15754
Andrew Ross
Participant

Unfortunately, I can’t think of a way to do the analysis with the current data format.

I am guessing that another way to express the data is something like this:

<style type=”text/css”>td {border: 1px solid #cccccc;}br {mso-data-placement:same-cell;}</style>
<table dir=”ltr” style=”table-layout: fixed; font-size: 10pt; font-family: Arial; width: 0px; border-collapse: collapse; border: none;” border=”1″ cellspacing=”0″ cellpadding=”0″ data-sheets-root=”1″ data-sheets-baot=”1″><colgroup><col width=”100″ /><col width=”100″ /><col width=”100″ /><col width=”100″ /></colgroup>
<tbody>
<tr style=”height: 21px;”>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>ParticipantName</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>Activity</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>Duration</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>HowManyTimes</td>
</tr>
<tr style=”height: 21px;”>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>PersonA</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>signatures</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>10</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>2</td>
</tr>
<tr style=”height: 21px;”>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>PersonA</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>signatures</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>20</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>4</td>
</tr>
<tr style=”height: 21px;”>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>PersonA</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>signatures</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>30</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>6</td>
</tr>
<tr style=”height: 21px;”>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>PersonA</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>signatures</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>40</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>8</td>
</tr>
<tr style=”height: 21px;”>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>PersonA</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>signatures</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>50</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”></td>
</tr>
<tr style=”height: 21px;”>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>PersonA</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>signatures</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>60</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>12</td>
</tr>
<tr style=”height: 21px;”>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>PersonB</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>typing</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>10</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>12</td>
</tr>
<tr style=”height: 21px;”>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>PersonB</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>typing</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>20</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>22</td>
</tr>
<tr style=”height: 21px;”>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>PersonB</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>typing</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>30</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>30</td>
</tr>
<tr style=”height: 21px;”>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>PersonB</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>typing</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>40</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>39</td>
</tr>
<tr style=”height: 21px;”>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>PersonB</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>typing</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>50</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”></td>
</tr>
<tr style=”height: 21px;”>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>PersonB</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>typing</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>60</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>56</td>
</tr>
<tr style=”height: 21px;”>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>PersonC</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>texting</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>10</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>12</td>
</tr>
<tr style=”height: 21px;”>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>PersonC</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>texting</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>20</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>22</td>
</tr>
<tr style=”height: 21px;”>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>PersonC</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>texting</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>30</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>30</td>
</tr>
<tr style=”height: 21px;”>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>PersonC</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>texting</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>40</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>39</td>
</tr>
<tr style=”height: 21px;”>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>PersonC</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>texting</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>50</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”></td>
</tr>
<tr style=”height: 21px;”>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>PersonC</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom;”>texting</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>60</td>
<td style=”overflow: hidden; padding: 2px 3px 2px 3px; vertical-align: bottom; text-align: right;”>56</td>
</tr>
</tbody>
</table>
etc.; though it’s possible that PersonA could have data from more than one activity.

 

I transformed your data table into this new format in this Google Sheet; look in row 26 etc. There might have been a better (more elegant) way to do it, which I look forward to learning about from anyone who knows it!

If that’s right and it’s formatted that way, then you could make a scatterplot with x=duration, y=count, with the legend variable (the variable that you “drop in the middle of the graph” to color the dots by) being the activity. Then if you add a trendline, you should get one trendline for each activity.

Visually, that might be a bit much. And it’s not clear which trendline is for which activity. You could make another graph with x=activity (and no y axis) to show dots for each activity, then select the dots for one activity, then on the scatterplot use the “View” icon and click “Hide Unselected Cases”. You could repeat (having to make a separate graph each time, I think) for the other activities.

To get the trendline slope and intercept etc. in a table, you can make columns in CODAP like this (feel free to use better column names; ignore whatever you don’t want)

column name: corr ; formula: correlation(Duration,HowManyTimes)

column name: linSlope ; formula: linRegrSlope(Duration,HowManyTimes)

column name: linIntercept ; formula: linRegrIntercept(Duration,HowManyTimes)

column name: DurationCount ; formula: count(Duration)

column name: resultCount ; formula: count(HowManyTimes)

At first all of those will have the same values, aggregating across all the activities in the table. But if you drag the “activity” column to the far left (so a yellow box appears that says “drop attribute to create new collection”), then the results will be different for the rows with different activities. You can also drag corr, linSlope, etc. all the way to the left as well to get a little table that summarizes by activity.

I tried it all in this codap file.

The data formatting issue reminds of what people in the R software universe call “tidy” data. The data that you have is in “wider” form, while the format I’m suggesting is “longer”; see https://tidyr.tidyverse.org/articles/pivot.html .