Skip to main content
Commonmark migration
Source Link

My previous answer was just too convoluted (and it didn't actually compute what OP wanted). It appears there's a much simpler way to do it:

#This is actually the way to do it

This is actually the way to do it

| Date  | sleep | productivity | determination coefficient |
|-------+-------+--------------+---------------------------|
| [meh] |  7.50 |         4.00 |                           |
| [meh] |  8.00 |         5.00 |                           |
| [meh] |  8.50 |         6.00 |                           |
| [meh] |  8.00 |         4.00 |                           |
| [meh] |  8.20 |         5.00 |                           |
| [meh] |  8.70 |         6.00 |                           |
|-------+-------+--------------+---------------------------|
|       |       |              |                0.89847792 |
|       |       |              |                0.89847792 |
#+TBLFM: @9$4=vcorr(@2$2..@7$2, @2$3..@7$3)
#+TBLFM: @8$4=vpcov(@2$2..@7$2, @2$3..@7$3)/(vpsdev(@2$2..@7$2)*vpsdev(@2$3..@7$3))

As suggested by the comments. Note that this gives you r, whereas RUserPassingBy's results give r^2 (but, finally, both results are correct).

My previous answer was just too convoluted (and it didn't actually compute what OP wanted). It appears there's a much simpler way to do it:

#This is actually the way to do it

| Date  | sleep | productivity | determination coefficient |
|-------+-------+--------------+---------------------------|
| [meh] |  7.50 |         4.00 |                           |
| [meh] |  8.00 |         5.00 |                           |
| [meh] |  8.50 |         6.00 |                           |
| [meh] |  8.00 |         4.00 |                           |
| [meh] |  8.20 |         5.00 |                           |
| [meh] |  8.70 |         6.00 |                           |
|-------+-------+--------------+---------------------------|
|       |       |              |                0.89847792 |
|       |       |              |                0.89847792 |
#+TBLFM: @9$4=vcorr(@2$2..@7$2, @2$3..@7$3)
#+TBLFM: @8$4=vpcov(@2$2..@7$2, @2$3..@7$3)/(vpsdev(@2$2..@7$2)*vpsdev(@2$3..@7$3))

As suggested by the comments. Note that this gives you r, whereas RUserPassingBy's results give r^2 (but, finally, both results are correct).

My previous answer was just too convoluted (and it didn't actually compute what OP wanted). It appears there's a much simpler way to do it:

This is actually the way to do it

| Date  | sleep | productivity | determination coefficient |
|-------+-------+--------------+---------------------------|
| [meh] |  7.50 |         4.00 |                           |
| [meh] |  8.00 |         5.00 |                           |
| [meh] |  8.50 |         6.00 |                           |
| [meh] |  8.00 |         4.00 |                           |
| [meh] |  8.20 |         5.00 |                           |
| [meh] |  8.70 |         6.00 |                           |
|-------+-------+--------------+---------------------------|
|       |       |              |                0.89847792 |
|       |       |              |                0.89847792 |
#+TBLFM: @9$4=vcorr(@2$2..@7$2, @2$3..@7$3)
#+TBLFM: @8$4=vpcov(@2$2..@7$2, @2$3..@7$3)/(vpsdev(@2$2..@7$2)*vpsdev(@2$3..@7$3))

As suggested by the comments. Note that this gives you r, whereas RUserPassingBy's results give r^2 (but, finally, both results are correct).

added 250 characters in body
Source Link
wvxvw
  • 11.5k
  • 3
  • 32
  • 57

My previous answer was just too convoluted (and it didn't actually compute what OP wanted). It appears there's a much simpler way to do it:

#This is actually the way to do it

| Date  | sleep | productivity | determination coefficient |
|-------+-------+--------------+---------------------------|
| [meh] |  7.50 |         4.00 |                           |
| [meh] |  8.00 |         5.00 |                           |
| [meh] |  8.50 |         6.00 |                           |
| [meh] |  8.00 |         4.00 |                           |
| [meh] |  8.20 |         5.00 |                           |
| [meh] |  8.70 |         6.00 |                           |
|-------+-------+--------------+---------------------------|
|       |       |              |                0.4358898989847792 |
|       |       |              |                0.89847792 |
#+TBLFM: @>$4=sqrt@9$4=vcorr(vvar@2$2..@7$2, @2$3..@7$3)
#+TBLFM: @8$4=vpcov(@2$2..@6$2@7$2, @2$3..@7$3)/vvar(vpsdev(@2$2..@7$2)*vpsdev(@2$3..@6$3@7$3))

As suggested by the comments. Note that this gives you r, whereas RUserPassingBy's results give r^2 (but, finally, both results are correct).

My previous answer was just too convoluted (and it didn't actually compute what OP wanted). It appears there's a much simpler way to do it:

#This is actually the way to do it

| Date  | sleep | productivity | determination coefficient |
|-------+-------+--------------+---------------------------|
| [meh] |  7.50 |         4.00 |                           |
| [meh] |  8.00 |         5.00 |                           |
| [meh] |  8.50 |         6.00 |                           |
| [meh] |  8.00 |         4.00 |                           |
| [meh] |  8.20 |         5.00 |                           |
| [meh] |  8.70 |         6.00 |                           |
|-------+-------+--------------+---------------------------|
|       |       |              |                0.43588989 |
#+TBLFM: @>$4=sqrt(vvar(@2$2..@6$2)/vvar(@2$3..@6$3))

My previous answer was just too convoluted (and it didn't actually compute what OP wanted). It appears there's a much simpler way to do it:

#This is actually the way to do it

| Date  | sleep | productivity | determination coefficient |
|-------+-------+--------------+---------------------------|
| [meh] |  7.50 |         4.00 |                           |
| [meh] |  8.00 |         5.00 |                           |
| [meh] |  8.50 |         6.00 |                           |
| [meh] |  8.00 |         4.00 |                           |
| [meh] |  8.20 |         5.00 |                           |
| [meh] |  8.70 |         6.00 |                           |
|-------+-------+--------------+---------------------------|
|       |       |              |                0.89847792 |
|       |       |              |                0.89847792 |
#+TBLFM: @9$4=vcorr(@2$2..@7$2, @2$3..@7$3)
#+TBLFM: @8$4=vpcov(@2$2..@7$2, @2$3..@7$3)/(vpsdev(@2$2..@7$2)*vpsdev(@2$3..@7$3))

As suggested by the comments. Note that this gives you r, whereas RUserPassingBy's results give r^2 (but, finally, both results are correct).

deleted 775 characters in body
Source Link
wvxvw
  • 11.5k
  • 3
  • 32
  • 57

Well, I'm not good with statistics, so I'm getting wrong results :D but I've got the general directionMy previous answer was just too convoluted (I thinkand it didn't actually compute what OP wanted). If you can figure out where my error in calculations is, you should be able to fix thisIt appears there's a much simpler way to get what you needdo it:

#This is actually the way to do it

  | Date  | sleep | productivity | determination | coefficient |
  |-------+-------+--------------+---------------+-------------|
  | [meh] |  87.0050 |         4.00 |               |             |
  | [meh] |  8.00 |         5.00 |               |             |
  | [meh] |  8.0050 |         6.00 |               |             |
  | [meh] |  8.00 |         4.00 |               |             |
  | [meh] |  8.0020 |         5.00 |               |             |
  | [meh] |  8.0070 |         6.00 |               |             |
  |-------+-------+--------------+---------------+-------------|
  | 5.    |    5. |           4. |            4.  |          1. |
  #+TBLFM: @>$1=fit(x, y, pack([2, 6], vconcat(@2$2.0.@-I$2,43588989 @2$3..@-I$3)))|
  #+TBLFM: @>$2=vmean(@2$3..@-I$3)::@>$3=vsum@>$4=sqrt(vvar(@2$3@2$2..@-I$3-@>$1)^2@6$2)
  #+TBLFM: @>$4=vsum(/vvar(@2$3..@-I$3-@>$2)^2@6$3)::@>$5=sqrt(@>$3/@>$4)

The names of the columns don't really reflect what's going on there, I just used some empty spaces to output intermediate info (for debugging).

So, here's the meaning of the last row:

  1. This should be the fitted value (for productivity as a function of sleep).
  2. This should be the productivity mean.
  3. Sum of square error of productivity.
  4. Sum of squared difference between the observed and fitted values.
  5. The square root of #3 divided by #4 (this should be the coefficient, according to the formula).

Well, I'm not good with statistics, so I'm getting wrong results :D but I've got the general direction (I think). If you can figure out where my error in calculations is, you should be able to fix this to get what you need:

  | Date  | sleep | productivity | determination | coefficient |
  |-------+-------+--------------+---------------+-------------|
  | [meh] |  8.00 |         4.00 |               |             |
  | [meh] |  8.00 |         5.00 |               |             |
  | [meh] |  8.00 |         6.00 |               |             |
  | [meh] |  8.00 |         4.00 |               |             |
  | [meh] |  8.00 |         5.00 |               |             |
  | [meh] |  8.00 |         6.00 |               |             |
  |-------+-------+--------------+---------------+-------------|
  | 5.    |    5. |           4. |            4. |          1. |
  #+TBLFM: @>$1=fit(x, y, pack([2, 6], vconcat(@2$2..@-I$2, @2$3..@-I$3)))
  #+TBLFM: @>$2=vmean(@2$3..@-I$3)::@>$3=vsum((@2$3..@-I$3-@>$1)^2)
  #+TBLFM: @>$4=vsum((@2$3..@-I$3-@>$2)^2)::@>$5=sqrt(@>$3/@>$4)

The names of the columns don't really reflect what's going on there, I just used some empty spaces to output intermediate info (for debugging).

So, here's the meaning of the last row:

  1. This should be the fitted value (for productivity as a function of sleep).
  2. This should be the productivity mean.
  3. Sum of square error of productivity.
  4. Sum of squared difference between the observed and fitted values.
  5. The square root of #3 divided by #4 (this should be the coefficient, according to the formula).

My previous answer was just too convoluted (and it didn't actually compute what OP wanted). It appears there's a much simpler way to do it:

#This is actually the way to do it

| Date  | sleep | productivity | determination coefficient |
|-------+-------+--------------+---------------------------|
| [meh] |  7.50 |         4.00 |                           |
| [meh] |  8.00 |         5.00 |                           |
| [meh] |  8.50 |         6.00 |                           |
| [meh] |  8.00 |         4.00 |                           |
| [meh] |  8.20 |         5.00 |                           |
| [meh] |  8.70 |         6.00 |                           |
|-------+-------+--------------+---------------------------|
|       |       |              |                0.43588989 |
#+TBLFM: @>$4=sqrt(vvar(@2$2..@6$2)/vvar(@2$3..@6$3))
Source Link
wvxvw
  • 11.5k
  • 3
  • 32
  • 57
Loading