Re: [R] Functions in lists or arrays?

2009-04-21 Thread Bill.Venables
 t - list()
 t[[1]] - function(b) b*2  ### NOTE, [[ not [
 t
[[1]]
function (b) 
b * 2

 

Bill Venables
http://www.cmis.csiro.au/bill.venables/ 


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Toby
Sent: Tuesday, 21 April 2009 3:51 PM
To: r-help@r-project.org
Subject: [R] Functions in lists or arrays?

I have a problem where I need to have a driver style R program that will
extend itself, given more
'source(extra.R)' style  lines.  IE: easy to modify by other people.  The
problem becomes when I
would like to create an array or list of functions.  Each function, possibly
hundreds of them, are really
created by other programs, generating an *.R file.  So for example, if I
try:

 t - list()
 t[1] - function(b) { b*2 }
Error in t[1] - function(b) { :
  cannot coerce type 'closure' to vector of type 'list'

Similar errors for arrays, and anything else I can think of.  I'm an R
neophite, which likely shows.  The
only way I seem to be able to do the above, is to generate unique names for
each function, and add
each name into a list, sort of like this:

# Register ourselves
models - cbind(models, Nasa_PART_Rules)
bounds - cbind(bounds, Nasa_PART_Bounds)
Nasa_PART_Rules - NULL
Nasa_PART_Bounds - NULL

# Rules section
Nasa_PART_Rules - rbind(Nasa_PART_Rules, c(Nasa_PART_R1, F))
Nasa_PART_R1 - function(f) {
f[,CYCLOMATIC_COMPLEXITY]  8 
f[,CYCLOMATIC_COMPLEXITY] = 60 
f[,LOC_TOTAL]  73
}
Nasa_PART_Bounds - rbind(Nasa_PART_Bounds, c(Nasa_PART_B1))
Nasa_PART_B1 - function(b) {
b[CYCLOMATIC_COMPLEXITY,0] - 8
b[CYCLOMATIC_COMPLEXITY,1] - 60
b[LOC_TOTAL,0] - 73
}
#...

And then using something like this function:

# Dispatch a function from its name
dispatch - function(f, x) {
eval(call(f, x))
}

to evaluate each rule over all the data rows:

# Read training+validation data
dat - read.csv(jm1_data(training+validation).csv)
mat - NULL
clt - NULL

# Evaluate each rule against the dataset
for (i in models) {
# Get the rules for the model
rules - eval(substitute(foo[,1], list(foo=as.name(i
cls - eval(substitute(foo[,2], list(foo=as.name(i
res - lapply(rules, dispatch, dat)
#...


Now, this seems way too uggly to me.  Can someone give me a hand and/or
point me into a more sane
direction to explore?

One option I have thought of, is to get rid of the *_B?() functions and just
fill in a 3 dimensional array using
something like:

x - NULL
dimnames(x) - c(colnames(mat),colnames(dat), c(lbound,ubound))

...
x[RULE_NAME_1, DATA_COL_NAME_1, lbound] - ...
...

But I'm not exactly sure how I would construct and/or add onto a global
array/etc extra dimnames, as I source
each generated *.R file.

Anyways, Not sure if I'm making much sense...  thanks for any help,

-Toby.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] automatic exploration of all possible loglinear models?

2009-04-21 Thread Dieter Menne
Christopher W. Ryan cryan at binghamton.edu writes:

 
 Is there a way to automate fitting and assessing loglinear models for
 several nominal variables . . . something akin to step or drop1 or add1
 for linear or logistic regression?

Not strictly for loglinear, but glm works with stepAIC. Make sure that 
in the field you are working this approach is an accepted ritual.

Dieter

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Sampling in R

2009-04-21 Thread skayis selcuk
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Sampling in R

2009-04-21 Thread skayis selcuk
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Samplin in R

2009-04-21 Thread skayis selcuk
Xvar-c(0.1818182,0.5384615,0.5535714,0.4680851,0.4545455,0.4385965,0.5185185,0.4035088,0.4901961,0.3650794,0.462963,0.4,0.56,0.3965517,0.4909091,

0.4716981,0.4310345,0.2,0.1509434,0.2647059,0.173913,0.1914894,0.1914894,0.1489362,0.1363636,0.2244898,0.2325581,0.133,0.1818182,0.1702128,

0.2173913,0.2380952,0.1632653,0.5614035,0.3396226,0.4909091,0.3770492,0.5,0.5185185,0.5,0.467,0.4464286,0.362069,0.4285714,0.4561404,

0.4736842,0.4545455,0.417,0.4181818,0.4590164,0.517,0.5423729,0.483,0.5454545,0.4393939,0.5172414,0.4098361,0.4745763,0.4754098,

0.517,0.5,0.4603175,0.42,0.4038462,0.4897959,0.3148148,0.3673469,0.4,0.458,0.3877551,0.4375,0.4117647,0.4313725,0.533,0.3962264,

0.3548387,0.5272727,0.4137931,0.3928571,0.467,0.4210526,0.4363636,0.4545455,0.4310345,0.4237288,0.4814815,0.4912281,0.433,0.4,0.4285714,

0.4516129,0.5090909,0.4464286,0.4642857,0.417,0.4098361,0.4909091,0.3809524,0.5272727,0.4814815,0.5254237,0.627451,0.5,0.5471698,0.5454545,

0.5925926,0.5769231,0.5818182,0.444,0.4915254,0.4727273,0.4107143,0.4285714,0.4310345,0.4237288,0.4285714,0.440678,0.4237288,0.4807692,

0.4150943,0.4615385,0.4107143,0.4814815,0.4074074,0.4210526,0.5263158,0.440678,0.4576271,0.5344828,0.5,0.5636364,0.4677419,0.5,0.5192308,

0.4642857,0.5090909,0.58,0.4482759,0.5098039,0.4035088,0.4210526,0.5098039,0.4385965,0.5283019,0.5471698,0.625,0.4310345,0.4912281,0.5283019,
0.4576271,0.5471698,0.4745763,0.4821429)

Yvar-c(0.2553191,0.4107143,0.5660377,0.389,0.3606557,0.2898551,0.3818182,0.4,0.4,0.3278689,0.2903226,0.4074074,0.4181818,0.3,0.2238806,0.3728814,

0.3709677,0.2307692,0.2830189,0.2244898,0.2142857,0.2131148,0.22,0.2258065,0.2321429,0.2,0.2264151,0.22,0.2115385,0.2459016,0.117,0.1785714,

0.2068966,0.6,0.4285714,0.3134328,0.4461538,0.3965517,0.4769231,0.6181818,0.4827586,0.3709677,0.3965517,0.4821429,0.4545455,0.359375,0.4576271,

0.4516129,0.5272727,0.4603175,0.4,0.4912281,0.5384615,0.5,0.4516129,0.4126984,0.4655172,0.5263158,0.4925373,0.358209,0.4285714,0.4920635,

0.4482759,0.3235294,0.4,0.4375,0.440678,0.3898305,0.35,0.4528302,0.58,0.4153846,0.3174603,0.5185185,0.3870968,0.2894737,0.3709677,0.369863,

0.3676471,0.3636364,0.3088235,0.328125,0.4032258,0.4084507,0.3188406,0.3636364,0.3823529,0.2816901,0.472,0.5,0.3521127,0.4393939,0.3787879,

0.453125,0.4324324,0.4057971,0.4545455,0.4492754,0.5,0.4098361,0.4067797,0.367,0.3928571,0.4285714,0.5,0.2923077,0.4561404,0.45,0.5538462,

0.4626866,0.4057971,0.3676471,0.5322581,0.5428571,0.375,0.4411765,0.4571429,0.4,0.3846154,0.3870968,0.4915254,0.530303,0.4375,0.4918033,0.4179104,

0.4032258,0.3606557,0.5178571,0.4848485,0.390625,0.375,0.4375,0.367,0.4,0.4477612,0.2571429,0.4032258,0.3382353,0.4814815,0.4090909,0.3548387,

0.4821429,0.5,0.557377,0.433,0.5454545,0.4590164,0.3943662,0.5076923,0.5,0.3283582,0.3676471,0.559322)

my.cor-cor(Xvar, Yvar)
print(my.cor)
 
nperm-4
Perm.Cor-NULL

for (iperm in 1:nperm)  {
XvarNew-sample(Xvar, size=length(Xvar), replace=FALSE)
YvarNew-sample(Yvar, size=length(Yvar), replace=FALSE) 
perm.cor-cor(XvarNew, YvarNew)
Perm.Cor-c(Perm.Cor, perm.cor)
}
print(max(Perm.Cor))
XvarSorted-sort(Xvar, decreasing=TRUE)
YvarSorted-sort(Yvar, decreasing=TRUE)
max.cor-cor(XvarSorted, YvarSorted)
print(max.cor)
if(mat.cor0) Perm.Cor.Sorted-sort(Perm.Cor, decreasing=TRUE)  
  
if(mat.cor0) Perm.Cor.Sorted-sort(Perm.Cor, decreasing=FALSE) 
   
T95-Perm.Cor.Sorted[(nperm+1)*0.05]# 95% treshold value
T99-Perm.Cor.Sorted[(nperm+1)*0.01]# 99% treshold value

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Sampling in R

2009-04-21 Thread skayis selcuk
(Sorry for multiple posting. Seems to be my msg is not distributed in my 
previous emails)
 
Dear R users, 
 
I need to do sampling without replacement (bootstraps). I have two variables 
(Xvar, Yvar). 
I have a correlation from original data set cor(Xvar, Yvar)=0.6174221. I am 
doing 5 sampling, 
and in each sampling  calculating correlations, saving, sorting and  getting 
95% cutt off point (0.1351877). 
I am getting maximum value as 0.3507219 (much smaller than correlation of my 
original data). 
I repeated the sampling a  couple of time and none of them produced a 
correlation 
coefficient higher than my original data set. However, if I sort out my Xvar 
and Yvar and 
obtain correlation it is 0.9657125 which is much higher than correlation for my 
original data. 
I am doing sampling in another program and getting at least 1% higher 
correlation than mine. 
Now I am getting confused with sampling(random data) in R. My data and codes 
for the scenario above are
in the attached file. I want to understand where I am making a mistake. Any 
comment is deeply appreciated.
 
Kind Regards
 
Seyit Ali


Xvar-c(0.1818182,0.5384615,0.5535714,0.4680851,0.4545455,0.4385965,0.5185185,0.4035088,0.4901961,0.3650794,0.462963,0.4,0.56,0.3965517,0.4909091,

0.4716981,0.4310345,0.2,0.1509434,0.2647059,0.173913,0.1914894,0.1914894,0.1489362,0.1363636,0.2244898,0.2325581,0.133,0.1818182,0.1702128,

0.2173913,0.2380952,0.1632653,0.5614035,0.3396226,0.4909091,0.3770492,0.5,0.5185185,0.5,0.467,0.4464286,0.362069,0.4285714,0.4561404,

0.4736842,0.4545455,0.417,0.4181818,0.4590164,0.517,0.5423729,0.483,0.5454545,0.4393939,0.5172414,0.4098361,0.4745763,0.4754098,

0.517,0.5,0.4603175,0.42,0.4038462,0.4897959,0.3148148,0.3673469,0.4,0.458,0.3877551,0.4375,0.4117647,0.4313725,0.533,0.3962264,

0.3548387,0.5272727,0.4137931,0.3928571,0.467,0.4210526,0.4363636,0.4545455,0.4310345,0.4237288,0.4814815,0.4912281,0.433,0.4,0.4285714,

0.4516129,0.5090909,0.4464286,0.4642857,0.417,0.4098361,0.4909091,0.3809524,0.5272727,0.4814815,0.5254237,0.627451,0.5,0.5471698,0.5454545,

0.5925926,0.5769231,0.5818182,0.444,0.4915254,0.4727273,0.4107143,0.4285714,0.4310345,0.4237288,0.4285714,0.440678,0.4237288,0.4807692,

0.4150943,0.4615385,0.4107143,0.4814815,0.4074074,0.4210526,0.5263158,0.440678,0.4576271,0.5344828,0.5,0.5636364,0.4677419,0.5,0.5192308,

0.4642857,0.5090909,0.58,0.4482759,0.5098039,0.4035088,0.4210526,0.5098039,0.4385965,0.5283019,0.5471698,0.625,0.4310345,0.4912281,0.5283019,
0.4576271,0.5471698,0.4745763,0.4821429)

Yvar-c(0.2553191,0.4107143,0.5660377,0.389,0.3606557,0.2898551,0.3818182,0.4,0.4,0.3278689,0.2903226,0.4074074,0.4181818,0.3,0.2238806,0.3728814,

0.3709677,0.2307692,0.2830189,0.2244898,0.2142857,0.2131148,0.22,0.2258065,0.2321429,0.2,0.2264151,0.22,0.2115385,0.2459016,0.117,0.1785714,

0.2068966,0.6,0.4285714,0.3134328,0.4461538,0.3965517,0.4769231,0.6181818,0.4827586,0.3709677,0.3965517,0.4821429,0.4545455,0.359375,0.4576271,

0.4516129,0.5272727,0.4603175,0.4,0.4912281,0.5384615,0.5,0.4516129,0.4126984,0.4655172,0.5263158,0.4925373,0.358209,0.4285714,0.4920635,

0.4482759,0.3235294,0.4,0.4375,0.440678,0.3898305,0.35,0.4528302,0.58,0.4153846,0.3174603,0.5185185,0.3870968,0.2894737,0.3709677,0.369863,

0.3676471,0.3636364,0.3088235,0.328125,0.4032258,0.4084507,0.3188406,0.3636364,0.3823529,0.2816901,0.472,0.5,0.3521127,0.4393939,0.3787879,

0.453125,0.4324324,0.4057971,0.4545455,0.4492754,0.5,0.4098361,0.4067797,0.367,0.3928571,0.4285714,0.5,0.2923077,0.4561404,0.45,0.5538462,

0.4626866,0.4057971,0.3676471,0.5322581,0.5428571,0.375,0.4411765,0.4571429,0.4,0.3846154,0.3870968,0.4915254,0.530303,0.4375,0.4918033,0.4179104,

0.4032258,0.3606557,0.5178571,0.4848485,0.390625,0.375,0.4375,0.367,0.4,0.4477612,0.2571429,0.4032258,0.3382353,0.4814815,0.4090909,0.3548387,

0.4821429,0.5,0.557377,0.433,0.5454545,0.4590164,0.3943662,0.5076923,0.5,0.3283582,0.3676471,0.559322)

my.cor-cor(Xvar, Yvar)
print(my.cor)
 
nperm-4
Perm.Cor-NULL

for (iperm in 1:nperm)  {
XvarNew-sample(Xvar, size=length(Xvar), replace=FALSE)
YvarNew-sample(Yvar, size=length(Yvar), replace=FALSE) 
perm.cor-cor(XvarNew, YvarNew)
Perm.Cor-c(Perm.Cor, perm.cor)
}
print(max(Perm.Cor))
XvarSorted-sort(Xvar, decreasing=TRUE)
YvarSorted-sort(Yvar, decreasing=TRUE)
max.cor-cor(XvarSorted, YvarSorted)
print(max.cor)
if(mat.cor0) Perm.Cor.Sorted-sort(Perm.Cor, decreasing=TRUE)  
  
if(mat.cor0) Perm.Cor.Sorted-sort(Perm.Cor, decreasing=FALSE) 
   
T95-Perm.Cor.Sorted[(nperm+1)*0.05]# 95% treshold value
T99-Perm.Cor.Sorted[(nperm+1)*0.01]# 99% treshold value

__
R-help@r-project.org mailing list

Re: [R] Vizualization of points within sets

2009-04-21 Thread Sigbert Klinke
Hi,

 I have a visualization question regarding sets. My problem is as follows:

I would define a distance matrix for the points as

d_ij = 0 if the points in the same set and 1 if not

In case that points can be in more than two sets use an more appropriate
distance measure, e.g. Jaccard etc. Then run a nonmetric
(two-dimensional) multidimensional scaling (package: MASS, function:
isoMDS) to determine the point positions. But I'am not sure that it will
be easy to draw the set borders.

Yours sincerely

Sigbert Klinke

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] bug when subtracting decimals?

2009-04-21 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 20.04.2009 19:01:46:

 wolfgang.siewert wolfgang.siewert at gmail.com writes:
 
  There is a way around: 
  round(0.7-0.3,1)==0.4
  (TRUE)
  
  Obviously there is a problem with some combinations of decimal 
subtractions,
  that - we have the feeling - shouldt be solved.
 
 Oh no, not that one again! This was lecture two in my first computer
 course in 1968, but it seems to be gone the way of the dodo since than.

Maybe that is because of Excel is so widespread now and gives expected 
results (it probably silently rounds all decimal numbers before 
calculation). 
Regards
Petr

 
 Dietr
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Sampling in R: Please read my email from attached text.

2009-04-21 Thread skayis selcuk
(Sorry for multiple posting. Seems to be my msg is not distributed in my 
previous emails)
 
Dear R users, 
 
I need to do sampling without replacement (bootstraps). I have two variables 
(Xvar, Yvar). 
I have a correlation from original data set cor(Xvar, Yvar)=0.6174221. I am 
doing 5 sampling, 
and in each sampling  calculating correlations, saving, sorting and  getting 
95% cutt off point (0.1351877). 
I am getting maximum value as 0.3507219 (much smaller than correlation of my 
original data). 
I repeated the sampling a  couple of time and none of them produced a 
correlation 
coefficient higher than my original data set. However, if I sort out my Xvar 
and Yvar and 
obtain correlation it is 0.9657125 which is much higher than correlation for my 
original data. 
I am doing sampling in another program and getting at least 1% higher 
correlation than mine. 
Now I am getting confused with sampling(random data) in R. My data and codes 
for the scenario above are
in the attached file. I want to understand where I am making a mistake. Any 
comment is deeply appreciated.
 
Kind Regards
 
Seyit Ali


Xvar-c(0.1818182,0.5384615,0.5535714,0.4680851,0.4545455,0.4385965,0.5185185,0.4035088,0.4901961,0.3650794,0.462963,0.4,0.56,0.3965517,0.4909091,

0.4716981,0.4310345,0.2,0.1509434,0.2647059,0.173913,0.1914894,0.1914894,0.1489362,0.1363636,0.2244898,0.2325581,0.133,0.1818182,0.1702128,

0.2173913,0.2380952,0.1632653,0.5614035,0.3396226,0.4909091,0.3770492,0.5,0.5185185,0.5,0.467,0.4464286,0.362069,0.4285714,0.4561404,

0.4736842,0.4545455,0.417,0.4181818,0.4590164,0.517,0.5423729,0.483,0.5454545,0.4393939,0.5172414,0.4098361,0.4745763,0.4754098,

0.517,0.5,0.4603175,0.42,0.4038462,0.4897959,0.3148148,0.3673469,0.4,0.458,0.3877551,0.4375,0.4117647,0.4313725,0.533,0.3962264,

0.3548387,0.5272727,0.4137931,0.3928571,0.467,0.4210526,0.4363636,0.4545455,0.4310345,0.4237288,0.4814815,0.4912281,0.433,0.4,0.4285714,

0.4516129,0.5090909,0.4464286,0.4642857,0.417,0.4098361,0.4909091,0.3809524,0.5272727,0.4814815,0.5254237,0.627451,0.5,0.5471698,0.5454545,

0.5925926,0.5769231,0.5818182,0.444,0.4915254,0.4727273,0.4107143,0.4285714,0.4310345,0.4237288,0.4285714,0.440678,0.4237288,0.4807692,

0.4150943,0.4615385,0.4107143,0.4814815,0.4074074,0.4210526,0.5263158,0.440678,0.4576271,0.5344828,0.5,0.5636364,0.4677419,0.5,0.5192308,

0.4642857,0.5090909,0.58,0.4482759,0.5098039,0.4035088,0.4210526,0.5098039,0.4385965,0.5283019,0.5471698,0.625,0.4310345,0.4912281,0.5283019,
0.4576271,0.5471698,0.4745763,0.4821429)

Yvar-c(0.2553191,0.4107143,0.5660377,0.389,0.3606557,0.2898551,0.3818182,0.4,0.4,0.3278689,0.2903226,0.4074074,0.4181818,0.3,0.2238806,0.3728814,

0.3709677,0.2307692,0.2830189,0.2244898,0.2142857,0.2131148,0.22,0.2258065,0.2321429,0.2,0.2264151,0.22,0.2115385,0.2459016,0.117,0.1785714,

0.2068966,0.6,0.4285714,0.3134328,0.4461538,0.3965517,0.4769231,0.6181818,0.4827586,0.3709677,0.3965517,0.4821429,0.4545455,0.359375,0.4576271,

0.4516129,0.5272727,0.4603175,0.4,0.4912281,0.5384615,0.5,0.4516129,0.4126984,0.4655172,0.5263158,0.4925373,0.358209,0.4285714,0.4920635,

0.4482759,0.3235294,0.4,0.4375,0.440678,0.3898305,0.35,0.4528302,0.58,0.4153846,0.3174603,0.5185185,0.3870968,0.2894737,0.3709677,0.369863,

0.3676471,0.3636364,0.3088235,0.328125,0.4032258,0.4084507,0.3188406,0.3636364,0.3823529,0.2816901,0.472,0.5,0.3521127,0.4393939,0.3787879,

0.453125,0.4324324,0.4057971,0.4545455,0.4492754,0.5,0.4098361,0.4067797,0.367,0.3928571,0.4285714,0.5,0.2923077,0.4561404,0.45,0.5538462,

0.4626866,0.4057971,0.3676471,0.5322581,0.5428571,0.375,0.4411765,0.4571429,0.4,0.3846154,0.3870968,0.4915254,0.530303,0.4375,0.4918033,0.4179104,

0.4032258,0.3606557,0.5178571,0.4848485,0.390625,0.375,0.4375,0.367,0.4,0.4477612,0.2571429,0.4032258,0.3382353,0.4814815,0.4090909,0.3548387,

0.4821429,0.5,0.557377,0.433,0.5454545,0.4590164,0.3943662,0.5076923,0.5,0.3283582,0.3676471,0.559322)

my.cor-cor(Xvar, Yvar)
print(my.cor)
 
nperm-4
Perm.Cor-NULL

for (iperm in 1:nperm)  {
XvarNew-sample(Xvar, size=length(Xvar), replace=FALSE)
YvarNew-sample(Yvar, size=length(Yvar), replace=FALSE) 
perm.cor-cor(XvarNew, YvarNew)
Perm.Cor-c(Perm.Cor, perm.cor)
}
print(max(Perm.Cor))
XvarSorted-sort(Xvar, decreasing=TRUE)
YvarSorted-sort(Yvar, decreasing=TRUE)
max.cor-cor(XvarSorted, YvarSorted)
print(max.cor)
if(mat.cor0) Perm.Cor.Sorted-sort(Perm.Cor, decreasing=TRUE)  
  
if(mat.cor0) Perm.Cor.Sorted-sort(Perm.Cor, decreasing=FALSE) 
   
T95-Perm.Cor.Sorted[(nperm+1)*0.05]# 95% treshold value
T99-Perm.Cor.Sorted[(nperm+1)*0.01]# 99% treshold value

__
R-help@r-project.org mailing list

Re: [R] bug when subtracting decimals?

2009-04-21 Thread Dieter Menne
Petr PIKAL petr.pikal at precheza.cz writes:

 Maybe that is because of Excel is so widespread now and gives expected 
 results (it probably silently rounds all decimal numbers before 
 calculation). 

Marc Schwartz already reminded me of that one, and it's a good point
to explicitly mention in lectures. 

I suggest to extend R by introducing %==% as being Excellently equal.

Dieter

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R 2.9.0 MASS package

2009-04-21 Thread Uwe Ligges



Peter Dalgaard wrote:

Tom La Bone wrote:

In Windows Xp Pro:

R2.8.1 USA(CA1) repository

markerSearchPower
MASS(VR)
MasterBayes


R2.9.0 USA(CA1) repository

markerSearchPower
MasterBayes

MASS is not where it used to be. I checked a couple of other 
repositories in

the US and got similar results.

Tom



But it's in R, no?

Anyways, the VR bundle appears to be in the Windows binary area on one 
CA CRAN mirror but not the other (UCLA doesn't have it, UCB does).



Yes, I forgot to enable the recommended packages in my build system 
directly after release (as it does not make sense to build them before 
release). The recommended packages from CRAN master should propagate 
around within a few days.


Uwe





-p



Peter Dalgaard wrote:

Tom La Bone wrote:

I can't seem to find MASS for the latest version of R. Is it coming or
has
the name of the package changed?

Tom

Where did you look?

It is in the sources (as part of VR), and also in my (SUSE) test builds.







__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] bug when subtracting decimals?

2009-04-21 Thread Petr PIKAL
r-help-boun...@r-project.org napsal dne 21.04.2009 10:00:06:

 Petr PIKAL petr.pikal at precheza.cz writes:
 
  Maybe that is because of Excel is so widespread now and gives expected 

  results (it probably silently rounds all decimal numbers before 
  calculation). 
 
 Marc Schwartz already reminded me of that one, and it's a good point
 to explicitly mention in lectures. 
 
 I suggest to extend R by introducing %==% as being Excellently equal.

It helps but not in all cases

 (0.7-0.3)-.40
[1] FALSE
 (0.7-0.3)-.40
[1] TRUE


There always could be different issues with not exact representation of 
decimals. So educated user or internal rounding could help but I am not 
sure if later is desired.

Regards
Petr

 
 Dieter
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] how to do analysis of PCA with raw data in R software.

2009-04-21 Thread ahburiro
Could any body help to how to do analysis of PCA with raw data in R software.

I will send you the data then.

Regards 

Abdul Hanan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Question on binomial data

2009-04-21 Thread ehud cohen
Hi,

We have an experiment with pass/fail outcome, and a continuous
parameter which may contribute to the outcome.

First, we've analyzed it by:

p=c(F,T,F,F,F,T,T,T,T,T,T,T,F,T,T,T,T);
w=c(53,67,59,59,53,89,72,56,65,63,62,58,59,72,61,68,63);
l-glm(p~w,family=binomial)
summary(l)

Which turned out to be non significant.

Then, we thought of comparing the parameters of the two groups (passed
vs. failed)

t.test(w[which(p)],w[which(!p)],alternative=two.sided)

which turned highly significant.

I'd appreciate some insight...

Thanks, Ehud.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] joined R-today

2009-04-21 Thread Bala subramanian
Friends,

I am a newbie to R. Just installed and started with R. I installed netcdf
library (netcdf-4.0.tar.gz) and then ncdf package of R from CRAN with the
following command.

 R CMD INSTALL
--configure-args=-with-netcdf_incdir=/usr/local/netcdf/include
-with-netcdf_libdir=/usr/local/netcdf/lib ncdf_1.6.tar.gz

The installation was successful. But when i try to use ncdf inside R, i get
the following error. Kindly help me how to resolve the problem.

 trjfile-system.file('test.netcdf',package='bio3d')
 trj-read.ncdf(trjfile)
Loading required package: ncdf
Error in dyn.load(file, DLLpath = DLLpath, ...) :
  unable to load shared library '/usr/lib/R/library/ncdf/libs/ncdf.so':
  /usr/lib/R/library/ncdf/libs/ncdf.so: cannot restore segment prot after
reloc: Permission denied
Error in read.ncdf(trjfile) : Please install the ncdf package from CRAN

Thanks in advance,
Bala

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Odp: how to do analysis of PCA with raw data in R software.

2009-04-21 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 21.04.2009 07:03:45:

 Could any body help to how to do analysis of PCA with raw data in R 
software.
 
 I will send you the data then.

What about you keeping the data and we sending you the software? Or you 
could download it.

Regards
Petr

 
 Regards 
 
 Abdul Hanan
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] n stage integer optimisation in R

2009-04-21 Thread WBRETT

Hi there, if anyone can please help it would be wonderful!

I have a integer programming problem. I have a list of objects, and i need
to select them according to certain contraints. In doing so, each object is
given a value, and this value is what needs to be maximised.
This is not the problem, i use a simple integer program(using lpSolve
package), with a constraint matrix, setting all.bin = TRUE, and the 1's will
indicate that the object must be selected, a zero indicates that it
shouldn't be selected. So selecting the objects at this stage is fine, but
here is my big problem:

There are multiple stages and each object is given different score a each
stage. I now need to optimise the total (over all 10 stages) knowing that i
can only make x changes to the set objects chosen at the first stage.

does anyone know of a package i can use that can do this for me?

If the problem is not clear, please let me know so i can try to rephrase it

Thanx
-- 
View this message in context: 
http://www.nabble.com/n-stage-integer-optimisation-in-R-tp23151632p23151632.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] joined R-today

2009-04-21 Thread Simon Pickett

Hi,

Check out the FAQ on the home page about installing packages.

You need to
1. Install the package from a local mirror, you can do this from the drop 
down menu (Install packages)

2. then call the package using library(name of the package)

It helps to know where your R library directory is on your computer.

HTH Simon.


- Original Message - 
From: Bala subramanian bala.biophys...@gmail.com

To: r-help@r-project.org
Sent: Tuesday, April 21, 2009 9:34 AM
Subject: [R] joined R-today



Friends,

I am a newbie to R. Just installed and started with R. I installed netcdf
library (netcdf-4.0.tar.gz) and then ncdf package of R from CRAN with the
following command.

R CMD INSTALL
--configure-args=-with-netcdf_incdir=/usr/local/netcdf/include
-with-netcdf_libdir=/usr/local/netcdf/lib ncdf_1.6.tar.gz

The installation was successful. But when i try to use ncdf inside R, i 
get

the following error. Kindly help me how to resolve the problem.


trjfile-system.file('test.netcdf',package='bio3d')
trj-read.ncdf(trjfile)

Loading required package: ncdf
Error in dyn.load(file, DLLpath = DLLpath, ...) :
 unable to load shared library '/usr/lib/R/library/ncdf/libs/ncdf.so':
 /usr/lib/R/library/ncdf/libs/ncdf.so: cannot restore segment prot after
reloc: Permission denied
Error in read.ncdf(trjfile) : Please install the ncdf package from CRAN

Thanks in advance,
Bala

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] line wrap in R console under windows

2009-04-21 Thread William Simpson
I would like the R console to wrap lines at 80 cols.
It does not do so, even though I have used the Rgui Configuration
Editor to set the Console cols at 80 and the Pager cols at 80.

Please tell me how to set it up so I have word wrap.

Just to be clear: in older/other R versions, console input is wrapped
at 80 cols and so you have something that looks like
 blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 
 blah blah blah
 blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah
Instead of what I see, which is
 blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 
 blah blah blah$
and I need to scroll sideways to see the rest of the stuff past $

I checked the archives and saw no postings on this.

Thanks very much for any help.

Bill

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] joined R-today

2009-04-21 Thread Bala subramanian
Hi,
Yes ncdf needs netcdf, netcdf is already installed in my fedora10. I
reinstalled ncdf with the following option
install.packages('ncdf',dep=TRUE)
library(ncdf) library(ncdf)
Error in dyn.load(file, DLLpath = DLLpath, ...) :
  unable to load shared library '/usr/lib/R/library/ncdf/libs/ncdf.so':
  /usr/lib/R/library/ncdf/libs/ncdf.so: cannot restore segment prot after
reloc: Permission denied
Error in library(ncdf) : .First.lib failed for 'ncdf'

Again the same error,
Bala


On Tue, Apr 21, 2009 at 12:12 PM, Liviu Andronic landronim...@gmail.comwrote:

 On Tue, Apr 21, 2009 at 11:57 AM, Bala subramanian
 bala.biophys...@gmail.com wrote:
  Dear Simon,
  I installed the ncdf package in the way you suggested but still i got the
  same error i got before. I haves pasted below the installation log and
  errors.
 
 Does ncdf depend on netcdf [1]? If so, perhaps it is missing, or is
 not up-to-date. Also, it's a good habit to install.packages('ncdf',
 dep=TRUE).
 Regards,
 Liviu

 [1] http://www.unidata.ucar.edu/software/netcdf/


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Sampling in R

2009-04-21 Thread Seyit Ali Kayis

Dear R users, 

I need to do sampling without replacement (bootstraps). I have two variables 
(Xvar, Yvar). 
I have a correlation from original data set cor(Xvar, Yvar)=0.6174221. I am 
doing 5 sampling, 
and in each sampling  calculating correlations, saving, sorting and  getting 
95% cutt off point (0.1351877). 
I am getting maximum value as 0.3507219 (much smaller than correlation of my 
original data). 
I repeated the sampling a  couple of time and none of them produced a 
correlation 
coefficient higher than my original data set. However, if I sort out my Xvar 
and Yvar and 
obtain correlation it is 0.9657125 which is much higher than correlation for my 
original data. 
I am doing sampling in another program and getting at least 1% higher 
correlation than mine. 
Now I am getting confused with sampling(random data) in R. My data and codes 
for the scenario above are below


Xvar-c(0.1818182,0.5384615,0.5535714,0.4680851,0.4545455,0.4385965,0.5185185,0.4035088,0.4901961,0.3650794,0.462963,0.4,0.56,0.3965517,0.4909091,

0.4716981,0.4310345,0.2,0.1509434,0.2647059,0.173913,0.1914894,0.1914894,0.1489362,0.1363636,0.2244898,0.2325581,0.133,0.1818182,0.1702128,

0.2173913,0.2380952,0.1632653,0.5614035,0.3396226,0.4909091,0.3770492,0.5,0.5185185,0.5,0.467,0.4464286,0.362069,0.4285714,0.4561404,

0.4736842,0.4545455,0.417,0.4181818,0.4590164,0.517,0.5423729,0.483,0.5454545,0.4393939,0.5172414,0.4098361,0.4745763,0.4754098,

0.517,0.5,0.4603175,0.42,0.4038462,0.4897959,0.3148148,0.3673469,0.4,0.458,0.3877551,0.4375,0.4117647,0.4313725,0.533,0.3962264,

0.3548387,0.5272727,0.4137931,0.3928571,0.467,0.4210526,0.4363636,0.4545455,0.4310345,0.4237288,0.4814815,0.4912281,0.433,0.4,0.4285714,

0.4516129,0.5090909,0.4464286,0.4642857,0.417,0.4098361,0.4909091,0.3809524,0.5272727,0.4814815,0.5254237,0.627451,0.5,0.5471698,0.5454545,

0.5925926,0.5769231,0.5818182,0.444,0.4915254,0.4727273,0.4107143,0.4285714,0.4310345,0.4237288,0.4285714,0.440678,0.4237288,0.4807692,

0.4150943,0.4615385,0.4107143,0.4814815,0.4074074,0.4210526,0.5263158,0.440678,0.4576271,0.5344828,0.5,0.5636364,0.4677419,0.5,0.5192308,

0.4642857,0.5090909,0.58,0.4482759,0.5098039,0.4035088,0.4210526,0.5098039,0.4385965,0.5283019,0.5471698,0.625,0.4310345,0.4912281,0.5283019,
0.4576271,0.5471698,0.4745763,0.4821429)

Yvar-c(0.2553191,0.4107143,0.5660377,0.389,0.3606557,0.2898551,0.3818182,0.4,0.4,0.3278689,0.2903226,0.4074074,0.4181818,0.3,0.2238806,0.3728814,

0.3709677,0.2307692,0.2830189,0.2244898,0.2142857,0.2131148,0.22,0.2258065,0.2321429,0.2,0.2264151,0.22,0.2115385,0.2459016,0.117,0.1785714,

0.2068966,0.6,0.4285714,0.3134328,0.4461538,0.3965517,0.4769231,0.6181818,0.4827586,0.3709677,0.3965517,0.4821429,0.4545455,0.359375,0.4576271,

0.4516129,0.5272727,0.4603175,0.4,0.4912281,0.5384615,0.5,0.4516129,0.4126984,0.4655172,0.5263158,0.4925373,0.358209,0.4285714,0.4920635,

0.4482759,0.3235294,0.4,0.4375,0.440678,0.3898305,0.35,0.4528302,0.58,0.4153846,0.3174603,0.5185185,0.3870968,0.2894737,0.3709677,0.369863,

0.3676471,0.3636364,0.3088235,0.328125,0.4032258,0.4084507,0.3188406,0.3636364,0.3823529,0.2816901,0.472,0.5,0.3521127,0.4393939,0.3787879,

0.453125,0.4324324,0.4057971,0.4545455,0.4492754,0.5,0.4098361,0.4067797,0.367,0.3928571,0.4285714,0.5,0.2923077,0.4561404,0.45,0.5538462,

0.4626866,0.4057971,0.3676471,0.5322581,0.5428571,0.375,0.4411765,0.4571429,0.4,0.3846154,0.3870968,0.4915254,0.530303,0.4375,0.4918033,0.4179104,

0.4032258,0.3606557,0.5178571,0.4848485,0.390625,0.375,0.4375,0.367,0.4,0.4477612,0.2571429,0.4032258,0.3382353,0.4814815,0.4090909,0.3548387,

0.4821429,0.5,0.557377,0.433,0.5454545,0.4590164,0.3943662,0.5076923,0.5,0.3283582,0.3676471,0.559322)

my.cor-cor(Xvar, Yvar)
print(my.cor)
 
nperm-4
Perm.Cor-NULL

for (iperm in 1:nperm)  {
XvarNew-sample(Xvar, size=length(Xvar), replace=FALSE)
YvarNew-sample(Yvar, size=length(Yvar), replace=FALSE) 
perm.cor-cor(XvarNew, YvarNew)
Perm.Cor-c(Perm.Cor, perm.cor)
}
print(max(Perm.Cor))
XvarSorted-sort(Xvar, decreasing=TRUE)
YvarSorted-sort(Yvar, decreasing=TRUE)
max.cor-cor(XvarSorted, YvarSorted)
print(max.cor)
if(mat.cor0) Perm.Cor.Sorted-sort(Perm.Cor, decreasing=TRUE)  
  
if(mat.cor0) Perm.Cor.Sorted-sort(Perm.Cor, decreasing=FALSE) 
   
T95-Perm.Cor.Sorted[(nperm+1)*0.05]# 95% treshold value
T99-Perm.Cor.Sorted[(nperm+1)*0.01]# 99% treshold value

 

I want to understand where I am making a mistake. Any comment is deeply 
appreciated.

Kind Regards

Seyit Ali


--
 
Dr. Seyit Ali KAYIS
Selcuk University
Faculty of Agriculture
Kampus, Konya, TURKEY

 

[R] Sampling in R

2009-04-21 Thread Seyit Ali Kayis

Dear R users, 
 
I need to do sampling without replacement (bootstraps). I have two variables 
(Xvar, Yvar). 
I have a correlation from original data set cor(Xvar, Yvar)=0.6174221. I am 
doing 5 sampling, 
and in each sampling  calculating correlations, saving, sorting and  getting 
95% cutt off point (0.1351877). 
I am getting maximum value as 0.3507219 (much smaller than correlation of my 
original data). 
I repeated the sampling a  couple of time and none of them produced a 
correlation 
coefficient higher than my original data set. However, if I sort out my Xvar 
and Yvar and 
obtain correlation it is 0.9657125 which is much higher than correlation for my 
original data. 
I am doing sampling in another program and getting at least 1% higher 
correlation than mine. 
Now I am getting confused with sampling(random data) in R. My data and codes 
for the scenario above are
in the attached file. I want to understand where I am making a mistake. Any 
comment is deeply appreciated.
 
Kind Regards
 
Seyit Ali


--
 
Dr. Seyit Ali KAYIS
Selcuk University
Faculty of Agriculture
Kampus, Konya, TURKEY

s_a_ka...@yahoo.com,s_a_ka...@hotmail.com
Tell: +90 332 223 2830  Mobile: +90 535 587 1139  Fax: +90 332 241 0108

   Greetings from Konya, TURKEY
http://www.ziraat.selcuk.edu.tr/skayis/
--
 






_
No-one wants to be lonely this Autumn Find someone to snuggle up with

Fchannel%2Findex%2Easpx%3Ftrackingid%3D1048628_t=773568480_r=nzWINDOWSliveMAILemailTAGLINES_m=EXTXvar-c(0.1818182,0.5384615,0.5535714,0.4680851,0.4545455,0.4385965,0.5185185,0.4035088,0.4901961,0.3650794,0.462963,0.4,0.56,0.3965517,0.4909091,

0.4716981,0.4310345,0.2,0.1509434,0.2647059,0.173913,0.1914894,0.1914894,0.1489362,0.1363636,0.2244898,0.2325581,0.133,0.1818182,0.1702128,

0.2173913,0.2380952,0.1632653,0.5614035,0.3396226,0.4909091,0.3770492,0.5,0.5185185,0.5,0.467,0.4464286,0.362069,0.4285714,0.4561404,

0.4736842,0.4545455,0.417,0.4181818,0.4590164,0.517,0.5423729,0.483,0.5454545,0.4393939,0.5172414,0.4098361,0.4745763,0.4754098,

0.517,0.5,0.4603175,0.42,0.4038462,0.4897959,0.3148148,0.3673469,0.4,0.458,0.3877551,0.4375,0.4117647,0.4313725,0.533,0.3962264,

0.3548387,0.5272727,0.4137931,0.3928571,0.467,0.4210526,0.4363636,0.4545455,0.4310345,0.4237288,0.4814815,0.4912281,0.433,0.4,0.4285714,

0.4516129,0.5090909,0.4464286,0.4642857,0.417,0.4098361,0.4909091,0.3809524,0.5272727,0.4814815,0.5254237,0.627451,0.5,0.5471698,0.5454545,

0.5925926,0.5769231,0.5818182,0.444,0.4915254,0.4727273,0.4107143,0.4285714,0.4310345,0.4237288,0.4285714,0.440678,0.4237288,0.4807692,

0.4150943,0.4615385,0.4107143,0.4814815,0.4074074,0.4210526,0.5263158,0.440678,0.4576271,0.5344828,0.5,0.5636364,0.4677419,0.5,0.5192308,

0.4642857,0.5090909,0.58,0.4482759,0.5098039,0.4035088,0.4210526,0.5098039,0.4385965,0.5283019,0.5471698,0.625,0.4310345,0.4912281,0.5283019,
0.4576271,0.5471698,0.4745763,0.4821429)

Yvar-c(0.2553191,0.4107143,0.5660377,0.389,0.3606557,0.2898551,0.3818182,0.4,0.4,0.3278689,0.2903226,0.4074074,0.4181818,0.3,0.2238806,0.3728814,

0.3709677,0.2307692,0.2830189,0.2244898,0.2142857,0.2131148,0.22,0.2258065,0.2321429,0.2,0.2264151,0.22,0.2115385,0.2459016,0.117,0.1785714,

0.2068966,0.6,0.4285714,0.3134328,0.4461538,0.3965517,0.4769231,0.6181818,0.4827586,0.3709677,0.3965517,0.4821429,0.4545455,0.359375,0.4576271,

0.4516129,0.5272727,0.4603175,0.4,0.4912281,0.5384615,0.5,0.4516129,0.4126984,0.4655172,0.5263158,0.4925373,0.358209,0.4285714,0.4920635,

0.4482759,0.3235294,0.4,0.4375,0.440678,0.3898305,0.35,0.4528302,0.58,0.4153846,0.3174603,0.5185185,0.3870968,0.2894737,0.3709677,0.369863,

0.3676471,0.3636364,0.3088235,0.328125,0.4032258,0.4084507,0.3188406,0.3636364,0.3823529,0.2816901,0.472,0.5,0.3521127,0.4393939,0.3787879,

0.453125,0.4324324,0.4057971,0.4545455,0.4492754,0.5,0.4098361,0.4067797,0.367,0.3928571,0.4285714,0.5,0.2923077,0.4561404,0.45,0.5538462,

0.4626866,0.4057971,0.3676471,0.5322581,0.5428571,0.375,0.4411765,0.4571429,0.4,0.3846154,0.3870968,0.4915254,0.530303,0.4375,0.4918033,0.4179104,

0.4032258,0.3606557,0.5178571,0.4848485,0.390625,0.375,0.4375,0.367,0.4,0.4477612,0.2571429,0.4032258,0.3382353,0.4814815,0.4090909,0.3548387,

0.4821429,0.5,0.557377,0.433,0.5454545,0.4590164,0.3943662,0.5076923,0.5,0.3283582,0.3676471,0.559322)

my.cor-cor(Xvar, Yvar)
print(my.cor)
 
nperm-4
Perm.Cor-NULL

for (iperm in 1:nperm)  {
XvarNew-sample(Xvar, size=length(Xvar), 

Re: [R] joined R-today

2009-04-21 Thread Bala subramanian
Dear Simon,
I installed the ncdf package in the way you suggested but still i got the
same error i got before. I haves pasted below the installation log and
errors.

 *install.packages('ncdf')*
Warning in install.packages(ncdf) :
  argument 'lib' is missing: using '/usr/lib/R/library'
--- Please select a CRAN mirror for use in this session ---
Loading Tcl/Tk interface ... done
trying URL '
http://rm.mirror.garr.it/mirrors/CRAN/src/contrib/ncdf_1.6.tar.gz'
Content type 'application/x-gzip' length 72533 bytes (70 Kb)
opened URL
==
downloaded 70 Kb

* Installing *source* package 'ncdf' ...
checking for gcc... gcc -m32 -std=gnu99
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -m32 -std=gnu99 accepts -g... yes
checking for gcc -m32 -std=gnu99 option to accept ANSI C... none needed
checking how to run the C preprocessor... gcc -m32 -std=gnu99 -E
checking for egrep... grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking netcdf.h usability... yes
checking netcdf.h presence... yes
checking for netcdf.h... yes
Found netcdf.h in: .
checking for nc_open in -lnetcdf... yes
Found netcdf library file libnetcdf.a in directory .
configure: creating ./config.status
config.status: creating R/load.R
config.status: creating src/Makevars
** libs
gcc -m32 -std=gnu99 -I/usr/include/R -I. -I/usr/local/include-fpic  -O2
-g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic
-fasynchronous-unwind-tables -c ncdf2.c -o ncdf2.o
gcc -m32 -std=gnu99 -I/usr/include/R -I. -I/usr/local/include-fpic  -O2
-g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic
-fasynchronous-unwind-tables -c ncdf3.c -o ncdf3.o
ncdf3.c: In function ‘R_nc_get_vara_charvarid’:
ncdf3.c:221: warning: assignment discards qualifiers from pointer target
type
ncdf3.c: In function ‘R_nc_get_vara_numvarid’:
ncdf3.c:267: warning: assignment discards qualifiers from pointer target
type
ncdf3.c:249: warning: ‘rv_data’ may be used uninitialized in this function
gcc -m32 -std=gnu99 -I/usr/include/R -I. -I/usr/local/include-fpic  -O2
-g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic
-fasynchronous-unwind-tables -c ncdf.c -o ncdf.o
ncdf.c: In function ‘R_nc_ttc_to_nctype’:
ncdf.c:424: warning: implicit declaration of function ‘exit’
ncdf.c:424: warning: incompatible implicit declaration of built-in function
‘exit’
gcc -m32 -std=gnu99 -shared -L/usr/local/lib -o ncdf.so ncdf2.o ncdf3.o
ncdf.o -L. -lnetcdf  -L/usr/lib/R/lib -lR
** R
** preparing package for lazy loading
** help
  Building/Updating help pages for package 'ncdf'
 Formats: text html latex example
  ancdf texthtmllatex
  aput.var.ncdf texthtmllatex   example
Note: unmatched right brace in file 'att.get.ncdf.Rd' on or after line 6
  att.get.ncdf  texthtmllatex   example
  att.put.ncdf  texthtmllatex   example
  close.ncdftexthtmllatex   example
  create.ncdf   texthtmllatex   example
  dim.def.ncdf  texthtmllatex   example
  enddef.ncdf   texthtmllatex   example
  get.var.ncdf  texthtmllatex   example
  ncdf-internal texthtmllatex
  open.ncdf texthtmllatex   example
  print.ncdftexthtmllatex   example
  redef.ncdftexthtmllatex   example
  set.missval.ncdf  texthtmllatex   example
  sync.ncdf texthtmllatex   example
  var.add.ncdf  texthtmllatex   example
  var.def.ncdf  texthtmllatex   example
Note: unmatched right brace in file 'version.ncdf.Rd' on or after line 6
Note: removing empty section \arguments in file 'version.ncdf.Rd'
  version.ncdf  texthtmllatex
** building package indices ...
** DONE (ncdf)*

The downloaded packages are in
/tmp/RtmpKrf8Vc/downloaded_packages
Updating HTML index of packages in '.Library'
 *library(ncdf)*
Error in dyn.load(file, DLLpath = DLLpath, ...) :
  unable 

[R] search through a matrix

2009-04-21 Thread onyourmark

Hi. I have a 925 by 925 correlation matrix corM. I want to identify all
variables that have correlation greater than 0.9.  Can anyone suggest an R
way of doing this?

Thank you.
-- 
View this message in context: 
http://www.nabble.com/search-through-a-matrix-tp23153538p23153538.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] bug when subtracting decimals?

2009-04-21 Thread Duncan Murdoch

On 21/04/2009 3:48 AM, Petr PIKAL wrote:

Hi

r-help-boun...@r-project.org napsal dne 20.04.2009 19:01:46:


wolfgang.siewert wolfgang.siewert at gmail.com writes:

There is a way around: 
round(0.7-0.3,1)==0.4

(TRUE)

Obviously there is a problem with some combinations of decimal 

subtractions,

that - we have the feeling - shouldt be solved.

Oh no, not that one again! This was lecture two in my first computer
course in 1968, but it seems to be gone the way of the dodo since than.


Maybe that is because of Excel is so widespread now and gives expected 
results (it probably silently rounds all decimal numbers before 
calculation). 


I don't have Excel, but I expect OpenOffice duplicates its bugs pretty 
well.  And in OpenOffice I see all sorts of bugs due to this, e.g. 
examples where x = y and y = z but x != z, cases where I can calculate a 
number like 1 + 4.e-15 and get something different from 1, but if I 
enter it directly as 1.004, it gets changed to 1.


So it only gives expected results in some tests, not others.

Duncan Murdoch

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Odp: Sampling in R

2009-04-21 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 21.04.2009 12:25:01:

 
 Dear R users, 
 
 I need to do sampling without replacement (bootstraps). I have two 
variables 
 (Xvar, Yvar). 
 I have a correlation from original data set cor(Xvar, Yvar)=0.6174221. I 
am 
 doing 5 sampling, 
 and in each sampling  calculating correlations, saving, sorting and 
getting 
 95% cutt off point (0.1351877). 
 I am getting maximum value as 0.3507219 (much smaller than correlation 
of my 
 original data). 
 I repeated the sampling a  couple of time and none of them produced a 
correlation 
 coefficient higher than my original data set. However, if I sort out my 
Xvar 
 and Yvar and 
 obtain correlation it is 0.9657125 which is much higher than correlation 
for 
 my original data. 
 I am doing sampling in another program and getting at least 1% higher 
 correlation than mine. 
 Now I am getting confused with sampling(random data) in R. My data and 
codes 
 for the scenario above are below
 
 
 
Xvar-c(0.1818182,0.5384615,0.5535714,0.4680851,0.4545455,0.4385965,0.5185185,
 0.4035088,0.4901961,0.3650794,0.462963,0.4,0.56,0.3965517,0.4909091,
 0.4716981,0.4310345,0.2,0.1509434,0.2647059,0.173913,0.1914894,0.
 
1914894,0.1489362,0.1363636,0.2244898,0.2325581,0.133,0.1818182,0.1702128,
 0.2173913,0.2380952,0.1632653,0.5614035,0.3396226,0.4909091,0.3770492,
 0.5,0.5185185,0.5,0.467,0.4464286,0.362069,0.4285714,0.4561404,
 0.4736842,0.4545455,0.417,0.4181818,0.4590164,0.517,0.5423729,
 0.483,0.5454545,0.4393939,0.5172414,0.4098361,0.4745763,0.4754098,
 0.517,0.5,0.4603175,0.42,0.4038462,0.4897959,0.3148148,0.3673469,
 0.4,0.458,0.3877551,0.4375,0.4117647,0.4313725,0.533,0.3962264,
 0.3548387,0.5272727,0.4137931,0.3928571,0.467,0.4210526,0.4363636,
 
0.4545455,0.4310345,0.4237288,0.4814815,0.4912281,0.433,0.4,0.4285714,
 0.4516129,0.5090909,0.4464286,0.4642857,0.417,0.4098361,0.4909091,
 
0.3809524,0.5272727,0.4814815,0.5254237,0.627451,0.5,0.5471698,0.5454545,
 0.5925926,0.5769231,0.5818182,0.444,0.4915254,0.4727273,0.4107143,
 0.4285714,0.4310345,0.4237288,0.4285714,0.440678,0.4237288,0.4807692,
 0.4150943,0.4615385,0.4107143,0.4814815,0.4074074,0.4210526,0.5263158,
 0.440678,0.4576271,0.5344828,0.5,0.5636364,0.4677419,0.5,0.5192308,
 0.4642857,0.5090909,0.58,0.4482759,0.5098039,0.4035088,0.4210526,0.
 
5098039,0.4385965,0.5283019,0.5471698,0.625,0.4310345,0.4912281,0.5283019,
 0.4576271,0.5471698,0.4745763,0.4821429)
 
 
Yvar-c(0.2553191,0.4107143,0.5660377,0.389,0.3606557,0.2898551,0.3818182,
 0.4,0.4,0.3278689,0.2903226,0.4074074,0.4181818,0.3,0.2238806,0.3728814,
 0.3709677,0.2307692,0.2830189,0.2244898,0.2142857,0.2131148,0.22,0.
 
2258065,0.2321429,0.2,0.2264151,0.22,0.2115385,0.2459016,0.117,0.1785714,
 0.2068966,0.6,0.4285714,0.3134328,0.4461538,0.3965517,0.4769231,0.
 
6181818,0.4827586,0.3709677,0.3965517,0.4821429,0.4545455,0.359375,0.4576271,
 0.4516129,0.5272727,0.4603175,0.4,0.4912281,0.5384615,0.5,0.4516129,0.
 4126984,0.4655172,0.5263158,0.4925373,0.358209,0.4285714,0.4920635,
 0.4482759,0.3235294,0.4,0.4375,0.440678,0.3898305,0.35,0.4528302,0.58,
 0.4153846,0.3174603,0.5185185,0.3870968,0.2894737,0.3709677,0.369863,
 0.3676471,0.3636364,0.3088235,0.328125,0.4032258,0.4084507,0.3188406,
 
0.3636364,0.3823529,0.2816901,0.472,0.5,0.3521127,0.4393939,0.3787879,
 0.453125,0.4324324,0.4057971,0.4545455,0.4492754,0.5,0.4098361,0.
 
4067797,0.367,0.3928571,0.4285714,0.5,0.2923077,0.4561404,0.45,0.5538462,
 0.4626866,0.4057971,0.3676471,0.5322581,0.5428571,0.375,0.4411765,0.
 
4571429,0.4,0.3846154,0.3870968,0.4915254,0.530303,0.4375,0.4918033,0.4179104,
 0.4032258,0.3606557,0.5178571,0.4848485,0.390625,0.375,0.4375,0.
 
367,0.4,0.4477612,0.2571429,0.4032258,0.3382353,0.4814815,0.4090909,0.3548387,
 0.4821429,0.5,0.557377,0.433,0.5454545,0.4590164,0.3943662,0.
 5076923,0.5,0.3283582,0.3676471,0.559322)
 
 my.cor-cor(Xvar, Yvar)
 print(my.cor)
 
 nperm-4
 Perm.Cor-NULL
 
 for (iperm in 1:nperm)  {
 XvarNew-sample(Xvar, size=length(Xvar), replace=FALSE) 
 YvarNew-sample(Yvar, size=length(Yvar), replace=FALSE) 
 perm.cor-cor(XvarNew, YvarNew)
 Perm.Cor-c(Perm.Cor, perm.cor)
 }

AFAICU you do not sample your data you shuffle them. Then you compute cor 
with shuffled data (X and Y are shuffled independently) which results in 
low correlation (it is like shuffling cards).

Maybe you could use smaller size and sample not original data but a vector 
of indices

perm.cor-rep(NA, 4)

for (iperm in 1:nperm)  {
ind - sample(1:length(Xvar), size = 100, replace=FALSE)
perm.cor[iperm] - cor(Xvar[ind], Yvar[ind])
perm.cor
}
max(perm.cor)
hist(perm.cor)

The result seems to be quite reasonable.

Regards
Petr



 print(max(Perm.Cor))
 XvarSorted-sort(Xvar, decreasing=TRUE)
 YvarSorted-sort(Yvar, decreasing=TRUE)
 max.cor-cor(XvarSorted, YvarSorted)
 print(max.cor)
 if(mat.cor0) Perm.Cor.Sorted-sort(Perm.Cor, 

Re: [R] search through a matrix

2009-04-21 Thread Dimitris Rizopoulos

Uwe Ligges wrote:



onyourmark wrote:

Hi. I have a 925 by 925 correlation matrix corM. I want to identify all
variables that have correlation greater than 0.9.  Can anyone suggest 
an R

way of doing this?

Thank you.


Example:

# prepare example data:
x - matrix((1:25) / 25, 5, 5)
rownames(x) - letters[1:5]
colnames(x) - letters[1:5]

# solution
cbind(rownames(x)[row(x)[x  0.9]], colnames(x)[col(x)[x  0.9]])


or even

which(x  0.9, arr.ind = TRUE)


Best,
Dimitris



Uwe Ligges

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.



--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] line wrap in R console under windows

2009-04-21 Thread Duncan Murdoch

On 21/04/2009 6:03 AM, William Simpson wrote:

I would like the R console to wrap lines at 80 cols.
It does not do so, even though I have used the Rgui Configuration
Editor to set the Console cols at 80 and the Pager cols at 80.

Please tell me how to set it up so I have word wrap.

Just to be clear: in older/other R versions, console input is wrapped
at 80 cols and so you have something that looks like

blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 
blah blah

 blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah
Instead of what I see, which is

blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 
blah blah$

and I need to scroll sideways to see the rest of the stuff past $


Which version are you talking about?  I don't recall Rgui ever wrapping 
input.  The config settings affect output.  Maybe you're thinking of Rterm?


Duncan Murdoch




I checked the archives and saw no postings on this.

Thanks very much for any help.

Bill

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Package or packages for randomization in a clinical trial

2009-04-21 Thread John Sorkin
Can anyone recommend a package that can be used to randomize subjects? I am 
looking for a generalized package, or several packages that can accomplish 
unrestricted randomization (i.e. simple random assignment)
restricted randomization including stratified randomization, blocked 
randomization, and adaptive randomization.
Thanks,
John

John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)

Confidentiality Statement:
This email message, including any attachments, is for th...{{dropped:6}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] How to compare parameters of non linear fitting curves

2009-04-21 Thread Etienne Toffin

Hi,

I'm using a non linear model to fit experimental survival curves.

This model describes the fraction of still active experiments as a  
function of time t as follows:

f(t)=(1+exp(-etaD*cD)) / (1+exp(etaD(t-cD)))

Moreover, when experiments are still active, they may change of state  
(from 0 to 1). But they may fall inactive before changing their state  
(their state still equals 0). The survival curve of state may also be  
fitted with the following model:
f(A)=(1+exp(-eta1*c1)) / (1+exp(eta1(t-c1))) * (1+exp(-etaD*cD)) /  
(1+exp(etaD(t-cD)))


I estimate with nlm 1°) values of etaD and cD parameters and 2°)  
inject them as constant in the function to be minimized by nlm to  
estimate values of eta1 and c1.


I perform these estimations for two different experimental conditions  
that both have their values of etaD,eta1, cD and c1.


I would like to know if there is any statistical method to compare the  
estimated values of parameters of the two distributions ? And wether  
it's the case, how to perform it in R ?


Hope I'm clear enough for getting help,

Etienne

---
Etienne Toffin, PhD Student
Unit of Social Ecology
Université Libre de Bruxelles, CP 231
Boulevard du Triomphe
B-1050 Brussels
Belgium

Tel: +32(0)2/650.55.30
Fax: +32(0)2/650.57.67
http://www.ulb.ac.be/sciences/use/toffin.html

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] search through a matrix

2009-04-21 Thread Uwe Ligges



onyourmark wrote:

Hi. I have a 925 by 925 correlation matrix corM. I want to identify all
variables that have correlation greater than 0.9.  Can anyone suggest an R
way of doing this?

Thank you.


Example:

# prepare example data:
x - matrix((1:25) / 25, 5, 5)
rownames(x) - letters[1:5]
colnames(x) - letters[1:5]

# solution
cbind(rownames(x)[row(x)[x  0.9]], colnames(x)[col(x)[x  0.9]])


Uwe Ligges

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Sampling in R

2009-04-21 Thread Mike Lawrence
When you shuffle the observations independently, you are performing a
permutation test (though for this you only need to shuffle one side of
the pairs). When you sort the observations you are doing something
ridiculous that has no statistical meaning that I know.

I'm not very familiar with bootstrap CI's, but I think the idea is to
sample the PAIRS of data WITH replacement:
http://lmgtfy.com/?q=bootstrap+correlation

(first link is to a good overview by David Howell)

On Tue, Apr 21, 2009 at 7:25 AM, Seyit Ali Kayis s_a_ka...@hotmail.com wrote:

 Dear R users,

 I need to do sampling without replacement (bootstraps). I have two variables 
 (Xvar, Yvar).
 I have a correlation from original data set cor(Xvar, Yvar)=0.6174221. I am 
 doing 5 sampling,
 and in each sampling  calculating correlations, saving, sorting and  getting 
 95% cutt off point (0.1351877).
 I am getting maximum value as 0.3507219 (much smaller than correlation of my 
 original data).
 I repeated the sampling a  couple of time and none of them produced a 
 correlation
 coefficient higher than my original data set. However, if I sort out my Xvar 
 and Yvar and
 obtain correlation it is 0.9657125 which is much higher than correlation for 
 my original data.
 I am doing sampling in another program and getting at least 1% higher 
 correlation than mine.
 Now I am getting confused with sampling(random data) in R. My data and codes 
 for the scenario above are below


 Xvar-c(0.1818182,0.5384615,0.5535714,0.4680851,0.4545455,0.4385965,0.5185185,0.4035088,0.4901961,0.3650794,0.462963,0.4,0.56,0.3965517,0.4909091,
        
 0.4716981,0.4310345,0.2,0.1509434,0.2647059,0.173913,0.1914894,0.1914894,0.1489362,0.1363636,0.2244898,0.2325581,0.133,0.1818182,0.1702128,
        
 0.2173913,0.2380952,0.1632653,0.5614035,0.3396226,0.4909091,0.3770492,0.5,0.5185185,0.5,0.467,0.4464286,0.362069,0.4285714,0.4561404,
        
 0.4736842,0.4545455,0.417,0.4181818,0.4590164,0.517,0.5423729,0.483,0.5454545,0.4393939,0.5172414,0.4098361,0.4745763,0.4754098,
        
 0.517,0.5,0.4603175,0.42,0.4038462,0.4897959,0.3148148,0.3673469,0.4,0.458,0.3877551,0.4375,0.4117647,0.4313725,0.533,0.3962264,
        
 0.3548387,0.5272727,0.4137931,0.3928571,0.467,0.4210526,0.4363636,0.4545455,0.4310345,0.4237288,0.4814815,0.4912281,0.433,0.4,0.4285714,
        
 0.4516129,0.5090909,0.4464286,0.4642857,0.417,0.4098361,0.4909091,0.3809524,0.5272727,0.4814815,0.5254237,0.627451,0.5,0.5471698,0.5454545,
        
 0.5925926,0.5769231,0.5818182,0.444,0.4915254,0.4727273,0.4107143,0.4285714,0.4310345,0.4237288,0.4285714,0.440678,0.4237288,0.4807692,
        
 0.4150943,0.4615385,0.4107143,0.4814815,0.4074074,0.4210526,0.5263158,0.440678,0.4576271,0.5344828,0.5,0.5636364,0.4677419,0.5,0.5192308,
        
 0.4642857,0.5090909,0.58,0.4482759,0.5098039,0.4035088,0.4210526,0.5098039,0.4385965,0.5283019,0.5471698,0.625,0.4310345,0.4912281,0.5283019,
        0.4576271,0.5471698,0.4745763,0.4821429)

 Yvar-c(0.2553191,0.4107143,0.5660377,0.389,0.3606557,0.2898551,0.3818182,0.4,0.4,0.3278689,0.2903226,0.4074074,0.4181818,0.3,0.2238806,0.3728814,
        
 0.3709677,0.2307692,0.2830189,0.2244898,0.2142857,0.2131148,0.22,0.2258065,0.2321429,0.2,0.2264151,0.22,0.2115385,0.2459016,0.117,0.1785714,
        
 0.2068966,0.6,0.4285714,0.3134328,0.4461538,0.3965517,0.4769231,0.6181818,0.4827586,0.3709677,0.3965517,0.4821429,0.4545455,0.359375,0.4576271,
        
 0.4516129,0.5272727,0.4603175,0.4,0.4912281,0.5384615,0.5,0.4516129,0.4126984,0.4655172,0.5263158,0.4925373,0.358209,0.4285714,0.4920635,
        
 0.4482759,0.3235294,0.4,0.4375,0.440678,0.3898305,0.35,0.4528302,0.58,0.4153846,0.3174603,0.5185185,0.3870968,0.2894737,0.3709677,0.369863,
        
 0.3676471,0.3636364,0.3088235,0.328125,0.4032258,0.4084507,0.3188406,0.3636364,0.3823529,0.2816901,0.472,0.5,0.3521127,0.4393939,0.3787879,
        
 0.453125,0.4324324,0.4057971,0.4545455,0.4492754,0.5,0.4098361,0.4067797,0.367,0.3928571,0.4285714,0.5,0.2923077,0.4561404,0.45,0.5538462,
        
 0.4626866,0.4057971,0.3676471,0.5322581,0.5428571,0.375,0.4411765,0.4571429,0.4,0.3846154,0.3870968,0.4915254,0.530303,0.4375,0.4918033,0.4179104,
        
 0.4032258,0.3606557,0.5178571,0.4848485,0.390625,0.375,0.4375,0.367,0.4,0.4477612,0.2571429,0.4032258,0.3382353,0.4814815,0.4090909,0.3548387,
        
 0.4821429,0.5,0.557377,0.433,0.5454545,0.4590164,0.3943662,0.5076923,0.5,0.3283582,0.3676471,0.559322)

 my.cor-cor(Xvar, Yvar)
 print(my.cor)

 nperm-4
 Perm.Cor-NULL

 for (iperm in 1:nperm)  {
 XvarNew-sample(Xvar, size=length(Xvar), replace=FALSE)
 YvarNew-sample(Yvar, size=length(Yvar), replace=FALSE)
 perm.cor-cor(XvarNew, YvarNew)
 Perm.Cor-c(Perm.Cor, perm.cor)
                        }
 print(max(Perm.Cor))
 XvarSorted-sort(Xvar, decreasing=TRUE)
 YvarSorted-sort(Yvar, decreasing=TRUE)
 max.cor-cor(XvarSorted, YvarSorted)
 print(max.cor)
 if(mat.cor0) 

Re: [R] Sampling in R: Please read my email from attached text.

2009-04-21 Thread David Winsemius
You need to sample pairs rather than sampling individually within Xvar  
and Yvar. You also generally sample with replacement. If you sample  
without replacement for the length of the data, then you just get the  
same set.



On Apr 21, 2009, at 3:54 AM, skayis selcuk wrote:


Data_and_Sampling_codes.txt


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Question on binomial data

2009-04-21 Thread David Winsemius
You should review your course material on interpreting general linear  
models. The criterion you have chosen for significance (looking at p  
values for indivdiual coefficients) is not the recommended one. Seek  
out the section that discusses the proper method for using deviance  
estimates for comparing nested models.


--
David Winsemius
On Apr 21, 2009, at 4:32 AM, ehud cohen wrote:


Hi,

We have an experiment with pass/fail outcome, and a continuous
parameter which may contribute to the outcome.

First, we've analyzed it by:

p=c(F,T,F,F,F,T,T,T,T,T,T,T,F,T,T,T,T);
w=c(53,67,59,59,53,89,72,56,65,63,62,58,59,72,61,68,63);
l-glm(p~w,family=binomial)
summary(l)

Which turned out to be non significant.

Then, we thought of comparing the parameters of the two groups (passed
vs. failed)

t.test(w[which(p)],w[which(!p)],alternative=two.sided)

which turned highly significant.

I'd appreciate some insight...



David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] joined R-today

2009-04-21 Thread Dimitri Liakhovitski
Try to install from scratch from a different mirror.
Dimitri

On Tue, Apr 21, 2009 at 6:21 AM, Bala subramanian
bala.biophys...@gmail.com wrote:
 Hi,
 Yes ncdf needs netcdf, netcdf is already installed in my fedora10. I
 reinstalled ncdf with the following option
install.packages('ncdf',dep=TRUE)
library(ncdf) library(ncdf)
 Error in dyn.load(file, DLLpath = DLLpath, ...) :
  unable to load shared library '/usr/lib/R/library/ncdf/libs/ncdf.so':
  /usr/lib/R/library/ncdf/libs/ncdf.so: cannot restore segment prot after
 reloc: Permission denied
 Error in library(ncdf) : .First.lib failed for 'ncdf'

 Again the same error,
 Bala


 On Tue, Apr 21, 2009 at 12:12 PM, Liviu Andronic 
 landronim...@gmail.comwrote:

 On Tue, Apr 21, 2009 at 11:57 AM, Bala subramanian
 bala.biophys...@gmail.com wrote:
  Dear Simon,
  I installed the ncdf package in the way you suggested but still i got the
  same error i got before. I haves pasted below the installation log and
  errors.
 
 Does ncdf depend on netcdf [1]? If so, perhaps it is missing, or is
 not up-to-date. Also, it's a good habit to install.packages('ncdf',
 dep=TRUE).
 Regards,
 Liviu

 [1] http://www.unidata.ucar.edu/software/netcdf/


        [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




-- 
Dimitri Liakhovitski
MarketTools, Inc.
dimitri.liakhovit...@markettools.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Random Forests: Question about R^2

2009-04-21 Thread Liaw, Andy
Just one small correction:  in #3 it should be squared residuals.

Yes, the function returns a vector of r^2 with length=ntree, with the k-th 
element being the r^2 for the forest consisting of the first k trees. 

Cheers,
Andy

From: Dimitri Liakhovitski 
 
 I would like to summarize. Would you please confirm that my summary is
 correct? Thank you very much!
 
 Determining R^2 in Random Forests (for a Regression Forest):
 
 1. For each individual case, record a mean prediction on the dependent
 variable y across all trees for which the case is OOB (Out-of-Bag);
 2. For each individual case, calculate a residual: residual = observed
 y - mean predicted y (from step 1)
 3. Calculate mean square residual MSE: MSE = sum of all individual
 residuals (from step 2) / n
 4. Because MSE/var(y) represents the proportion of y variance that is
 due to error, then R^2 = 1 - MSE/var(y).
 
 If it's correct, my last question would be:
 I am getting as many R^2 as the number of trees because each time the
 residuals are recalculated using all trees built so far, correct?
 
 Thank you very much!
 Dimitri
 
 
 On Mon, Apr 13, 2009 at 6:22 PM, Liaw, Andy 
 andy_l...@merck.com wrote:
  Apologies: that should have been sum(residual^2)!
 
  -Original Message-
  From: Dimitri Liakhovitski [mailto:ld7...@gmail.com]
  Sent: Monday, April 13, 2009 4:35 PM
  To: Liaw, Andy
  Cc: R-Help List
  Subject: Re: [R] Random Forests: Question about R^2
 
  Andy,
  thank you very much!
  One clarification question:
 
  If MSE = sum(residuals) / n, then
  in the formula (1 - mse / Var(y)) - shouldn't one square mse before
  dividing by variance?
 
  Dimitri
 
 
  On Mon, Apr 13, 2009 at 10:52 AM, Liaw, Andy
  andy_l...@merck.com wrote:
   MSE is the mean squared residuals.  For the training 
 data, the OOB
   estimate is used (i.e., residual = data - OOB prediction, MSE =
   sum(residuals) / n, OOB prediction is the mean of
  predictions from all
   trees for which the case is OOB).  It is _not_ the average
  OOB MSE of
   trees in the forest.
  
   I hope there's no question about how the pseudo R^2 is 
 computed on a
   test set?  If you understand how that's done, I assume the
  confusion is
   only how the OOB MSE is formed.
  
   Best,
   Andy
  
   From: Dimitri Liakhovitski
  
   Dear Random Forests gurus,
  
   I have a question about R^2 provided by randomForest (for
  regression).
   I don't succeed in finding this information.
  
   In the help file for randomForest under Value it says:
  
   rsq: (regression only) - pseudo R-squared'': 1 - mse / Var(y).
  
   Could someone please explain in somewhat more detail how
  exactly R^2
   is calculated?
   Is mse mean squared error for prediction?
   Is mse an average of mse's for all trees run on out-of-bag
   holdout samples?
   In other words - is this R^2 based on out-of-bag samples?
  
   Thank you very much for clarification!
  
   --
   Dimitri Liakhovitski
   MarketTools, Inc.
   dimitri.liakhovit...@markettools.com
  
   __
   R-help@r-project.org mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide
   http://www.R-project.org/posting-guide.html
   and provide commented, minimal, self-contained, 
 reproducible code.
  
   Notice:  This e-mail message, together with any
  attachments, contains
   information of Merck  Co., Inc. (One Merck Drive,
  Whitehouse Station,
   New Jersey, USA 08889), and/or its affiliates (which may be known
   outside the United States as Merck Frosst, Merck Sharp  Dohme or
   MSD and in Japan, as Banyu - direct contact information for
  affiliates is
   available at http://www.merck.com/contact/contacts.html) 
 that may be
   confidential, proprietary copyrighted and/or legally
  privileged. It is
   intended solely for the use of the individual or entity
  named on this
   message. If you are not the intended recipient, and have
  received this
   message in error, please notify us immediately by reply 
 e-mail and
   then delete it from your system.
  
  
 
 
 
  --
  Dimitri Liakhovitski
  MarketTools, Inc.
  dimitri.liakhovit...@markettools.com
 
  Notice:  This e-mail message, together with any 
 attachments, contains
  information of Merck  Co., Inc. (One Merck Drive, 
 Whitehouse Station,
  New Jersey, USA 08889), and/or its affiliates (which may be known
  outside the United States as Merck Frosst, Merck Sharp  Dohme or
  MSD and in Japan, as Banyu - direct contact information for 
 affiliates is
  available at http://www.merck.com/contact/contacts.html) that may be
  confidential, proprietary copyrighted and/or legally 
 privileged. It is
  intended solely for the use of the individual or entity 
 named on this
  message. If you are not the intended recipient, and have 
 received this
  message in error, please notify us immediately by reply e-mail and
  then delete it from your system.
 
 
 
 
 
 -- 
 Dimitri Liakhovitski
 MarketTools, Inc.
 

Re: [R] Random Forests: Predictor importance for Regression Trees

2009-04-21 Thread Liaw, Andy
Yes, you've got it!

Cheers,
Andy 

From: Behalf Of Dimitri 
 
 Hello!
 
 I think I am relatively clear on how predictor importance (the first
 one) is calculated by Random Forests for a Classification tree:
 
 Importance of predictor P1 when the response variable is categorical:
 
 1. For out-of-bag (oob) cases, randomly permute their values on
 predictor P1 and then put them down the tree
 2. For a given tree, subtract the number of votes for the correct
 class in the predictor-P1-permuted oob dataset from the number of
 votes for the correct class in the untouched oob dataset: if P1 is
 important, this number will be large.
 3. The average of this number over all trees in the forest is the raw
 importance score for predictor P1.
 
 I am wondering what step 2 above looks like if the response variable
 is continous and not categorical, in other words - for a Regression
 tree. Could you please correct if what I wrote below is wrong? Thank
 you very much!
 
 Importance of predictor P1 when the response variable is continous:
 
 1. For out-of-bag (oob) cases, randomly permute their values on
 predictor P1 and then put them down the tree
 2. For a given tree, calculate mean squared deviation of observed y
 minus predicted y for (a) the untouched oob dataset and for (b) the
 predictor-P1-permuted oob dataset. Subtract (a) from (b).
 3. The average of this number over all trees in the forest is the raw
 importance score for predictor P1.
 
 -- 
 Dimitri Liakhovitski
 MarketTools, Inc.
 dimitri.liakhovit...@markettools.com
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
Notice:  This e-mail message, together with any attachme...{{dropped:12}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] joined R-today

2009-04-21 Thread Bala subramanian
Hi,
I tried to install from four different mirrors. The result is the same. I
dnt understand what the following error means.
/usr/lib/R/library/ncdf/libs/ncdf.so: cannot restore segment prot after
reloc: Permission denied
Error in library(ncdf) : .First.lib failed for 'ncdf'

I even tried to change the permission of ncdf.so but still i am not able to
load the library.

Bala


On Tue, Apr 21, 2009 at 2:03 PM, Dimitri Liakhovitski ld7...@gmail.comwrote:

 Try to install from scratch from a different mirror.
 Dimitri

 On Tue, Apr 21, 2009 at 6:21 AM, Bala subramanian
 bala.biophys...@gmail.com wrote:
  Hi,
  Yes ncdf needs netcdf, netcdf is already installed in my fedora10. I
  reinstalled ncdf with the following option
 install.packages('ncdf',dep=TRUE)
 library(ncdf) library(ncdf)
  Error in dyn.load(file, DLLpath = DLLpath, ...) :
   unable to load shared library '/usr/lib/R/library/ncdf/libs/ncdf.so':
   /usr/lib/R/library/ncdf/libs/ncdf.so: cannot restore segment prot after
  reloc: Permission denied
  Error in library(ncdf) : .First.lib failed for 'ncdf'
 
  Again the same error,
  Bala
 
 
  On Tue, Apr 21, 2009 at 12:12 PM, Liviu Andronic landronim...@gmail.com
 wrote:
 
  On Tue, Apr 21, 2009 at 11:57 AM, Bala subramanian
  bala.biophys...@gmail.com wrote:
   Dear Simon,
   I installed the ncdf package in the way you suggested but still i got
 the
   same error i got before. I haves pasted below the installation log and
   errors.
  
  Does ncdf depend on netcdf [1]? If so, perhaps it is missing, or is
  not up-to-date. Also, it's a good habit to install.packages('ncdf',
  dep=TRUE).
  Regards,
  Liviu
 
  [1] http://www.unidata.ucar.edu/software/netcdf/
 
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 



 --
 Dimitri Liakhovitski
 MarketTools, Inc.
 dimitri.liakhovit...@markettools.com


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Sampling in R

2009-04-21 Thread Jorge Ivan Velez
Dear Seyit,
You might consider the boot package in this situation. Here is an example:

require(boot)

DF-data.frame(Xvar,Yvar)

temp - boot(DF, function(DF,d){
  S - DF[d,]
  cor(S$Xvar,S$Yvar)
   },
  R = 5000)
temp$t0
# [1] 0.617422
max(temp$t)
# [1] 0.7783784
hist(temp$t)

Once you load the boot package, take a look at ?boot.

HTH,

Jorge


On Tue, Apr 21, 2009 at 4:53 AM, Seyit Ali Kayis s_a_ka...@hotmail.comwrote:


 Dear R users,

 I need to do sampling without replacement (bootstraps). I have two
 variables (Xvar, Yvar).
 I have a correlation from original data set cor(Xvar, Yvar)=0.6174221. I am
 doing 5 sampling,
 and in each sampling  calculating correlations, saving, sorting and
  getting 95% cutt off point (0.1351877).
 I am getting maximum value as 0.3507219 (much smaller than correlation of
 my original data).
 I repeated the sampling a  couple of time and none of them produced a
 correlation
 coefficient higher than my original data set. However, if I sort out my
 Xvar and Yvar and
 obtain correlation it is 0.9657125 which is much higher than correlation
 for my original data.
 I am doing sampling in another program and getting at least 1% higher
 correlation than mine.
 Now I am getting confused with sampling(random data) in R. My data and
 codes for the scenario above are
 in the attached file. I want to understand where I am making a mistake. Any
 comment is deeply appreciated.

 Kind Regards

 Seyit Ali



 --
 Dr. Seyit Ali KAYIS
 Selcuk University
 Faculty of Agriculture
 Kampus, Konya, TURKEY

s_a_ka...@yahoo.com,s_a_ka...@hotmail.com
 Tell: +90 332 223 2830  Mobile: +90 535 587 1139  Fax: +90 332 241 0108

   Greetings from Konya, TURKEY
http://www.ziraat.selcuk.edu.tr/skayis/

 --






 _
 No-one wants to be lonely this Autumn Find someone to snuggle up with


 Fchannel%2Findex%2Easpx%3Ftrackingid%3D1048628_t=773568480_r=nzWINDOWSliveMAILemailTAGLINES_m=EXT
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] joined R-today

2009-04-21 Thread Bala subramanian
Hi,
In install.packages, there is something called *lib* which says,

lib: character vector giving the library directories where to install the
packages.  Recycled as needed.  If missing, defaults to '.libPaths()[1]'.

If i have to give the lib option as an arguement, what should be the path
for the installation, should it be */usr/local/lib* or */usr/lib/R/lib* or *
/usr/lib/R/library/ncdf/libs/*

Bala

On Tue, Apr 21, 2009 at 2:14 PM, Bala subramanian bala.biophys...@gmail.com
 wrote:

 Hi,
 I tried to install from four different mirrors. The result is the same. I
 dnt understand what the following error means.
 /usr/lib/R/library/ncdf/libs/ncdf.so: cannot restore segment prot after
 reloc: Permission denied
 Error in library(ncdf) : .First.lib failed for 'ncdf'

 I even tried to change the permission of ncdf.so but still i am not able to
 load the library.

 Bala



 On Tue, Apr 21, 2009 at 2:03 PM, Dimitri Liakhovitski ld7...@gmail.comwrote:

 Try to install from scratch from a different mirror.
 Dimitri

 On Tue, Apr 21, 2009 at 6:21 AM, Bala subramanian
 bala.biophys...@gmail.com wrote:
  Hi,
  Yes ncdf needs netcdf, netcdf is already installed in my fedora10. I
  reinstalled ncdf with the following option
 install.packages('ncdf',dep=TRUE)
 library(ncdf) library(ncdf)
  Error in dyn.load(file, DLLpath = DLLpath, ...) :
   unable to load shared library '/usr/lib/R/library/ncdf/libs/ncdf.so':
   /usr/lib/R/library/ncdf/libs/ncdf.so: cannot restore segment prot after
  reloc: Permission denied
  Error in library(ncdf) : .First.lib failed for 'ncdf'
 
  Again the same error,
  Bala
 
 
  On Tue, Apr 21, 2009 at 12:12 PM, Liviu Andronic 
 landronim...@gmail.comwrote:
 
  On Tue, Apr 21, 2009 at 11:57 AM, Bala subramanian
  bala.biophys...@gmail.com wrote:
   Dear Simon,
   I installed the ncdf package in the way you suggested but still i got
 the
   same error i got before. I haves pasted below the installation log
 and
   errors.
  
  Does ncdf depend on netcdf [1]? If so, perhaps it is missing, or is
  not up-to-date. Also, it's a good habit to install.packages('ncdf',
  dep=TRUE).
  Regards,
  Liviu
 
  [1] http://www.unidata.ucar.edu/software/netcdf/
 
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 



 --
 Dimitri Liakhovitski
 MarketTools, Inc.
 dimitri.liakhovit...@markettools.com




[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] explicit documentation

2009-04-21 Thread Wacek Kusnierczyk
Duncan Murdoch wrote:
 ronggui wrote:
 It is always unfair to complain about volunteer work, and what you
 should do is to make contributions.
   

 I only half agree with this:

... and i half agree with this (thus quarter agree with that).  i think
it's pretty fair to complain about unclear documentation *without*
proposing a rewrite.  after all, one may be complaining because one is
unable to understand from the existing docs what the intended and
to-be-documented behaviour is, and this is hardly a position from which
to propose concrete modifications.  but a message that a help page is
unclear can still be useful -- it should, however, clearly explain why
the page is not considered clear. 

vQ


 I think that it's fair to complain, as long as you make
 contributions.  With documentation, if you don't think it's clear, as
 part of your complaint you should rewrite it in a way that is clear: 
 then the author can understand what you found unclear about it.  (It
 may well happen that your revision isn't accepted, because it may be
 less clear than the original in the author's opinion, or it may be
 incorrect:  but at least it saves the author the time of trying to
 figure out what you'd prefer.)

 Duncan Murdoch
 2009/4/20 Rolf Turner r.tur...@auckland.ac.nz:
  
 On 19/04/2009, at 8:59 PM, Patrick Burns wrote:


 Rolf Turner wrote:
  
 On 17/04/2009, at 10:21 PM, Duncan Murdoch wrote:


 Benjamin Tyner wrote:
  
 Many thanks Duncan. Perhaps this merits a more explicit note in the
 documentation?

 
 The quote I gave is from the documentation.  How could it be more
 explicit?
   
 This is unfortunately typical of the attitude of R-core people
 toward the
 documentation.  ``It's clear.'' they say.  ``It's explicit.'' 
 Clear and
 explicit once you *know* what it's saying.  Not before, but.
 
 I think this unfairly blames R-core for being human.
   
Why is this unfair?  R-core is supposed to be superhuman! :-)

cheers,

Rolf

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Fix/Edit Error

2009-04-21 Thread Bronagh Grimes
Hi, I am wondering if anyone can help me with the following error.

 

I am using R on a Linux machine and wish to use either the edit or fix
function to look at the data.

 

However, we I try to run either of these commands I get the following
error

 

Error in data entry(datalist, modes) : invalid device In addition:
Warning message: In edit.data.frame(get(subx, envir = parent), title =
subx, ...) : unable to create fontset
-*-fixed-medium-r-*-*-*-120-*-*-*-*-*-*
http://www.google.co.uk/search?hl=enei=h6ntSbXfHMeTjAe727ANsa=Xoi=sp
ellresnum=0ct=resultcd=1q=Error+in+data+entry(datalist,+modes)+%3A+i
nvalid+device+In+addition%3A+Warning+message%3A+In+edit.data.frame(get(s
ubx,+envir+%3D+parent),+title+%3D+subx,+...)+%3A+unable+to+create+fontse
t+-*-fixed-medium-r-*-*-*-120-*-*-*-*-*-*spell=1   

 

Does anyone know how I can get around this so I can look at the data?

 

Many thanks in advance,

 


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] joined R-today

2009-04-21 Thread Liviu Andronic
On Tue, Apr 21, 2009 at 11:57 AM, Bala subramanian
bala.biophys...@gmail.com wrote:
 Dear Simon,
 I installed the ncdf package in the way you suggested but still i got the
 same error i got before. I haves pasted below the installation log and
 errors.

Does ncdf depend on netcdf [1]? If so, perhaps it is missing, or is
not up-to-date. Also, it's a good habit to install.packages('ncdf',
dep=TRUE).
Regards,
Liviu

[1] http://www.unidata.ucar.edu/software/netcdf/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] lme for between-within anova

2009-04-21 Thread William Simpson
I have the following between-within anova:
aovn1 - aov(amplitude ~ stereo*site*stimulus +
Error(subject/(site*stimulus)), stereon1)

This works fine. BUT I need to do Tukey HSD multiple comparisons, and
the aov() approach won't work. So I am trying the method posted on
r-help:
lmen1 - lme(amplitude ~ stereo*site*stimulus, random =
~1|subject/(site*stimulus), stereon1)

This doesn't work:
 lmen1 - lme(amplitude ~ stereo*site*stimulus, random = 
 ~1|subject/(site*stimulus), stereon1)
Error in getGroups.data.frame(dataMix, groups) :
Invalid formula for groups

Please tell me what to do to get the lme() fit to work.

After I get lmen1, I will do:
anova(lmen1)

summary(lmen1)
summary(glht(lmen1, linfct=mcp(V=Tukey)))

Please tell me if that sounds right.

Thanks very much for any help!

Bill

= This is the example I am following (with modifications
for my expt design)
You want to use lme() in package nlme, then glht() in the multcomp
package.  This will give you multiplicity adjusted p-values and
confidence intervals.

## Example
require(MASS) ## for oats data set
require(nlme) ## for lme()
require(multcomp)  ## for multiple comparison stuff

Aov.mod - aov(Y ~ N + V + Error(B/V), data = oats)
Lme.mod - lme(Y ~ N + V, random = ~1 | B/V, data = oats)

summary(Aov.mod)
anova(Lme.mod)

summary(Lme.mod)
summary(glht(Lme.mod, linfct=mcp(V=Tukey)))

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] rmysql fetch issues

2009-04-21 Thread Albert Vilella
I am trying to fetch data using RMySQL fetch method with n=100 in this loop:

lquery = paste(query, limit 10)
input = dbGetQuery(con1,lquery)
res = dbSendQuery(con1,query)
completed = FALSE
count = 0
while (completed != TRUE) {
  count = count + 1
  batch = fetch(res, n = 100)
  print (paste(batch,count))
  input = merge(input,batch,all=TRUE)
  print (paste(merge,count))
  completed = dbHasCompleted(res)
}

But after a while, I get this error:

...
[1] batch 211
[1] merge 211
[1] batch 212
Error in rep.int(rep.int(seq_len(nx), rep.int(rep.fac, nx)), orep) :
  invalid 'times' value
In addition: Warning messages:
1: In mysqlFetch(res, n, ...) :
  RS-DBI driver warning: (error while fetching rows)
2: In mysqlFetch(res, n, ...) :
  RS-DBI driver warning: (error while fetching rows)


What could be causing this? Is there any other way to do this?

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Sampling in R

2009-04-21 Thread Uwe Ligges



Seyit Ali Kayis wrote:
Dear R users, 

I need to do sampling without replacement (bootstraps). I have two variables (Xvar, Yvar). 
I have a correlation from original data set cor(Xvar, Yvar)=0.6174221. I am doing 5 sampling, 
and in each sampling  calculating correlations, saving, sorting and  getting 95% cutt off point (0.1351877). 
I am getting maximum value as 0.3507219 (much smaller than correlation of my original data). 
I repeated the sampling a  couple of time and none of them produced a correlation 
coefficient higher than my original data set. However, if I sort out my Xvar and Yvar and 
obtain correlation it is 0.9657125 which is much higher than correlation for my original data. 
I am doing sampling in another program and getting at least 1% higher correlation than mine. 
Now I am getting confused with sampling(random data) in R. My data and codes for the scenario above are below



Xvar-c(0.1818182,0.5384615,0.5535714,0.4680851,0.4545455,0.4385965,0.5185185,0.4035088,0.4901961,0.3650794,0.462963,0.4,0.56,0.3965517,0.4909091,

0.4716981,0.4310345,0.2,0.1509434,0.2647059,0.173913,0.1914894,0.1914894,0.1489362,0.1363636,0.2244898,0.2325581,0.133,0.1818182,0.1702128,

0.2173913,0.2380952,0.1632653,0.5614035,0.3396226,0.4909091,0.3770492,0.5,0.5185185,0.5,0.467,0.4464286,0.362069,0.4285714,0.4561404,

0.4736842,0.4545455,0.417,0.4181818,0.4590164,0.517,0.5423729,0.483,0.5454545,0.4393939,0.5172414,0.4098361,0.4745763,0.4754098,

0.517,0.5,0.4603175,0.42,0.4038462,0.4897959,0.3148148,0.3673469,0.4,0.458,0.3877551,0.4375,0.4117647,0.4313725,0.533,0.3962264,

0.3548387,0.5272727,0.4137931,0.3928571,0.467,0.4210526,0.4363636,0.4545455,0.4310345,0.4237288,0.4814815,0.4912281,0.433,0.4,0.4285714,

0.4516129,0.5090909,0.4464286,0.4642857,0.417,0.4098361,0.4909091,0.3809524,0.5272727,0.4814815,0.5254237,0.627451,0.5,0.5471698,0.5454545,

0.5925926,0.5769231,0.5818182,0.444,0.4915254,0.4727273,0.4107143,0.4285714,0.4310345,0.4237288,0.4285714,0.440678,0.4237288,0.4807692,

0.4150943,0.4615385,0.4107143,0.4814815,0.4074074,0.4210526,0.5263158,0.440678,0.4576271,0.5344828,0.5,0.5636364,0.4677419,0.5,0.5192308,

0.4642857,0.5090909,0.58,0.4482759,0.5098039,0.4035088,0.4210526,0.5098039,0.4385965,0.5283019,0.5471698,0.625,0.4310345,0.4912281,0.5283019,
0.4576271,0.5471698,0.4745763,0.4821429)

Yvar-c(0.2553191,0.4107143,0.5660377,0.389,0.3606557,0.2898551,0.3818182,0.4,0.4,0.3278689,0.2903226,0.4074074,0.4181818,0.3,0.2238806,0.3728814,

0.3709677,0.2307692,0.2830189,0.2244898,0.2142857,0.2131148,0.22,0.2258065,0.2321429,0.2,0.2264151,0.22,0.2115385,0.2459016,0.117,0.1785714,

0.2068966,0.6,0.4285714,0.3134328,0.4461538,0.3965517,0.4769231,0.6181818,0.4827586,0.3709677,0.3965517,0.4821429,0.4545455,0.359375,0.4576271,

0.4516129,0.5272727,0.4603175,0.4,0.4912281,0.5384615,0.5,0.4516129,0.4126984,0.4655172,0.5263158,0.4925373,0.358209,0.4285714,0.4920635,

0.4482759,0.3235294,0.4,0.4375,0.440678,0.3898305,0.35,0.4528302,0.58,0.4153846,0.3174603,0.5185185,0.3870968,0.2894737,0.3709677,0.369863,

0.3676471,0.3636364,0.3088235,0.328125,0.4032258,0.4084507,0.3188406,0.3636364,0.3823529,0.2816901,0.472,0.5,0.3521127,0.4393939,0.3787879,

0.453125,0.4324324,0.4057971,0.4545455,0.4492754,0.5,0.4098361,0.4067797,0.367,0.3928571,0.4285714,0.5,0.2923077,0.4561404,0.45,0.5538462,

0.4626866,0.4057971,0.3676471,0.5322581,0.5428571,0.375,0.4411765,0.4571429,0.4,0.3846154,0.3870968,0.4915254,0.530303,0.4375,0.4918033,0.4179104,

0.4032258,0.3606557,0.5178571,0.4848485,0.390625,0.375,0.4375,0.367,0.4,0.4477612,0.2571429,0.4032258,0.3382353,0.4814815,0.4090909,0.3548387,

0.4821429,0.5,0.557377,0.433,0.5454545,0.4590164,0.3943662,0.5076923,0.5,0.3283582,0.3676471,0.559322)

my.cor-cor(Xvar, Yvar)
print(my.cor)
 
nperm-4

Perm.Cor-NULL

for (iperm in 1:nperm)  {
XvarNew-sample(Xvar, size=length(Xvar), replace=FALSE)
YvarNew-sample(Yvar, size=length(Yvar), replace=FALSE) 
perm.cor-cor(XvarNew, YvarNew)

Perm.Cor-c(Perm.Cor, perm.cor)
}
print(max(Perm.Cor))
XvarSorted-sort(Xvar, decreasing=TRUE)
YvarSorted-sort(Yvar, decreasing=TRUE)
max.cor-cor(XvarSorted, YvarSorted)
print(max.cor)
if(mat.cor0) Perm.Cor.Sorted-sort(Perm.Cor, decreasing=TRUE)
if(mat.cor0) Perm.Cor.Sorted-sort(Perm.Cor, decreasing=FALSE)
T95-Perm.Cor.Sorted[(nperm+1)*0.05]# 95% treshold value

T99-Perm.Cor.Sorted[(nperm+1)*0.01]# 99% treshold value

 


I want to understand where I am making a mistake. Any comment is deeply 
appreciated.



Well, if you are permuting Xvar and Yvar separately or sorting them 
(separately), then you cannot expect to get the same correlation again. 
Look at the formula and make an example for yourself with just, say, 

Re: [R] search through a matrix

2009-04-21 Thread onyourmark

Thanks very much.

I don't really understand the row() function. I looked in the reference but
I don't really get it. It says:
Description
Returns a matrix of integers indicating their row number in a matrix-like
object, or a factor indicating the row labels. 

Usage
row(x, as.factor = FALSE)

Arguments
x a matrix-like object, that is one with a two-dimensional dim. 

I don't understand what row() does. 

And in the example in the documentation it says:
x - matrix(1:12, 3, 4)
# extract the diagonal of a matrix
dx - x[row(x) == col(x)]
dx
[1] 1 5 9

I thought the single square bracket notation accepts a pair separated by a
comma but I don't see how 
row(x)==col(x) produces that?

Thanks again.


onyourmark wrote:
 
 Hi. I have a 925 by 925 correlation matrix corM. I want to identify all
 variables that have correlation greater than 0.9.  Can anyone suggest an
 R way of doing this?
 
 Thank you.
 

-- 
View this message in context: 
http://www.nabble.com/search-through-a-matrix-tp23153538p23155104.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] search through a matrix

2009-04-21 Thread David Winsemius


On Apr 21, 2009, at 8:33 AM, onyourmark wrote:



Thanks very much.

I don't really understand the row() function. I looked in the  
reference but

I don't really get it. It says:
Description
Returns a matrix of integers indicating their row number in a matrix- 
like

object, or a factor indicating the row labels.

Usage
row(x, as.factor = FALSE)

Arguments
x a matrix-like object, that is one with a two-dimensional dim.

I don't understand what row() does.


It returns a matrix of the same size as its arguments populated with  
the row numbers instead of the matrix elements.



And in the example in the documentation it says:
x - matrix(1:12, 3, 4)


Now try row(x)



# extract the diagonal of a matrix
dx - x[row(x) == col(x)]
dx
[1] 1 5 9

I thought the single square bracket notation accepts a pair  
separated by a

comma but I don't see how
row(x)==col(x) produces that?


The single square bracket notation can be used as [r,c] or  without  
the comma which requires a logical index. In the second method the  
matrix entries get processed serially, column-wise.


 x - matrix(1:12, 3, 4)
 x[TRUE]
 [1]  1  2  3  4  5  6  7  8  9 10 11 12
 row(x)
 [,1] [,2] [,3] [,4]
[1,]1111
[2,]2222
[3,]3333

--
David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Help with R 2.9.0 and XML

2009-04-21 Thread Luis Orlindo Tedeschi
After I installed R 2.9.0 and XML package, I get an error This application
has failed to start because iconv.dll was not found. Re-installing the
application may fix this problem. I already re-installed both but the
problem persists. Does anyone know what is going on? Thanks.

-- 

___
Luís Orlindo Tedeschi
mailto:luis.tedes...@gmail.com
___

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] search through a matrix

2009-04-21 Thread Kushantha Perera
row() gives the row number of each element of the matrix, similarly
col() gives the column number. By definition, diagonal elements are the
elements correspond to same row and column numbers. That's how it
works...

x - matrix(1:12, 3, 4)
 x
 [,1] [,2] [,3] [,4]
[1,]   12963
[2,]   11852
[3,]   10741
 row(x)
 [,1] [,2] [,3] [,4]
[1,]1111
[2,]2222
[3,]3333
 col(x)
 [,1] [,2] [,3] [,4]
[1,]1234
[2,]1234
[3,]1234


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of onyourmark
Sent: Tuesday, April 21, 2009 6:03 PM
To: r-help@r-project.org
Subject: Re: [R] search through a matrix


Thanks very much.

I don't really understand the row() function. I looked in the reference
but
I don't really get it. It says:
Description
Returns a matrix of integers indicating their row number in a
matrix-like
object, or a factor indicating the row labels. 

Usage
row(x, as.factor = FALSE)

Arguments
x a matrix-like object, that is one with a two-dimensional dim. 

I don't understand what row() does. 

And in the example in the documentation it says:
x - matrix(1:12, 3, 4)
# extract the diagonal of a matrix
dx - x[row(x) == col(x)]
dx
[1] 1 5 9

I thought the single square bracket notation accepts a pair separated by
a
comma but I don't see how 
row(x)==col(x) produces that?

Thanks again.


onyourmark wrote:
 
 Hi. I have a 925 by 925 correlation matrix corM. I want to identify
all
 variables that have correlation greater than 0.9.  Can anyone suggest
an
 R way of doing this?
 
 Thank you.
 

-- 
View this message in context:
http://www.nabble.com/search-through-a-matrix-tp23153538p23155104.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
This e-mail may contain confidential and/or privileged i...{{dropped:10}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] search through a matrix

2009-04-21 Thread onyourmark

Hi again. Thanks. I get it now. 
So row(x) is a matrix with just the row number for each entry.

How about x[row(x) == col(x)] ?
Can the square bracket function take a matrix as its argument? If so, I
guess I understand this statement.
The argument is a boolean matrix.

Thank you.


David Winsemius wrote:
 
 
 On Apr 21, 2009, at 8:33 AM, onyourmark wrote:
 

 Thanks very much.

 I don't really understand the row() function. I looked in the  
 reference but
 I don't really get it. It says:
 Description
 Returns a matrix of integers indicating their row number in a matrix- 
 like
 object, or a factor indicating the row labels.

 Usage
 row(x, as.factor = FALSE)

 Arguments
 x a matrix-like object, that is one with a two-dimensional dim.

 I don't understand what row() does.
 
 It returns a matrix of the same size as its arguments populated with  
 the row numbers instead of the matrix elements.


 And in the example in the documentation it says:
 x - matrix(1:12, 3, 4)
 
 Now try row(x)
 

 # extract the diagonal of a matrix
 dx - x[row(x) == col(x)]
 dx
 [1] 1 5 9

 I thought the single square bracket notation accepts a pair  
 separated by a
 comma but I don't see how
 row(x)==col(x) produces that?
 
 The single square bracket notation can be used as [r,c] or  without  
 the comma which requires a logical index. In the second method the  
 matrix entries get processed serially, column-wise.
 
   x - matrix(1:12, 3, 4)
   x[TRUE]
   [1]  1  2  3  4  5  6  7  8  9 10 11 12
   row(x)
   [,1] [,2] [,3] [,4]
 [1,]1111
 [2,]2222
 [3,]3333
 
 -- 
 David Winsemius, MD
 Heritage Laboratories
 West Hartford, CT
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/search-through-a-matrix-tp23153538p23155615.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] bug when subtracting decimals?

2009-04-21 Thread Marc Schwartz

On Apr 21, 2009, at 5:55 AM, Duncan Murdoch wrote:


On 21/04/2009 3:48 AM, Petr PIKAL wrote:

Hi
r-help-boun...@r-project.org napsal dne 20.04.2009 19:01:46:

wolfgang.siewert wolfgang.siewert at gmail.com writes:


There is a way around: round(0.7-0.3,1)==0.4
(TRUE)

Obviously there is a problem with some combinations of decimal

subtractions,

that - we have the feeling - shouldt be solved.

Oh no, not that one again! This was lecture two in my first computer
course in 1968, but it seems to be gone the way of the dodo since  
than.
Maybe that is because of Excel is so widespread now and gives  
expected results (it probably silently rounds all decimal numbers  
before calculation).


I don't have Excel, but I expect OpenOffice duplicates its bugs  
pretty well.  And in OpenOffice I see all sorts of bugs due to this,  
e.g. examples where x = y and y = z but x != z, cases where I can  
calculate a number like 1 + 4.e-15 and get something different from  
1, but if I enter it directly as 1.004, it gets changed  
to 1.


So it only gives expected results in some tests, not others.

Duncan Murdoch




As Dieter noted from our offlist exchange, this had been discussed  
previously back in 2003. Just to refresh memories:


  https://stat.ethz.ch/pipermail/r-help/2003-June/034565.html

  https://stat.ethz.ch/pipermail/r-help/2003-June/034860.html


OO.org has replicated Excel's behavior to a fault.  Thus:

  Spreadsheet Use - Brain to Porridge


Just to update OO.org's behavior using version 3.0.1 on OSX:

  Formula: =4.145 * 100 + 0.5 Result: 415.

  Formula: =0.5 - 0.4 - 0.1   Result: 0.

  Formula: =(0.5 - 0.4 - 0.1) Result: 0.

So nothing has changed in OO.org in five years.  Somebody with Excel  
2007 might want to try the 2nd and 3rd formula examples to see if  
using parens still makes a difference in the result as compared to the  
formula without the parens.



FWIW, now that I am on OSX, I can add the following output using  
Numbers '09:


  Formula: =4.145 * 100 + 0.5 Result: 415.

  Formula: =0.5 - 0.4 - 0.1   Result: -2.77556E-17

  Formula: =(0.5 - 0.4 - 0.1) Result: -2.77556E-17


It does look like R's behavior has changed since then. Using:

  R version 2.9.0 Patched (2009-04-18 r48348)

on OSX:

# This first example has changed.
# Prior result was 414.94
 print(4.145 * 100 + 0.5, digits = 20)
[1] 415

 formatC(4.145 * 100 + 0.5, format = E, digits = 20)
[1] 4.14943157E+02

 print(0.5 - 0.4 - 0.1, digits = 20)
[1] -2.77555756156289e-17

 formatC(0.5 - 0.4 - 0.1, format = E, digits = 20)
[1] -2.77555756156289135106E-17


What is interesting is that:

 4.145 * 100 + 0.5 == 415
[1] FALSE

 (4.145 * 100 + 0.5) - 415
[1] -5.684342e-14

 all.equal(4.145 * 100 + 0.5, 415, 0)
[1] Mean relative difference: 1.369721e-16


So it would appear that in the first R example above, the print()  
function has changed in a material fashion.


HTH,

Marc Schwartz

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] automatic exploration of all possible loglinear models?

2009-04-21 Thread Frank E Harrell Jr

Dieter Menne wrote:

Christopher W. Ryan cryan at binghamton.edu writes:


Is there a way to automate fitting and assessing loglinear models for
several nominal variables . . . something akin to step or drop1 or add1
for linear or logistic regression?


Not strictly for loglinear, but glm works with stepAIC. Make sure that 
in the field you are working this approach is an accepted ritual.


Dieter



Dieter was kind.  I would say the following: Make sure your colleagues 
are interested in non-reproducible results, overfitting, incorrect 
P-values, and incorrect confidence limits before proceeding.


Frank


--
Frank E Harrell Jr   Professor and Chair   School of Medicine
 Department of Biostatistics   Vanderbilt University

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Matrix package,solve() errors and crashes

2009-04-21 Thread Martin Maechler
 SS == Surendar Swaminathan surendar.swaminat...@gmail.com
 on Mon, 20 Apr 2009 12:10:47 -0700 writes:

SS Hello All, I am working on graph object using IGRAPH
SS package wanted to do Bonacich Power.  This is my graph
SS object.

SS The file 'Graph.RData' (4.2 MB) is available for
SS download at
SS http://dropbox.unl.edu/uploads/20090424/cfe4fcb854bb17f2/Graph.RData

SS Graph size

SS Vertices: 20984 Edges: 326033 Directed: FALSE No graph
SS attributes.  Vertex attributes: name.  No edge
SS attributes.

SS When I use bonacich power it goes out of memory

SS Error in get.adjacency.dense(graph, type = type, attr =
SS attr, names = names, : At vector.pmt:409 : cannot
SS reserve space for vector, Out of memory

how much memory (RAM) has your computer?

I have tried in a few ways to reproduce your problem,
but have not got any errors, neither when using the 'test.g'
example you use below, nor by using  
bonpow.sparse(g)
where 'g' comes from your  'Graph.RData' file (you mention above).

But you have not provided (in your e-mail) a fully reproducible
example, so I am not sure how exactly you got the memory problem
(or even worse the crashes).

Regards,
Martin Maechler, ETH Zurich
(co-maintainer of 'Matrix').

SS I got help from IGRAPH community to use sparse Matrix

SS http://igraph.wikidot.com/r-recipes#toc6

SS bonpow.sparse - function(graph, nodes=V(graph),
SS loops=FALSE, exponent=1, rescale=FALSE, tol=1e-07) {

SS   ## remove loops if requested if (!loops) { graph -
SS simplify(graph, remove.multiple=FALSE,
SS remove.loops=TRUE) }

SS   ## sparse adjacency matrix d - get.adjacency(graph,
SS sparse=TRUE)

SS   ## sparse identity matrix id -
SS spMatrix(vcount(graph), vcount(graph),
SS i=1:vcount(graph), j=1:vcount(graph), x=rep(1,
SS vcount(graph))) id - as(id, dgCMatrix)

SS   ## solve it ev - solve(id - exponent * d, tol=tol)
SS %*% degree(graph, mode=out)

SS   if (rescale) { ev - ev/sum(ev) } else { ev - ev *
SS sqrt(vcount(graph)/sum((ev)^2)) }

SS   ev[as.numeric(nodes) + 1] }

SS ## test graph test.g - simplify(ba.game(1000,m=2))

SS ## test run system.time(bp1 - bonpow(test.g))
SS system.time(bp2 - bonpow.sparse(test.g))

SS ## check that they are the same max(abs(bp1-bp2)) I get
SS following error and sometime it crashes.

SS In solve(id - exponent * d, tol = tol) : Reached total
SS allocation of 1535Mb: see help(memory.size).I increased
SS the memory size and still it is not helpful

SS Help on this would be great.

SS These are steps I followed

SS 1. Created graph object using Igraph version 0.6 on R
SS 2.8.1 windows XP 2. Bonpow(g) 3. Bonpow.sparse function

SS sessionInfo()

SS R version 2.8.1 (2008-12-22) i386-pc-mingw32 locale:
SS LC_COLLATE=English_United
SS States.1252;LC_CTYPE=English_United
SS States.1252;LC_MONETARY=English_United
SS States.1252;LC_NUMERIC=C;LC_TIME=English_United
SS States.1252 attached base packages: [1] stats graphics
SS grDevices utils datasets methods base other attached
SS packages: [1] Matrix_0.999375-23 lattice_0.17-20
SS igraph_0.6 loaded via a namespace (and not attached):
SS [1] grid_2.8.1

SS Thanks in advance

SS Nathan

SS [[alternative HTML version deleted]]

SS __
SS R-help@r-project.org mailing list
SS https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do
SS read the posting guide
SS http://www.R-project.org/posting-guide.html and provide
SS commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] search through a matrix

2009-04-21 Thread Dimitri Liakhovitski
Just try to run x[row(x) == col(x)] .
You'll see it's a vector.
It's the same as diag(x)
Dimitri

On Tue, Apr 21, 2009 at 9:02 AM, onyourmark william...@gmail.com wrote:

 Hi again. Thanks. I get it now.
 So row(x) is a matrix with just the row number for each entry.

 How about x[row(x) == col(x)] ?
 Can the square bracket function take a matrix as its argument? If so, I
 guess I understand this statement.
 The argument is a boolean matrix.

 Thank you.


 David Winsemius wrote:


 On Apr 21, 2009, at 8:33 AM, onyourmark wrote:


 Thanks very much.

 I don't really understand the row() function. I looked in the
 reference but
 I don't really get it. It says:
 Description
 Returns a matrix of integers indicating their row number in a matrix-
 like
 object, or a factor indicating the row labels.

 Usage
 row(x, as.factor = FALSE)

 Arguments
 x a matrix-like object, that is one with a two-dimensional dim.

 I don't understand what row() does.

 It returns a matrix of the same size as its arguments populated with
 the row numbers instead of the matrix elements.


 And in the example in the documentation it says:
 x - matrix(1:12, 3, 4)

 Now try row(x)


 # extract the diagonal of a matrix
 dx - x[row(x) == col(x)]
 dx
 [1] 1 5 9

 I thought the single square bracket notation accepts a pair
 separated by a
 comma but I don't see how
 row(x)==col(x) produces that?

 The single square bracket notation can be used as [r,c] or  without
 the comma which requires a logical index. In the second method the
 matrix entries get processed serially, column-wise.

   x - matrix(1:12, 3, 4)
   x[TRUE]
   [1]  1  2  3  4  5  6  7  8  9 10 11 12
   row(x)
       [,1] [,2] [,3] [,4]
 [1,]    1    1    1    1
 [2,]    2    2    2    2
 [3,]    3    3    3    3

 --
 David Winsemius, MD
 Heritage Laboratories
 West Hartford, CT

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



 --
 View this message in context: 
 http://www.nabble.com/search-through-a-matrix-tp23153538p23155615.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




-- 
Dimitri Liakhovitski
MarketTools, Inc.
dimitri.liakhovit...@markettools.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] OT: Strange bootstrap approach to significance testing

2009-04-21 Thread Mike Lawrence
Hi all,

I'm reviewing a paper that employs a strange (to me) approach to a
non-parametric significance testing. I'm familiar with permutation
tests and bootstrapping confidence intervals around parameter
estimates, but here they seem to be bootstrapping CIs for a
manufactured Null F-value. They have a simple 3 groups between-Ss
design and compute the F-value of the observed data. Then, they
re-center each group's mean to zero then repeatedly: randomly resample
values from each group (with replacement, doubling each group's size)
and re-compute the F-value. The distribution of re-centered/resampled
F-values is then used as a reference distribution within which the
percentile of the observed F-value is computed. They determine that
the observed F-value is outside the 95% confidence interval of the
re-centered/resampled F-values and conclude a significant effect of
group.

In my head this makes some sense (though I'd think a straight
permutation test would be a lot simpler), but having never heard of
anything like this before I thought I'd see what others on this list
think of the approach.

Mike

-- 
Mike Lawrence
Graduate Student
Department of Psychology
Dalhousie University

Looking to arrange a meeting? Check my public calendar:
http://tr.im/mikes_public_calendar

~ Certainty is folly... I think. ~

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Package or packages for randomization in a clinical trial

2009-04-21 Thread Marc Schwartz

On Apr 21, 2009, at 5:12 AM, John Sorkin wrote:

Can anyone recommend a package that can be used to randomize  
subjects? I am looking for a generalized package, or several  
packages that can accomplish

unrestricted randomization (i.e. simple random assignment)
restricted randomization including stratified randomization, blocked  
randomization, and adaptive randomization.

Thanks,
John


John,

Take a look at the 'blockrand' and 'crossdes' packages on CRAN.

If you need something beyond those, it is not overly difficult to  
write functions in R to do this.


HTH,

Marc Schwartz

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] bug when subtracting decimals?

2009-04-21 Thread ivan valencia
try this

 0.3-0.1 == 0.2
[1] FALSE
 round(0.3-0.1,1)==round(0.2,1)
[1] TRUE

liov

2009/4/21 Marc Schwartz marc_schwa...@me.com

 On Apr 21, 2009, at 5:55 AM, Duncan Murdoch wrote:

  On 21/04/2009 3:48 AM, Petr PIKAL wrote:

 Hi
 r-help-boun...@r-project.org napsal dne 20.04.2009 19:01:46:

 wolfgang.siewert wolfgang.siewert at gmail.com writes:

  There is a way around: round(0.7-0.3,1)==0.4
 (TRUE)

 Obviously there is a problem with some combinations of decimal

 subtractions,

 that - we have the feeling - shouldt be solved.

 Oh no, not that one again! This was lecture two in my first computer
 course in 1968, but it seems to be gone the way of the dodo since than.

 Maybe that is because of Excel is so widespread now and gives expected
 results (it probably silently rounds all decimal numbers before
 calculation).


 I don't have Excel, but I expect OpenOffice duplicates its bugs pretty
 well.  And in OpenOffice I see all sorts of bugs due to this, e.g. examples
 where x = y and y = z but x != z, cases where I can calculate a number like
 1 + 4.e-15 and get something different from 1, but if I enter it directly as
 1.004, it gets changed to 1.

 So it only gives expected results in some tests, not others.

 Duncan Murdoch




 As Dieter noted from our offlist exchange, this had been discussed
 previously back in 2003. Just to refresh memories:

  https://stat.ethz.ch/pipermail/r-help/2003-June/034565.html

  https://stat.ethz.ch/pipermail/r-help/2003-June/034860.html


 OO.org has replicated Excel's behavior to a fault.  Thus:

  Spreadsheet Use - Brain to Porridge


 Just to update OO.org's behavior using version 3.0.1 on OSX:

  Formula: =4.145 * 100 + 0.5 Result: 415.

  Formula: =0.5 - 0.4 - 0.1   Result: 0.

  Formula: =(0.5 - 0.4 - 0.1) Result: 0.

 So nothing has changed in OO.org in five years.  Somebody with Excel 2007
 might want to try the 2nd and 3rd formula examples to see if using parens
 still makes a difference in the result as compared to the formula without
 the parens.


 FWIW, now that I am on OSX, I can add the following output using Numbers
 '09:

  Formula: =4.145 * 100 + 0.5 Result: 415.

  Formula: =0.5 - 0.4 - 0.1   Result: -2.77556E-17

  Formula: =(0.5 - 0.4 - 0.1) Result: -2.77556E-17


 It does look like R's behavior has changed since then. Using:

  R version 2.9.0 Patched (2009-04-18 r48348)

 on OSX:

 # This first example has changed.
 # Prior result was 414.94
  print(4.145 * 100 + 0.5, digits = 20)
 [1] 415

  formatC(4.145 * 100 + 0.5, format = E, digits = 20)
 [1] 4.14943157E+02

  print(0.5 - 0.4 - 0.1, digits = 20)
 [1] -2.77555756156289e-17

  formatC(0.5 - 0.4 - 0.1, format = E, digits = 20)
 [1] -2.77555756156289135106E-17


 What is interesting is that:

  4.145 * 100 + 0.5 == 415
 [1] FALSE

  (4.145 * 100 + 0.5) - 415
 [1] -5.684342e-14

  all.equal(4.145 * 100 + 0.5, 415, 0)
 [1] Mean relative difference: 1.369721e-16


 So it would appear that in the first R example above, the print() function
 has changed in a material fashion.

 HTH,

 Marc Schwartz


 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




-- 
Luis Iván Ortiz Valencia
Estatístico Msc.
...
Curriculum Lattes

http://buscatextual.cnpq.br/buscatextual/visualizacv.jsp?id=K4778724J3
...
http://oplanetaliov.blogspot.com/
...

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] search through a matrix

2009-04-21 Thread David Winsemius


On Apr 21, 2009, at 9:02 AM, onyourmark wrote:



Hi again. Thanks. I get it now.
So row(x) is a matrix with just the row number for each entry.


Yes.



How about x[row(x) == col(x)] ?
Can the square bracket function take a matrix as its argument? If  
so, I

guess I understand this statement.
The argument is a boolean matrix.


It can and it often does. The argument to the [] operation can be  
either a logical vector or a numeric vector which gets treated as an  
index. Try x[8]. My understanding is that the matrix, row(x) ==  
col(x), as an argument would first get coerced to a vector constructed  
from the column-wise projection of the matrix. You can read further on  
the help page in the section that discusses matrices and arrays:


?[




David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] ncdf,RNetCDF

2009-04-21 Thread Bala subramanian
Friends,

Someone please share your experience in installing ncdf and RNetCDF in
fedora10. I am not able make it work as it throws me the following error. My
R version is 2.8.0.

 library(ncdf)
  unable to load shared library '/usr/lib/R/library/ncdf/libs/ncdf.so':
  /usr/lib/R/library/ncdf/libs/ncdf.so: cannot restore segment prot after
reloc: Permission denied
Error in library(ncdf) : .First.lib failed for 'ncdf'

Thanks,
Bala

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] what is R best for? Evidence please.

2009-04-21 Thread John C Nash
Discussion about R capabilities seem to suggest that for optimization 
one may want to use some other software. As I've been working (with Ravi 
Varadhan mainly) to try to improve what is now called optim(), I needed 
to test some new methods, including a variant of CG. Coding only in R on 
a pretty vanilla 3Ghz PC, I was surprised that a generalized Rosenbrock 
function in n=5 parameters solved in less than 2 minutes. It seems a 
lot of my experiences in building routines that appear in optim() -- 
which were written on a machine with 8K (that's K) bytes for program AND 
data -- are really not valid any more. This has prompted us to try (and 
it not simple) to set up some infrastructure to get good (well, better?) 
measures of performance for optimization and nonlinear parameter 
estimation. Complications involve the variety of environments and 
configurations, as well as codings of test functions, choices of how to 
provide gradient information etc. Contact me off-line if you are 
interested in this, as we would like it to be relatively easy to use and 
share. That can come only by communication, and we want to have lots of 
real tests, and they take a fair bit of effort to set up in a 
standardized way.


However, the main message here is to ask, as I was reasonably asked by 
another R worker, that people be much more cautious with conjectures. We 
can and should check our opinions by measuring, no matter what tasks or 
tools, when we give advice.


JN

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Cross-Correlation function (CCF) issues

2009-04-21 Thread manta

??
-- 
View this message in context: 
http://www.nabble.com/Cross-Correlation-function-%28CCF%29-issues-tp23145411p23156769.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] automatic exploration of all possible loglinear models?

2009-04-21 Thread Ben Bolker



Dieter Menne wrote:
 
 Christopher W. Ryan cryan at binghamton.edu writes:
 
 
 Is there a way to automate fitting and assessing loglinear models for
 several nominal variables . . . something akin to step or drop1 or add1
 for linear or logistic regression?
 
 Not strictly for loglinear, but glm works with stepAIC. Make sure that 
 in the field you are working this approach is an accepted ritual.
 
 Dieter
 
 

There is also the package formerly known as dRedging:
http://r-forge.r-project.org/projects/mumin/


-- 
View this message in context: 
http://www.nabble.com/automatic-exploration-of-all-possible--loglinear-models--tp23141046p23156882.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] ncdf,RNetCDF

2009-04-21 Thread Andris Jankevics
Hi,

just quick googling gave me the hint that it can be ralated to SE
Linux restrictions of Fedora linux. Just try to disable SE Linux
feature.

http://www.appistry.com/community/forums/content/cannot-restore-segment-prot-after-reloc-permission-denied

Best regards,
-- 
Andris

subramanian bala.biophys...@gmail.com wrote:
 Friends,

 Someone please share your experience in installing ncdf and RNetCDF in
 fedora10. I am not able make it work as it throws me the following error. My
 R version is 2.8.0.

 library(ncdf)
  unable to load shared library '/usr/lib/R/library/ncdf/libs/ncdf.so':
  /usr/lib/R/library/ncdf/libs/ncdf.so: cannot restore segment prot after
 reloc: Permission denied
 Error in library(ncdf) : .First.lib failed for 'ncdf'

 Thanks,
 Bala

        [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] bug when subtracting decimals?

2009-04-21 Thread John C Nash
A quarter-century ago I was part of the IEEE 854 group that tried to 
suggest a
radix free arithmetic standard. One of the interests was decimal 
arithmetic. I actually
have owned 2 decimal arithmetic computers, a North Star Horizon (with 
decimal
hardware I had to build by hand from a kit) and a Radio Shack TRS80 
Model 100,
which used software BCD arithmetic. Interestingly, the same h/w for the 
TRS80 by

NEC used binary FP.

With the number of times the question of arithmetic coming up on this 
list, one wonders
if a decimal arithmetic version of R, or other software too, might not 
be worthwhile.
There are other issues that arise, of course, but binary floating point 
does upset folk
used to working in base 10, and the I/O conversions do make things look 
messy.


JN

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] broken example: lme() + multcomp() Tukey on repeated measures design

2009-04-21 Thread William Simpson
I am trying to do Tukey HSD comparisons on a repeated measures expt.
I found the following example on r-help and quoted approvingly elsewhere.
It is broken. Can anyone please tell me how to get it to work?

I am using R 2.4.1.

 require(MASS) ## for oats data set
 require(nlme) ## for lme()
 require(multcomp) ## for multiple comparison stuff
 Aov.mod - aov(Y ~ N + V + Error(B/V), data = oats)
 Lme.mod - lme(Y ~ N + V, random = ~1 | B/V, data = oats)
 summary(Aov.mod)
 anova(Lme.mod)
 summary(Lme.mod)
 summary(glht(Lme.mod, linfct=mcp(V=Tukey)))
Error in eval(expr, envir, enclos) : object Y not found
Error in factor_contrasts(model) : no 'model.matrix' method for 'model' found!

It all went ok until the last line, where the actual Tukey multiple
comparisons was requested.

Thanks very much for any help!

Bill

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] joined R-today

2009-04-21 Thread Peter Dalgaard
Bala subramanian wrote:
 Hi,
 I tried to install from four different mirrors. The result is the same. I
 dnt understand what the following error means.
 /usr/lib/R/library/ncdf/libs/ncdf.so: cannot restore segment prot after
 reloc: Permission denied
 Error in library(ncdf) : .First.lib failed for 'ncdf'
 
 I even tried to change the permission of ncdf.so but still i am not able to
 load the library.


Nothing to do with the download. I think SElinux is getting in your way
(so your unstated system could be RedHat Enterprise Linux?).

Contact your sysadm or google for the error message.

(One of the hits suggests that you might need to run

chcon -t texrel_shlib_t ncdf.so

but, well, no warranties...)

 
 Bala
 
 
 On Tue, Apr 21, 2009 at 2:03 PM, Dimitri Liakhovitski ld7...@gmail.comwrote:
 
 Try to install from scratch from a different mirror.
 Dimitri

 On Tue, Apr 21, 2009 at 6:21 AM, Bala subramanian
 bala.biophys...@gmail.com wrote:
 Hi,
 Yes ncdf needs netcdf, netcdf is already installed in my fedora10. I
 reinstalled ncdf with the following option
 install.packages('ncdf',dep=TRUE)
 library(ncdf) library(ncdf)
 Error in dyn.load(file, DLLpath = DLLpath, ...) :
  unable to load shared library '/usr/lib/R/library/ncdf/libs/ncdf.so':
  /usr/lib/R/library/ncdf/libs/ncdf.so: cannot restore segment prot after
 reloc: Permission denied
 Error in library(ncdf) : .First.lib failed for 'ncdf'

 Again the same error,
 Bala


 On Tue, Apr 21, 2009 at 12:12 PM, Liviu Andronic landronim...@gmail.com
 wrote:

 On Tue, Apr 21, 2009 at 11:57 AM, Bala subramanian
 bala.biophys...@gmail.com wrote:
 Dear Simon,
 I installed the ncdf package in the way you suggested but still i got
 the
 same error i got before. I haves pasted below the installation log and
 errors.

 Does ncdf depend on netcdf [1]? If so, perhaps it is missing, or is
 not up-to-date. Also, it's a good habit to install.packages('ncdf',
 dep=TRUE).
 Regards,
 Liviu

 [1] http://www.unidata.ucar.edu/software/netcdf/

[[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



 --
 Dimitri Liakhovitski
 MarketTools, Inc.
 dimitri.liakhovit...@markettools.com

 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45) 35327907

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] broken example: lme() + multcomp() Tukey on repeated measures design

2009-04-21 Thread Dieter Menne
William Simpson william.a.simpson at gmail.com writes:

 
 I am trying to do Tukey HSD comparisons on a repeated measures expt.
 I found the following example on r-help and quoted approvingly elsewhere.
 It is broken. Can anyone please tell me how to get it to work?
 


 I am using R 2.4.1. 

That's the problem. Not the R-Version, but the likelihood that the
multcomp package was not updated also, and lme definitively not
in early version.s



other attached packages:
[1] multcomp_1.0-7 mvtnorm_0.9-5  nlme_3.1-90MASS_7.2-46   


 glht(Lme.mod, linfct=mcp(V=Tukey))

 General Linear Hypotheses

Multiple Comparisons of Means: Tukey Contrasts


Linear Hypotheses:
  Estimate
Marvellous - Golden.rain == 05.292
Victory - Golden.rain == 0  -6.875
Victory - Marvellous == 0  -12.167



Dieter

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] broken example: lme() + multcomp() Tukey on repeated measures design

2009-04-21 Thread David Winsemius


On Apr 21, 2009, at 10:12 AM, William Simpson wrote:


I am trying to do Tukey HSD comparisons on a repeated measures expt.
I found the following example on r-help and quoted approvingly  
elsewhere.

It is broken. Can anyone please tell me how to get it to work?

I am using R 2.4.1.


How many years have you had that version without updating?




require(MASS) ## for oats data set
require(nlme) ## for lme()
require(multcomp) ## for multiple comparison stuff
Aov.mod - aov(Y ~ N + V + Error(B/V), data = oats)
Lme.mod - lme(Y ~ N + V, random = ~1 | B/V, data = oats)
summary(Aov.mod)
anova(Lme.mod)
summary(Lme.mod)
summary(glht(Lme.mod, linfct=mcp(V=Tukey)))

Error in eval(expr, envir, enclos) : object Y not found
Error in factor_contrasts(model) : no 'model.matrix' method for  
'model' found!


It is not broken when run in version 2.8.1.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] ncdf,RNetCDF

2009-04-21 Thread Bala subramanian
Hi Andris,

THANK YOU SO MUCH. THIS WAS THE PROBLEM INDEED. When disable SE Linux, it
worked fine.

Thank you once again,
Bala


On Tue, Apr 21, 2009 at 4:01 PM, Andris Jankevics an...@osi.lv wrote:

 Hi,

 just quick googling gave me the hint that it can be ralated to SE
 Linux restrictions of Fedora linux. Just try to disable SE Linux
 feature.


 http://www.appistry.com/community/forums/content/cannot-restore-segment-prot-after-reloc-permission-denied

 Best regards,
 --
 Andris

 subramanian bala.biophys...@gmail.com wrote:
  Friends,
 
  Someone please share your experience in installing ncdf and RNetCDF in
  fedora10. I am not able make it work as it throws me the following error.
 My
  R version is 2.8.0.
 
  library(ncdf)
   unable to load shared library '/usr/lib/R/library/ncdf/libs/ncdf.so':
   /usr/lib/R/library/ncdf/libs/ncdf.so: cannot restore segment prot after
  reloc: Permission denied
  Error in library(ncdf) : .First.lib failed for 'ncdf'
 
  Thanks,
  Bala
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Cross-Correlation function (CCF) issues

2009-04-21 Thread David Winsemius
Are you trying to imply that people should be able to answer a  
question that included no data? As others have pointed out, our powers  
of telepathy are generally less than commonly assumed.


On Apr 21, 2009, at 10:00 AM, manta wrote:



??
--
View this message in context: 
http://www.nabble.com/Cross-Correlation-function-%28CCF%29-issues-tp23145411p23156769.html
Sent from the R help mailing list archive at Nabble.com.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] ggplot2 - boxplot of variables / columns

2009-04-21 Thread Andreas Christoffersen
Hi,

ggplot/qplot is great - it has really helped me do some nice things.
However, simple boxplot of different columns/variables is a bit
tricky, because of (i think) qplot's generic Y conditional on X input
form. Se below.

# Some data:
a - rnorm(100)
b - rnorm(100,1,2)
c - rnorm(100,2,0.5)
# normal boxplot of a,b,c
boxplot(a,b,c) # Looks good
library(ggplot2) # loads qqplot2
# Tries do replicate the simple boxplot
qplot(a,b,c, geom=boxplot) # Not good
# Workaround
d - c(a,b,c)
e - c(rep(a,100),rep(b,100),rep(c,100))
qplot(e,d,geom=boxplot) # Works - but there must be a simpler way?

What is the simple to compare multiple variables like this?

thanks in advance

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] joined R-today

2009-04-21 Thread Marc Schwartz


On Apr 21, 2009, at 9:28 AM, Peter Dalgaard wrote:


Bala subramanian wrote:

Hi,
I tried to install from four different mirrors. The result is the  
same. I

dnt understand what the following error means.
/usr/lib/R/library/ncdf/libs/ncdf.so: cannot restore segment prot  
after

reloc: Permission denied
Error in library(ncdf) : .First.lib failed for 'ncdf'

I even tried to change the permission of ncdf.so but still i am not  
able to

load the library.



Nothing to do with the download. I think SElinux is getting in your  
way

(so your unstated system could be RedHat Enterprise Linux?).

Contact your sysadm or google for the error message.

(One of the hits suggests that you might need to run

chcon -t texrel_shlib_t ncdf.so

but, well, no warranties...)


The OP did indicate that F10 was the platform:

  
https://stat.ethz.ch/pipermail/r-help/attachments/20090421/65ee5d6e/attachment.pl

so I would agree here that SELinux is almost certainly the culprit as  
it does control relocation.


If you have the SE Troubleshoot daemon running, you should get a  
yellow star/badge symbol on one of your desktop dock panels.  
Typically, if you click on this, it will bring up a dialog window that  
will have some specific suggestions for resolving the problem. You can  
see some visual examples here:


  https://fedoraproject.org/wiki/Design/SETroubleshootUsabilityImprovements

More info on SETroubleshoot here:

  https://fedorahosted.org/setroubleshoot/

HTH,

Marc Schwartz

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] joined R-today

2009-04-21 Thread Bala subramanian
Dear Marc and Peter,

Thank you so much. In fact disabling  the SElinux solved the problem.

Bala

On Tue, Apr 21, 2009 at 4:43 PM, Marc Schwartz marc_schwa...@me.com wrote:


 On Apr 21, 2009, at 9:28 AM, Peter Dalgaard wrote:

  Bala subramanian wrote:

 Hi,
 I tried to install from four different mirrors. The result is the same. I
 dnt understand what the following error means.
 /usr/lib/R/library/ncdf/libs/ncdf.so: cannot restore segment prot after
 reloc: Permission denied
 Error in library(ncdf) : .First.lib failed for 'ncdf'

 I even tried to change the permission of ncdf.so but still i am not able
 to
 load the library.



 Nothing to do with the download. I think SElinux is getting in your way
 (so your unstated system could be RedHat Enterprise Linux?).

 Contact your sysadm or google for the error message.

 (One of the hits suggests that you might need to run

 chcon -t texrel_shlib_t ncdf.so

 but, well, no warranties...)


 The OP did indicate that F10 was the platform:


 https://stat.ethz.ch/pipermail/r-help/attachments/20090421/65ee5d6e/attachment.pl

 so I would agree here that SELinux is almost certainly the culprit as it
 does control relocation.

 If you have the SE Troubleshoot daemon running, you should get a yellow
 star/badge symbol on one of your desktop dock panels. Typically, if you
 click on this, it will bring up a dialog window that will have some specific
 suggestions for resolving the problem. You can see some visual examples
 here:

  https://fedoraproject.org/wiki/Design/SETroubleshootUsabilityImprovements

 More info on SETroubleshoot here:

  https://fedorahosted.org/setroubleshoot/

 HTH,

 Marc Schwartz



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Cross-Correlation function (CCF) issues

2009-04-21 Thread manta

Sorry, my bad, i did not mean to 'be mean'.
Here are the first five observations for three variables (dr1, dr2 and doil)

dr1
  1996-01-021996-01-031996-01-041996-01-051996-01-08 
 0.0005814396 -0.0023725000 -0.0072835915  0.0074536448 -0.0007004221 

dr2
   1996-01-031996-01-041996-01-051996-01-081996-01-09 
-0.0029539396 -0.0049110915  0.0147372363 -0.0081540669 -0.0003020745 

do1
1996-01-02 1996-01-03 1996-01-04 1996-01-05 1996-01-08 
  0.08   0.01   0.17  -0.03   0.00 

As you can see, dr2 is nothing but the 1st difference of dr1. In my case,
I'm trying to find out the cross-correlation between the two variables do1
and dr1 up to their 10th lag (i.e. do1 with do2, do3, ...,
do10,dr1,dr2,...,dr10, and the same for dr1).

Hope it helps,
Marco


David Winsemius wrote:
 
 Are you trying to imply that people should be able to answer a  
 question that included no data? As others have pointed out, our powers  
 of telepathy are generally less than commonly assumed.
 

-- 
View this message in context: 
http://www.nabble.com/Cross-Correlation-function-%28CCF%29-issues-tp23145411p23157961.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] plotting with R

2009-04-21 Thread Bala subramanian
Friends,

i) I am new to R. Kindly suggest some resources that has examples of
plotting with R.

ii) How to set number of tick marks and labels, i have a x axis ranging fro
1 to 21. By default R shows the tick marks at 5, 10,15,20. How can i change
this.

Thanks,
Bala

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Fitting linear models

2009-04-21 Thread Vemuri, Aparna
David,
Thanks for the suggestions. No, I did not label my dependent variable 
function.

My dependent variable PBW and all the independent variables are continuous 
variables. It is especially troubling since the order in which I input 
independent variables determines whether or not it gets a coefficient.  Like I 
already mentioned, I checked the correlation matrix and picked the variables 
with moderate to high correlation with the independent variable. . So I guess 
it is not so naïve to expect a regression coefficient on all of them.

Dimitri 
model1-lm(PBW~SO4+NO3+NH4), gives me the same result as before.

Bert:
 This is not homework. But I will remember to do my research before posting 
here.

Aparna 


-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net] 
Sent: Monday, April 20, 2009 5:35 PM
To: Vemuri, Aparna
Cc: r-help@r-project.org
Subject: Re: [R] Fitting linear models


On Apr 20, 2009, at 7:26 PM, Vemuri, Aparna wrote:

 I am not sure if this is an R-users question, but since most of you  
 here
 are statisticians, I decided to give it a shot.

You can omit the unnecessary preambles.


 I am using the lm() function in R to fit a dependent variable to a set
 of 3 to 5 independent variables. For this, I used the following
 commands:

 model1-lm(function=PBW~SO4+NO3+NH4)
 Coefficients:
 (Intercept)  SO4  NO3  NH4
0.01323  0.01968  0.01856   NA

 and

 model2-lm(function=PBW~SO4+NO3+NH4+Na+Cl)

 Coefficients:
 (Intercept)   SO4  NO3  NH4
 Na   Cl
 -0.0006987   -0.0119750   -0.02950420.08429890.1344751
 NA

 In both cases, the last independent variable has a coefficient of NA  
 in
 the result. I say last variable because, when I change the order of  
 the
 variables, the coefficient changes (see below). Can anyone point me to
 the reason R behaves this way?  Is there anyway for me to force R to  
 use
 all the variables? I checked the correlation matrices to makes sure
 there is no orthogonality between the variables.

You really did not name your dependent variable function did you?  
Please stop that.

Just a guess, ... since you have not provided enough information to do  
otherwise, ... Are all of those variables 1/0 dummy variables? If so  
and if you want to have an output that satisfies your need for  
labeling the coefficients as you naively anticipate, then put 0+ at  
the beginning of the formula or -1 at the end, so that the intercept  
will disappear and then all variables will get labeled as you expect.

-- 
David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] joined R-today

2009-04-21 Thread Marc Schwartz

Bala,

I would not advocate disabling SELinux entirely to resolve this issue.  
SELinux is one of the key security features of Fedora Linux and some  
other Linux distributions that have adopted it. It has already been  
demonstrated to be robust with respect to so-called zero-day attacks.


I would first look to take a more surgical approach to resolve this  
particular issue with this package. Using the SETroubleshoot daemon is  
the easiest way to accomplish this as it will provide specific  
instructions.


As with any security approach, there are trade-offs between security  
and usability, but SELinux as a mandatory access control system is  
well worthwhile keeping in place.


BTW, as a future reference, there is a r-sig-fedora list:

  https://stat.ethz.ch/mailman/listinfo/r-sig-fedora

HTH,

Marc


On Apr 21, 2009, at 9:56 AM, Bala subramanian wrote:


Dear Marc and Peter,

Thank you so much. In fact disabling  the SElinux solved the problem.

Bala

On Tue, Apr 21, 2009 at 4:43 PM, Marc Schwartz  
marc_schwa...@me.com wrote:


On Apr 21, 2009, at 9:28 AM, Peter Dalgaard wrote:

Bala subramanian wrote:
Hi,
I tried to install from four different mirrors. The result is the  
same. I

dnt understand what the following error means.
/usr/lib/R/library/ncdf/libs/ncdf.so: cannot restore segment prot  
after

reloc: Permission denied
Error in library(ncdf) : .First.lib failed for 'ncdf'

I even tried to change the permission of ncdf.so but still i am not  
able to

load the library.


Nothing to do with the download. I think SElinux is getting in your  
way

(so your unstated system could be RedHat Enterprise Linux?).

Contact your sysadm or google for the error message.

(One of the hits suggests that you might need to run

chcon -t texrel_shlib_t ncdf.so

but, well, no warranties...)

The OP did indicate that F10 was the platform:

 
https://stat.ethz.ch/pipermail/r-help/attachments/20090421/65ee5d6e/attachment.pl

so I would agree here that SELinux is almost certainly the culprit  
as it does control relocation.


If you have the SE Troubleshoot daemon running, you should get a  
yellow star/badge symbol on one of your desktop dock panels.  
Typically, if you click on this, it will bring up a dialog window  
that will have some specific suggestions for resolving the problem.  
You can see some visual examples here:


 https://fedoraproject.org/wiki/Design/SETroubleshootUsabilityImprovements

More info on SETroubleshoot here:

 https://fedorahosted.org/setroubleshoot/

HTH,

Marc Schwartz




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] ggplot2 - boxplot of variables / columns

2009-04-21 Thread David Winsemius


On Apr 21, 2009, at 10:42 AM, Andreas Christoffersen wrote:


Hi,

ggplot/qplot is great - it has really helped me do some nice things.
However, simple boxplot of different columns/variables is a bit
tricky, because of (i think) qplot's generic Y conditional on X input
form. Se below.

# Some data:
a - rnorm(100)
b - rnorm(100,1,2)
c - rnorm(100,2,0.5)
# normal boxplot of a,b,c
boxplot(a,b,c) # Looks good
library(ggplot2) # loads qqplot2
# Tries do replicate the simple boxplot
qplot(a,b,c, geom=boxplot) # Not good
# Workaround
d - c(a,b,c)
e - c(rep(a,100),rep(b,100),rep(c,100))
qplot(e,d,geom=boxplot) # Works - but there must be a simpler way?


qplot(ind, values, data=stack(data.frame(a,b,c)), geom=boxplot)

I first tried stack(list(a,b,c)) but did not get the expected results.  
If anyone wants to enlighten me on why, I would be happy to offer a  
rewrite of the stack help page that clarifies my inability to parse it  
correctly in its current incarnation.




What is the simple to compare multiple variables like this?


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] ggplot2 - boxplot of variables / columns

2009-04-21 Thread ONKELINX, Thierry
Dear Andreas,

melt() and cast() are nice tools for this kind of problems. They both
reside in the reshape package that automatic loaded when ggplot2 is.

a - rnorm(100)
b - rnorm(100,1,2)
c - rnorm(100,2,0.5)
ds - data.frame(a = a, b = b, c = c)
library(ggplot2) # loads qqplot2
ggplot(melt(ds), aes(x = variable, y = value)) + geom_boxplot()

HTH,

Thierry




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
thierry.onkel...@inbo.be 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
data.
~ John Tukey

-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Andreas Christoffersen
Verzonden: dinsdag 21 april 2009 16:42
Aan: r-help@r-project.org
Onderwerp: [R] ggplot2 - boxplot of variables / columns

Hi,

ggplot/qplot is great - it has really helped me do some nice things.
However, simple boxplot of different columns/variables is a bit
tricky, because of (i think) qplot's generic Y conditional on X input
form. Se below.

# Some data:
a - rnorm(100)
b - rnorm(100,1,2)
c - rnorm(100,2,0.5)
# normal boxplot of a,b,c
boxplot(a,b,c) # Looks good
library(ggplot2) # loads qqplot2
# Tries do replicate the simple boxplot
qplot(a,b,c, geom=boxplot) # Not good
# Workaround
d - c(a,b,c)
e - c(rep(a,100),rep(b,100),rep(c,100))
qplot(e,d,geom=boxplot) # Works - but there must be a simpler way?

What is the simple to compare multiple variables like this?

thanks in advance

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Cross-Correlation function (CCF) issues

2009-04-21 Thread David Winsemius
We still have an inadequate characterization of the data to answe the  
question ( as I remember it from yesterday). Missing, for example, is  
any information about lengths which would seem essential since (as I  
remember) you wantted to know why the result was so short. Why not put  
in a full working example with an extract of the data. Suggest you try  
using dput as a method of creating a working example. That way we (and  
the R interpreter) would get labels and class information.


--
David Winsemius

On Apr 21, 2009, at 10:56 AM, manta wrote:



Sorry, my bad, i did not mean to 'be mean'.
Here are the first five observations for three variables (dr1, dr2  
and doil)


dr1
 1996-01-021996-01-031996-01-041996-01-051996-01-08
0.0005814396 -0.0023725000 -0.0072835915  0.0074536448 -0.0007004221

dr2
  1996-01-031996-01-041996-01-051996-01-081996-01-09
-0.0029539396 -0.0049110915  0.0147372363 -0.0081540669 -0.0003020745

do1
1996-01-02 1996-01-03 1996-01-04 1996-01-05 1996-01-08
 0.08   0.01   0.17  -0.03   0.00

As you can see, dr2 is nothing but the 1st difference of dr1. In my  
case,
I'm trying to find out the cross-correlation between the two  
variables do1

and dr1 up to their 10th lag (i.e. do1 with do2, do3, ...,
do10,dr1,dr2,...,dr10, and the same for dr1).

Hope it helps,
Marco


David Winsemius wrote:


Are you trying to imply that people should be able to answer a
question that included no data? As others have pointed out, our  
powers

of telepathy are generally less than commonly assumed.



--
View this message in context: 
http://www.nabble.com/Cross-Correlation-function-%28CCF%29-issues-tp23145411p23157961.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] plotting with R

2009-04-21 Thread David Winsemius


On Apr 21, 2009, at 11:07 AM, Bala subramanian wrote:


Friends,

i) I am new to R. Kindly suggest some resources that has examples of
plotting with R.


http://addictedtor.free.fr/graphiques/
http://lmdvr.r-forge.r-project.org/figures/figures.html




ii) How to set number of tick marks and labels, i have a x axis  
ranging fro
1 to 21. By default R shows the tick marks at 5, 10,15,20. How can i  
change

this.


?axis

--

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Fitting linear models

2009-04-21 Thread Dimitri Liakhovitski
Aparna,

I should have been more explicit. Run ?lm . You'll see this:

lm(formula, data, subset, weights, na.action,
   method = qr, model = TRUE, x = FALSE, y = FALSE, qr = TRUE,
   singular.ok = TRUE, contrasts = NULL, offset, ...)

So, in addition to specifying the formula, you have to specify the
data frame in which you keep your variables. I assume they are in a
data frame? (unless for some reasons you keep all variables as
separate vectors).
So, after you wrote the formula, you have to indicate the name of the
data frame, for example MyData:

model1-lm(PBW~SO4+NO3+NH4, MyData)

Dimitri

On Tue, Apr 21, 2009 at 11:12 AM, Vemuri, Aparna avem...@epri.com wrote:
 David,
 Thanks for the suggestions. No, I did not label my dependent variable 
 function.

 My dependent variable PBW and all the independent variables are continuous 
 variables. It is especially troubling since the order in which I input 
 independent variables determines whether or not it gets a coefficient.  Like 
 I already mentioned, I checked the correlation matrix and picked the 
 variables with moderate to high correlation with the independent variable. . 
 So I guess it is not so naïve to expect a regression coefficient on all of 
 them.

 Dimitri
 model1-lm(PBW~SO4+NO3+NH4), gives me the same result as before.

 Bert:
  This is not homework. But I will remember to do my research before posting 
 here.

 Aparna


 -Original Message-
 From: David Winsemius [mailto:dwinsem...@comcast.net]
 Sent: Monday, April 20, 2009 5:35 PM
 To: Vemuri, Aparna
 Cc: r-help@r-project.org
 Subject: Re: [R] Fitting linear models


 On Apr 20, 2009, at 7:26 PM, Vemuri, Aparna wrote:

 I am not sure if this is an R-users question, but since most of you
 here
 are statisticians, I decided to give it a shot.

 You can omit the unnecessary preambles.


 I am using the lm() function in R to fit a dependent variable to a set
 of 3 to 5 independent variables. For this, I used the following
 commands:

 model1-lm(function=PBW~SO4+NO3+NH4)
 Coefficients:
 (Intercept)          SO4          NO3      NH4
    0.01323      0.01968      0.01856           NA

 and

 model2-lm(function=PBW~SO4+NO3+NH4+Na+Cl)

 Coefficients:
 (Intercept)               SO4                  NO3      NH4
 Na       Cl
 -0.0006987   -0.0119750   -0.0295042    0.0842989    0.1344751
 NA

 In both cases, the last independent variable has a coefficient of NA
 in
 the result. I say last variable because, when I change the order of
 the
 variables, the coefficient changes (see below). Can anyone point me to
 the reason R behaves this way?  Is there anyway for me to force R to
 use
 all the variables? I checked the correlation matrices to makes sure
 there is no orthogonality between the variables.

 You really did not name your dependent variable function did you?
 Please stop that.

 Just a guess, ... since you have not provided enough information to do
 otherwise, ... Are all of those variables 1/0 dummy variables? If so
 and if you want to have an output that satisfies your need for
 labeling the coefficients as you naively anticipate, then put 0+ at
 the beginning of the formula or -1 at the end, so that the intercept
 will disappear and then all variables will get labeled as you expect.

 --
 David Winsemius, MD
 Heritage Laboratories
 West Hartford, CT

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




-- 
Dimitri Liakhovitski
MarketTools, Inc.
dimitri.liakhovit...@markettools.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Fitting linear models

2009-04-21 Thread Vemuri, Aparna
The variables are all in separate vectors. 

-Original Message-
From: Dimitri Liakhovitski [mailto:ld7...@gmail.com] 
Sent: Tuesday, April 21, 2009 8:26 AM
To: Vemuri, Aparna
Cc: David Winsemius; r-help@r-project.org
Subject: Re: [R] Fitting linear models

Aparna,

I should have been more explicit. Run ?lm . You'll see this:

lm(formula, data, subset, weights, na.action,
   method = qr, model = TRUE, x = FALSE, y = FALSE, qr = TRUE,
   singular.ok = TRUE, contrasts = NULL, offset, ...)

So, in addition to specifying the formula, you have to specify the
data frame in which you keep your variables. I assume they are in a
data frame? (unless for some reasons you keep all variables as
separate vectors).
So, after you wrote the formula, you have to indicate the name of the
data frame, for example MyData:

model1-lm(PBW~SO4+NO3+NH4, MyData)

Dimitri

On Tue, Apr 21, 2009 at 11:12 AM, Vemuri, Aparna avem...@epri.com wrote:
 David,
 Thanks for the suggestions. No, I did not label my dependent variable 
 function.

 My dependent variable PBW and all the independent variables are continuous 
 variables. It is especially troubling since the order in which I input 
 independent variables determines whether or not it gets a coefficient.  Like 
 I already mentioned, I checked the correlation matrix and picked the 
 variables with moderate to high correlation with the independent variable. . 
 So I guess it is not so naïve to expect a regression coefficient on all of 
 them.

 Dimitri
 model1-lm(PBW~SO4+NO3+NH4), gives me the same result as before.

 Bert:
  This is not homework. But I will remember to do my research before posting 
 here.

 Aparna


 -Original Message-
 From: David Winsemius [mailto:dwinsem...@comcast.net]
 Sent: Monday, April 20, 2009 5:35 PM
 To: Vemuri, Aparna
 Cc: r-help@r-project.org
 Subject: Re: [R] Fitting linear models


 On Apr 20, 2009, at 7:26 PM, Vemuri, Aparna wrote:

 I am not sure if this is an R-users question, but since most of you
 here
 are statisticians, I decided to give it a shot.

 You can omit the unnecessary preambles.


 I am using the lm() function in R to fit a dependent variable to a set
 of 3 to 5 independent variables. For this, I used the following
 commands:

 model1-lm(function=PBW~SO4+NO3+NH4)
 Coefficients:
 (Intercept)          SO4          NO3      NH4
    0.01323      0.01968      0.01856           NA

 and

 model2-lm(function=PBW~SO4+NO3+NH4+Na+Cl)

 Coefficients:
 (Intercept)               SO4                  NO3      NH4
 Na       Cl
 -0.0006987   -0.0119750   -0.0295042    0.0842989    0.1344751
 NA

 In both cases, the last independent variable has a coefficient of NA
 in
 the result. I say last variable because, when I change the order of
 the
 variables, the coefficient changes (see below). Can anyone point me to
 the reason R behaves this way?  Is there anyway for me to force R to
 use
 all the variables? I checked the correlation matrices to makes sure
 there is no orthogonality between the variables.

 You really did not name your dependent variable function did you?
 Please stop that.

 Just a guess, ... since you have not provided enough information to do
 otherwise, ... Are all of those variables 1/0 dummy variables? If so
 and if you want to have an output that satisfies your need for
 labeling the coefficients as you naively anticipate, then put 0+ at
 the beginning of the formula or -1 at the end, so that the intercept
 will disappear and then all variables will get labeled as you expect.

 --
 David Winsemius, MD
 Heritage Laboratories
 West Hartford, CT

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




-- 
Dimitri Liakhovitski
MarketTools, Inc.
dimitri.liakhovit...@markettools.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] plotting with R

2009-04-21 Thread Stephen J. Barr
Lookup the R graph gallery. Also, any R tutorial should have some rudimentary 
plots.

Type
?plot
Into the prompt to get help with the command.

-stephen
Sent via BlackBerry from T-Mobile

-Original Message-
From: Bala subramanian bala.biophys...@gmail.com

Date: Tue, 21 Apr 2009 17:07:24 
To: r-help@r-project.org
Subject: [R] plotting with R


Friends,

i) I am new to R. Kindly suggest some resources that has examples of
plotting with R.

ii) How to set number of tick marks and labels, i have a x axis ranging fro
1 to 21. By default R shows the tick marks at 5, 10,15,20. How can i change
this.

Thanks,
Bala

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Fitting linear models

2009-04-21 Thread Dimitri Liakhovitski
Are they of the same length?

On Tue, Apr 21, 2009 at 11:31 AM, Vemuri, Aparna avem...@epri.com wrote:
 The variables are all in separate vectors.

 -Original Message-
 From: Dimitri Liakhovitski [mailto:ld7...@gmail.com]
 Sent: Tuesday, April 21, 2009 8:26 AM
 To: Vemuri, Aparna
 Cc: David Winsemius; r-help@r-project.org
 Subject: Re: [R] Fitting linear models

 Aparna,

 I should have been more explicit. Run ?lm . You'll see this:

 lm(formula, data, subset, weights, na.action,
   method = qr, model = TRUE, x = FALSE, y = FALSE, qr = TRUE,
   singular.ok = TRUE, contrasts = NULL, offset, ...)

 So, in addition to specifying the formula, you have to specify the
 data frame in which you keep your variables. I assume they are in a
 data frame? (unless for some reasons you keep all variables as
 separate vectors).
 So, after you wrote the formula, you have to indicate the name of the
 data frame, for example MyData:

 model1-lm(PBW~SO4+NO3+NH4, MyData)

 Dimitri

 On Tue, Apr 21, 2009 at 11:12 AM, Vemuri, Aparna avem...@epri.com wrote:
 David,
 Thanks for the suggestions. No, I did not label my dependent variable 
 function.

 My dependent variable PBW and all the independent variables are continuous 
 variables. It is especially troubling since the order in which I input 
 independent variables determines whether or not it gets a coefficient.  Like 
 I already mentioned, I checked the correlation matrix and picked the 
 variables with moderate to high correlation with the independent variable. . 
 So I guess it is not so naïve to expect a regression coefficient on all of 
 them.

 Dimitri
 model1-lm(PBW~SO4+NO3+NH4), gives me the same result as before.

 Bert:
  This is not homework. But I will remember to do my research before posting 
 here.

 Aparna


 -Original Message-
 From: David Winsemius [mailto:dwinsem...@comcast.net]
 Sent: Monday, April 20, 2009 5:35 PM
 To: Vemuri, Aparna
 Cc: r-help@r-project.org
 Subject: Re: [R] Fitting linear models


 On Apr 20, 2009, at 7:26 PM, Vemuri, Aparna wrote:

 I am not sure if this is an R-users question, but since most of you
 here
 are statisticians, I decided to give it a shot.

 You can omit the unnecessary preambles.


 I am using the lm() function in R to fit a dependent variable to a set
 of 3 to 5 independent variables. For this, I used the following
 commands:

 model1-lm(function=PBW~SO4+NO3+NH4)
 Coefficients:
 (Intercept)          SO4          NO3      NH4
    0.01323      0.01968      0.01856           NA

 and

 model2-lm(function=PBW~SO4+NO3+NH4+Na+Cl)

 Coefficients:
 (Intercept)               SO4                  NO3      NH4
 Na       Cl
 -0.0006987   -0.0119750   -0.0295042    0.0842989    0.1344751
 NA

 In both cases, the last independent variable has a coefficient of NA
 in
 the result. I say last variable because, when I change the order of
 the
 variables, the coefficient changes (see below). Can anyone point me to
 the reason R behaves this way?  Is there anyway for me to force R to
 use
 all the variables? I checked the correlation matrices to makes sure
 there is no orthogonality between the variables.

 You really did not name your dependent variable function did you?
 Please stop that.

 Just a guess, ... since you have not provided enough information to do
 otherwise, ... Are all of those variables 1/0 dummy variables? If so
 and if you want to have an output that satisfies your need for
 labeling the coefficients as you naively anticipate, then put 0+ at
 the beginning of the formula or -1 at the end, so that the intercept
 will disappear and then all variables will get labeled as you expect.

 --
 David Winsemius, MD
 Heritage Laboratories
 West Hartford, CT

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




 --
 Dimitri Liakhovitski
 MarketTools, Inc.
 dimitri.liakhovit...@markettools.com




-- 
Dimitri Liakhovitski
MarketTools, Inc.
dimitri.liakhovit...@markettools.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Fitting linear models

2009-04-21 Thread Vemuri, Aparna
Yes, they are all of the same length.

-Original Message-
From: Dimitri Liakhovitski [mailto:ld7...@gmail.com] 
Sent: Tuesday, April 21, 2009 8:32 AM
To: Vemuri, Aparna
Cc: r-help@r-project.org
Subject: Re: [R] Fitting linear models

Are they of the same length?

On Tue, Apr 21, 2009 at 11:31 AM, Vemuri, Aparna avem...@epri.com wrote:
 The variables are all in separate vectors.

 -Original Message-
 From: Dimitri Liakhovitski [mailto:ld7...@gmail.com]
 Sent: Tuesday, April 21, 2009 8:26 AM
 To: Vemuri, Aparna
 Cc: David Winsemius; r-help@r-project.org
 Subject: Re: [R] Fitting linear models

 Aparna,

 I should have been more explicit. Run ?lm . You'll see this:

 lm(formula, data, subset, weights, na.action,
   method = qr, model = TRUE, x = FALSE, y = FALSE, qr = TRUE,
   singular.ok = TRUE, contrasts = NULL, offset, ...)

 So, in addition to specifying the formula, you have to specify the
 data frame in which you keep your variables. I assume they are in a
 data frame? (unless for some reasons you keep all variables as
 separate vectors).
 So, after you wrote the formula, you have to indicate the name of the
 data frame, for example MyData:

 model1-lm(PBW~SO4+NO3+NH4, MyData)

 Dimitri

 On Tue, Apr 21, 2009 at 11:12 AM, Vemuri, Aparna avem...@epri.com wrote:
 David,
 Thanks for the suggestions. No, I did not label my dependent variable 
 function.

 My dependent variable PBW and all the independent variables are continuous 
 variables. It is especially troubling since the order in which I input 
 independent variables determines whether or not it gets a coefficient.  Like 
 I already mentioned, I checked the correlation matrix and picked the 
 variables with moderate to high correlation with the independent variable. . 
 So I guess it is not so naïve to expect a regression coefficient on all of 
 them.

 Dimitri
 model1-lm(PBW~SO4+NO3+NH4), gives me the same result as before.

 Bert:
  This is not homework. But I will remember to do my research before posting 
 here.

 Aparna


 -Original Message-
 From: David Winsemius [mailto:dwinsem...@comcast.net]
 Sent: Monday, April 20, 2009 5:35 PM
 To: Vemuri, Aparna
 Cc: r-help@r-project.org
 Subject: Re: [R] Fitting linear models


 On Apr 20, 2009, at 7:26 PM, Vemuri, Aparna wrote:

 I am not sure if this is an R-users question, but since most of you
 here
 are statisticians, I decided to give it a shot.

 You can omit the unnecessary preambles.


 I am using the lm() function in R to fit a dependent variable to a set
 of 3 to 5 independent variables. For this, I used the following
 commands:

 model1-lm(function=PBW~SO4+NO3+NH4)
 Coefficients:
 (Intercept)          SO4          NO3      NH4
    0.01323      0.01968      0.01856           NA

 and

 model2-lm(function=PBW~SO4+NO3+NH4+Na+Cl)

 Coefficients:
 (Intercept)               SO4                  NO3      NH4
 Na       Cl
 -0.0006987   -0.0119750   -0.0295042    0.0842989    0.1344751
 NA

 In both cases, the last independent variable has a coefficient of NA
 in
 the result. I say last variable because, when I change the order of
 the
 variables, the coefficient changes (see below). Can anyone point me to
 the reason R behaves this way?  Is there anyway for me to force R to
 use
 all the variables? I checked the correlation matrices to makes sure
 there is no orthogonality between the variables.

 You really did not name your dependent variable function did you?
 Please stop that.

 Just a guess, ... since you have not provided enough information to do
 otherwise, ... Are all of those variables 1/0 dummy variables? If so
 and if you want to have an output that satisfies your need for
 labeling the coefficients as you naively anticipate, then put 0+ at
 the beginning of the formula or -1 at the end, so that the intercept
 will disappear and then all variables will get labeled as you expect.

 --
 David Winsemius, MD
 Heritage Laboratories
 West Hartford, CT

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




 --
 Dimitri Liakhovitski
 MarketTools, Inc.
 dimitri.liakhovit...@markettools.com




-- 
Dimitri Liakhovitski
MarketTools, Inc.
dimitri.liakhovit...@markettools.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Fitting linear models

2009-04-21 Thread David Winsemius


On Apr 21, 2009, at 11:12 AM, Vemuri, Aparna wrote:


David,
Thanks for the suggestions. No, I did not label my dependent  
variable function.


That was from my error in reading your call to lm. In my defense I am  
reasonably sure the proper assignment to arguments is lm(formula= ...)  
rather than lm(function= ...).



My dependent variable PBW and all the independent variables are  
continuous variables. It is especially troubling since the order in  
which I input independent variables determines whether or not it  
gets a coefficient.  Like I already mentioned, I checked the  
correlation matrix and picked the variables with moderate to high  
correlation with the independent variable. . So I guess it is not so  
naïve to expect a regression coefficient on all of them.


Dimitri
model1-lm(PBW~SO4+NO3+NH4), gives me the same result as before.


Did you get the expected results with;
model1-lm(formula=PBW~SO4+NO3+NH4+0)

You could, of course, provide either the data or the results of str()  
applied to each of the variables and then we could all stop guessing.




Aparna




I am using the lm() function in R to fit a dependent variable to a  
set

of 3 to 5 independent variables. For this, I used the following
commands:


model1-lm(function=PBW~SO4+NO3+NH4)

Coefficients:
(Intercept)  SO4  NO3  NH4
  0.01323  0.01968  0.01856   NA

and


model2-lm(function=PBW~SO4+NO3+NH4+Na+Cl)


Coefficients:
(Intercept) SO4  NO3  NH4
Na   Cl
-0.0006987   -0.0119750   -0.02950420.08429890.1344751
NA

In both cases, the last independent variable has a coefficient of NA
in
the result. I say last variable because, when I change the order of
the
variables, the coefficient changes (see below). Can anyone point me  
to

the reason R behaves this way?  Is there anyway for me to force R to
use
all the variables? I checked the correlation matrices to makes sure
there is no orthogonality between the variables.


You really did not name your dependent variable function did you?
Please stop that.

Just a guess, ... since you have not provided enough information to do
otherwise, ... Are all of those variables 1/0 dummy variables? If so
and if you want to have an output that satisfies your need for
labeling the coefficients as you naively anticipate, then put 0+ at
the beginning of the formula or -1 at the end, so that the intercept
will disappear and then all variables will get labeled as you expect.

--
David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] My surprising experience in trying out REvolution's R

2009-04-21 Thread Jason Liao
 

I care a lot about R's speed. So I decided to give REvolution's R
(http://revolution-computing.com/) a try, which bills itself as an
optimized R. Note that I used the free version.

My machine is a Intel core 2 duo under Windows XP professional. The code
I run is in the end of this post.

First, the regular R 1.9. It takes 2 minutes and 6 seconds, CPU usage
50%

Next, REvolution's R. It takes 2 minutes and 10 seconds, CPU usage 100%.


In other words, REvolution's R consumes double the CPU with slightly
less speed.

The above has been replicated a few times (as a statistician of course).


Anyone has any insight on this? Anyway, my high hope was dashed.

 

  rm(list=ls(all=TRUE))

  library(MASS);

 

 ###small and common functions##

  glmm.sample.y - function(b, D.u, x, z)

  {

pp - matrix(0, nrow = n, ncol = m);

zero - numeric(n.random);

 

ran - t( mvrnorm(m, zero, D.u) );

for(j in 1:m) pp[, j] - as.vector( x[, , j] %*% b + z[, , j] %*%
ran[ ,j] );

 

pp - exp(pp)/( 1+exp(pp) );

 

y - runif(m*n);

ifelse(ypp, 1, 0);

  }

 

  #

   quadratic.form - function(A, x) { return( as.vector(x %*% A %*% x) )
}

 

   quadratic.form2 - function(A, x)

   {

  x - chol(A) %*% x;

  colSums(x*x)

}

 

 ###



  REML.b.D.u - function(b, D.u, x, y, z, n.iter)

  {

 u.mean.initial - array( 0, c(n.random, m) );



 TT - matrix(0, n.random, n.random);

 for(i in 1:n.iter)

 {

TT - TT*(1-1/i) + bias(b, D.u, x, z)/i;



obj - sample.u(b, D.u, x, y, z, u.mean.initial);

b - b - solve(obj$Hessian, obj$score);

D.u - obj$uu + TT;



u.mean.initial - obj$u.mean.initial;



print(i); print(date());

print(inside REML); print(TT);

if(i==n.iter)  write(TT, file=c:/liao/reml/simu50_8.dat,
append=T);

print(D.u);

 }

  list(b=b, D.u=D.u);

  }



   bias - function(b, D.u, x, z)

   {

  yy - glmm.sample.y(b, D.u, x, z);  #this is the sampling stage



  obj1 - mle(b, D.u, x, yy, z, F, F, n.iter=50);

  obj2 - mle(b, D.u, x, yy, z, T, F, n.iter=50);



  obj1$uu - obj2$uu

}



   ##

   mle - function(b, D.u, x, y, z, indx1, indx2, n.iter)

   {

  u.mean.initial - array( 0, c(n.random, m) );



  for(i in 1:n.iter)

  {

obj - sample.u(b, D.u, x, y, z, u.mean.initial);

if(indx1) b - b - solve(obj$Hessian, obj$score);

if(indx2) D.u - obj$uu;



u.mean.initial - obj$u.mean.initial;

  }

  list(b=b, D.u=D.u, uu=obj$uu, u.mean.initial=u.mean.initial);

 }



##

   sample.u - function(b, D.u, x, y, z, u.mean.initial)

   {

 D.u.inv - solve(D.u);



 uu - matrix(0, n.random, n.random);

 score - numeric(n.fixed);

 Hessian - matrix(0, n.fixed, n.fixed);



 for(i in 1:m)

 {

   ada.part - as.vector(x[, , i] %*% b);

   obj -  sample.u.one( D.u.inv, ada.part, x[, , i], y[, i], z[,
,i], u.mean.initial[, i] );



   uu - uu + obj$uu;

   score - score + obj$score;

   Hessian - Hessian + obj$Hessian;



   u.mean.initial[, i] - obj$u.mean.initial;

 }



 uu - uu/m;

 list(uu=uu, score=score, Hessian=Hessian,
u.mean.initial=u.mean.initial);

  }

 ##

   sample.u.one - function(D.u.inv, ada.part, x, y, z, u.mean.initial)
#ada.part, x, y, z for one subject only

   {

  fn - log.like(y, z, D.u.inv, ada.part);

  obj - optim(u.mean.initial, fn, control=list(fnscale=-1), hessian
= T)

  u.mean.initial - obj$par;



  var.root - solve(-obj$hessian);

  var.root - t( chol(var.root) );



  u - matrix( rnorm(n.random*n.simu), nrow=n.random, ncol=n.simu );

  log.prob1 - -colSums(u*u)/2;



  u - u.mean.initial + var.root %*% u;



  ada - exp( ada.part + z %*% u );

  ada - ada/(1+ada); #it is probability now



  log.prob2 - colSums( y*log(ada) + (1-y)*log(1-ada) );

  log.prob2 - -quadratic.form2(D.u.inv, u)/2 + log.prob2;



  weight - exp(log.prob2 - log.prob1);

  weight - weight/sum(weight);



  ada - t(ada);

  pi - colSums(ada*weight);

  product - colSums( ada*(1-ada)*weight );



  score - as.vector( (y - pi) %*% x );

  Hessian - -t(x) %*% ( rep(product, n.fixed)*x );



  obj - cov.wt( t(u), weight, center=T );

  uu - obj$cov + obj$center %*% t(obj$center);



  list(uu=uu, score=score, Hessian=Hessian,
u.mean.initial=obj$center);

}



  #



  log.like - function(y, z, D.u.inv, ada.part)

  {

 function(u)

 {

ada - exp( ada.part + z %*% u );

ada - ada/(1+ada);

sum( y*log(ada) + (1-y)*log(1-ada) ) -quadratic.form(D.u.inv,
u)/2;

 

Re: [R] ggplot2 - boxplot of variables / columns

2009-04-21 Thread Andreas Christoffersen
David, you solution
 qplot(ind, values, data=stack(data.frame(a,b,c)), geom=boxplot)
Works a treat - thank you!

Thierry, your solution
 ds - data.frame(a = a, b = b, c = c)
 library(ggplot2) # loads qqplot2
 ggplot(melt(ds), aes(x = variable, y = value)) + geom_boxplot()
Also works.

I can even combine the two solutions, using stack / melt interchangeably.

I am very glad that today I both learned melt/stack and Thierry has
made me curious as to the finer ggplots fine tuning wizardry in ggplot
vs. the simple qplot.

Again - thx.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Fitting linear models

2009-04-21 Thread Vemuri, Aparna
Attached are the first hundred rows of my data in comma separated format.   
Forcing the regression line through the origin, still does not give a 
coefficient on the last independent variable. Also, I don't mind if there is a 
coefficient on the dependent axis. I just want all of the variables to have 
coefficients in the regression equation or a at least a consistent result, 
irrespective of the order of input information.

-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net] 
Sent: Tuesday, April 21, 2009 8:38 AM
To: Vemuri, Aparna
Cc: r-help@r-project.org
Subject: Re: [R] Fitting linear models


On Apr 21, 2009, at 11:12 AM, Vemuri, Aparna wrote:

 David,
 Thanks for the suggestions. No, I did not label my dependent  
 variable function.

That was from my error in reading your call to lm. In my defense I am  
reasonably sure the proper assignment to arguments is lm(formula= ...)  
rather than lm(function= ...).


 My dependent variable PBW and all the independent variables are  
 continuous variables. It is especially troubling since the order in  
 which I input independent variables determines whether or not it  
 gets a coefficient.  Like I already mentioned, I checked the  
 correlation matrix and picked the variables with moderate to high  
 correlation with the independent variable. . So I guess it is not so  
 naïve to expect a regression coefficient on all of them.

 Dimitri
 model1-lm(PBW~SO4+NO3+NH4), gives me the same result as before.

Did you get the expected results with;
model1-lm(formula=PBW~SO4+NO3+NH4+0)

You could, of course, provide either the data or the results of str()  
applied to each of the variables and then we could all stop guessing.


 Aparna



 I am using the lm() function in R to fit a dependent variable to a  
 set
 of 3 to 5 independent variables. For this, I used the following
 commands:

 model1-lm(function=PBW~SO4+NO3+NH4)
 Coefficients:
 (Intercept)  SO4  NO3  NH4
   0.01323  0.01968  0.01856   NA

 and

 model2-lm(function=PBW~SO4+NO3+NH4+Na+Cl)

 Coefficients:
 (Intercept)  SO4  NO3  NH4
 Na   Cl
 -0.0006987   -0.0119750   -0.02950420.08429890.1344751
 NA

 In both cases, the last independent variable has a coefficient of NA
 in
 the result. I say last variable because, when I change the order of
 the
 variables, the coefficient changes (see below). Can anyone point me  
 to
 the reason R behaves this way?  Is there anyway for me to force R to
 use
 all the variables? I checked the correlation matrices to makes sure
 there is no orthogonality between the variables.

 You really did not name your dependent variable function did you?
 Please stop that.

 Just a guess, ... since you have not provided enough information to do
 otherwise, ... Are all of those variables 1/0 dummy variables? If so
 and if you want to have an output that satisfies your need for
 labeling the coefficients as you naively anticipate, then put 0+ at
 the beginning of the formula or -1 at the end, so that the intercept
 will disappear and then all variables will get labeled as you expect.
-- 
David Winsemius, MD
Heritage Laboratories
West Hartford, CT

PBW,SO4,NO3,NH4
0.063,3.218,0.089,1.233
0.036,1.837,0.088,0.714
0.032,1.655,0.188,0.675
0.024,1.249,0.132,0.507
0.053,2.72,0.125,1.056
0.055,2.775,0.028,1.049
0.06,3.035,0.022,1.144
0.029,1.491,0.03,0.568
0.038,1.911,0.049,0.731
0.033,1.675,0.042,0.64
0.043,2.183,0.02,0.825
0.024,1.228,0.03,0.469
0.042,2.159,0.055,0.825
0.04,2.047,0.036,0.778
0.008,0.413,0.027,0.163
0.152,7.678,0.04,2.891
0.106,5.383,0.019,2.024
0.076,3.842,0.071,1.461
0.029,1.474,0.01,0.556
0.048,2.454,0.028,0.928
0.064,3.239,0.03,1.223
0.074,3.761,0.054,1.426
0.074,3.731,0.062,1.417
0.216,10.953,0.027,4.115
0.158,8.095,0.384,3.147
0.065,3.441,0.614,1.468
0.027,1.383,0.079,0.541
0.084,4.242,0.072,1.612
0.096,4.875,0.049,1.842
0.052,2.617,0.052,0.996
0.025,1.257,0.033,0.481
0.057,2.913,0.042,1.104
0.081,4.097,0.051,1.551
0.028,1.431,0.009,0.539
0.134,6.799,0.05,2.564
0.095,4.808,0.056,1.819
0.023,1.173,0.025,0.447
0.024,1.23,0.045,0.474
0.021,1.123,0.148,0.464
0.027,1.366,0.073,0.534
0.049,2.467,0.045,0.938
0.05,2.537,0.061,0.969
0.06,3.033,0.077,1.16
0.093,4.708,0.106,1.796
0.095,4.838,0.073,1.835
0.086,4.342,0.07,1.649
0.032,1.725,0.465,0.782
0.041,2.304,0.881,1.12
0.106,5.919,1.955,2.787
0.062,3.146,0.059,1.197
0.104,5.285,0.065,2.001
0.017,0.849,0.009,0.321
0.03,1.514,0.031,0.577
0.032,1.651,0.058,0.636
0.039,1.975,0.021,0.747
0.048,2.434,0.045,0.926
0.045,2.283,0.073,0.877
0.065,3.294,0.009,1.238
0.105,5.323,0.028,2.004
0.029,1.45,0.02,0.55
0.062,3.202,0.156,1.246
0.119,6.018,0.009,2.259
0.147,7.418,0.009,2.785
0.042,2.116,0.061,0.811
0.03,1.589,0.218,0.659
0.043,2.177,0.055,0.832
0.067,3.377,0.009,1.269
0.051,2.564,0.009,0.964
0.063,3.194,0.041,1.21
0.082,4.183,0.035,1.578
0.047,2.362,0.026,0.893
0.063,3.204,0.089,1.227
0.062,3.151,0.049,1.196

[R] Blanchard Quah/Impulse Response Functions

2009-04-21 Thread Laura Carvalho
Dear all,


How can I compute an impulse response function for a BQ (or any SVAR)
in which the endogenous variable for output is given in
log-difference, and I want the response in terms of the level of
output, as done in Blanchard and Quah(1989)?

Does the function irf require that the response is exactly as given in
the set of endogenous variables?

Thank you,

Laura Carvalho

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Fitting linear models

2009-04-21 Thread Dimitri Liakhovitski
I am not sure what the problem is.
I found no errors:

data-read.csv(file.choose())  # I had to change your file extension
to .csv first
dim(data)
names(data)

lapply(data,function(x){sum(is.na(x))})
lm.model.1-lm(PBW~SO4+NO3+NH4,data)
lm.model.2-lm(PBW~SO4+NH4+NO3,data)
print(lm.model.1)  # Getting nice results
print(lm.model.2) # Getting same results

# Another method (gets exactly the same results):
library(Design)
ols.model.1-ols(PBW~SO4+NO3+NH4,data)
ols.model.2-ols(PBW~SO4+NH4+NO3,data)

Dimitri
On Tue, Apr 21, 2009 at 11:50 AM, Vemuri, Aparna avem...@epri.com wrote:
 Attached are the first hundred rows of my data in comma separated format.
 Forcing the regression line through the origin, still does not give a 
 coefficient on the last independent variable. Also, I don't mind if there is 
 a coefficient on the dependent axis. I just want all of the variables to have 
 coefficients in the regression equation or a at least a consistent result, 
 irrespective of the order of input information.

 -Original Message-
 From: David Winsemius [mailto:dwinsem...@comcast.net]
 Sent: Tuesday, April 21, 2009 8:38 AM
 To: Vemuri, Aparna
 Cc: r-help@r-project.org
 Subject: Re: [R] Fitting linear models


 On Apr 21, 2009, at 11:12 AM, Vemuri, Aparna wrote:

 David,
 Thanks for the suggestions. No, I did not label my dependent
 variable function.

 That was from my error in reading your call to lm. In my defense I am
 reasonably sure the proper assignment to arguments is lm(formula= ...)
 rather than lm(function= ...).


 My dependent variable PBW and all the independent variables are
 continuous variables. It is especially troubling since the order in
 which I input independent variables determines whether or not it
 gets a coefficient.  Like I already mentioned, I checked the
 correlation matrix and picked the variables with moderate to high
 correlation with the independent variable. . So I guess it is not so
 naïve to expect a regression coefficient on all of them.

 Dimitri
 model1-lm(PBW~SO4+NO3+NH4), gives me the same result as before.

 Did you get the expected results with;
 model1-lm(formula=PBW~SO4+NO3+NH4+0)

 You could, of course, provide either the data or the results of str()
 applied to each of the variables and then we could all stop guessing.


 Aparna



 I am using the lm() function in R to fit a dependent variable to a
 set
 of 3 to 5 independent variables. For this, I used the following
 commands:

 model1-lm(function=PBW~SO4+NO3+NH4)
 Coefficients:
 (Intercept)          SO4          NO3      NH4
   0.01323      0.01968      0.01856           NA

 and

 model2-lm(function=PBW~SO4+NO3+NH4+Na+Cl)

 Coefficients:
 (Intercept)              SO4                  NO3      NH4
 Na       Cl
 -0.0006987   -0.0119750   -0.0295042    0.0842989    0.1344751
 NA

 In both cases, the last independent variable has a coefficient of NA
 in
 the result. I say last variable because, when I change the order of
 the
 variables, the coefficient changes (see below). Can anyone point me
 to
 the reason R behaves this way?  Is there anyway for me to force R to
 use
 all the variables? I checked the correlation matrices to makes sure
 there is no orthogonality between the variables.

 You really did not name your dependent variable function did you?
 Please stop that.

 Just a guess, ... since you have not provided enough information to do
 otherwise, ... Are all of those variables 1/0 dummy variables? If so
 and if you want to have an output that satisfies your need for
 labeling the coefficients as you naively anticipate, then put 0+ at
 the beginning of the formula or -1 at the end, so that the intercept
 will disappear and then all variables will get labeled as you expect.
 --
 David Winsemius, MD
 Heritage Laboratories
 West Hartford, CT





-- 
Dimitri Liakhovitski
MarketTools, Inc.
dimitri.liakhovit...@markettools.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Polyspline Integration

2009-04-21 Thread Denney, William S.
Hello,

I wrote the function below to integrate polysplines and thought that it
may be useful to others.  Please consider this code released under the
GPL2 or later.

Thanks,

Bill

 integrate.polySpline.R 
Notice:  This e-mail message, together with any attachments, contains
information of Merck  Co., Inc. (One Merck Drive, Whitehouse Station,
New Jersey, USA 08889), and/or its affiliates (which may be known
outside the United States as Merck Frosst, Merck Sharp  Dohme or
MSD and in Japan, as Banyu - direct contact information for affiliates is
available at http://www.merck.com/contact/contacts.html) that may be
confidential, proprietary copyrighted and/or legally privileged. It is
intended solely for the use of the individual or entity named on this
message. If you are not the intended recipient, and have received this
message in error, please notify us immediately by reply e-mail and
then delete it from your system.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Fitting linear models

2009-04-21 Thread Marc Schwartz

On Apr 21, 2009, at 10:37 AM, David Winsemius wrote:



On Apr 21, 2009, at 11:12 AM, Vemuri, Aparna wrote:


David,
Thanks for the suggestions. No, I did not label my dependent  
variable function.


That was from my error in reading your call to lm. In my defense I  
am reasonably sure the proper assignment to arguments is  
lm(formula= ...) rather than lm(function= ...).



My dependent variable PBW and all the independent variables are  
continuous variables. It is especially troubling since the order in  
which I input independent variables determines whether or not it  
gets a coefficient.  Like I already mentioned, I checked the  
correlation matrix and picked the variables with moderate to high  
correlation with the independent variable. . So I guess it is not  
so naïve to expect a regression coefficient on all of them.


Dimitri
model1-lm(PBW~SO4+NO3+NH4), gives me the same result as before.


Did you get the expected results with;
model1-lm(formula=PBW~SO4+NO3+NH4+0)

You could, of course, provide either the data or the results of  
str() applied to each of the variables and then we could all stop  
guessing.


I am going to take a wild stab in the dark here and suggest that 'NH4'  
is exactly correlated to or even identical to one of the other IVs  
used in the formula.


 set.seed(1)
 PBW - rnorm(100)
 SO4 - rnorm(100)
 NO3 - rnorm(100)
 NH4 - rnorm(100)

 lm(PBW ~ SO4 + NO3 + NH4)

Call:
lm(formula = PBW ~ SO4 + NO3 + NH4)

Coefficients:
(Intercept)  SO4  NO3  NH4
0.11065 -0.00273  0.02096 -0.04826


Now watch:

NH4 - NO3 * 1.5

 lm(PBW ~ SO4 + NO3 + NH4)

Call:
lm(formula = PBW ~ SO4 + NO3 + NH4)

Coefficients:
(Intercept)  SO4  NO3  NH4
  1.084e-01   -7.871e-051.596e-02   NA


 cor(cbind(SO4, NO3, NH4))
SO4 NO3 NH4
SO4  1. -0.04953621 -0.04953621
NO3 -0.04953621  1.  1.
NH4 -0.04953621  1.  1.


I suspect that there is a collinearity problem here. Aparna, post back  
with the correlation matrix of your IV's (full data set) and that  
should either support or refute my theory. If supported and you use:


 summary(lm(PBW ~ SO4 + NO3 + NH4))

Call:
lm(formula = PBW ~ SO4 + NO3 + NH4)

Residuals:
 Min   1Q   Median   3Q  Max
-2.30129 -0.60350  0.01765  0.58513  2.27806

Coefficients: (1 not defined because of singularities)
  Estimate Std. Error t value Pr(|t|)
(Intercept)  1.084e-01  9.083e-02   1.1940.236
SO4 -7.871e-05  9.531e-02  -0.0010.999
NO3  1.596e-02  8.827e-02   0.1810.857
NH4 NA NA  NA   NA

Residual standard error: 0.9073 on 97 degrees of freedom
Multiple R-squared: 0.0003379,  Adjusted R-squared: -0.02027
F-statistic: 0.01639 on 2 and 97 DF,  p-value: 0.9837


Note the warning message about singularities for NH4.

BTW, as an aside, picking variables for a model based upon their  
correlation with the DV is not a good way to go. You might want to  
pick up a copy of Frank's book Regression Modeling Strategies:


  http://biostat.mc.vanderbilt.edu/twiki/bin/view/Main/RmS

HTH,

Marc Schwartz

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Fitting linear models

2009-04-21 Thread Dimitri Liakhovitski
Can we see your data to be able to replicate the error? Or maybe a
subset of data with some fake variable names?

On Tue, Apr 21, 2009 at 11:32 AM, Vemuri, Aparna avem...@epri.com wrote:
 Yes, they are all of the same length.

 -Original Message-
 From: Dimitri Liakhovitski [mailto:ld7...@gmail.com]
 Sent: Tuesday, April 21, 2009 8:32 AM
 To: Vemuri, Aparna
 Cc: r-help@r-project.org
 Subject: Re: [R] Fitting linear models

 Are they of the same length?

 On Tue, Apr 21, 2009 at 11:31 AM, Vemuri, Aparna avem...@epri.com wrote:
 The variables are all in separate vectors.

 -Original Message-
 From: Dimitri Liakhovitski [mailto:ld7...@gmail.com]
 Sent: Tuesday, April 21, 2009 8:26 AM
 To: Vemuri, Aparna
 Cc: David Winsemius; r-help@r-project.org
 Subject: Re: [R] Fitting linear models

 Aparna,

 I should have been more explicit. Run ?lm . You'll see this:

 lm(formula, data, subset, weights, na.action,
   method = qr, model = TRUE, x = FALSE, y = FALSE, qr = TRUE,
   singular.ok = TRUE, contrasts = NULL, offset, ...)

 So, in addition to specifying the formula, you have to specify the
 data frame in which you keep your variables. I assume they are in a
 data frame? (unless for some reasons you keep all variables as
 separate vectors).
 So, after you wrote the formula, you have to indicate the name of the
 data frame, for example MyData:

 model1-lm(PBW~SO4+NO3+NH4, MyData)

 Dimitri

 On Tue, Apr 21, 2009 at 11:12 AM, Vemuri, Aparna avem...@epri.com wrote:
 David,
 Thanks for the suggestions. No, I did not label my dependent variable 
 function.

 My dependent variable PBW and all the independent variables are continuous 
 variables. It is especially troubling since the order in which I input 
 independent variables determines whether or not it gets a coefficient.  
 Like I already mentioned, I checked the correlation matrix and picked the 
 variables with moderate to high correlation with the independent variable. 
 . So I guess it is not so naïve to expect a regression coefficient on all 
 of them.

 Dimitri
 model1-lm(PBW~SO4+NO3+NH4), gives me the same result as before.

 Bert:
  This is not homework. But I will remember to do my research before posting 
 here.

 Aparna


 -Original Message-
 From: David Winsemius [mailto:dwinsem...@comcast.net]
 Sent: Monday, April 20, 2009 5:35 PM
 To: Vemuri, Aparna
 Cc: r-help@r-project.org
 Subject: Re: [R] Fitting linear models


 On Apr 20, 2009, at 7:26 PM, Vemuri, Aparna wrote:

 I am not sure if this is an R-users question, but since most of you
 here
 are statisticians, I decided to give it a shot.

 You can omit the unnecessary preambles.


 I am using the lm() function in R to fit a dependent variable to a set
 of 3 to 5 independent variables. For this, I used the following
 commands:

 model1-lm(function=PBW~SO4+NO3+NH4)
 Coefficients:
 (Intercept)          SO4          NO3      NH4
    0.01323      0.01968      0.01856           NA

 and

 model2-lm(function=PBW~SO4+NO3+NH4+Na+Cl)

 Coefficients:
 (Intercept)               SO4                  NO3      NH4
 Na       Cl
 -0.0006987   -0.0119750   -0.0295042    0.0842989    0.1344751
 NA

 In both cases, the last independent variable has a coefficient of NA
 in
 the result. I say last variable because, when I change the order of
 the
 variables, the coefficient changes (see below). Can anyone point me to
 the reason R behaves this way?  Is there anyway for me to force R to
 use
 all the variables? I checked the correlation matrices to makes sure
 there is no orthogonality between the variables.

 You really did not name your dependent variable function did you?
 Please stop that.

 Just a guess, ... since you have not provided enough information to do
 otherwise, ... Are all of those variables 1/0 dummy variables? If so
 and if you want to have an output that satisfies your need for
 labeling the coefficients as you naively anticipate, then put 0+ at
 the beginning of the formula or -1 at the end, so that the intercept
 will disappear and then all variables will get labeled as you expect.

 --
 David Winsemius, MD
 Heritage Laboratories
 West Hartford, CT

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




 --
 Dimitri Liakhovitski
 MarketTools, Inc.
 dimitri.liakhovit...@markettools.com




 --
 Dimitri Liakhovitski
 MarketTools, Inc.
 dimitri.liakhovit...@markettools.com




-- 
Dimitri Liakhovitski
MarketTools, Inc.
dimitri.liakhovit...@markettools.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] DNAcopy package in R

2009-04-21 Thread Selena Niu

Hi All:

Has anyone analyzed Illumina 550K data using DNAcopy package? I have around
2300 samples. According to
Venkatraman and Olshen 2007 paper, it needs about 25 min to run a single
sample for Affymetrix 100K. I am afraid it will take too long to analyzed my
data. Anybody has an idea? Thanks!

Best, 
-- 
View this message in context: 
http://www.nabble.com/DNAcopy-package-in-R-tp23158907p23158907.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] fitting assimptotic decaing with - and + on X

2009-04-21 Thread milton ruser
Dear all,

I need to adjust a decaing function between preference as function
of distance (dst). As you can see below, the X values range from
highly negative to higly positive. The preferences range from 1 to ~0.

I tryed to use drc() packages, but I I am not wrong, the packages
is developed mainly to responde-dose, so the X is from 0-infinite.

I need to fit the data and get an assintoptic (inverse-S) shape.
Any help are welcome.

milton
brazil-toronto
---
sp.coredep.attr-read.table(stdin(), head=T, sep=,)
species,dst,preference,probdye
coredep,-7500,1,0.001
coredep,-1000,0.95,0.002
coredep,-500,0.9,0.003
coredep,-250,0.8,0.005
coredep,-120,0.7,0.01
coredep,-100,0.5,0.02
coredep,-90,0.3,0.03
coredep,-60,0.2,0.05
coredep,-30,0.15,0.065
coredep,0,0.1,0.08
coredep,30,0.09,0.1
coredep,60,0.08,0.15
coredep,90,0.07,0.2
coredep,120,0.06,0.3
coredep,240,0.05,0.4
coredep,500,0.04,0.5
coredep,1000,0.02,0.6
coredep,7500,0.01,0.7
plot(preference~as.factor(dst), data=sp.coredep.attr, type=n, cex=0.001,
col=transparent, xlab=Distance (m), main=CORE Dependent)
lines(sp.coredep.attr$preference, type=b, lwd=2, col=blue)
abline(v=10, col=blue, lty=3)
text(10, 1, EDGE, cex=1.5)
text(7, 1, CORE, cex=1.5, col=green)
text(13, 1, MATRIX, cex=1.5, col=red)
text(4,0.65, Preference, col=blue)
text(16,0.65, Prob.Die, col=red)
lines(sp.coredep.attr$probdye, type=b, lwd=2, col=red, lty=2)

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] bug when subtracting decimals?

2009-04-21 Thread hadley wickham
 Have you read the posting guide and the FAQs? If you do not get a reply
 within two days, you may want to look at both and think about reformulating
 your query. Oh, and while you are at it, look through the archives, a lot of
 questions have already been asked and answered before.

As I say every time someone brings this up, there are currently ~130
printed pages of FAQs.  Reading all that seems a rather large burden
on the novice poster.

Hadley

-- 
http://had.co.nz/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Fitting linear models

2009-04-21 Thread Vemuri, Aparna
Thanks Dimitri! Following exactly what you did, I wrote all my individual 
variable vectors to a data frame and used lm(formula,data) and this time it 
works for me too. 

Marc, your theory is correct.NH4 variable shares a strong correlation with one 
of the IV along with the DV. 
SO4 NO3 NH4 PBW
SO4 1   -0.0867 0.999   0.999
NO3 -0.0867   1 -0.0527 -0.0938
NH4 0.999   -0.0527   1 0.999
PBW 0.999   -0.0938  0.999  1


Aparna 

-Original Message-
From: Dimitri Liakhovitski [mailto:ld7...@gmail.com] 
Sent: Tuesday, April 21, 2009 9:02 AM
To: Vemuri, Aparna
Cc: r-help@r-project.org; David Winsemius
Subject: Re: [R] Fitting linear models

I am not sure what the problem is.
I found no errors:

data-read.csv(file.choose())  # I had to change your file extension
to .csv first
dim(data)
names(data)

lapply(data,function(x){sum(is.na(x))})
lm.model.1-lm(PBW~SO4+NO3+NH4,data)
lm.model.2-lm(PBW~SO4+NH4+NO3,data)
print(lm.model.1)  # Getting nice results
print(lm.model.2) # Getting same results

# Another method (gets exactly the same results):
library(Design)
ols.model.1-ols(PBW~SO4+NO3+NH4,data)
ols.model.2-ols(PBW~SO4+NH4+NO3,data)

Dimitri
On Tue, Apr 21, 2009 at 11:50 AM, Vemuri, Aparna avem...@epri.com wrote:
 Attached are the first hundred rows of my data in comma separated format.
 Forcing the regression line through the origin, still does not give a 
 coefficient on the last independent variable. Also, I don't mind if there is 
 a coefficient on the dependent axis. I just want all of the variables to have 
 coefficients in the regression equation or a at least a consistent result, 
 irrespective of the order of input information.

 -Original Message-
 From: David Winsemius [mailto:dwinsem...@comcast.net]
 Sent: Tuesday, April 21, 2009 8:38 AM
 To: Vemuri, Aparna
 Cc: r-help@r-project.org
 Subject: Re: [R] Fitting linear models


 On Apr 21, 2009, at 11:12 AM, Vemuri, Aparna wrote:

 David,
 Thanks for the suggestions. No, I did not label my dependent
 variable function.

 That was from my error in reading your call to lm. In my defense I am
 reasonably sure the proper assignment to arguments is lm(formula= ...)
 rather than lm(function= ...).


 My dependent variable PBW and all the independent variables are
 continuous variables. It is especially troubling since the order in
 which I input independent variables determines whether or not it
 gets a coefficient.  Like I already mentioned, I checked the
 correlation matrix and picked the variables with moderate to high
 correlation with the independent variable. . So I guess it is not so
 naïve to expect a regression coefficient on all of them.

 Dimitri
 model1-lm(PBW~SO4+NO3+NH4), gives me the same result as before.

 Did you get the expected results with;
 model1-lm(formula=PBW~SO4+NO3+NH4+0)

 You could, of course, provide either the data or the results of str()
 applied to each of the variables and then we could all stop guessing.


 Aparna



 I am using the lm() function in R to fit a dependent variable to a
 set
 of 3 to 5 independent variables. For this, I used the following
 commands:

 model1-lm(function=PBW~SO4+NO3+NH4)
 Coefficients:
 (Intercept)          SO4          NO3      NH4
   0.01323      0.01968      0.01856           NA

 and

 model2-lm(function=PBW~SO4+NO3+NH4+Na+Cl)

 Coefficients:
 (Intercept)              SO4                  NO3      NH4
 Na       Cl
 -0.0006987   -0.0119750   -0.0295042    0.0842989    0.1344751
 NA

 In both cases, the last independent variable has a coefficient of NA
 in
 the result. I say last variable because, when I change the order of
 the
 variables, the coefficient changes (see below). Can anyone point me
 to
 the reason R behaves this way?  Is there anyway for me to force R to
 use
 all the variables? I checked the correlation matrices to makes sure
 there is no orthogonality between the variables.

 You really did not name your dependent variable function did you?
 Please stop that.

 Just a guess, ... since you have not provided enough information to do
 otherwise, ... Are all of those variables 1/0 dummy variables? If so
 and if you want to have an output that satisfies your need for
 labeling the coefficients as you naively anticipate, then put 0+ at
 the beginning of the formula or -1 at the end, so that the intercept
 will disappear and then all variables will get labeled as you expect.
 --
 David Winsemius, MD
 Heritage Laboratories
 West Hartford, CT





-- 
Dimitri Liakhovitski
MarketTools, Inc.
dimitri.liakhovit...@markettools.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


  1   2   >