From: Uwe Brauer <oub@mat.ucm.es>
To: emacs-orgmode@gnu.org
Subject: Re: orgmode and anova
Date: Fri, 22 Apr 2016 08:07:22 +0000 [thread overview]
Message-ID: <877ffqt6bp.fsf@mat.ucm.es> (raw)
In-Reply-To: CAG3md+tXKSfKYoCVSbVw=ENCTSDAkyt5a0bUfuzrbV_LG4RJfg@mail.gmail.com
>>> "Kyle" == Kyle Andrews <kyle.c.andrews@gmail.com> writes:
> If you wanted to fit a linear regression model with R, you could do
> so with the lm function. Calling anova on the output of the
> regression would give you a regression anova table.
> model <- lm(delivered_seeing ~ zeenith_seeing, data = delsee)
> anova(model)
> You would need non-zero residuals for that to be useful of course.
> Otherwise, you need to stack your *_seeing columns into one column
> with another column saying which kind of seeing it was and then:
> model.aov <- aov(seeing ~ factor(kind), data = delsee2)
> You could do the stacking in a number of ways. My favorite is to use
> the gather function in the tidyr package.
> aov is just a wrapper around lm, so just take the same approach as
> before to get the ANOVA table. Hope that helps.
Yes to a certain extend. I was able to perform an anova just comparing
the means of three samples. I did this in the following way:
First the data in table form
#+tblname: myanova
| C1 | C2 | C3 |
|------+----+----|
| 19 | 20 | 16 |
| 22 | 21 | 15 |
| 20 | 33 | 18 |
| 18 | 27 | 26 |
| 25 | 40 | 17 |
Then the following command did precisely what I wanted
#+begin_src R :results output org wrap :exports results
a = c(19,22,20,18,25)
b = c(20,21,33,27,40)
c = c(16,15,18,26,17)
dati = c(a, b, c)
groups = factor(rep(letters[1:3], each = 5))
fit = lm(formula = dati ~ groups)
anova(fit)
#+end_src
I actually do not really understand precisely the meaning of
groups = factor(rep(letters[1:3], each = 5))
but I also do not care much
Now executing the code, resulted in
#+RESULTS:
#+BEGIN_SRC org
Analysis of Variance Table
Response: dati
Df Sum Sq Mean Sq F value Pr(>F)
groups 2 260.93 130.467 4.0061 0.04648 *
Residuals 12 390.80 32.567
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#+END_SRC
The only thing I was interested in was the F and the p valor.
However now comes the question. I don't want to write the data in vector
form as in
a = c(19,22,20,18,25)
I want to extract them from the table:
#+tblname: myanova
| C1 1 | C2 | C3 |
| 19 | 20 | 16 |
| 22 | 21 | 15 |
| 20 | 33 | 18 |
| 18 | 27 | 26 |
| 25 | 40 | 17 |
(Rationale: I have a huge table with 300 entries and I don't want to
transform each colum in question into a vector)
So this is more a orgmode than a R question: is there a way to extract
from a given table its columns and perform via R an anova??
(I could ask the same for matlab, for which I have to transform the
table into a matlab matrix, which again I want to avoid.)
By hope is there is a sort of generalisation of my first example:
#+tblname: myan1
| growth | sugar |
|--------+-------|
| 75 | 45 |
| 72 | 44 |
| 73 | 89 |
| 61 | 40 |
| 67 | 23 |
| 64 | 33 |
| 62 | 22 |
| 63 | 22 |
#+begin_src R :results output :var myan1=myan1
summary(myan1)
#+end_src
The command summary directly extracts the information from that table. I
hope that something similar is possible for the anova.
thanks
Uwe Brauer
prev parent reply other threads:[~2016-04-22 8:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-21 19:09 orgmode and anova Uwe Brauer
2016-04-22 1:56 ` Kyle Andrews
2016-04-22 8:07 ` Uwe Brauer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877ffqt6bp.fsf@mat.ucm.es \
--to=oub@mat.ucm.es \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.