[R] GarchOxFit Interface

2007-03-03 Thread pilar . grau


Hello,

I am having problems with the GarchOxFit. I have my Ox Console instaled in
c:\Program Files\ox, and when I execute the GarchOxFit the result is 
C:\Ox\bin\oxl.exe not found. I there any posiblility to execute the command
without installing again Ox in c:\?

My OS is windows XP.

Thankyou for your help.

Pilar Grau

__
R-help@stat.math.ethz.ch 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] format of summary.lm for 2-way ANOVA

2007-03-03 Thread Patrick Drechsler
 Hi,

I am performing a two-way ANOVA (2 factors with 4 and 5 levels,
respectively). If I'm interpreting the output of summary correctly,
then the interaction between both factors is significant:

,
| ## Two-way ANOVA with possible interaction:
|  model1 - aov(log(y) ~ xForce*xVel, data=mydataset)
|
|  summary(model1)
|  Df  Sum Sq Mean Sq F valuePr(F)
| xForce3  16.640   5.547 19.0191 1.708e-11 ***
| xVel  4  96.391  24.098 82.6312  2.2e-16 ***
| xForce:xVel  12  10.037   0.836  2.8681 0.0008528 ***
| Residuals   371 108.194   0.292  
| ---
| Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 
| 3 observations deleted due to missingness
`

To see the interactions in detail I call summary.lm:

,
|  summary.lm(model1)
| 
| Call:
| aov(formula = log(y) ~ xForce * xVel, data = mydataset)
| 
| Residuals:
|  Min   1Q   Median   3Q  Max 
| -2.04830 -0.32420 -0.04653  0.34928  1.46755 
| 
| Coefficients:
|  Estimate Std. Error t value Pr(|t|)
| (Intercept) -1.663406   0.027335 -60.853   2e-16 ***
| xForce.L 0.408977   0.054726   7.473 5.68e-13 ***
| xForce.Q 0.101240   0.054670   1.852   0.0648 .  
| xForce.C-0.068068   0.054613  -1.246   0.2134
| xVel.L   1.079042   0.061859  17.444   2e-16 ***
| xVel.Q   0.339802   0.061439   5.531 6.03e-08 ***
| xVel.C   0.015422   0.060751   0.254   0.7997
| xVel^4  -0.044399   0.060430  -0.735   0.4630
| xForce.L:xVel.L  0.622060   0.123966   5.018 8.12e-07 ***
| xForce.Q:xVel.L  0.034298   0.123718   0.277   0.7818
| xForce.C:xVel.L -0.114776   0.123470  -0.930   0.3532
| xForce.L:xVel.Q  0.309293   0.123057   2.513   0.0124 *  
| xForce.Q:xVel.Q  0.054798   0.122879   0.446   0.6559
| xForce.C:xVel.Q -0.144219   0.122700  -1.175   0.2406
| xForce.L:xVel.C  0.110588   0.121565   0.910   0.3636
| xForce.Q:xVel.C -0.001929   0.121502  -0.016   0.9873
| xForce.C:xVel.C -0.039477   0.121438  -0.325   0.7453
| xForce.L:xVel^4  0.090491   0.120870   0.749   0.4545
| xForce.Q:xVel^4 -0.002762   0.120861  -0.023   0.9818
| xForce.C:xVel^4 -0.028836   0.120852  -0.239   0.8115
| ---
| Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 
| 
| Residual standard error: 0.54 on 371 degrees of freedom
|   (3 observations deleted due to missingness)
| Multiple R-Squared: 0.5322,   Adjusted R-squared: 0.5082 
| F-statistic: 22.21 on 19 and 371 DF,  p-value:  2.2e-16 
`

I am wondering what the logic is behind the formatting of
rownames. What do the strings L, Q, C and ^4 mean?

Apologies in case I missed something obvious in the relevant
documentations/archives.

Thanks for any pointers,

Patrick

PS: Here are some details about the dataset:

,
|  summary(mydataset)
|yxForce xVel   
|  Min.   :0.03662   0.01:97   10  :79  
|  1st Qu.:0.10376   0.1 :98   50  :80  
|  Median :0.16314   1   :98   100 :80  
|  Mean   :0.26592   2   :98   500 :80  
|  3rd Qu.:0.28077   NA's: 3   5000:72  
|  Max.   :2.39490 NA's: 3  
|  NA's   :3.0
| 
|  str(mydataset)
| 'data.frame': 394 obs. of  3 variables:
|  $ y : num  0.167 0.158 0.152 0.158 0.131 ...
|  $ xForce: Ord.factor w/ 4 levels 0.010.11..: 1 2 3 4 1 2 3 4 1 2 ...
|  $ xVel  : Ord.factor w/ 5 levels 1050100..: 3 3 3 3 1 1 1 1 2 2 ...
`

I am using

platform   i486-pc-linux-gnu   
arch   i486
os linux-gnu   
system i486, linux-gnu 
status 
major  2   
minor  4.1 
year   2006
month  12  
day18  
svn rev40228   
language   R   
version.string R version 2.4.1 (2006-12-18)

__
R-help@stat.math.ethz.ch 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] GarchOxFit Interface

2007-03-03 Thread Martin Becker
[EMAIL PROTECTED] wrote:
 Hello,

 I am having problems with the GarchOxFit. I have my Ox Console instaled in
 c:\Program Files\ox, and when I execute the GarchOxFit the result is 
 C:\Ox\bin\oxl.exe not found. I there any posiblility to execute the command
 without installing again Ox in c:\?

   
I suppose you are speaking of GarchOxFit in package fSeries, but you 
didn't mention which version of fSeries you are using. I think, in 
current versions (240.10068), you may set OXPATH in the global 
environment to your installation of OX, maybe it is even necessary to do so.
Apart from that I think there is still a buglet in the Ox-Interface 
functions, which I mentioned some time ago on R-sig-finance, see  
https://stat.ethz.ch/pipermail/r-sig-finance/2005q4/000498.html. I think 
you still find this buglet in the current version source (line 217 of 
4D-GarchOxInterface.R), but since I don't use the Ox interface any more, 
I am not sure. I think the quick workaround is to always store the time 
series to be fitted in the variable x in the global environment.

hth,
  Martin
 My OS is windows XP.

 Thankyou for your help.

 Pilar Grau

 __
 R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] format of summary.lm for 2-way ANOVA

2007-03-03 Thread Chuck Cleland
Patrick Drechsler wrote:
  Hi,
 
 I am performing a two-way ANOVA (2 factors with 4 and 5 levels,
 respectively). If I'm interpreting the output of summary correctly,
 then the interaction between both factors is significant:
 
 ,
 | ## Two-way ANOVA with possible interaction:
 |  model1 - aov(log(y) ~ xForce*xVel, data=mydataset)
 |
 |  summary(model1)
 |  Df  Sum Sq Mean Sq F valuePr(F)
 | xForce3  16.640   5.547 19.0191 1.708e-11 ***
 | xVel  4  96.391  24.098 82.6312  2.2e-16 ***
 | xForce:xVel  12  10.037   0.836  2.8681 0.0008528 ***
 | Residuals   371 108.194   0.292  
 | ---
 | Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 
 | 3 observations deleted due to missingness
 `
 
 To see the interactions in detail I call summary.lm:
 
 ,
 |  summary.lm(model1)
 | 
 | Call:
 | aov(formula = log(y) ~ xForce * xVel, data = mydataset)
 | 
 | Residuals:
 |  Min   1Q   Median   3Q  Max 
 | -2.04830 -0.32420 -0.04653  0.34928  1.46755 
 | 
 | Coefficients:
 |  Estimate Std. Error t value Pr(|t|)
 | (Intercept) -1.663406   0.027335 -60.853   2e-16 ***
 | xForce.L 0.408977   0.054726   7.473 5.68e-13 ***
 | xForce.Q 0.101240   0.054670   1.852   0.0648 .  
 | xForce.C-0.068068   0.054613  -1.246   0.2134
 | xVel.L   1.079042   0.061859  17.444   2e-16 ***
 | xVel.Q   0.339802   0.061439   5.531 6.03e-08 ***
 | xVel.C   0.015422   0.060751   0.254   0.7997
 | xVel^4  -0.044399   0.060430  -0.735   0.4630
 | xForce.L:xVel.L  0.622060   0.123966   5.018 8.12e-07 ***
 | xForce.Q:xVel.L  0.034298   0.123718   0.277   0.7818
 | xForce.C:xVel.L -0.114776   0.123470  -0.930   0.3532
 | xForce.L:xVel.Q  0.309293   0.123057   2.513   0.0124 *  
 | xForce.Q:xVel.Q  0.054798   0.122879   0.446   0.6559
 | xForce.C:xVel.Q -0.144219   0.122700  -1.175   0.2406
 | xForce.L:xVel.C  0.110588   0.121565   0.910   0.3636
 | xForce.Q:xVel.C -0.001929   0.121502  -0.016   0.9873
 | xForce.C:xVel.C -0.039477   0.121438  -0.325   0.7453
 | xForce.L:xVel^4  0.090491   0.120870   0.749   0.4545
 | xForce.Q:xVel^4 -0.002762   0.120861  -0.023   0.9818
 | xForce.C:xVel^4 -0.028836   0.120852  -0.239   0.8115
 | ---
 | Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 
 | 
 | Residual standard error: 0.54 on 371 degrees of freedom
 |   (3 observations deleted due to missingness)
 | Multiple R-Squared: 0.5322, Adjusted R-squared: 0.5082 
 | F-statistic: 22.21 on 19 and 371 DF,  p-value:  2.2e-16 
 `
 
 I am wondering what the logic is behind the formatting of
 rownames. What do the strings L, Q, C and ^4 mean?

  The default contrast for ordered factors is contr.poly(), and L,
Q, C and ^4 refer to linear, quadratic, cubic, and quartic,
respectively.
  You might look at some plots if you have not already.  For example:

with(mydataset, interaction.plot(xForce, xVel, log(y)))

library(lattice)
bwplot(log(y) ~ xForce | xVel, data = mydataset)

 Apologies in case I missed something obvious in the relevant
 documentations/archives.
 
 Thanks for any pointers,
 
 Patrick
 
 PS: Here are some details about the dataset:
 
 ,
 |  summary(mydataset)
 |yxForce xVel   
 |  Min.   :0.03662   0.01:97   10  :79  
 |  1st Qu.:0.10376   0.1 :98   50  :80  
 |  Median :0.16314   1   :98   100 :80  
 |  Mean   :0.26592   2   :98   500 :80  
 |  3rd Qu.:0.28077   NA's: 3   5000:72  
 |  Max.   :2.39490 NA's: 3  
 |  NA's   :3.0
 | 
 |  str(mydataset)
 | 'data.frame':   394 obs. of  3 variables:
 |  $ y : num  0.167 0.158 0.152 0.158 0.131 ...
 |  $ xForce: Ord.factor w/ 4 levels 0.010.11..: 1 2 3 4 1 2 3 4 1 2 
 ...
 |  $ xVel  : Ord.factor w/ 5 levels 1050100..: 3 3 3 3 1 1 1 1 2 2 
 ...
 `
 
 I am using
 
 platform   i486-pc-linux-gnu   
 arch   i486
 os linux-gnu   
 system i486, linux-gnu 
 status 
 major  2   
 minor  4.1 
 year   2006
 month  12  
 day18  
 svn rev40228   
 language   R   
 version.string R version 2.4.1 (2006-12-18)
 
 __
 R-help@stat.math.ethz.ch 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.

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894


Re: [R] Horvitz Thompson Variance

2007-03-03 Thread Tobias Verbeke
Gen wrote:
 I am performing linear regression R and would like to incorporate sampling
 weights.  
   

There is a survey package for the analysis of data from complex sample 
designs
of which svyglm might fit your purposes.

For the home page of the package (with lots of materials), see
http://faculty.washington.edu/tlumley/survey/

HTH,
Tobias

 Does any one know how to obtain Horvitz-Thompson variance estimates when
 performing linear regression?
 Thank you for your help.
   

-- 

Tobias Verbeke - Consultant
Business  Decision Benelux
Rue de la révolution 8
1000 Brussels - BELGIUM

+32 499 36 33 15
[EMAIL PROTECTED]

__
R-help@stat.math.ethz.ch 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] format of summary.lm for 2-way ANOVA

2007-03-03 Thread Patrick Drechsler
Chuck Cleland [EMAIL PROTECTED] writes:

 Patrick Drechsler wrote:

[...]
 To see the interactions in detail I call summary.lm:
 
 ,
 |  summary.lm(model1)
[...]
 | xVel.L   1.079042   0.061859  17.444   2e-16 ***
 | xVel.Q   0.339802   0.061439   5.531 6.03e-08 ***
 | xVel.C   0.015422   0.060751   0.254   0.7997
 | xVel^4  -0.044399   0.060430  -0.735   0.4630
[...]

 I am wondering what the logic is behind the formatting of
 rownames. What do the strings L, Q, C and ^4 mean?

   The default contrast for ordered factors is contr.poly(), and L,
 Q, C and ^4 refer to linear, quadratic, cubic, and quartic,
 respectively.

Thank you very much this explanation! Could you point me in the right
direction where this is documented? I have looked at ?summary,
?summary.lm and ?contr.poly etc.

   You might look at some plots if you have not already.  For example:

 with(mydataset, interaction.plot(xForce, xVel, log(y)))

 library(lattice)
 bwplot(log(y) ~ xForce | xVel, data = mydataset)

Nice, thanks also for this pointer.

Cheers

Patrick
-- 
By working faithfully eight hours a day,
you may eventually get to be boss and work twelve.
-- Robert Frost

__
R-help@stat.math.ethz.ch 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] significant anova but no distinct groups ?

2007-03-03 Thread rolf
Frederic Jean wrote:

 I am studying a dataset using the aov() function.
 
 The independant variable 'cds' is a factor() with 8 levels and here is  
 the result in studying the dependant variable 'rta' with aov() :
 
  summary(aov(rta ~ cds))
  Df  Sum Sq Mean Sq F value  Pr(F)
 cds  7 0.34713 0.04959  2.3807 0.02777
 Residuals   92 1.91635 0.02083
 
 The dependant variable 'rta' is normally distributed and variances are  
 homogeneous.
 But when studying the result with TukeyHSD, no differences in 'rta'  
 are seen among groups of 'cds' :
 
  TukeyHSD(aov(rta ~ cds), which=cds)
Tukey multiple comparisons of means
  95% family-wise confidence level
 
 Fit: aov(formula = rta ~ cds)
 
 $cds
   difflwrupr p adj
 1-0 -0.1046092796 -0.4331100 0.22389141 0.9751178
 2-0  0.0359991860 -0.1371359 0.20913425 0.9980970
 3-0  0.0261665235 -0.1348524 0.18718540 0.9996165
 4-0  0.0004502442 -0.1805448 0.18144531 1.000
 5-0 -0.1438949939 -0.3104752 0.02268526 0.1422670
 [...]
 7-5  0.0621598639 -0.1027595 0.22707926 0.9386170
 7-6  0.0256519274 -0.1757408 0.22704465 0.248
 
 I tried a pairwise.t.test (holm correction) which also was not able to  
 detect differences in 'rta' among groups of 'cds'
 I've never been confronted to such a situation before : is it just a  
 problem of power of the /a posteriori/ tests used ? Do I miss  
 something important in basic stats or in R ?
 How to highlight differences among 'cds' groups seen with aov() ?

The apparent paradox is only apparent.  This sort of thing
can and does happen.

One way of thinking about this situation is to envisage a
circle (Anova) and a square (multiple comparisons),
superimposed, with the corners of the square sticking outside
of the circle, and the extremities of the circle protruding
beyond the edges of the square.

You get a ``significant'' result from the Anova if a point
lands outside the circle; you get a ``significant'' result
from the multiple comparisons if a point lands outside the
square.  So if a point lands in the corners of the square
that stick out beyond the circle, you have a ``significant''
Anova result, but find no ``significant'' differences in the
multiple comparisons.  Conversely a point could land in the
extremities of the circle that protrude beyond the edges of
the square, in which case you would find ``significant''
differences in the multiple comparisons but your Anova test
would not be ``significant''.

These are rare but not unheard of phenomena.  The essence of
the situation is that the data are giving you an ambiguous
message.  There is no real way to resolve the ambiguity
except by collecting more data.

Note that if there is a significant Anova result there
will be at least one ``contrast'' amongst the means that
is significantly different from zero on an a posteriori
basis.  This contrast need not however be a pairwise
difference between means.

cheers,

Rolf Turner
[EMAIL PROTECTED]

__
R-help@stat.math.ethz.ch 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 convert List object to function arguments?

2007-03-03 Thread Shiazy
Dear R gurus,

I have a function goftests that receives the following arguments:
* a vector x of data values;
* a distribution name dist;
* the dots list (...) containing a list a parameters to pass to CDF 
function;
and calls several goodness-of-fit tests on the given data values against 
the given distribution.
That is:

# BEGIN CODE SNIP #

# Covert a distribution name to the related CDF function name
distname2cdfname - function( dist )
{
   if ( dist == beta ) { return( pbeta ); }
   if ( dist == cauchy ) { return( pcauchy ); }

   # many other and personalized (e.g. pareto, ...) distributions ...

   return(  ); # fall-back case
}

# Performs some GoF tests (KS, Chi-Square, Anderson-Darling,...)
# (the ... list contains parameters for CDF function)
goftests - function( x, dist, ... )
{
   cdfname - distname2cdfname( dist );
   res$ks - ks.test( x, cdfname, ... );
   # res$chisq - ...
   # res$anddarl - ...

   return( res )
};

# END CODE SNIP #

So the problem is passing ... to CDF function (for instance, see 
ks.test above) in the right form. The ... is passed (to goftests) 
as a list object and it should be converted to an argument list.
For instance:

# BEGIN CODE SNIP #

parms - list( shape1 = 2, shape2 = 5 );
goftests( x, beta, parms[[shape1]], parms[[shape2]] ); # Works!
goftests( x, beta, parms ) # Don't Works!

parms - list( aNum = 5, aVector = c(1,2,3), aMatrix = 
matrix(c(4,5,6,7,8,9),nrow=2,byrow=T) );
goftests( x, my-special-distr, parms[[aVector]], parms[[aMatrix]], 
parms[[aNumber]] ); # Works!
goftests( x, my-special-distr, parms ) # Don't Works!

# END CODE SNIP #

Obviously I have to use the don't work form.

How can I do this in R (if possible)?

Thank you very much in advance!

Best regards,

-- Marco

__
R-help@stat.math.ethz.ch 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] How to convert List object to function arguments?

2007-03-03 Thread hadley wickham
Have a look at do.call

Hadley

On 3/3/07, Shiazy [EMAIL PROTECTED] wrote:
 Dear R gurus,

 I have a function goftests that receives the following arguments:
 * a vector x of data values;
 * a distribution name dist;
 * the dots list (...) containing a list a parameters to pass to CDF
 function;
 and calls several goodness-of-fit tests on the given data values against
 the given distribution.
 That is:

 # BEGIN CODE SNIP #

 # Covert a distribution name to the related CDF function name
 distname2cdfname - function( dist )
 {
if ( dist == beta ) { return( pbeta ); }
if ( dist == cauchy ) { return( pcauchy ); }

# many other and personalized (e.g. pareto, ...) distributions ...

return(  ); # fall-back case
 }

 # Performs some GoF tests (KS, Chi-Square, Anderson-Darling,...)
 # (the ... list contains parameters for CDF function)
 goftests - function( x, dist, ... )
 {
cdfname - distname2cdfname( dist );
res$ks - ks.test( x, cdfname, ... );
# res$chisq - ...
# res$anddarl - ...

return( res )
 };

 # END CODE SNIP #

 So the problem is passing ... to CDF function (for instance, see
 ks.test above) in the right form. The ... is passed (to goftests)
 as a list object and it should be converted to an argument list.
 For instance:

 # BEGIN CODE SNIP #

 parms - list( shape1 = 2, shape2 = 5 );
 goftests( x, beta, parms[[shape1]], parms[[shape2]] ); # Works!
 goftests( x, beta, parms ) # Don't Works!

 parms - list( aNum = 5, aVector = c(1,2,3), aMatrix =
 matrix(c(4,5,6,7,8,9),nrow=2,byrow=T) );
 goftests( x, my-special-distr, parms[[aVector]], parms[[aMatrix]],
 parms[[aNumber]] ); # Works!
 goftests( x, my-special-distr, parms ) # Don't Works!

 # END CODE SNIP #

 Obviously I have to use the don't work form.

 How can I do this in R (if possible)?

 Thank you very much in advance!

 Best regards,

 -- Marco

 __
 R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] How to convert List object to function arguments?

2007-03-03 Thread Shiazy
do.call createa a function call and evaluates it. I think this isn't 
for me. Same thing for call; it wants the function name as first argument.

However, I have to pass to ks.test the CDF function name and, 
separately, the related arguments.

ks.test( x, cdfname, ... );

The problem is ... comes as a list object and I didn't find a way to 
coerce this object to a arguments list, preserving names a values 
(note each list item can be a complex object such as a vector, matrix, 
... so I cannot use unlist o as.array)

-- Marco

hadley wickham wrote:
 Have a look at do.call
 
 Hadley
 
 On 3/3/07, Shiazy [EMAIL PROTECTED] wrote:
 Dear R gurus,

 I have a function goftests that receives the following arguments:
 * a vector x of data values;
 * a distribution name dist;
 * the dots list (...) containing a list a parameters to pass to CDF
 function;
 and calls several goodness-of-fit tests on the given data values against
 the given distribution.
 That is:

 # BEGIN CODE SNIP #

 # Covert a distribution name to the related CDF function name
 distname2cdfname - function( dist )
 {
if ( dist == beta ) { return( pbeta ); }
if ( dist == cauchy ) { return( pcauchy ); }

# many other and personalized (e.g. pareto, ...) distributions ...

return(  ); # fall-back case
 }

 # Performs some GoF tests (KS, Chi-Square, Anderson-Darling,...)
 # (the ... list contains parameters for CDF function)
 goftests - function( x, dist, ... )
 {
cdfname - distname2cdfname( dist );
res$ks - ks.test( x, cdfname, ... );
# res$chisq - ...
# res$anddarl - ...

return( res )
 };

 # END CODE SNIP #

 So the problem is passing ... to CDF function (for instance, see
 ks.test above) in the right form. The ... is passed (to goftests)
 as a list object and it should be converted to an argument list.
 For instance:

 # BEGIN CODE SNIP #

 parms - list( shape1 = 2, shape2 = 5 );
 goftests( x, beta, parms[[shape1]], parms[[shape2]] ); # Works!
 goftests( x, beta, parms ) # Don't Works!

 parms - list( aNum = 5, aVector = c(1,2,3), aMatrix =
 matrix(c(4,5,6,7,8,9),nrow=2,byrow=T) );
 goftests( x, my-special-distr, parms[[aVector]], parms[[aMatrix]],
 parms[[aNumber]] ); # Works!
 goftests( x, my-special-distr, parms ) # Don't Works!

 # END CODE SNIP #

 Obviously I have to use the don't work form.

 How can I do this in R (if possible)?

 Thank you very much in advance!

 Best regards,

 -- Marco

 __
 R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] How to convert List object to function arguments?

2007-03-03 Thread Shiazy
With a little change it's seem to work:

x - c(0, 1855, 72, 4830, 493, 424, 193, 2489, 156262, 4557, 958)
params - list(shape2=5, shape1=2)
do.call( ks.test,  c(list(x), cdfname( beta ), params ))

In fact if I do

call(ks.test, list(x=x, cdfname=cdfname, ...))

I get:

ks.test(list(x = c(0, 1855, 72, 4830, 493, 424, 193, 2489, 156262, 4557, 
958), y = pbeta, list(shape2 = 5, shape1 = 2)))

and the error:

Error in y(sort(x), ...) : argument shape2 is missing, with no default

Instead with the new form:

call( ks.test,  c(list(x), mg_dists_cdfName( beta ), parms ))

I get:

ks.test(list(c(0, 1855, 72, 4830, 493, 424, 193, 2489, 156262, 4557, 
958), pbeta, shape2 = 5, shape1 = 2))

and no error.

Thank you so much!!!

-- Marco

hadley wickham wrote:
 On 3/3/07, Shiazy [EMAIL PROTECTED] wrote:
 do.call createa a function call and evaluates it. I think this isn't
 for me. Same thing for call; it wants the function name as first 
 argument.

 However, I have to pass to ks.test the CDF function name and,
 separately, the related arguments.

 ks.test( x, cdfname, ... );

 The problem is ... comes as a list object and I didn't find a way to
 coerce this object to a arguments list, preserving names a values
 (note each list item can be a complex object such as a vector, matrix,
 ... so I cannot use unlist o as.array)
 
 I think
 do.call(ks.test, list(x=x, cdfname=cdfname, ...))
 will do what you want.
 
 Hadley
 
 PS.  You don't need ; at the end of every line.


__
R-help@stat.math.ethz.ch 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] Mitools and lmer

2007-03-03 Thread Douglas Bates
On 3/2/07, Beth Gifford [EMAIL PROTECTED] wrote:
 Hey there
 I am estimating a multilevel model using lmer.  I have 5 imputed datasets so
 I am using mitools to pool the estimates from the 5
 datasets.  Everything seems to work until I try to use
 MIcombine to produced pooled estimates.  Does anyone have any suggestions?  
 The betas and the standard errors were extracted with no problem so 
 everything seems to work smoothly up until that point.

I'm not familiar with the mltools package and I didn't see it listed
in the CRAN packages.  Can you provide a reference or a link to the
package?

  Program
  #Read data
  data.dir-system.file(dta,package=mitools)
  files.imp-imputationList(lapply(list.files(data.dir,
  pattern=imp.\\.dta, full=TRUE), read.dta))
 
  #estimate model over each imputed dataset
  model0-with(files.imp,lmer( erq2tnc ~1+trt2+nash+wash+male+coh2+coh3+(1 |
  sitebeth)))
  #extract betas and standard errors
  betas-MIextract(model0,fun=coef)
  vars-MIextract(model0,fun=vcov)
  #Combine the results
  summary(MIcombine(betas,vars))

  Error in cbar + results[[i]] : non-numeric argument to binary operator
  Error in summary(MIcombine(betas, vars)) :
  error in evaluating the argument 'object' in selecting a method for
  function 'summary'

First use traceback() to discover where the (first) error occurred.
My guess is that Mlcombine expects a particular type of object for the
vars argument and it is not getting that type (and not checking for
the correct type).




 Thanks
 Beth

 [[alternative HTML version deleted]]

 __
 R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] How to convert List object to function arguments?

2007-03-03 Thread Shiazy
Patrick Burns wrote:
 You might have found 'do.call' in S Poetry.
 

I've taken a look just now.

Thank you so much!

-- Marco

 Patrick Burns
 [EMAIL PROTECTED]
 +44 (0)20 8525 0696
 http://www.burns-stat.com
 (home of S Poetry and A Guide for the Unwilling S User)
 
 Shiazy wrote:
 
 Dear R gurus,

 I have a function goftests that receives the following arguments:
 * a vector x of data values;
 * a distribution name dist;
 * the dots list (...) containing a list a parameters to pass to CDF 
 function;
 and calls several goodness-of-fit tests on the given data values 
 against the given distribution.
 That is:

 # BEGIN CODE SNIP #

 # Covert a distribution name to the related CDF function name
 distname2cdfname - function( dist )
 {
   if ( dist == beta ) { return( pbeta ); }
   if ( dist == cauchy ) { return( pcauchy ); }

   # many other and personalized (e.g. pareto, ...) distributions ...

   return(  ); # fall-back case
 }

 # Performs some GoF tests (KS, Chi-Square, Anderson-Darling,...)
 # (the ... list contains parameters for CDF function)
 goftests - function( x, dist, ... )
 {
   cdfname - distname2cdfname( dist );
   res$ks - ks.test( x, cdfname, ... );
   # res$chisq - ...
   # res$anddarl - ...

   return( res )
 };

 # END CODE SNIP #

 So the problem is passing ... to CDF function (for instance, see 
 ks.test above) in the right form. The ... is passed (to 
 goftests) as a list object and it should be converted to an 
 argument list.
 For instance:

 # BEGIN CODE SNIP #

 parms - list( shape1 = 2, shape2 = 5 );
 goftests( x, beta, parms[[shape1]], parms[[shape2]] ); # Works!
 goftests( x, beta, parms ) # Don't Works!

 parms - list( aNum = 5, aVector = c(1,2,3), aMatrix = 
 matrix(c(4,5,6,7,8,9),nrow=2,byrow=T) );
 goftests( x, my-special-distr, parms[[aVector]], 
 parms[[aMatrix]], parms[[aNumber]] ); # Works!
 goftests( x, my-special-distr, parms ) # Don't Works!

 # END CODE SNIP #

 Obviously I have to use the don't work form.

 How can I do this in R (if possible)?

 Thank you very much in advance!

 Best regards,

 -- Marco

 __
 R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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 paste()

2007-03-03 Thread Michael Kubovy
Dear r-helpers,

Could you please tell me what's missing:
rbind(paste('txt.est',1:24, sep = ''))
txt.est1, ... txt.est24 are vectors that I wish to rbind.
_
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400Charlottesville, VA 22904-4400
Parcels:Room 102Gilmer Hall
 McCormick RoadCharlottesville, VA 22903
Office:B011+1-434-982-4729
Lab:B019+1-434-982-4751
Fax:+1-434-982-4766
WWW:http://www.people.virginia.edu/~mk9y/

__
R-help@stat.math.ethz.ch 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] Help with paste()

2007-03-03 Thread Christos Hatzis
What do you want to do with rbind?
paste produces a single vector of 24 character-valued elements.
If you want a column vector, you could do that by

x - paste('txt.est',1:24, sep = '')
matrix(x, ncol=1)

-Christos

Christos Hatzis, Ph.D.
Nuvera Biosciences, Inc.
400 West Cummings Park
Suite 5350
Woburn, MA 01801
Tel: 781-938-3830
www.nuverabio.com
 
  

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Michael Kubovy
 Sent: Saturday, March 03, 2007 2:30 PM
 To: r-help@stat.math.ethz.ch list
 Subject: [R] Help with paste()
 
 Dear r-helpers,
 
 Could you please tell me what's missing:
 rbind(paste('txt.est',1:24, sep = ''))
 txt.est1, ... txt.est24 are vectors that I wish to rbind.
 _
 Professor Michael Kubovy
 University of Virginia
 Department of Psychology
 USPS: P.O.Box 400400Charlottesville, VA 22904-4400
 Parcels:Room 102Gilmer Hall
  McCormick RoadCharlottesville, VA 22903
 Office:B011+1-434-982-4729
 Lab:B019+1-434-982-4751
 Fax:+1-434-982-4766
 WWW:http://www.people.virginia.edu/~mk9y/
 
 __
 R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] Help with paste()

2007-03-03 Thread Charilaos Skiadas

On Mar 3, 2007, at 2:29 PM, Michael Kubovy wrote:

 Dear r-helpers,

 Could you please tell me what's missing:
 rbind(paste('txt.est',1:24, sep = ''))
 txt.est1, ... txt.est24 are vectors that I wish to rbind.

the paste call just returns a vector of the strings txt.est1 and so  
on. Then you tell it to rbind this vector with nothing else.

You might want to try something like this, though I hope someone else  
comes with a better solution:

cmd - paste(rbind(,paste('txt.est',1:24, sep = '',collapse=, ),  
), sep=)
eval(parse(text=cmd))


Haris Skiadas
Department of Mathematics and Computer Science
Hanover College

__
R-help@stat.math.ethz.ch 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] R software to place points on Yahoo maps

2007-03-03 Thread Gabor Grothendieck
Is there any R software that create an image from Yahoo maps together
with points of known UTM coordinates (or lat/long marked?  Note that
my region of interest is not covered in sufficient detail by Google maps.
It actually does not have to be Yahoo maps as long as it has sufficient
coverage of my region but that's the one I have found with coverage of
my region.  The scale I am interested in is a city block.

Thanks.

__
R-help@stat.math.ethz.ch 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 override ordering of panels in xyplot()

2007-03-03 Thread Michael Kubovy
Dear r-helpers,

I'm conditioning an xyplot on a variable whose levels are'low',  
'med', 'high'. How do I override the alphabetical ordering for the  
panels of the plot?
_
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400Charlottesville, VA 22904-4400
Parcels:Room 102Gilmer Hall
 McCormick RoadCharlottesville, VA 22903
Office:B011+1-434-982-4729
Lab:B019+1-434-982-4751
Fax:+1-434-982-4766
WWW:http://www.people.virginia.edu/~mk9y/

__
R-help@stat.math.ethz.ch 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] Help with paste()

2007-03-03 Thread Marc Schwartz
On Sat, 2007-03-03 at 14:29 -0500, Michael Kubovy wrote:
 Dear r-helpers,
 
 Could you please tell me what's missing:
 rbind(paste('txt.est',1:24, sep = ''))
 txt.est1, ... txt.est24 are vectors that I wish to rbind.


Micheal,

Try this, presuming that each vector is the same length:

# Create three vectors 

txt.est1 - letters
txt.est2 - letters
txt.est3 - letters


MAT - t(sapply(paste('txt.est',1:3, sep = ''), get))

 MAT
 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
txt.est1 a  b  c  d  e  f  g  h  i  j   k   l  
txt.est2 a  b  c  d  e  f  g  h  i  j   k   l  
txt.est3 a  b  c  d  e  f  g  h  i  j   k   l  
 [,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22]
txt.est1 m   n   o   p   q   r   s   t   u   v  
txt.est2 m   n   o   p   q   r   s   t   u   v  
txt.est3 m   n   o   p   q   r   s   t   u   v  
 [,23] [,24] [,25] [,26]
txt.est1 w   x   y   z  
txt.est2 w   x   y   z  
txt.est3 w   x   y   z 


So in your case:

MAT - t(sapply(paste('txt.est',1:24, sep = ''), get))

See ?get

You need to use get() in order to 'get' the actual vectors using the
vector names created in paste()

HTH,

Marc Schwartz

__
R-help@stat.math.ethz.ch 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] How to override ordering of panels in xyplot()

2007-03-03 Thread Deepayan Sarkar
On 3/3/07, Michael Kubovy [EMAIL PROTECTED] wrote:
 Dear r-helpers,

 I'm conditioning an xyplot on a variable whose levels are'low',
 'med', 'high'. How do I override the alphabetical ordering for the
 panels of the plot?

This has less to do with xyplot and more to do with the default of the
'levels' argument in the factor() function. Just make sure the levels
are in the right order in your data when xyplot is called.

Deepayan

__
R-help@stat.math.ethz.ch 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] function doesnt return/create object

2007-03-03 Thread Matthias Bannert
hello,
i have written a function to extract certain lines from a matrix. the  
result is a matrix with 6 cols, named dynamically according to the  
functions arguments.

the problem is now, that i'm not able to return the resultmatrix for  
further use. the object is not being created.

example from my console:

getans(27,27)
[...]
[189,] 3969  161   27101
[190,] 2142   87   27101
[191,] 1318   52   27101
[192,] 2881  120   27101
[193,] 3669  152   27101
[194,] 5653  229   27101
[195,] 2308   95   27102
[196,] 4942  200   27101
the matrix ansblock27 contains answers to block 27
  ansblock27
error: object ansblock27 not found
 



the code of the function:

getans = function(x=qids,bnr=1,type=block)
{
#generate name of matrix
matnam=paste(ans,type,as.character(bnr),sep=)

#display result matrix
show(assign(matnam,matrix(as.numeric(as.matrix(allans[(allans[, 3] %in 
% x), , drop = FALSE])),ncol=dim(allans)[2])))

#create result matrix
assign(matnam,matrix(as.numeric(as.matrix(allans[(allans[, 3] %in%  
x), , drop = FALSE])),ncol=dim(allans)[2]))

#print info
cat(the matrix,matnam,contains answers to,type,as.character(bnr))   

}

i have tried to use return, but had no success.

what else can i do?

thx in advance, and have a nice weekend
regards,
matthias




es schreibt Ihnen:

Matthias Bannert
---
mediabar (Off / Bannert GbR)
Brüelstr.21
78462 Konstanz
fon.: 0711 50 88 72 34
mobil.: 0179 29 85 630

web: http://www.mediabar.info
email: [EMAIL PROTECTED]




[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] apply ? function doesnt create object

2007-03-03 Thread bunny , lautloscrew.com
hello,
i have written a function to extract certain lines from a matrix. the  
result is a matrix with 6 cols, named dynamically according to the  
functions arguments.

the problem is now, that i'm not able to return the resultmatrix for  
further use. the object is not being created.

example from my console:

getans(27,27)
[...]
[189,] 3969  161   27101
[190,] 2142   87   27101
[191,] 1318   52   27101
[192,] 2881  120   27101
[193,] 3669  152   27101
[194,] 5653  229   27101
[195,] 2308   95   27102
[196,] 4942  200   27101
the matrix ansblock27 contains answers to block 27
  ansblock27
error: object ansblock27 not found
 



the code of the function:

getans = function(x=qids,bnr=1,type=block)
{
#generate name of matrix
matnam=paste(ans,type,as.character(bnr),sep=)

#display result matrix
show(assign(matnam,matrix(as.numeric(as.matrix(allans[(allans[, 3] %in 
% x), , drop = FALSE])),ncol=dim(allans)[2])))

#create result matrix
assign(matnam,matrix(as.numeric(as.matrix(allans[(allans[, 3] %in%  
x), , drop = FALSE])),ncol=dim(allans)[2]))

#print info
cat(the matrix,matnam,contains answers to,type,as.character(bnr))   

}

i have tried to use return, but had no success.

what else can i do?

thx in advance, and have a nice weekend
regards,


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] Sigmoidal fitting

2007-03-03 Thread Cressoni, Massimo \(NIH/NHLBI\) [F]

I am trying to write a function that fits a sigmoid given a X and Y vector 
guessing the start parameters.
I use nls. What I did (enclosed) seems to work well with many data points but 
if I want to fit small
vectors like :

pressure - c(5,15,9,35,45)
gas - c(1000,2000,3000,4000,5000)

it do not work. The help page says that it do no not work on zero residual data.

Massimo Cressoni

__
R-help@stat.math.ethz.ch 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 a sigmoid

2007-03-03 Thread Cressoni, Massimo \(NIH/NHLBI\) [F]

I am trying to write a function that fits a sigmoid given a X and Y vector 
guessing the start parameters.
I use nls. What I did (enclosed) seems to work well with many data points but 
if I want to fit small
vectors like :

pressure - c(5,15,9,35,45)
gas - c(1000,2000,3000,4000,5000)

it do not work. The help page says that it do no not work on zero residual data.

Massimo Cressoni

PS 
The functions I wrote are the following :


x25 = function(y_range)
{
 x25r = min(y_range) + (max(y_range) - min(y_range))/4
 x25r
}

x75 = function(y_range)
{
 x75r = min(y_range) + 3*(max(y_range) - min(y_range))/4
 x75r
}Get

GetStartSigmoidValues = function(pointsY)
{
 start_a = max(pointsY) - min(pointsY)
 start_x0 = min(pointsY) + (max(pointsY) - min(pointsY))/2
 start_b = (x75(pointsY) - x25(pointsY))/4
 start_y0 = min(pointsY)

 start_list = list(a=start_a,x0=start_x0,b=start_b,y0=start_y0)
 start_list
}

FitSigmoid = function(pointsX,pointsY)
{
 start_list = GetStartSigmoidValues(pointsY)
 fitting = nls(pointsY ~ y0+a/(1+exp(-(pointsX - x0)/b)),start=start_list)
 fitting
}

__
R-help@stat.math.ethz.ch 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] apply ? function doesnt create object

2007-03-03 Thread Charilaos Skiadas
On Mar 3, 2007, at 4:28 PM, bunny , lautloscrew.com wrote:

Please use - for assignments instead of = :

 getans = function(x=qids,bnr=1,type=block)
   {
 #generate name of matrix
 matnam=paste(ans,type,as.character(bnr),sep=)

 #display result matrix
 show(assign(matnam,matrix(as.numeric(as.matrix(allans[(allans[, 3] %in
 % x), , drop = FALSE])),ncol=dim(allans)[2])))

You are assigning things twice here.

 #create result matrix
 assign(matnam,matrix(as.numeric(as.matrix(allans[(allans[, 3] %in%
 x), , drop = FALSE])),ncol=dim(allans)[2]))

The documentation for assign makes it pretty clear that the  
assignment happens by default in the current environment, so it will  
be local to the function unless you alter the call. The description  
there, along with the examples, and a study of environments, should  
provide you with the answer.

 #print info
 cat(the matrix,matnam,contains answers to,type,as.character 
 (bnr))
   
 }

Haris Skiadas
Department of Mathematics and Computer Science
Hanover College

__
R-help@stat.math.ethz.ch 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] tcl/tk printing to console is far too slow

2007-03-03 Thread Alex Couture-Beil
Hello - I am finding that printing to the console from a function that 
is invoked from tcl/tk (i.e. pushing a button) is really slow.
Consider the following example.

doStuff - function() {
source(file.path(system.file(package = base), demo, 
is.things.R), echo=TRUE)
}

tt - tktoplevel()
button.widget - tkbutton(tt,text=Do Stuff, command=doStuff)
tkpack(button.widget)


I find that this is significantly slower than if I ran source(...) 
directly from the console prompt. In the back of my mind, I am thinking 
this might be some effect related to multi-threading and the 
locking/unlocking of a mutex - am I right?

Any help to speed this up would be appreciated.

Thanks,
Alex Couture-Beil

PS: I am running this test with R 2.4.1 on WinXP

__
R-help@stat.math.ethz.ch 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] function doesnt return/create object

2007-03-03 Thread jim holtman
Instead of trying to create object back in the global environment (which is
not really recommended from a function), return the answer in a list that
you can then access it as you want.  Here is an example:


 getans - function(x){
+ # create the name that you want in the list
+ .name - paste(x, '.Ans', sep='')
+ .ans - list(runif(10))   # create some data to return
+ names(.ans) - .name
+ .ans# return the answer
+ }

 my.ans - getans('newName')
 my.ans  # show what was returned
$newName.Ans
 [1] 0.2059746 0.1765568 0.6870228 0.3841037 0.7698414 0.4976992 0.7176185
0.9919061 0.3800352 0.7774452

 # access by the new name
 my.ans$newName.Ans
 [1] 0.2059746 0.1765568 0.6870228 0.3841037 0.7698414 0.4976992 0.7176185
0.9919061 0.3800352 0.7774452





On 3/3/07, Matthias Bannert [EMAIL PROTECTED] wrote:

 hello,
 i have written a function to extract certain lines from a matrix. the
 result is a matrix with 6 cols, named dynamically according to the
 functions arguments.

 the problem is now, that i'm not able to return the resultmatrix for
 further use. the object is not being created.

 example from my console:

 getans(27,27)
 [...]
 [189,] 3969  161   27101
 [190,] 2142   87   27101
 [191,] 1318   52   27101
 [192,] 2881  120   27101
 [193,] 3669  152   27101
 [194,] 5653  229   27101
 [195,] 2308   95   27102
 [196,] 4942  200   27101
 the matrix ansblock27 contains answers to block 27
  ansblock27
 error: object ansblock27 not found
 



 the code of the function:

 getans = function(x=qids,bnr=1,type=block)
{
 #generate name of matrix
 matnam=paste(ans,type,as.character(bnr),sep=)

 #display result matrix
 show(assign(matnam,matrix(as.numeric(as.matrix(allans[(allans[, 3] %in
 % x), , drop = FALSE])),ncol=dim(allans)[2])))

 #create result matrix
 assign(matnam,matrix(as.numeric(as.matrix(allans[(allans[, 3] %in%
 x), , drop = FALSE])),ncol=dim(allans)[2]))

 #print info
 cat(the matrix,matnam,contains answers to,type,as.character(bnr))

 }

 i have tried to use return, but had no success.

 what else can i do?

 thx in advance, and have a nice weekend
 regards,
 matthias



 
 es schreibt Ihnen:

 Matthias Bannert
 ---
 mediabar (Off / Bannert GbR)
 Brüelstr.21
 78462 Konstanz
 fon.: 0711 50 88 72 34
 mobil.: 0179 29 85 630

 web: http://www.mediabar.info
 email: [EMAIL PROTECTED]




[[alternative HTML version deleted]]


 __
 R-help@stat.math.ethz.ch 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.




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] lattice histogram

2007-03-03 Thread Aimin Yan
How to add mean,sd, number of observation in each panel for lattice histogram?

Aimin

__
R-help@stat.math.ethz.ch 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.