Re: [R-sig-phylo] weirdness in confidence intervals returned by ace, pic option

2011-03-24 Thread Nick Matzke
Ah -- I get it now.  Even my rescaled trait data have the 
same width 95% CI, e.g. my CI for a particular node could be 
mean +/- 2.345 whether my input trait data ranges from 
0.3-0.5, or 400-800.


My "fix" with scaled data occurred because I was 
back-transforming, which scaled the size of the 95% CI with 
the size of the mean.  So I guess neither of these options 
is a "real" estimate of the CI, unlike when one runs ace, 
method=ML.


I noticed the same behavior using ace, method="gls", so that 
should be noted as well.  I have been using method="ml" for 
ancestral character estimation, the width of its CIs vary as 
you might expect, so I was just surprised when PIC & GLS 
didn't exhibit the same behavior.


Cheers,
Nick

On 3/24/11 12:21 AM, Nick Matzke wrote:

On Wed, Mar 23, 2011 at 10:24 PM, Emmanuel Paradis
  wrote:

Hi Nick,

With method = "pic", the CIs are computed using the expected variances under
the model, so they depend only on the tree. I've added a paragraph in the
man page to explain this.

Cheers,

Emmanuel


___
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo


Re: [R-sig-phylo] weirdness in confidence intervals returned by ace, pic option

2011-03-24 Thread Nick Matzke
On Wed, Mar 23, 2011 at 10:24 PM, Emmanuel Paradis
 wrote:
> Hi Nick,
>
> With method = "pic", the CIs are computed using the expected variances under
> the model, so they depend only on the tree. I've added a paragraph in the
> man page to explain this.
>
> Cheers,
>
> Emmanuel


Obviously, though, if one set of tip data ranges from 100-1000, and
another set of tip data ranges from 0.001-1, and both are mapped on
the same tree, the variances & confidence intervals will be different
at the estimated internal nodes for each trait.  But I was getting
identical confidence intervals across ~20 traits of widely different
magnitudes -- and then when I rescaled the trait data, the problem
went away, and each trait had different-sized CIs like you would
expect.  It was as if there some bizarre bug where there was a memory
error or some such and the same CI values were getting copied from one
trait to the next in some situations.

It's probably pointless to discuss, though, unless someone else can
replicate the problem I saw with the code I posted.  If the problem
disappears on other computers, then it's a local problem.  R.app
sometimes throws messages about memory errors and the like for no
apparent reason (not specifically associated with this, though), so it
might not even be an APE issue.

Cheers!
Nick



>
> Nick Matzke wrote on 22/03/2011 12:30:
>>
>> Hi all,
>>
>> This isn't crucial to my work at the moment since I am not using the PIC
>> option of ace to do ancestral character estimation.  But while trying it out
>> I noticed a very weird result that I can't explain...basically when I run
>> ace on my raw trait values, I get the same sized confidence interval (97.5%
>> CI minus 2.5% confidence interval) for all of my (drastically different)
>> traits.
>
>

___
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo


Re: [R-sig-phylo] weirdness in confidence intervals returned by ace, pic option

2011-03-23 Thread Emmanuel Paradis

Hi Nick,

With method = "pic", the CIs are computed using the expected variances 
under the model, so they depend only on the tree. I've added a paragraph 
in the man page to explain this.


Cheers,

Emmanuel

Nick Matzke wrote on 22/03/2011 12:30:

Hi all,

This isn't crucial to my work at the moment since I am not using the PIC 
option of ace to do ancestral character estimation.  But while trying it 
out I noticed a very weird result that I can't explain...basically when 
I run ace on my raw trait values, I get the same sized confidence 
interval (97.5% CI minus 2.5% confidence interval) for all of my 
(drastically different) traits.


___
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo


[R-sig-phylo] weirdness in confidence intervals returned by ace, pic option

2011-03-21 Thread Nick Matzke

Hi all,

This isn't crucial to my work at the moment since I am not 
using the PIC option of ace to do ancestral character 
estimation.  But while trying it out I noticed a very weird 
result that I can't explain...basically when I run ace on my 
raw trait values, I get the same sized confidence interval 
(97.5% CI minus 2.5% confidence interval) for all of my 
(drastically different) traits.


E.g.:

===
s1n  s1t s2en s2et s2in s2it
20 4.852213 4.852213 4.852213 4.852213 4.852213
21 2.445078 2.445078 2.445078 2.445078 2.445078
22 3.200703 3.200703 3.200703 3.200703 3.200703
23 2.960947 2.960947 2.960947 2.960947 2.960947
24 2.240474 2.240474 2.240474 2.240474 2.240474
25 2.654838 2.654838 2.654838 2.654838 2.654838
===

When I transform the data in various ways, the problem goes 
away, even though the rest of the code is identical 
(copy-paste identical, except for the input data), so I have 
(I think!) excluded some idiotic error on my part.  Although 
the result is so strange, I can't imagine what would cause it.


An example of the expected result:
=
s1n   s1t s2en  s2et s2in  s2it
20 63.84491 1.4760944 44.97236 0.6305324 47.01539
21 32.17208 0.7438184 22.66201 0.3177314 23.69152
22 42.11451 0.9736874 29.66546 0.4159229 31.01312
23 38.95982 0.9007511 27.44330 0.3847672 28.69001
24 29.47992 0.6815757 20.76565 0.2911437 21.70901
25 34.93208 0.8076297 24.60616 0.3449892 25.72398
=

I got the same results on 2 different computers, on APE 2.4 
and 2.7, so I doubt it is something specific to my computer.


The code below should load the data & analysis from scratch 
& reproduce the weirdness.  Thoughts welcome!


Nick


==



library(ape)

#
# Setup
#
# as.data.frame shortcut function
adf <- function(x)
{
	return(as.data.frame(x, row.names=NULL, 
stringsAsFactors=FALSE))

}


#
# Read in the ultrametric tree
#
trstring = 
"(((tessulatus:0.5015255487,(((gloriamaris:0.3047954399,(ammiralis:0.2417876544,(dalli:0.1923168953,textile:0.1923168953):0.04947075908):0.06300778553):0.07060254417,(furvus:0.3149966906,((crocatus:0.2453337596,omaria:0.2453337596):0.009171713364,(aulicus:0.1887595997,episcopatus:0.1887595997):0.06574587326):0.06049121772):0.06040129347):0.07403402886,(bandanus:0.06858755301,marmoreus:0.06858755301):0.38084446):0.05209353574):0.06339155354,((laterculatus:0.4407953441,(arenatus:0.1438581051,pulicarius:0.1438581051):0.296937239):0.06667390592,(consors:0.3221133412,(aurisiacus:0.2279167829,stercusmuscarum:0.2279167829):0.09419655831):0.1853559088):0.05744785226):0.4350828977,orbignyi:1);"


chtr2 = read.tree(file="", trstring)
num_internal_nodes = chtr2$Nnode
treenodes = c(20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 
31, 32, 33, 34, 35, 36, 37)



#
# Read in trait values
#

tmpdata = c(8, 15, 15, 15, 15, 8, 15, 15, 15, 15, 15, 15, 6, 
15, 15, 10, 15, 15, 8, 0.42, 0.28, 0.19, 0.28, 0.28, 0.42, 
0.3, 0.28, 0.28, 0.28, 0.25, 0.25, 0.3, 0.3, 0.3, 0.35, 0.3, 
0.3, 0.42, 6.7, 14, 17, 14, 14, 6.7, 5, 14, 14, 14, 10, 10, 
5, 5, 5, 5, 5, 5, 6.7, 0.033, 0.17, 0.3, 0.17, 0.17, 0.033, 
0.1, 0.17, 0.17, 0.17, 0.17, 0.17, 0.01, 0.1, 0.1, 0.2, 0.1, 
0.1, 0.033, 8.3, 12.7, 3, 12.7, 12.7, 8.3, 5, 12.7, 12.7, 
12.7, 20, 20, 5, 5, 5, 10, 5, 5, 8.3, 0.074, 0.1, 0.54, 0.1, 
0.1, 0.074, 0.06, 0.1, 0.1, 0.1, 0.35, 0.35, 0.06, 0.06, 
0.06, 0.15, 0.06, 0.06, 0.074, 30, 19.5, 20, 19.5, 19.5, 31, 
7.9, 25, 19.5, 19.5, 40, 40, 5, 8, 8, 6, 8, 22, 30, 0.4, 
0.1, 0.37, 0.1, 0.1, 0.37, 0.14, 0.1, 0.1, 0.1, 0.1, 0.1, 
0.1, 0.15, 0.15, 0.1, 0.15, 0.03, 0.4, 5, 4.5, 5, 7, 4.5, 5, 
3.5, 5, 4, 4, 6, 6, 2.5, 3.5, 3.5, 1.5, 3.1, 1.3, 5, 0.015, 
0.005, 0.008, 0.006, 0.006, 0.006, 0.02, 0.0065, 0.006, 
0.0065, 0.007, 0.01, 0.009, 0.0044, 0.02, 0.06, 0.015, 
0.0067, 0.008, 0.029, 0.007, 0.041, 0.007, 0.007, 0.018, 
0.1, 0.007, 0.007, 0.007, 0.12, 0.18, 0.03, 0.012, 0.055, 
0.13, 0.041, 0.009, 0.015, 5, 3.665, 3.96, 3.665, 3.665, 5, 
2.28, 3.665, 3.665, 3.665, 3.79, 3.79, 3.28, 2.28, 2.28, 1, 
2.28, 2.28, 5, 0.02, 0.21, 0, 0.21, 0.21, 0.02, 0, 0.21, 
0.21, 0.21, 0.45, 0.45, 0, 0, 0, 0, 0, 0, 0.02, 4, 2.665, 
2.96, 2.665, 2.665, 4, 1.28, 2.665, 2.665, 2.665, 2.79, 
2.79, 2.28, 1.28, 1.28, 0, 1.28, 1.28, 4, 0.01, 0.33, 0.17, 
0.33, 0.33, 0.01, 0.32, 0.33, 0.33, 0.33, 0.56, 0.56, 0.3, 
0.32, 0.32, 0, 0.3, 0.3, 0.01, 1.2, 1.2, 6.82, 1.2, 1.2, 
1.2, 1.78, 1.2, 1.2, 1.2, 2.47, 2.47, 2.58, 1.78, 1.78, 1, 
1.78, 1.78, 1.2, 0.15, 0.085, 0, 0.085, 0.085, 0.15, 0, 
0.085, 0.085, 0.085, 0.03, 0.03, 0, 0, 0, 0, 0, 0, 0.15, 
0.2, 0.2, 5.82, 0.2, 0.2, 0.2, 0.78, 0.2, 0.2, 0.2, 1.47, 
1.47, 1.58, 0.78, 0.78, 0, 0.78, 0.78, 0.2, 0.14, 0.18, 
0.04, 0.18, 0.18, 0.14, 0.32, 0.18, 0.18, 0.18, 0.25, 0.25, 
0.4, 0.32, 0.32, 0, 0.29, 0.29, 0.14, 0.03, 0.03, 0