[R] Problem of lmer under FreeBSD

2007-12-27 Thread ronggui
I encounter such problem with lmer under FreeBSD, but not under
Windows. Anyone knows why? Thanks.

 example(lmer)

lmer (fm1 - lmer(Reaction ~ Days + (Days|Subject), sleepstudy))
Error in UseMethod(as.logical) : no applicable method for as.logical
 traceback()
9: as.logical(EMverbose)
8: as.logical(EMverbose)
7: lmerControl()
6: do.call(lmerControl, control)
5: lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
4: eval.with.vis(expr, envir, enclos)
3: eval.with.vis(ei, envir)
2: source(zfile, local, echo = echo, prompt.echo = paste(prompt.prefix,
   getOption(prompt), sep = ), continue.echo = paste(prompt.prefix,
   getOption(continue), sep = ), verbose = verbose,
max.deparse.length = Inf,
   encoding = encoding, skip.echo = skips)
1: example(lmer)


 sessionInfo()
R version 2.6.0 (2007-10-03)
i386-portbld-freebsd6.3

locale:
C

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

other attached packages:
[1] lme4_0.99875-9Matrix_0.999375-2 lattice_0.16-5

loaded via a namespace (and not attached):
[1] grid_2.6.0  rcompgen_0.1-15 tools_2.6.0

-- 
Ronggui Huang

Department of Sociology, Fudan University, Shanghai, China

Department of Public and Social Administration, CityU, HK

__
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] Error: cannot allocate vector of size ... Bcc: Add Cc | Add Bcc

2007-12-27 Thread Maura E Monville
I read the subject message in a number of R archived emails.
Since I am experiencing the same problem:

 upfmla
A ~ T + cosP + cos2P + cos4P + cos5P + sin3P + sin5P + cosP2 +
sinP3 + P2
 glmod - gls(upfmla,correlation=corAR1(),method=ML)
Error: cannot allocate vector of size 491.3 Mb

 dim(xx)
[1] 8025   14

and since I'm running R on a 64-bit Linux platform ... I wonder whether this
problem has
been solved or I'm better off giving up the Generalized Least Squares
models.
Would it make sense to break the data into two halves and fit one half at a
time ?

Thank you .

Happy new year,
-- 
Maura E.M

[[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] (package e1071) SVM tune for best parameters: why they are different everytime i run?

2007-12-27 Thread Maggie Wang
Hi,

I run the following tuning function for svm. It's very strange that every
time i run this function, the best.parameters give different values.

[A]

svm.tune - tune(svm, train.x, train.y,

validation.x=train.x, validation.y=train.y,

 ranges = list(gamma = 2^(-1:2),

 cost = 2^(-3:2)))



# where train.x and train.y are matrix specified.



# output command:



svm.tune$best.parameters$cost

svm.tune$best.parameters$gamma



result:

 cost gamma
 0.25  4.00



run A again:

 cost gamma
1 4



again:

  cost gamma
 0.25  4.00



The result is so unstable, if it varies so much, why do we need to tune? Do
you know if this behavior is normal? Can we trust the best.parameters for
prediction?



Thank you so much to help out!!



Best Regards,

Maggie

[[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] nlme package

2007-12-27 Thread Uwe Ligges

AGAIN, please do not crosspost!


Vallejo, Roger wrote:
 In using the NLME package (R 2.6.1 for Windows),

Which version of nlme? nlme is a contributed package that can be updated 
independently of R releases.


 I am having a problem in running an R script that used to run with no 
 problems using a Linux OS in 2004. So I am wondering if during these last ~3 
 yrs we had major changes in the syntax of the NLME package that I am not 
 aware. 

For sure you are not aware. And which version of nlme have you used in 2004?


 This is the R script:
  
 library(nlme)
  
 treat=as.factor(c(1,2,1,2,1,2,1,2))
 mouse=as.factor(c(1,1,2,2,3,3,4,4))
 time=as.factor(c(1,1,1,1,2,2,2,2))
 
 mouse.anova=function(vec){lme(vec~treat+time+treat*time,random=~1|mouse/time)}
  
  
 lme.out=apply(exprmat,1,mouse.anova)


Well, out error message is:

Error in apply(exprmat, 1, mouse.anova) : object exprmat not found


Guess why ... and re-read the posting guide, please.


Uwe Ligges



 This is the ERROR message:
  
 Error in lme.formula(vec ~ treat + time + treat * time, random = ~1 |  : 
   nlminb problem, convergence error code = 1
   message = singular convergence (7)
  
 I will appreciate your help in pointing mistakes in this R script. 
 Thank you very much.
 Roger
 
 Roger L. Vallejo, Ph.D.
 Computational Biologist  Geneticist
 U.S. Department of Agriculture, ARS
 National Center for Cool  Cold Water Aquaculture
 11861 Leetown Road
 Kearneysville, WV 25430
 Voice:  (304) 724-8340 Ext. 2141
 Email:  [EMAIL PROTECTED]
 http://www.ars.usda.gov/pandp/people/people.htm?personid=37662
 
 
   [[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] data.frame - how to calculate the number of rows

2007-12-27 Thread Henrique Dallazuanna
Try this:

summaryBy(B+C~ A+D,  data=daten,FUN=c(mean, var, length))

On 26/12/2007, Agrarimmobilien [EMAIL PROTECTED] wrote:
 this works now,

 cbind(summaryBy(B+C~ A,  data=df, FUN=c(mean, var)),
 'numrows'=as.numeric(table(df$A)))


 but now, I cannot add another column D beside A, as I do before, like

 cbind(summaryBy(B+C~ A+D,  data=df,FUN=c(mean, var)),
 'numrows'=as.numeric(table(df$A)))

 because of this D, I got the following error message in german:
 Fehler in data.frame(..., check.names = FALSE) :  Argumente implizieren
 unterschiedliche Anzahl Zeilen: 21, 18

 error in data.frame(, check.names = FALSE): arguments has differents
 counts of rows: 21, 18

 has anybody an idea, what I can do ?




 On 26/12/2007, Agrarimmobilien [EMAIL PROTECTED] wrote:
  Hello,
 
  I had to give some more information to my posting:
 
  as ouput there are more than one row, depending on the values of column A
  (transformierung to distinct values, here 3 and 4, but there are much
  more)
 
  ABC
   1  3 6 5
   2  3 4 20
   3  3 8 2
   4  4 8 3
   5  4 2 6
 
  Output:
 
  ABC  num rows
   1  36 6.16  3
   2  45 4.00  3
 
 
  B is mean and C variance.
 
 
  thank you
  Macki
 
 
 
   Hello,
  
   it seems to be a simple problem, but  I couldn't find an answer in the
   archiv. (I think, it must has something to do with the group-select,
   like
   in
   php)
  
   I've the following data.frame:
  
  ABC
   1  3 6 5
   2  4 4 20
   3  5 8 2
  
   I want to get the number of the rows in the 4th column, like:
  
  ABC  num rows
   1  36 6.16  3
  
  
   (B is mean, C is variance by using summaryBy(B+C~ A,  data=daten,
   FUN=c(mean,var))  from the doBy-package)
  
   But, how can I add the column 'numrow' and count the number of the rows?
  
   Thanks!
  
   Macki
  
   __
   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.
 


 --
 Henrique Dallazuanna
 Curitiba-Paraná-Brasil
 25° 25' 40 S 49° 16' 22 O

 __
 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.



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

__
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] how to remove paths from where library() looks for packages

2007-12-27 Thread Henrique Dallazuanna
Perhaps this:

.libPaths(unique(installed.packages()[,2]))

On 25/12/2007, Lynd Bacon [EMAIL PROTECTED] wrote:
 Greetings.  My current installation of R 2.6.1 on Unbuntu 7.10 (Gutsy)
 is looking for packages in a directory that doesn't contain any:

   library()
 Warning message:
 In library() : library /usr/lib/R/site-library contains no packages

   .libPaths()
 [1] /usr/local/lib/R/site-library /usr/lib/R/site-library
 [3] /usr/lib/R/library

 I'd like to eliminate the path to the empty directory so I don't get
 this vexsome warning message.  Any and all suggestions will be greatly
 appreciated!

 Cheers,

 Lynd

 --
 _
 Lynd Bacon
 Woodside CA USA GMT-08:00

 __
 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.



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

__
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 e1071) SVM tune for best parameters: why they are different everytime i run?

2007-12-27 Thread Uwe Ligges


Maggie Wang wrote:
 Hi,
 
 I run the following tuning function for svm. It's very strange that every
 time i run this function, the best.parameters give different values.
 
 [A]
 
 svm.tune - tune(svm, train.x, train.y,
 
 validation.x=train.x, validation.y=train.y,
 
  ranges = list(gamma = 2^(-1:2),
 
  cost = 2^(-3:2)))
 
 
 
 # where train.x and train.y are matrix specified.
 
 
 
 # output command:
 
 
 
 svm.tune$best.parameters$cost
 
 svm.tune$best.parameters$gamma
 
 
 
 result:
 
  cost gamma
  0.25  4.00
 
 
 
 run A again:
 
  cost gamma
 1 4
 
 
 
 again:
 
   cost gamma
  0.25  4.00
 
 
 
 The result is so unstable, if it varies so much, why do we need to tune? Do
 you know if this behavior is normal? Can we trust the best.parameters for
 prediction?

I guess you do not have really many observations in your dataset. Then 
it highly depends ion the cross validation sets which parameter is best. 
And therefore you get quite different results.

Uwe Ligges



 
 
 Thank you so much to help out!!
 
 
 
 Best Regards,
 
 Maggie
 
   [[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] (package e1071) SVM tune for best parameters: why they are different everytime i run?

2007-12-27 Thread Maggie Wang
Thank you so much! I will have a try!! ~ maggie

On Dec 27, 2007 6:43 PM, Uwe Ligges [EMAIL PROTECTED]
wrote:



 Maggie Wang wrote:
  Hi, Uwe,
 
  Thanks for the reply!!  I have 87 observations in total. If this amount
  causes the different best.parameters, is there a better way than cross
  validation to tune them?


 In order to get stable (I do not say best) results, you could try some
 bootstrap with many replications or leave-one-out crossvalidation.

 Uwe

  Thank you so much for the help!
 
  Best Regards,
  Maggie
 
  On Dec 27, 2007 6:17 PM, Uwe Ligges [EMAIL PROTECTED]
  wrote:
 
 
  Maggie Wang wrote:
  Hi,
 
  I run the following tuning function for svm. It's very strange that
  every
  time i run this function, the best.parameters give different values.
 
  [A]
 
  svm.tune - tune(svm, train.x, train.y,
  validation.x=train.x, validation.y=train.y,
 
   ranges = list(gamma = 2^(-1:2),
 
   cost = 2^(-3:2)))
 
 
 
  # where train.x and train.y are matrix specified.
 
 
 
  # output command:
 
 
 
  svm.tune$best.parameters$cost
  svm.tune$best.parameters$gamma
 
 
  result:
 
   cost gamma
   0.25  4.00
 
 
 
  run A again:
 
   cost gamma
  1 4
 
 
 
  again:
 
cost gamma
   0.25  4.00
 
 
 
  The result is so unstable, if it varies so much, why do we need to
 tune?
  Do
  you know if this behavior is normal? Can we trust the
 best.parametersfor
  prediction?
  I guess you do not have really many observations in your dataset. Then
  it highly depends ion the cross validation sets which parameter is
 best.
  And therefore you get quite different results.
 
  Uwe Ligges
 
 
 
 
  Thank you so much to help out!!
 
 
 
  Best Regards,
 
  Maggie
 
[[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.htmlhttp://www.r-project.org/posting-guide.html
 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] Affy Package

2007-12-27 Thread Uwe Ligges
Damn, this was a cross-post (and I replied to all), apologies for my 
re-cross-posting.

To Roger, the original poster: PLEASE do read the posting guide of 
R-help before posting and NEVER EVER do crossposting again.

Thanks,
Uwe Ligges

Uwe Ligges wrote:
 
 
 Vallejo, Roger wrote:
 Dear R Users,
 In the expresso function, which combination of these methods for data 
 pre-processing (when using affymetrix oligo arrays) is the best:

 bgcorrect.metod = rma rma2 mas

 normalize.method = qspline quantiles loess

 pmcorrect.method = pmonly subtractmm mas

 summary.method = liwong avgdiff medianpolish mas

 There are many options within each method. I would appreciate a hint 
 on the best combination. 
 
 
 There is more than one implemented, hence we can guess that there is no 
 generally best one among these, i.e. it depends on your data what to use.
 
 Uwe Ligges
 
 
 Thank you very much in advance.
 Roger
  
  
 Roger L. Vallejo, Ph.D.
 Computational Biologist  Geneticist
 U.S. Department of Agriculture, ARS
 National Center for Cool  Cold Water Aquaculture
 11861 Leetown Road
 Kearneysville, WV 25430
 Voice:  (304) 724-8340 Ext. 2141
 Email:  [EMAIL PROTECTED]
 http://www.ars.usda.gov/pandp/people/people.htm?personid=37662

 [[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] (package e1071) SVM tune for best parameters: why they are different everytime i run?

2007-12-27 Thread Uwe Ligges


Maggie Wang wrote:
 Hi, Uwe,
 
 Thanks for the reply!!  I have 87 observations in total. If this amount
 causes the different best.parameters, is there a better way than cross
 validation to tune them?


In order to get stable (I do not say best) results, you could try some 
bootstrap with many replications or leave-one-out crossvalidation.

Uwe

 Thank you so much for the help!
 
 Best Regards,
 Maggie
 
 On Dec 27, 2007 6:17 PM, Uwe Ligges [EMAIL PROTECTED]
 wrote:
 

 Maggie Wang wrote:
 Hi,

 I run the following tuning function for svm. It's very strange that
 every
 time i run this function, the best.parameters give different values.

 [A]

 svm.tune - tune(svm, train.x, train.y,
 validation.x=train.x, validation.y=train.y,

  ranges = list(gamma = 2^(-1:2),

  cost = 2^(-3:2)))



 # where train.x and train.y are matrix specified.



 # output command:



 svm.tune$best.parameters$cost
 svm.tune$best.parameters$gamma


 result:

  cost gamma
  0.25  4.00



 run A again:

  cost gamma
 1 4



 again:

   cost gamma
  0.25  4.00



 The result is so unstable, if it varies so much, why do we need to tune?
 Do
 you know if this behavior is normal? Can we trust the best.parametersfor
 prediction?
 I guess you do not have really many observations in your dataset. Then
 it highly depends ion the cross validation sets which parameter is best.
 And therefore you get quite different results.

 Uwe Ligges




 Thank you so much to help out!!



 Best Regards,

 Maggie

   [[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.htmlhttp://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] (package e1071) SVM tune for best parameters: why they are different everytime i run?

2007-12-27 Thread Maggie Wang
Hi, Uwe,

Thanks for the reply!!  I have 87 observations in total. If this amount
causes the different best.parameters, is there a better way than cross
validation to tune them?

Thank you so much for the help!

Best Regards,
Maggie

On Dec 27, 2007 6:17 PM, Uwe Ligges [EMAIL PROTECTED]
wrote:



 Maggie Wang wrote:
  Hi,
 
  I run the following tuning function for svm. It's very strange that
 every
  time i run this function, the best.parameters give different values.
 
  [A]
 
  svm.tune - tune(svm, train.x, train.y,
 
  validation.x=train.x, validation.y=train.y,
 
   ranges = list(gamma = 2^(-1:2),
 
   cost = 2^(-3:2)))
 
 
 
  # where train.x and train.y are matrix specified.
 
 
 
  # output command:
 
 
 
  svm.tune$best.parameters$cost
 
  svm.tune$best.parameters$gamma
 
 
 
  result:
 
   cost gamma
   0.25  4.00
 
 
 
  run A again:
 
   cost gamma
  1 4
 
 
 
  again:
 
cost gamma
   0.25  4.00
 
 
 
  The result is so unstable, if it varies so much, why do we need to tune?
 Do
  you know if this behavior is normal? Can we trust the best.parametersfor
  prediction?

 I guess you do not have really many observations in your dataset. Then
 it highly depends ion the cross validation sets which parameter is best.
 And therefore you get quite different results.

 Uwe Ligges



 
 
  Thank you so much to help out!!
 
 
 
  Best Regards,
 
  Maggie
 
[[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.htmlhttp://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] Error: cannot allocate vector of size ...

2007-12-27 Thread Uwe Ligges


Maura E Monville wrote:
 I read the subject message in a number of R archived emails.
 Since I am experiencing the same problem:
 
 upfmla
 A ~ T + cosP + cos2P + cos4P + cos5P + sin3P + sin5P + cosP2 +
 sinP3 + P2
 glmod - gls(upfmla,correlation=corAR1(),method=ML)
 Error: cannot allocate vector of size 491.3 Mb
 
 dim(xx)
 [1] 8025   14

How much memory is consumed in your workspace? If so, remove huge 
objects from your workspace
How big is upfmla? Are there factors in it? If so, how many levels? Then 
you can calculate the size of your design matrix.
64-bit is nice, but how much RAM is in your machine?

Uwe Ligges


 and since I'm running R on a 64-bit Linux platform ... I wonder whether this
 problem has
 been solved or I'm better off giving up the Generalized Least Squares
 models.
 Would it make sense to break the data into two halves and fit one half at a
 time ?
 
 Thank you .
 
 Happy new year,

__
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] Affy Package

2007-12-27 Thread Uwe Ligges


Vallejo, Roger wrote:
 Dear R Users,
 In the expresso function, which combination of these methods for data 
 pre-processing (when using affymetrix oligo arrays) is the best:
 
 bgcorrect.metod = rma rma2 mas
 
 normalize.method = qspline quantiles loess
 
 pmcorrect.method = pmonly subtractmm mas
 
 summary.method = liwong avgdiff medianpolish mas
 
 There are many options within each method. I would appreciate a hint on the 
 best combination. 


There is more than one implemented, hence we can guess that there is no 
generally best one among these, i.e. it depends on your data what to use.

Uwe Ligges


 Thank you very much in advance.
 Roger
  
  
 Roger L. Vallejo, Ph.D.
 Computational Biologist  Geneticist
 U.S. Department of Agriculture, ARS
 National Center for Cool  Cold Water Aquaculture
 11861 Leetown Road
 Kearneysville, WV 25430
 Voice:  (304) 724-8340 Ext. 2141
 Email:  [EMAIL PROTECTED]
 http://www.ars.usda.gov/pandp/people/people.htm?personid=37662
 
   [[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] Problem of lmer under FreeBSD

2007-12-27 Thread Rainer Hurling
Hello Ronggui Huang,

I am working with FreeBSD 8.0-CURRENT (i386) and R-2.6.1 (not built from 
ports). After loading version 0.99875-9 of lme4 and then executing the 
example

   library(lme4)
   example(lmer)

all works fine for me.


On 27.12.2007 09:19 (UTC+1), Ronggui wrote:
 I encounter such problem with lmer under FreeBSD, but not under
 Windows. Anyone knows why? Thanks.

Assuming, that your R installation is correct (from math/R ?), you 
should consider to reinstall lme4 and its dependencies. It is possible 
that these package have been built on a prior version of R.

For installing the package 'Matrix' on FreeBSD you have to use
gmake instead of make. The following example will do it

setenv MAKE gmake
R CMD INSTALL Matrix_0.999375-3.tar.gz
unsetenv MAKE

If reinstalling packages not solves your problem, please try if 
reinstalling R does. (Under FreeBSD the R sources build and install 
fine, so there is no need to use the port at math/R ...)

Hope this helps,
Rainer


 example(lmer)
 
 lmer (fm1 - lmer(Reaction ~ Days + (Days|Subject), sleepstudy))
 Error in UseMethod(as.logical) : no applicable method for as.logical
 traceback()
 9: as.logical(EMverbose)
 8: as.logical(EMverbose)
 7: lmerControl()
 6: do.call(lmerControl, control)
 5: lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
 4: eval.with.vis(expr, envir, enclos)
 3: eval.with.vis(ei, envir)
 2: source(zfile, local, echo = echo, prompt.echo = paste(prompt.prefix,
getOption(prompt), sep = ), continue.echo = paste(prompt.prefix,
getOption(continue), sep = ), verbose = verbose,
 max.deparse.length = Inf,
encoding = encoding, skip.echo = skips)
 1: example(lmer)
 
 sessionInfo()
 R version 2.6.0 (2007-10-03)
 i386-portbld-freebsd6.3
 
 locale:
 C
 
 attached base packages:
 [1] stats graphics  grDevices utils datasets  methods   base
 
 other attached packages:
 [1] lme4_0.99875-9Matrix_0.999375-2 lattice_0.16-5
 
 loaded via a namespace (and not attached):
 [1] grid_2.6.0  rcompgen_0.1-15 tools_2.6.0

__
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] Problem of lmer under FreeBSD

2007-12-27 Thread ronggui
Dear Rainer,

Thanks for your suggestion.

The problem lies in the Matrix package. I installed it under R-2.5.0.
When I upgraded R to R-2.6.0, I didn't upgrade all the add-on
packages. I reinstall Matrix and lme4 packages, things are going fine.

Regards

Ronggui HUANG

2007/12/27, Rainer Hurling [EMAIL PROTECTED]:
 Hello Ronggui Huang,

 I am working with FreeBSD 8.0-CURRENT (i386) and R-2.6.1 (not built from
 ports). After loading version 0.99875-9 of lme4 and then executing the
 example

library(lme4)
example(lmer)

 all works fine for me.


 On 27.12.2007 09:19 (UTC+1), Ronggui wrote:
  I encounter such problem with lmer under FreeBSD, but not under
  Windows. Anyone knows why? Thanks.

 Assuming, that your R installation is correct (from math/R ?), you
 should consider to reinstall lme4 and its dependencies. It is possible
 that these package have been built on a prior version of R.

 For installing the package 'Matrix' on FreeBSD you have to use
 gmake instead of make. The following example will do it

 setenv MAKE gmake
 R CMD INSTALL Matrix_0.999375-3.tar.gz
 unsetenv MAKE

 If reinstalling packages not solves your problem, please try if
 reinstalling R does. (Under FreeBSD the R sources build and install
 fine, so there is no need to use the port at math/R ...)

 Hope this helps,
 Rainer


  example(lmer)
 
  lmer (fm1 - lmer(Reaction ~ Days + (Days|Subject), sleepstudy))
  Error in UseMethod(as.logical) : no applicable method for as.logical
  traceback()
  9: as.logical(EMverbose)
  8: as.logical(EMverbose)
  7: lmerControl()
  6: do.call(lmerControl, control)
  5: lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
  4: eval.with.vis(expr, envir, enclos)
  3: eval.with.vis(ei, envir)
  2: source(zfile, local, echo = echo, prompt.echo = paste(prompt.prefix,
 getOption(prompt), sep = ), continue.echo = paste(prompt.prefix,
 getOption(continue), sep = ), verbose = verbose,
  max.deparse.length = Inf,
 encoding = encoding, skip.echo = skips)
  1: example(lmer)
 
  sessionInfo()
  R version 2.6.0 (2007-10-03)
  i386-portbld-freebsd6.3
 
  locale:
  C
 
  attached base packages:
  [1] stats graphics  grDevices utils datasets  methods   base
 
  other attached packages:
  [1] lme4_0.99875-9Matrix_0.999375-2 lattice_0.16-5
 
  loaded via a namespace (and not attached):
  [1] grid_2.6.0  rcompgen_0.1-15 tools_2.6.0





-- 
Ronggui Huang

Department of Sociology, Fudan University, Shanghai, China

Department of Public and Social Administration, CityU, HK

__
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] probability from different values

2007-12-27 Thread Matthias Kohl
one addition ...
 Hello Ricardo,

 another solution could be using package distr:

 library(distr)
 A - c(18,18,18,19,20,21,22,23,24,25,26,27,28)
 DA - DiscreteDistribution(A)
 # maybe
 # support(DA)
 # plot (DA)

 B - c(82,83,84,85,85,86,87,88,89,90,91,91,92)
 DB - DiscreteDistribution(B)
 # support(DB)
 # plot(DB)

 DC - DB - DA# convolution with of DB with (-DA)
 # support(DC)
 # plot(DC)
   
to get the probabilities for the C-values:
p(DC)(support(DC))

 hth,
 Matthias

 [EMAIL PROTECTED] wrote:
   
 i have two vectors (A and B) and i need create another vector (C) 
 from the subtraction of A's values with the B's values. How can i 
 estimate the probability of C's values if i have differents values 
 combinations of A and B that can result in the same value? like 90 
 -20 = 70 and 91 - 21 = 70.

 example:
 B = {18  1818 19  20  21  22  23  24
 25  26  27   28} 
 A = {82 83 84 85  85 86   87 88   89
 90  91 9192 }
 
   
 Try this:
 A = c(18,18,18,19,20,21,22,23,24,25,26,27,28)
 B = c(82,83,84,85,85,86,87,88,89,90,91,91,92)
 lenA = length(A)
 lenB = length(B)
 AA = rep(A, lenB)
 BB = rep(B, each=lenA)
 table(AA-BB)/(lenA*lenB)

 Regards,
 Richie.

 Mathematical Sciences Unit
 HSL


 
 ATTENTION:

 This message contains privileged and confidential inform...{{dropped:20}}

 __
 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-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] probability from different values

2007-12-27 Thread Matthias Kohl
Hello Ricardo,

another solution could be using package distr:

library(distr)
A - c(18,18,18,19,20,21,22,23,24,25,26,27,28)
DA - DiscreteDistribution(A)
# maybe
# support(DA)
# plot (DA)

B - c(82,83,84,85,85,86,87,88,89,90,91,91,92)
DB - DiscreteDistribution(B)
# support(DB)
# plot(DB)

DC - DB - DA# convolution with of DB with (-DA)
# support(DC)
# plot(DC)

hth,
Matthias

[EMAIL PROTECTED] wrote:
 i have two vectors (A and B) and i need create another vector (C) 
 from the subtraction of A's values with the B's values. How can i 
 estimate the probability of C's values if i have differents values 
 combinations of A and B that can result in the same value? like 90 
 -20 = 70 and 91 - 21 = 70.

 example:
 B = {18  1818 19  20  21  22  23  24
 25  26  27   28} 
 A = {82 83 84 85  85 86   87 88   89
 90  91 9192 }
 

 Try this:
 A = c(18,18,18,19,20,21,22,23,24,25,26,27,28)
 B = c(82,83,84,85,85,86,87,88,89,90,91,91,92)
 lenA = length(A)
 lenB = length(B)
 AA = rep(A, lenB)
 BB = rep(B, each=lenA)
 table(AA-BB)/(lenA*lenB)

 Regards,
 Richie.

 Mathematical Sciences Unit
 HSL


 
 ATTENTION:

 This message contains privileged and confidential inform...{{dropped:20}}

 __
 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] R Compilation error on Ubuntu

2007-12-27 Thread Dirk Eddelbuettel
On Tue, Dec 25, 2007 at 01:35:19AM -0800, Satoshi Takahama wrote:
 Hi Taka,
 
 I was just trying to do this yesterday and ran into the same problem 
 (compiling R 2.6.1 on Gutsy Gibbon). Apparently this happens on Debian/Ubuntu 
 distributions because the developer install is separate from the user install.
 
 Basically, to address the configure error:
 
 --with-readline=yes (default) and headers/libs are not available
 
 you need the development version of readline:
   sudo apt-get install libreadline5-dev
 (see http://cran.r-project.org/doc/manuals/R-admin.html)
 
 Later, I ran into another configure error:
 --with-x=yes (default) and X11 headers/libs are not available
 so I installed xorg-dev:
   sudo apt-get install xorg-dev
 (see http://tolstoy.newcastle.edu.au/R/e2/help/06/11/5193.html)
 
 At the end, I also got a configure WARNING:
 you cannot build info or HTML versions of the R manuals 
 so then I installed texinfo:
   sudo apt-get install texinfo
 (see http://tolstoy.newcastle.edu.au/R/e2/help/07/04/15498.html)


If you do 

  sudo apt-get build-dep r-base

you get all build-dependencies automatically filled in by the system.

Dirk


 Hope this helps,
 
 ST
 
 
 - Original Message 
 From: Takatsugu Kobayashi [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Monday, December 24, 2007 10:52:11 AM
 Subject: Re: [R] R Compilation error on Ubuntu
 
 
 Hi
 
 I bought a new laptop HP dv9500 just a week ago and installed a Ubuntu
 gutsy ribbon on this laptop. I wanted to install Fedora but there are
 more threads on Ubuntu, so I decided to install Ubuntu. After hours of
 struggle in configuring x server/graphic card stuff, I installed R for
 Gutsy ribbon using sudo apt-get install g77 r-core'. 
 
 Now when I tried to install 'sp' package I got this error message: 
 
 Warning in install.packages(sp) : argument 'lib' is missing: using
 '/usr/local/lib/R/site-library'
 --- Please select a CRAN mirror for use in this session ---
 Loading Tcl/Tk interface ... done
 trying URL 'http://cran.mtu.edu/src/contrib/sp_0.9-17.tar.gz'
 Content type 'application/x-gzip' length 359194 bytes
 opened URL
 ==
 downloaded 350Kb
 
 * Installing *source* package 'sp' ...
 ** libs
 gcc-4.2 -std=gnu99 -I/usr/share/R/include -I/usr/share/R/include
 -fpic  -g -O2 -c gcdist.c -o gcdist.o
 /bin/bash: gcc-4.2: command not found
 make: *** [gcdist.o] Error 127
 ERROR: compilation failed for package 'sp'
 ** Removing '/usr/local/lib/R/site-library/sp'
 
 The downloaded packages are in
 /tmp/RtmpfOk3H7/downloaded_packages
 Warning message:
 installation of package 'sp' had non-zero exit status in:
 install.packages(sp) 
 
 Then, I removed this gutsy ribbon version of R and attempted to install
 fresh R-2.6.1.tar.gz. When I tried to build it, I got this error
 message:
 
 configure: error: --with-readline=yes (default) and headers/libs are
  not
 available
 
 I installed xserver-xorg-dev ok. 
 
 I am using Fedora 6 on my desktop and have never seen these above error
 messages. Should I install a Fedora and R on it? Or should I just
  create
 a link using 'ln -s'? 
 
 I appreciate your help.
 
 [[replacing trailing spam]]
 
 taka
 
 __
 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.
 
 
 
 
 
   
 
 Never miss a thing.  Make Yahoo your home page.
 
 __
 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.

-- 
Three out of two people have difficulties with fractions.

__
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] probability from different values

2007-12-27 Thread Ricardo Perrone
Hi all,

i'm new R user and i need some help:

i have two vectors (A and B) and i need create another vector (C) from the 
subtraction of A's values with the B's values. How can i estimate the 
probability of C's values if i have differents values combinations of A and B 
that can result in the same value? like 90 -20 = 70 and 91 - 21 = 70.

example:
B = {18  1818 19  20  21  22  23  24  25
  26  27   28} 
A = {82 83 84 85  85 86   87 88   89  90
  91 9192 }

Considering C's values that were computed from different frequencies of the A 
and B, is it necessary any mathematical convolution to estimated the  
probability more precisely?

Thanks a lot

Ricardo




  

Be a better friend, newshound, and

__
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] Too many open files

2007-12-27 Thread Markus Loecher
Dear all,
Did this problem that was posted in 2006 (see below) ever got fully resolved
?
I am encountering the exact same issue
; I have executed get.hist.quote() in a loop and now R not only refuses to
establish any further connections to yahoo, but, worse, it will not open any
files either. For example, I cannot even save my current workspace for that
reason.
I tried 
  closeAllConnections()
As well as 
  showConnections()
But I do not see any open connections.
Also, does get.hist.quote() not close its connection internally once it is
done ?

Any help would be immensely useful as I am quite stuck.
Thanks!

Markus



Re: [R] Too many open files

* This message: [ Message body ] [ More options ]
* Related messages: [ Next message ] [ Previous message ] [ In reply to
] [ [R] error reports ] [ Next in thread ]

From: Seth Falcon sfalcon_at_fhcrc.org
Date: Sat 27 May 2006 - 09:21:36 EST

Omar Lakkis [EMAIL PROTECTED] writes:

 This may be more of an OS question ...
 I have this call

 r = get.hist.quote(symbol, start= format(start, %Y-%m-%d), end=
 format(end, %Y-%m-%d))
 which does a url request

 in a loop and my program runs out of file handlers after few hundred
 rotations. The error message is: 'Too many open files'. Other than
 increasing the file handlers assigned to my process, is there a way to
 cleanly release and reuse these connections?

Inside your loop you need to close the connection object created by url().

for (i in 1:500) {

con - url(urls[i])
## ... stuff here ...
close(con)
}

R only allows you to have a fixed number of open connections at one time,
and they do not get closed automatically when they go out of scope. These
commands may help make clear how things work...

 showConnections()

 description class mode text isopen can read can write
 f = url(http://www.r-project.org;, open=r)
 showConnections()

From: Gabor Grothendieck ggrothendieck_at_gmail.com
Date: Sat 27 May 2006 - 09:47:20 EST

Try closeAllConnections()

__
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] probability from different values

2007-12-27 Thread Richard . Cotton
 i have two vectors (A and B) and i need create another vector (C) 
 from the subtraction of A's values with the B's values. How can i 
 estimate the probability of C's values if i have differents values 
 combinations of A and B that can result in the same value? like 90 
 -20 = 70 and 91 - 21 = 70.
 
 example:
 B = {18  1818 19  20  21  22  23  24
 25  26  27   28} 
 A = {82 83 84 85  85 86   87 88   89
 90  91 9192 }

Try this:
A = c(18,18,18,19,20,21,22,23,24,25,26,27,28)
B = c(82,83,84,85,85,86,87,88,89,90,91,91,92)
lenA = length(A)
lenB = length(B)
AA = rep(A, lenB)
BB = rep(B, each=lenA)
table(AA-BB)/(lenA*lenB)

Regards,
Richie.

Mathematical Sciences Unit
HSL



ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}

__
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] A function for random test based on longest run (UNCLASSIFIED)

2007-12-27 Thread Park, Kyong H Mr ECBC
Classification:  UNCLASSIFIED 
Caveats: NONE

Hello, R users,

Has anybody written a function for random test based on the length of
longest run of same events. I really appreciate your help.

Kyong Park
Classification:  UNCLASSIFIED 
Caveats: NONE


[[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] A function for random test based on longest run of same events (U NCLASSIFIED)

2007-12-27 Thread Park, Kyong H Mr ECBC
Classification:  UNCLASSIFIED 
Caveats: NONE

Hello, R users,

Has anybody written a function for random test based on the length of
longest run of same events. I really appreciate your help.

Kyong Park
Classification:  UNCLASSIFIED 
Caveats: NONE


[[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] how to remove paths from where library() looks for packages

2007-12-27 Thread Lynd Bacon
Thanks, Henrique!  I'm not sure this will help since the paths are 
already unique.

Phil Spector wrote separately(Phil, I hope it's ok that I quote you here 
for the list):
 Lynd -
If the message bothers you, look at /etc/R/Renviron and modify
 the line that defines R_LIBS .  However, note that these are set
 up for you so that if you install packages through either Ubuntu's
 repositories or the install.package() function, everything should
 just work, so you might want to leave things as they are.
This line in this particular installation of R 2.6.1 on my Ubuntu 7.10 
workstation reads:

R_LIBS=${R_LIBS-'/usr/local/lib/R/site-library:/usr/lib/R/site-library:/usr/lib/R/library'}

One question (for me, at least), is why did I start to get this warning 
message, to begin with?  I wasn't getting it with  an earlier version of R.

The warning I'm getting started to appear after I updated from 2.5.1 to 
2.6.1. I did this using the procedure described on:

http://cran.cnr.berkeley.edu/bin/linux/ubuntu/

I used Ubuntu's Synaptic Package Manager to install R initially on this 
particular machine, from what I can recall.  After updating to 2.6.1, 
the packages I had previously installed with 2.5.1 were in the directory 
/usr/local/lib/R/site-library.   When I now install additional packages 
in 2.6.1, they are installed to this directory, and not to 
/usr/lib/R/site-library, the directory library() gives warnings about.   
My hypothesis is that the default library configurations for the two 
versions were different for some reason.

Thanks, Henrique and Phil, for your help!

Cheers,

Lynd


Henrique Dallazuanna wrote:
 Perhaps this:

 .libPaths(unique(installed.packages()[,2]))

 On 25/12/2007, Lynd Bacon [EMAIL PROTECTED] wrote:
   
 Greetings.  My current installation of R 2.6.1 on Unbuntu 7.10 (Gutsy)
 is looking for packages in a directory that doesn't contain any:

   library()
 Warning message:
 In library() : library /usr/lib/R/site-library contains no packages

   .libPaths()
 [1] /usr/local/lib/R/site-library /usr/lib/R/site-library
 [3] /usr/lib/R/library

 I'd like to eliminate the path to the empty directory so I don't get
 this vexsome warning message.  Any and all suggestions will be greatly
 appreciated!

 Cheers,

 Lynd

 --
 _
 Lynd Bacon
 Woodside CA USA GMT-08:00

 __
 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.

 


   

-- 
_
Lynd Bacon
Woodside CA USA GMT-08:00
+1 650.593.2198 (home office)
+1 650.462.8015 (YouGov/Polimetrix Inc.)
+1 650.863.1959 (mobile)
[EMAIL PROTECTED]

__
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] Principal Components Analysis

2007-12-27 Thread Prof Brian Ripley
On Wed, 26 Dec 2007, SNN wrote:


 Hi,

 I do have a file that has 50 columns and 40 rows. I want to apply PCA on
 that data and this is what I did

 h1-read.table(Ccode.txt, sep='\t', header=F) # reads the data from the
 file Ccode.txt
 h2-prcomp(na.omit(h1),center=T)

 but I am getting the following error

 Error in svd(x, nu = 0) : 0 extent dimensions


 I appreciate if someone can help

You probably have a missing value in every row.  But does PCA with 50 
columns make sense: 461 of the PCs are constant and arbitrary?
It is possible you meant PC on the transpose (sometimes called Q-mode)

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
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] Problem of lmer under FreeBSD

2007-12-27 Thread Prof Brian Ripley
On Thu, 27 Dec 2007, ronggui wrote:

 I encounter such problem with lmer under FreeBSD, but not under
 Windows. Anyone knows why? Thanks.

Most likely you have a mixed-up system, with some packages installed under 
an earlier version of R.  Please use update.packages(checkBuilt=TRUE) to 
fix this.  (The culprit is probably Matrix.)

Searching the archives just after the releases of R 2.6.0 will find
quite a few postings from people who had made the same mistake.


 example(lmer)

 lmer (fm1 - lmer(Reaction ~ Days + (Days|Subject), sleepstudy))
 Error in UseMethod(as.logical) : no applicable method for as.logical
 traceback()
 9: as.logical(EMverbose)
 8: as.logical(EMverbose)
 7: lmerControl()
 6: do.call(lmerControl, control)
 5: lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
 4: eval.with.vis(expr, envir, enclos)
 3: eval.with.vis(ei, envir)
 2: source(zfile, local, echo = echo, prompt.echo = paste(prompt.prefix,
   getOption(prompt), sep = ), continue.echo = paste(prompt.prefix,
   getOption(continue), sep = ), verbose = verbose,
 max.deparse.length = Inf,
   encoding = encoding, skip.echo = skips)
 1: example(lmer)


 sessionInfo()
 R version 2.6.0 (2007-10-03)
 i386-portbld-freebsd6.3

 locale:
 C

 attached base packages:
 [1] stats graphics  grDevices utils datasets  methods   base

 other attached packages:
 [1] lme4_0.99875-9Matrix_0.999375-2 lattice_0.16-5

 loaded via a namespace (and not attached):
 [1] grid_2.6.0  rcompgen_0.1-15 tools_2.6.0



-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
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] A function for random test based on longest run (UNCLASSIFIED)

2007-12-27 Thread bogdan romocea
   require(tseries)
   ?runs.test
Also, take a look at dieharder, it implements a large number of
randomness tests:
http://www.phy.duke.edu/~rgb/General/dieharder.php



 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Park,
 Kyong H Mr ECBC
 Sent: Thursday, December 27, 2007 11:05 AM
 To: 'r-help@r-project.org'
 Subject: [R] A function for random test based on longest run
 (UNCLASSIFIED)

 Classification:  UNCLASSIFIED
 Caveats: NONE

 Hello, R users,

 Has anybody written a function for random test based on the length of
 longest run of same events. I really appreciate your help.

 Kyong Park
 Classification:  UNCLASSIFIED
 Caveats: NONE


   [[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] Principal Components Analysis

2007-12-27 Thread Bert Gunter
Are there lots of missing values in the data? If so, my guess would be that
na.omit(h1) leaves you with no data. Have you checked this?

Bert Gunter
Genentech

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of SNN
Sent: Wednesday, December 26, 2007 2:49 PM
To: r-help@r-project.org
Subject: [R] Principal Components Analysis


Hi,

I do have a file that has 50 columns and 40 rows. I want to apply PCA on
that data and this is what I did

h1-read.table(Ccode.txt, sep='\t', header=F) # reads the data from the
file Ccode.txt
 h2-prcomp(na.omit(h1),center=T)
 
but I am getting the following error
 
Error in svd(x, nu = 0) : 0 extent dimensions


I appreciate if someone can help

Thanks

-- 
View this message in context:
http://www.nabble.com/Principal--Components-Analysis-tp14507365p14507365.htm
l
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-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] Apresentação Evangelismcenter

2007-12-27 Thread Evangelismcenter
Prezados Cybernautas:


Em fase de crescimento, a Evangelismcenter apresenta agora um sistema mais 
acessível a todos os visitantes e com mais conteúdos para consulta.

Destacamos entre outros, um sistema de Bíblia On-line, Vídeos, Notícias, Links, 
Fórum, Chat, etc etc...

http://www.evangelismcenter.org/


Desejamos a todos umas Boas Festas e umas Boas Entradas em 2008 com muita Paz e 
Amor
Evangelismcenter
 


Modificar Dados ( 
http://www.evangelismcenter.org/eva/index.php?option=com_acajoomact=changesubscriber=6436cle=d2f731f3e7a962b2b0aa7e9be6bc9b8elistid=1
 )
Remover E-mail ( 
http://www.evangelismcenter.org/eva/index.php?option=com_acajoomact=unsubscribesubscriber=6436cle=d2f731f3e7a962b2b0aa7e9be6bc9b8elistid=1
 ) 


[[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] Apresentação Evangelismcenter

2007-12-27 Thread Evangelismcenter
Prezados Cybernautas:


Em fase de crescimento, a Evangelismcenter apresenta agora um sistema mais 
acessível a todos os visitantes e com mais conteúdos para consulta.

Destacamos entre outros, um sistema de Bíblia On-line, Vídeos, Notícias, Links, 
Fórum, Chat, etc etc...

http://www.evangelismcenter.org/


Desejamos a todos umas Boas Festas e umas Boas Entradas em 2008 com muita Paz e 
Amor
Evangelismcenter
 


Modificar Dados ( 
http://www.evangelismcenter.org/eva/index.php?option=com_acajoomact=changesubscriber=6435cle=db8cf5b0beb7e55ada18179dd273listid=1
 )
Remover E-mail ( 
http://www.evangelismcenter.org/eva/index.php?option=com_acajoomact=unsubscribesubscriber=6435cle=db8cf5b0beb7e55ada18179dd273listid=1
 ) 


[[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] A function for random test based on longest run (UNCLASSI FIED)

2007-12-27 Thread Park, Kyong H Mr ECBC
Classification:  UNCLASSIFIED 
Caveats: NONE

 Thanks for your quick response. The program you mentioned below available
from R is based on number of runs (up or down) not based on a longest length
of runs of same events. To be more specific, for example, from a series,
HHTHHHH, the number of runs are 5, and the longest length of runs of the
same events is 4. I'll check for the website you mentioned below. 

Kyong

-Original Message-
From: bogdan romocea [mailto:[EMAIL PROTECTED] 
Sent: Thursday, December 27, 2007 12:08 PM
To: [EMAIL PROTECTED]
Cc: r-help
Subject: RE: [R] A function for random test based on longest run
(UNCLASSIFIED)

   require(tseries)
   ?runs.test
Also, take a look at dieharder, it implements a large number of randomness
tests:
http://www.phy.duke.edu/~rgb/General/dieharder.php



 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Park, Kyong H Mr 
 ECBC
 Sent: Thursday, December 27, 2007 11:05 AM
 To: 'r-help@r-project.org'
 Subject: [R] A function for random test based on longest run
 (UNCLASSIFIED)

 Classification:  UNCLASSIFIED
 Caveats: NONE

 Hello, R users,

 Has anybody written a function for random test based on the length of 
 longest run of same events. I really appreciate your help.

 Kyong Park
 Classification:  UNCLASSIFIED
 Caveats: NONE


   [[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.

Classification:  UNCLASSIFIED 
Caveats: NONE


[[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] getting a string output from str

2007-12-27 Thread eggsbrown

I would like to use the output from str() in a homemade function but str does
not return a value! 

eg: 
list(x=str(1:20),y=str(1:15))
returns odd output...

Thanks - Kevin.
-- 
View this message in context: 
http://www.nabble.com/getting-a-string-output-from-str-tp14517059p14517059.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] getting a string output from str

2007-12-27 Thread Greg Snow
If you want to capture the output of the str function in a vector of character 
strings, try the capture.output function.



From: [EMAIL PROTECTED] on behalf of eggsbrown
Sent: Thu 12/27/2007 11:51 AM
To: r-help@r-project.org
Subject: [R] getting a string output from str




I would like to use the output from str() in a homemade function but str does
not return a value!

eg:
list(x=str(1:20),y=str(1:15))
returns odd output...

Thanks - Kevin.
--
View this message in context: 
http://www.nabble.com/getting-a-string-output-from-str-tp14517059p14517059.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.



[[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] Odd time conversion glitch

2007-12-27 Thread Pat Carroll
Hello, all.

I ran across an odd problem while working in R 2.6.0. The command line text 
follows. Basically, I attempted to convert a character vector of length 13 (in 
a data frame with 13 rows) from a character representation of dates to a POSIX 
representation using strptime. strptime returned a vector of length 9, which 
appears to contain 13 values (!) in the appropriate format.

I can't find any way to convince the strptime output that it has 13 values . . 
. even though (for example) posixvector[1:13] returns 13 values, 
anothervectorof length13-posixvector[1:13] produces a length mismatch error.

Can anyone help diagnose this, or work around it?

Many thanks,
~Pat Carroll.


 Dataset$DateFilled
 [1] 10/20/2005 11/4/2005  11/18/2005 12/2/2005  4/3/2006   
6/5/2006   7/14/2006  4/27/2007  5/7/2007   7/17/2007  2/14/2005 
[12] 2/14/2005  2/21/2005 
 datefilledpos-strptime(Dataset$DateFilled,format=%m/%d/%Y)
 datefilledpos
 [1] 2005-10-20 2005-11-04 2005-11-18 2005-12-02 2006-04-03 
2006-06-05 2006-07-14 2007-04-27 2007-05-07 2007-07-17 2005-02-14
[12] 2005-02-14 2005-02-21
 length(datefilledpos)
[1] 9
 length(Dataset$DateFilled)
[1] 13
 datefilledpos[1:13]
 [1] 2005-10-20 2005-11-04 2005-11-18 2005-12-02 2006-04-03 
2006-06-05 2006-07-14 2007-04-27 2007-05-07 2007-07-17 2005-02-14
[12] 2005-02-14 2005-02-21
 Dataset$DateFilled-datefilledpos
Error in `$-.data.frame`(`*tmp*`, DateFilled, value = list(sec = c(0,  : 
  replacement has 9 rows, data has 13
 Dataset$DateFilled-datefilledpos[1:13]
Error in `$-.data.frame`(`*tmp*`, DateFilled, value = list(sec = c(0,  : 
  replacement has 9 rows, data has 13
 

 
Pat Carroll. 
what matters most is how well you walk through the fire. 
bukowski.





  

Be a better friend, newshound, and

__
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] Running R from a CD on Windows?

2007-12-27 Thread Charles Annis, P.E.
Greetings, R-ians:

Yes it's easy to run R from a CD: I copied my windows installation folder to
the CD, then copied my R working directory to the CD.

To run from the CD, I copy the working directory from the CD to the desktop,
and then create an R desktop icon that points to Rgui.exe on the CD, and
starts in the working directory folder I just copied to the desktop.

The problem is that to create the desktop R icon you need to know that
Rgui.exe is on the CD in the bin subfolder of the R-2.6.1 folder, which I
know but the person being introduced to R for the first time does not.  And
creating a desktop icon is busywork that some find annoying.  And then the
user needs to copy the basic working directory folder to the desktop, since
R needs to be able to write to it and writing to the CD can't work with a
write-once CD.  Alas, my uses just want to put the CD in the drive and have
the autorun facility take care all this:

1) If there isn't a folder named R-project on the desktop, copy the one on
the CD to the desktop.
2) Create a desktop icon for R that points to Rgui.exe on the CD.  The
installation must determine what drive is currently being accessed, since
D:\R-2.6.1\bin\Rgui.exe would only work if the CD was running from drive
D.
3) Have the icon Start in desktop\R-project which is legal if you create
the icon yourself, but apparently not legal to put on the CD since the
windows are erased and cannot be filled in if the icon is copied back from
the CD to the desktop.

Since the basic R installation on Windows can create a desktop icon, I know
this must be possible.  I would be grateful for any help.

Thanks

Charles Annis, P.E.

[EMAIL PROTECTED]
phone: 561-352-9699
eFax:  614-455-3265
http://www.StatisticalEngineering.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] Running R from a CD on Windows?

2007-12-27 Thread Gabor Grothendieck
There is a batch script, rgui.bat, in batchfiles, see home page at
batchfiles.googlecode.com, that will search the registry and a
few other places for R and start up R if it can find it.  It does
not search  CD's automatically but that would be simple to add.

On Dec 27, 2007 3:25 PM, Charles Annis, P.E.
[EMAIL PROTECTED] wrote:
 Greetings, R-ians:

 Yes it's easy to run R from a CD: I copied my windows installation folder to
 the CD, then copied my R working directory to the CD.

 To run from the CD, I copy the working directory from the CD to the desktop,
 and then create an R desktop icon that points to Rgui.exe on the CD, and
 starts in the working directory folder I just copied to the desktop.

 The problem is that to create the desktop R icon you need to know that
 Rgui.exe is on the CD in the bin subfolder of the R-2.6.1 folder, which I
 know but the person being introduced to R for the first time does not.  And
 creating a desktop icon is busywork that some find annoying.  And then the
 user needs to copy the basic working directory folder to the desktop, since
 R needs to be able to write to it and writing to the CD can't work with a
 write-once CD.  Alas, my uses just want to put the CD in the drive and have
 the autorun facility take care all this:

 1) If there isn't a folder named R-project on the desktop, copy the one on
 the CD to the desktop.
 2) Create a desktop icon for R that points to Rgui.exe on the CD.  The
 installation must determine what drive is currently being accessed, since
 D:\R-2.6.1\bin\Rgui.exe would only work if the CD was running from drive
 D.
 3) Have the icon Start in desktop\R-project which is legal if you create
 the icon yourself, but apparently not legal to put on the CD since the
 windows are erased and cannot be filled in if the icon is copied back from
 the CD to the desktop.

 Since the basic R installation on Windows can create a desktop icon, I know
 this must be possible.  I would be grateful for any help.

 Thanks

 Charles Annis, P.E.

 [EMAIL PROTECTED]
 phone: 561-352-9699
 eFax: 614-455-3265
 http://www.StatisticalEngineering.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-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] Running R from a CD on Windows?

2007-12-27 Thread Uwe Ligges
Sounds like you want to write some VisualBasic script that sets up the 
link etc., started by the autorun.inf facility.
In any case, many virus and/or behavior checkers will shout when you 
implement things like that ... - and I have disabled auto-anything for 
CD/USB devices not only form security reasons.

Uwe Ligges




Charles Annis, P.E. wrote:
 Greetings, R-ians:
 
 Yes it's easy to run R from a CD: I copied my windows installation folder to
 the CD, then copied my R working directory to the CD.
 
 To run from the CD, I copy the working directory from the CD to the desktop,
 and then create an R desktop icon that points to Rgui.exe on the CD, and
 starts in the working directory folder I just copied to the desktop.
 
 The problem is that to create the desktop R icon you need to know that
 Rgui.exe is on the CD in the bin subfolder of the R-2.6.1 folder, which I
 know but the person being introduced to R for the first time does not.  And
 creating a desktop icon is busywork that some find annoying.  And then the
 user needs to copy the basic working directory folder to the desktop, since
 R needs to be able to write to it and writing to the CD can't work with a
 write-once CD.  Alas, my uses just want to put the CD in the drive and have
 the autorun facility take care all this:
 
 1) If there isn't a folder named R-project on the desktop, copy the one on
 the CD to the desktop.
 2) Create a desktop icon for R that points to Rgui.exe on the CD.  The
 installation must determine what drive is currently being accessed, since
 D:\R-2.6.1\bin\Rgui.exe would only work if the CD was running from drive
 D.
 3) Have the icon Start in desktop\R-project which is legal if you create
 the icon yourself, but apparently not legal to put on the CD since the
 windows are erased and cannot be filled in if the icon is copied back from
 the CD to the desktop.
 
 Since the basic R installation on Windows can create a desktop icon, I know
 this must be possible.  I would be grateful for any help.
 
 Thanks
 
 Charles Annis, P.E.
 
 [EMAIL PROTECTED]
 phone: 561-352-9699
 eFax:  614-455-3265
 http://www.StatisticalEngineering.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-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] Conditionally incrementing a loop counter

2007-12-27 Thread Mike Jones
Hi,
I am trying a for loop from 1 to 100 by 1. However, if a condition does
not get met, I want to throw away that iteration. So if my loop is
for (i in 1:100)
and i is say, 25 and the condition is not met then I don't want i to go
up to 26.  Is there a way to do that? I can't seem to manually adjust i
because from what I understand, R creates 100 long vector and uses that
to loops thru and I'm not sure how to get at the index of that vector.
Any suggestions? Thanks in advance.










Mike Jones
Westat
1650 Research Blvd. RE401
Rockville, MD 20850
Ph: 240.314.2312


[[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] Conditionally incrementing a loop counter

2007-12-27 Thread Peter Dalgaard
Mike Jones wrote:
 Hi,
 I am trying a for loop from 1 to 100 by 1. However, if a condition does
 not get met, I want to throw away that iteration. So if my loop is
 for (i in 1:100)
 and i is say, 25 and the condition is not met then I don't want i to go
 up to 26.  Is there a way to do that? I can't seem to manually adjust i
 because from what I understand, R creates 100 long vector and uses that
 to loops thru and I'm not sure how to get at the index of that vector.
 Any suggestions? Thanks in advance.
   
You're not being entirely clear. If you don't increment the loop 
counter, you generally get stuck in an infinite loop. That is, unless 
you rely on external input somehow, which you never told us about. You 
can easily do a while()-type loop in R, but whether that solves your 
problem is hard to tell.

Often the solution lies in whole-object thinking, and can end up quite 
different from index-fiddling, so it might help if you said what the 
actual problem is.

-- 
   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
~~ - ([EMAIL PROTECTED])  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.


[R] Reminiscing on 20 years using S

2007-12-27 Thread John Maindonald
My first exposure to S was on an ATT 3B2 (a 3B2/100,
I think), at the Auckland (Mt Albert) Applied Mathematics
Division Station of the NZ Dept of Scientific and Industrial
Research.  The AMD Head Office in Wellington had one
also.  There may have been one or more others; I cannot
remember. This would have been in 1983, maybe.

It was a superbly engineered machine, but the sofware
(System V, version 3.2) had its problems.  If you back
deleted too far along the command line, something
unpleasant (losing the line? or worse?) happened.
On typing 1+1 at the S command line, it took a second
to get an answer.

John Maindonald email: [EMAIL PROTECTED]
phone : +61 2 (6125)3473fax  : +61 2(6125)5549
Centre for Mathematics  Its Applications, Room 1194,
John Dedman Mathematical Sciences Building (Building 27)
Australian National University, Canberra ACT 0200.


On 27 Dec 2007, at 10:00 PM, [EMAIL PROTECTED] wrote:

 From: roger koenker [EMAIL PROTECTED]
 Date: 27 December 2007 9:56:45 AM
 To: Greg Snow [EMAIL PROTECTED]
 Cc: R-help list [EMAIL PROTECTED]
 Subject: Re: [R] Reminiscing on 20 years using S

 On Dec 26, 2007, at 2:05 PM, Greg Snow wrote:

 I realized earlier this year (2007) that it was in 1987 that I first
 started using an early version of S (it was ported to VMS and was  
 called
 success).  That means that I have been using some variant of S (to
 various degrees) for over 20 years now (I don't feel that old).

 Boxing day somehow seems appropriate for this thread.  R.I.P. to all  
 those old boxes
 of yesteryore and the software that ran on them -- and yet there is  
 always a residual  archaeological curiosity.

 I discovered recently that the MIT athena network contains a circa  
 1989 version
 of S:  http://stuff.mit.edu/afs/athena/astaff/project/Sdev/S/  which  
 made me wonder
 whether there was any likelihood that one could recreate S Thu Dec   
 7 16:49:47 EST 1989.
 Curiosity is one thing, time to dig through the layers of ancient  
 civilizations is quite another.
 But if anyone would like to offer a (preferably educated) guess  
 about the feasibility of  such a project, like I said, I would be  
 curious.


 url:www.econ.uiuc.edu/~rogerRoger Koenker
 email   [EMAIL PROTECTED]   Department of  
 Economics
 vox:217-333-4558University of Illinois
 fax:217-244-6678Champaign, IL 61820

__
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] warning on gamma option in par(args) or calling par(= new)?

2007-12-27 Thread AA
Dear All,

I have the following function

tstpar -
  function(n = 200, want.pdf = FALSE, pdfFileName = NULL){
oldpar - par(no.readonly = TRUE)
on.exit(par(oldpar))
steps  - seq(from = 1, to = 8, by = 1)
h - 10; w - 6
if(want.pdf){pdf(file = pdfFileName, onefile = TRUE,
paper = letter, width = w, height = h)}
par(mfrow = c(4,2))
for(i in steps){
  txt - paste(i = , i)
  hist(rnorm(n), main = txt)
}
if(want.pdf){dev.off()}
  }

when called with default values tstpar() every thing works fine.
However I get 2 sorts of warnings
1- if I call the function to generate a pdf as
   tstpar(want.pdf = TRUE, pdfFilename = jj.pdf)
   I get the following warning msg:
   calling par(new=) with no plot in: par(oldpar)
   with an empty device which I don not understand since I close
   the device in the function.
2- If I comment the line 
   if (want.pdf){dev.off()}
   I get the following warning
   'gamma' cannot be modified on this device in: par(args)
   with 2 empty devices. 
  
I do not understand why I get those warnings and why I get those empty devices.
I looked up in RSiteSearch and I found the 2 following posts
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/38553.html
In this post M. Schwarz explains that there is not a plot created that's why R 
generates the 
warning. In the case of tstpar, I generate the hist plots and should not be 
getting the warning.

And in the following post Prof Ripley refers to an old R warning for pdf() 
devices
Which is not the case here.
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/23215.html 

I do not see what I am missing. Thanks for any hint.
I use R 2.5.1 under Win XP.
I apologize if the question is related to my older R version which I will 
upgrade.

AA.

[[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] Conditionally incrementing a loop counter

2007-12-27 Thread Bert Gunter
Please read the posting guide and provide a simple reproducible example as
it asks you to. Very likely a loop is not even needed.

-- Bert Gunter
Genentech, Inc. 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Mike Jones
Sent: Thursday, December 27, 2007 1:35 PM
To: [EMAIL PROTECTED]
Subject: [R] Conditionally incrementing a loop counter

Hi,
I am trying a for loop from 1 to 100 by 1. However, if a condition does
not get met, I want to throw away that iteration. So if my loop is
for (i in 1:100)
and i is say, 25 and the condition is not met then I don't want i to go
up to 26.  Is there a way to do that? I can't seem to manually adjust i
because from what I understand, R creates 100 long vector and uses that
to loops thru and I'm not sure how to get at the index of that vector.
Any suggestions? Thanks in advance.










Mike Jones
Westat
1650 Research Blvd. RE401
Rockville, MD 20850
Ph: 240.314.2312


[[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] groupedData function not found

2007-12-27 Thread andrea previtali

Hello,
I'm trying to use the groupedData function and R is giving me the message: 
Error: can not find function groupedData
The code is coming from a textbook so I think it should be correct:

pigs-data.frame(cbind(pig.time,pig.id,pig.wt))
pig.growth-groupedData(pig.wt~pig.time|pig.id,data=pigs)

I have added the package nlme and to confirm that it was installed correctly 
I requested the list of functions included in the package (library(help=nlme)) 
and I do see groupData in the list.
I am using R 2.6.1 in Windows XP.

I'll appreciate your help.
Thanks,
Andrea Previtali
Post-doc fellow
Dept. of Biology,
Univ. of Utah, SLC, UT.

__
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] Conditionally incrementing a loop counter: Take 2

2007-12-27 Thread Mike Jones
My apologies for not including a working example.

Here it is:

for (i in 1:10){
   cat(initial i = ,i,\n)
   x - runif(1)
   if (x  0.7){
  i - i-1
   }   
   cat(second i = ,i,\n)
}

When I ran this i got what follows, so there were four cases where I
wanted the i not to increment.

initial i =  1 
second i =  1 
initial i =  2 
second i =  1 
initial i =  3 
second i =  3 
initial i =  4 
second i =  3 
initial i =  5 
second i =  4 
initial i =  6 
second i =  6 
initial i =  7 
second i =  7 
initial i =  8 
second i =  7 
initial i =  9 
second i =  9 
initial i =  10 
second i =  10 

  -Original Message-
 From: Mike Jones  
 Sent: Thursday, December 27, 2007 4:35 PM
 To:   '[EMAIL PROTECTED]'
 Subject:  Conditionally incrementing a loop counter
 
 Hi,
 I am trying a for loop from 1 to 10 by 1. However, if a condition does
 not get met, I want to throw away that iteration. So if my loop is
 for (i in 1:10)
 and i is say, 4 and the condition is not met then I don't want i to go
 up to 5.  Is there a way to do that? I can't seem to manually adjust i
 because from what I understand, R creates 10 long vector and uses that
 to loops thru and I'm not sure how to get at the index of that
 vector. Any suggestions? Thanks in advance.
 
 
 
 
 
 
 
 
 
 
 Mike Jones
 Westat
 1650 Research Blvd. RE401
 Rockville, MD 20850
 Ph: 240.314.2312
 

[[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] Conditionally incrementing a loop counter: Take 2

2007-12-27 Thread Peter Dalgaard
Mike Jones wrote:
 My apologies for not including a working example.

 Here it is:

 for (i in 1:10){
cat(initial i = ,i,\n)
x - runif(1)
if (x  0.7){
   i - i-1
}   
cat(second i = ,i,\n)
 }

 When I ran this i got what follows, so there were four cases where I
 wanted the i not to increment.

 initial i =  1 
 second i =  1 
 initial i =  2 
 second i =  1 
 initial i =  3 
 second i =  3 
 initial i =  4 
 second i =  3 
 initial i =  5 
 second i =  4 
 initial i =  6 
 second i =  6 
 initial i =  7 
 second i =  7 
 initial i =  8 
 second i =  7 
 initial i =  9 
 second i =  9 
 initial i =  10 
 second i =  10 

   
Is this the kind of effect you want?

  x - runif(10)
  cbind(x, 1:10, cumsum(x  .7))
x
 [1,] 0.384165631  1 1
 [2,] 0.392715845  2 2
 [3,] 0.895936431  3 2
 [4,] 0.910242185  4 2
 [5,] 0.689987301  5 3
 [6,] 0.237071326  6 4
 [7,] 0.225032680  7 5
 [8,] 0.001856286  8 6
 [9,] 0.392034868  9 7
[10,] 0.655076045 10 8

If you insist on using a loop, you need to separate the loop control 
from the manipulation of i, as in (e.g.)

i - 0
for (j in 1:10){
   i - i + 1
   cat(initial i = ,i,\n)
   x - runif(1)
   if (x  0.7){
  i - i-1
   }   
   cat(second i = ,i,\n)
}


  -Original Message-
 From:Mike Jones  
 Sent:Thursday, December 27, 2007 4:35 PM
 To:  '[EMAIL PROTECTED]'
 Subject: Conditionally incrementing a loop counter

 Hi,
 I am trying a for loop from 1 to 10 by 1. However, if a condition does
 not get met, I want to throw away that iteration. So if my loop is
 for (i in 1:10)
 and i is say, 4 and the condition is not met then I don't want i to go
 up to 5.  Is there a way to do that? I can't seem to manually adjust i
 because from what I understand, R creates 10 long vector and uses that
 to loops thru and I'm not sure how to get at the index of that
 vector. Any suggestions? Thanks in advance.










 Mike Jones
 Westat
 1650 Research Blvd. RE401
 Rockville, MD 20850
 Ph: 240.314.2312

 

   [[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
~~ - ([EMAIL PROTECTED])  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] Odd time conversion glitch

2007-12-27 Thread Gabor Grothendieck
Read RNews 4/1 and follow the advice there.

On Dec 27, 2007 2:31 PM, Pat Carroll [EMAIL PROTECTED] wrote:
 Hello, all.

 I ran across an odd problem while working in R 2.6.0. The command line text 
 follows. Basically, I attempted to convert a character vector of length 13 
 (in a data frame with 13 rows) from a character representation of dates to a 
 POSIX representation using strptime. strptime returned a vector of length 9, 
 which appears to contain 13 values (!) in the appropriate format.

 I can't find any way to convince the strptime output that it has 13 values . 
 . . even though (for example) posixvector[1:13] returns 13 values, 
 anothervectorof length13-posixvector[1:13] produces a length mismatch error.

 Can anyone help diagnose this, or work around it?

 Many thanks,
 ~Pat Carroll.


  Dataset$DateFilled
  [1] 10/20/2005 11/4/2005  11/18/2005 12/2/2005  4/3/2006   
 6/5/2006   7/14/2006  4/27/2007  5/7/2007   7/17/2007  2/14/2005
 [12] 2/14/2005  2/21/2005
  datefilledpos-strptime(Dataset$DateFilled,format=%m/%d/%Y)
  datefilledpos
  [1] 2005-10-20 2005-11-04 2005-11-18 2005-12-02 2006-04-03 
 2006-06-05 2006-07-14 2007-04-27 2007-05-07 2007-07-17 2005-02-14
 [12] 2005-02-14 2005-02-21
  length(datefilledpos)
 [1] 9
  length(Dataset$DateFilled)
 [1] 13
  datefilledpos[1:13]
  [1] 2005-10-20 2005-11-04 2005-11-18 2005-12-02 2006-04-03 
 2006-06-05 2006-07-14 2007-04-27 2007-05-07 2007-07-17 2005-02-14
 [12] 2005-02-14 2005-02-21
  Dataset$DateFilled-datefilledpos
 Error in `$-.data.frame`(`*tmp*`, DateFilled, value = list(sec = c(0,  :
  replacement has 9 rows, data has 13
  Dataset$DateFilled-datefilledpos[1:13]
 Error in `$-.data.frame`(`*tmp*`, DateFilled, value = list(sec = c(0,  :
  replacement has 9 rows, data has 13
 


 Pat Carroll.
 what matters most is how well you walk through the fire.
 bukowski.





  
 
 Be a better friend, newshound, and

 __
 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] Lda and Qda

2007-12-27 Thread pedrosmarques


Hi all,

I'm working with some data: 54 variables and a column of classes, each 
observation as one of a possible seven different classes:

 var.can3-lda(x=dados[,c(1:28,30:54)],grouping=dados[,55],CV=TRUE)
Warning message:
In lda.default(x, grouping, ...) : variables are collinear
 summary(var.can3)
  Length Class  Mode   
class  3 factor numeric   ### why?? I don't understand it
posterior 21 -none- numeric
call   4 -none- call## what's this?


 var.can-lda(dados[,c(1:28,30:54)],dados[,55])#porque a variavel 29 é 
 constante
Warning message:
In lda.default(x, grouping, ...) : variables are collinear
 summary(var.can)
Length Class  Mode 
prior 7-none- numeric  
counts7-none- numeric  
means   371-none- numeric  
scaling 318-none- numeric  
lev   7-none- character
svd   6-none- numeric  
N 1-none- numeric  
call  3-none- call 
 (normalizar-function(matriz){ n-dim(matriz)[1]; m-dim(matriz)[2]; 
 normas-sqrt(colSums(matriz*matriz)); 
 matriz.normalizada-matriz/t(matrix(rep(normas,n),m,n));return(matriz.normalizada)})
function(matriz){ n-dim(matriz)[1]; m-dim(matriz)[2]; 
normas-sqrt(colSums(matriz*matriz)); 
matriz.normalizada-matriz/t(matrix(rep(normas,n),m,n));return(matriz.normalizada)}
 var.canonicas-as.matrix(dados[,c(1:28,30:54)])%*%(normalizar(var.can$scaling))
 summary(var.canonicas)
  LD1   LD2  LD3   LD4
 Min.   :-21.942   Min.   :-6.820   Min.   :-10.138   Min.   :-6.584  
 1st Qu.:-20.014   1st Qu.:-5.480   1st Qu.: -8.280   1st Qu.: 0.872  
 Median :-19.495   Median :-5.007   Median : -7.800   Median : 1.083  
 Mean   :-18.827   Mean   :-4.760   Mean   : -7.803   Mean   : 1.134  
 3rd Qu.:-18.975   3rd Qu.:-4.456   3rd Qu.: -7.278   3rd Qu.: 1.311  
 Max.   : -7.886   Max.   : 3.116   Max.   : -1.619   Max.   : 5.556  
  LD5   LD6 
 Min.   :-11.083   Min.   :-4.4972  
 1st Qu.: -1.237   1st Qu.:-1.6497  
 Median : -1.100   Median :-1.0909  
 Mean   : -1.100   Mean   :-0.9808  
 3rd Qu.: -0.957   3rd Qu.:-0.4598  
 Max.   :  4.712   Max.   : 7.5356  
 


I don't know wether I need to specify a training set and a testing set, I also 
don't know the error nor the classifier; shouldn't the lenght of class of 
var.can3 be 7 since  I only have 7 different classes?

Best regards,

Pedro Marques

__
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 lm and multiple linear regression?

2007-12-27 Thread Aaron Barzilai
Hello,

I'm new to R, but I've read the intro to R and successfully connected it to an 
instance of mysql.  I'm trying to perform multiple linear regression, but I'm 
having trouble using the lm function.  To start, I have read in a simply y 
matrix of values(dependent variable) and x matrix of independent variables.  It 
says both are data frames, but lm is giving me an error that my y variable is a 
list.

Any suggestions on how to do this?  It's not clear to me what the problem is as 
they're both data frames.  My actual problem will use a much wider matrix of 
coefficients, I've only included two for illustration.  

Additionally, I'd actually like to weight the observations.  How would I go 
about doing that?  I also have that as a separate column vector.

Thanks,
Aaron

Here's my session:

 margin
margin
166.67
2   -58.33
3   100.00
4   -33.33
5   200.00
6   -83.33
7  -100.00
8 0.00
9   100.00
10  -18.18
11  -55.36
12 -125.00
13  -33.33
14 -200.00
150.00
16 -100.00
17   75.00
180.00
19 -200.00
20   35.71
21  100.00
22   50.00
23  -86.67
24  165.00
 personcoeff
   Person1 Person2
1   -1   1
2   -1   1
3   -1   1
4   -1   1
5   -1   1
6   -1   1
70   0
80   0
90   1
10  -1   1
11  -1   1
12  -1   1
13  -1   1
14  -1   0
15   0   0
16   0   0
17   0   1
18  -1   1
19  -1   1
20  -1   1
21  -1   1
22  -1   1
23  -1   1
24  -1   1
 class(margin)
[1] data.frame
 class(personcoeff)
[1] data.frame
 lm(margin~personcoeff)
Error in model.frame(formula, rownames, variables, varnames, extras, 
extranames,  : 
invalid type (list) for variable 'margin'


  

Be a better friend, newshound, and 


[[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] Conditionally incrementing a loop counter: Take 2

2007-12-27 Thread Mike Jones
Since I didn't want the i to increment in the loop when the condition is not 
met, then in my example I wanted the loop to actually run 14 times instead of 
the 10 since I wanted 4 of the iterations to be thrown away, or ignored.  I 
still haven't been able to figure this out.  Going the while route doesn't 
seem to work for me either.


nums - numeric(10)
i - 1
garbage - 0

while (i = 10){
x - runif(1)
cat(x = ,x,\n)
if (x  0.1){
nums[i] - x
i - i + 1
}
else{
garbage - garbage+1
}
cat(i = ,i,garbage = ,garbage,\n)
}

-Original Message-
From: Peter Dalgaard [mailto:[EMAIL PROTECTED] 
Sent: Thursday, December 27, 2007 5:36 PM
To: Mike Jones
Cc: [EMAIL PROTECTED]
Subject: Re: [R] Conditionally incrementing a loop counter: Take 2


Mike Jones wrote:
 My apologies for not including a working example.

 Here it is:

 for (i in 1:10){
cat(initial i = ,i,\n)
x - runif(1)
if (x  0.7){
   i - i-1
}   
cat(second i = ,i,\n)
 }

 When I ran this i got what follows, so there were four cases where I 
 wanted the i not to increment.

 initial i =  1
 second i =  1 
 initial i =  2 
 second i =  1 
 initial i =  3 
 second i =  3 
 initial i =  4 
 second i =  3 
 initial i =  5 
 second i =  4 
 initial i =  6 
 second i =  6 
 initial i =  7 
 second i =  7 
 initial i =  8 
 second i =  7 
 initial i =  9 
 second i =  9 
 initial i =  10 
 second i =  10 

   
Is this the kind of effect you want?

  x - runif(10)
  cbind(x, 1:10, cumsum(x  .7))
x
 [1,] 0.384165631  1 1
 [2,] 0.392715845  2 2
 [3,] 0.895936431  3 2
 [4,] 0.910242185  4 2
 [5,] 0.689987301  5 3
 [6,] 0.237071326  6 4
 [7,] 0.225032680  7 5
 [8,] 0.001856286  8 6
 [9,] 0.392034868  9 7
[10,] 0.655076045 10 8

If you insist on using a loop, you need to separate the loop control 
from the manipulation of i, as in (e.g.)

i - 0
for (j in 1:10){
   i - i + 1
   cat(initial i = ,i,\n)
   x - runif(1)
   if (x  0.7){
  i - i-1
   }   
   cat(second i = ,i,\n)
}


  -Original Message-
 From:Mike Jones  
 Sent:Thursday, December 27, 2007 4:35 PM
 To:  '[EMAIL PROTECTED]'
 Subject: Conditionally incrementing a loop counter

 Hi,
 I am trying a for loop from 1 to 10 by 1. However, if a condition 
 does not get met, I want to throw away that iteration. So if my 
 loop is for (i in 1:10) and i is say, 4 and the condition is not met 
 then I don't want i to go up to 5.  Is there a way to do that? I 
 can't seem to manually adjust i because from what I understand, R 
 creates 10 long vector and uses that to loops thru and I'm not sure 
 how to get at the index of that vector. Any suggestions? Thanks in 
 advance.










 Mike Jones
 Westat
 1650 Research Blvd. RE401
 Rockville, MD 20850
 Ph: 240.314.2312

 

   [[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
~~ - ([EMAIL PROTECTED])  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.


[R] SAS to R - if you don't have a SAS license

2007-12-27 Thread Gyula Gulyas
Hi all,

if you do not have a SAS license but want to convert
native SAS data files, the solution below will work.

# read SAS data without SAS

# 1. Download free SAS System Viewer from either of
the sites below:
#  
http://www.sas.com/apps/demosdownloads/setupcat.jsp?cat=SAS+System+Viewer
(requires registration)
#  
http://www.umass.edu/statdata/software/downloads/SASViewer/index.html
# 2. Open SAS data in the SAS System Viewer
# 3. View-Formatted sets the data in formatted view
# 4. Save As File...csv file - this is your SAS data
file
# 5. View-Variables (now showing the variable names
and formats)
# 6. Save As File...csv file - this is your SAS
variable definition file

# run code below

wrkdir-getwd() # save working directory to reset
later

# Select the SAS data file...
sas.data-read.table(file.choose(),header=T, sep=,,
na.strings=.)

# Select SAS variable definition file...
sas.def-read.csv(file.choose())

# str(sas.def)
# sas.def$SASFORMAT[sas.def$Type==Char]-character
# sas.def$SASFORMAT[sas.def$Type==Num]-numeric

sas.def$SASFORMAT[substr(sas.def$Format,1,4)==DATE]-date

sas.def-sas.def[,length(names(sas.def))] # pick last
column

tmp-which(sas.def==date)

sas.data[,tmp] -
as.data.frame(strptime(sas.data[,tmp],
%d%b%Y:%H:%M:%S))

str(sas.data)
print(head(sas.data))

setwd(wrkdir) # reset working directory

rm(wrkdir,tmp,sas.def)

# the end




  

Be a better friend, newshound, and

__
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] Efficiency of for-loop in R

2007-12-27 Thread Tong Wang
Hi,
   I just realized that in Matlab, as long as memory is pre-allocated, doing 
for-loop doesn't cost more time than doing things in vector form. 
   But it seems in R, it still cost a lot to do for-loop.  Is there any 
improvement in R that I missed. Thanks a lot. 

Merry Xmas Everyone !

__
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] SAS to R - if you don't have a SAS license

2007-12-27 Thread Wensui Liu
while I move data between SAS and R all the time, personally I don't
think your recommendation is very practical. Instead, I feel SAS
transport file is much better than csv.

Plus, the sas dataset created on unix can't be opened by sas viewer on
windows. It is even undoable if the dataset is large.

Just my $0.02.


On Dec 27, 2007 6:33 PM, Gyula Gulyas [EMAIL PROTECTED] wrote:
 Hi all,

 if you do not have a SAS license but want to convert
 native SAS data files, the solution below will work.

 # read SAS data without SAS

 # 1. Download free SAS System Viewer from either of
 the sites below:
 #
 http://www.sas.com/apps/demosdownloads/setupcat.jsp?cat=SAS+System+Viewer
 (requires registration)
 #
 http://www.umass.edu/statdata/software/downloads/SASViewer/index.html
 # 2. Open SAS data in the SAS System Viewer
 # 3. View-Formatted sets the data in formatted view
 # 4. Save As File...csv file - this is your SAS data
 file
 # 5. View-Variables (now showing the variable names
 and formats)
 # 6. Save As File...csv file - this is your SAS
 variable definition file

 # run code below

 wrkdir-getwd() # save working directory to reset
 later

 # Select the SAS data file...
 sas.data-read.table(file.choose(),header=T, sep=,,
 na.strings=.)

 # Select SAS variable definition file...
 sas.def-read.csv(file.choose())

 # str(sas.def)
 # sas.def$SASFORMAT[sas.def$Type==Char]-character
 # sas.def$SASFORMAT[sas.def$Type==Num]-numeric

 sas.def$SASFORMAT[substr(sas.def$Format,1,4)==DATE]-date

 sas.def-sas.def[,length(names(sas.def))] # pick last
 column

 tmp-which(sas.def==date)

 sas.data[,tmp] -
 as.data.frame(strptime(sas.data[,tmp],
 %d%b%Y:%H:%M:%S))

 str(sas.data)
 print(head(sas.data))

 setwd(wrkdir) # reset working directory

 rm(wrkdir,tmp,sas.def)

 # the end




   
 
 Be a better friend, newshound, and

 __
 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.




-- 
===
WenSui Liu
Statistical Project Manager
ChoicePoint Precision Marketing
(http://spaces.msn.com/statcompute/blog)

__
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] Help with lm and multiple linear regression? (Plain Text version)

2007-12-27 Thread Tim Calkins
consider merging everything into a singe dataframe.  i haven't tried
it, but something like the following could work:

 reg.data - cbind(margin, personcoeff)
 names(reg.data) - c('margin', 'p1', 'p2')
 lm(margin~p1+p2, data = reg.data)

the idea here is that by specifying the data frame with the data
argument in lm, R looks for the columns of the names specified in the
formula.

for weights, see ?lm and look for the weights argument.

cheers,
tc

On Dec 28, 2007 10:22 AM, Aaron Barzilai [EMAIL PROTECTED] wrote:
 (Apologies the previous version was sent as rich text)

 Hello,
 I'm new to R, but I've read the intro to R and successfully connected it to 
 an instance of mysql.  I'm trying to perform multiple linear regression, but 
 I'm having trouble using the lm function.  To start, I have read in a simply 
 y matrix of values(dependent variable) and x matrix of independent variables. 
  It says both are data frames, but lm is giving me an error that my y 
 variable is a list.

 Any suggestions on how to do this?  It's not clear to me what the problem is 
 as they're both data frames.  My actual problem will use a much wider matrix 
 of coefficients, I've only included two for illustration.

 Additionally, I'd actually like to weight the observations.  How would I go 
 about doing that?  I also have that as a separate column vector.

 Thanks,
 Aaron

 Here's my session:
  margin
 margin
 166.67
 2   -58.33
 3   100.00
 4   -33.33
 5   200.00
 6   -83.33
 7  -100.00
 8 0.00
 9   100.00
 10  -18.18
 11  -55.36
 12 -125.00
 13  -33.33
 14 -200.00
 150.00
 16 -100.00
 17   75.00
 180.00
 19 -200.00
 20   35.71
 21  100.00
 22   50.00
 23  -86.67
 24  165.00
  personcoeff
Person1 Person2
 1   -1   1
 2   -1   1
 3   -1   1
 4   -1   1
 5   -1   1
 6   -1   1
 70   0
 80   0
 90   1
 10  -1   1
 11  -1   1
 12  -1   1
 13  -1   1
 14  -1   0
 15   0   0
 16   0   0
 17   0   1
 18  -1   1
 19  -1   1
 20  -1   1
 21  -1   1
 22  -1   1
 23  -1   1
 24  -1   1
  class(margin)
 [1] data.frame
  class(personcoeff)
 [1] data.frame
  lm(margin~personcoeff)
 Error in model.frame(formula, rownames, variables, varnames, extras, 
 extranames,  :
 invalid type (list) for variable 'margin'


   
 
 Be a better friend, newshound, and

 __
 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.




-- 
Tim Calkins
0406 753 997

__
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 lm and multiple linear regression? (Plain Text version)

2007-12-27 Thread Aaron Barzilai
(Apologies the previous version was sent as rich text)

Hello,
I'm new to R, but I've read the intro to R and successfully connected it to an 
instance of mysql.  I'm trying to perform multiple linear regression, but I'm 
having trouble using the lm function.  To start, I have read in a simply y 
matrix of values(dependent variable) and x matrix of independent variables.  It 
says both are data frames, but lm is giving me an error that my y variable is a 
list.

Any suggestions on how to do this?  It's not clear to me what the problem is as 
they're both data frames.  My actual problem will use a much wider matrix of 
coefficients, I've only included two for illustration.  

Additionally, I'd actually like to weight the observations.  How would I go 
about doing that?  I also have that as a separate column vector.

Thanks,
Aaron

Here's my session:
 margin
margin
166.67
2   -58.33
3   100.00
4   -33.33
5   200.00
6   -83.33
7  -100.00
8 0.00
9   100.00
10  -18.18
11  -55.36
12 -125.00
13  -33.33
14 -200.00
150.00
16 -100.00
17   75.00
180.00
19 -200.00
20   35.71
21  100.00
22   50.00
23  -86.67
24  165.00
 personcoeff
   Person1 Person2
1   -1   1
2   -1   1
3   -1   1
4   -1   1
5   -1   1
6   -1   1
70   0
80   0
90   1
10  -1   1
11  -1   1
12  -1   1
13  -1   1
14  -1   0
15   0   0
16   0   0
17   0   1
18  -1   1
19  -1   1
20  -1   1
21  -1   1
22  -1   1
23  -1   1
24  -1   1
 class(margin)
[1] data.frame
 class(personcoeff)
[1] data.frame
 lm(margin~personcoeff)
Error in model.frame(formula, rownames, variables, varnames, extras, 
extranames,  : 
invalid type (list) for variable 'margin'


  

Be a better friend, newshound, and

__
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] Efficiency of for-loop in R

2007-12-27 Thread jim holtman
Exactly what is the problem you are trying to solve?  Could you
provide commented, minimal, self-contained, reproducible code?

A lot depends on what you are trying to do,  There might be other
ways, in R, than a 'for' loop to solve your problems.

On Dec 27, 2007 6:44 PM, Tong Wang [EMAIL PROTECTED] wrote:
 Hi,
   I just realized that in Matlab, as long as memory is pre-allocated, doing 
 for-loop doesn't cost more time than doing things in vector form.
   But it seems in R, it still cost a lot to do for-loop.  Is there any 
 improvement in R that I missed. Thanks a lot.

 Merry Xmas Everyone !

 __
 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.




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

What is the problem you are trying to solve?

__
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] Reminiscing on 20 years using S

2007-12-27 Thread jim holtman
My introduction to S was around 1984 on a 3B20 and VAX systems at Bell
Labs.  I still have a copy of the brown book written by Becker and
Chambers on the S Interactive Language (copyright 1984).  I remember
the graphical output on a daisy-wheel printer and using the HP
plotter that was connected in serial with the terminal you were using.
 When you wanted to plot, escape sequences were sent so the plotter
interpreted the output and plotted on paper that it moved back and
forth as the pens went horizontal.  It has changed a lot, but has also
stayed the same in a number of ways.

On Dec 27, 2007 5:12 PM, John Maindonald [EMAIL PROTECTED] wrote:
 My first exposure to S was on an ATT 3B2 (a 3B2/100,
 I think), at the Auckland (Mt Albert) Applied Mathematics
 Division Station of the NZ Dept of Scientific and Industrial
 Research.  The AMD Head Office in Wellington had one
 also.  There may have been one or more others; I cannot
 remember. This would have been in 1983, maybe.

 It was a superbly engineered machine, but the sofware
 (System V, version 3.2) had its problems.  If you back
 deleted too far along the command line, something
 unpleasant (losing the line? or worse?) happened.
 On typing 1+1 at the S command line, it took a second
 to get an answer.

 John Maindonald email: [EMAIL PROTECTED]
 phone : +61 2 (6125)3473fax  : +61 2(6125)5549
 Centre for Mathematics  Its Applications, Room 1194,
 John Dedman Mathematical Sciences Building (Building 27)
 Australian National University, Canberra ACT 0200.


 On 27 Dec 2007, at 10:00 PM, [EMAIL PROTECTED] wrote:

  From: roger koenker [EMAIL PROTECTED]
  Date: 27 December 2007 9:56:45 AM
  To: Greg Snow [EMAIL PROTECTED]
  Cc: R-help list [EMAIL PROTECTED]
  Subject: Re: [R] Reminiscing on 20 years using S
 
  On Dec 26, 2007, at 2:05 PM, Greg Snow wrote:
 
  I realized earlier this year (2007) that it was in 1987 that I first
  started using an early version of S (it was ported to VMS and was
  called
  success).  That means that I have been using some variant of S (to
  various degrees) for over 20 years now (I don't feel that old).
 
  Boxing day somehow seems appropriate for this thread.  R.I.P. to all
  those old boxes
  of yesteryore and the software that ran on them -- and yet there is
  always a residual  archaeological curiosity.
 
  I discovered recently that the MIT athena network contains a circa
  1989 version
  of S:  http://stuff.mit.edu/afs/athena/astaff/project/Sdev/S/  which
  made me wonder
  whether there was any likelihood that one could recreate S Thu Dec
  7 16:49:47 EST 1989.
  Curiosity is one thing, time to dig through the layers of ancient
  civilizations is quite another.
  But if anyone would like to offer a (preferably educated) guess
  about the feasibility of  such a project, like I said, I would be
  curious.
 
 
  url:www.econ.uiuc.edu/~rogerRoger Koenker
  email   [EMAIL PROTECTED]   Department of
  Economics
  vox:217-333-4558University of Illinois
  fax:217-244-6678Champaign, IL 61820

 __
 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.




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

What is the problem you are trying to solve?

__
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] Conditionally incrementing a loop counter: Take 2

2007-12-27 Thread Peter Dalgaard
John Fox wrote:
 Dear Mike,

 You could use a repeat loop and manage the index yourself:

 i - 0
 repeat{
   x - runif(1)
   if (x  .1){
  i - i + 1
  cat(x = , x, \n)
  }
 if (i == 10) break
 }

 But if your example problem reflects your actual application, why not just
 generate uniform random numbers on the interval (0, .1)?
   

As I read it, it is the sequence of i's not the x's that are sought. The 
example suddenly skipped from something with x  .7 to something with x 
 .1, but it might be that Mike's while loop just needed to print i at 
the top of the loop rather than at the bottom. The result should 
(AFAICS) be equivalent to

  rep(1:10, 1+rgeom(10, .7))
 [1]  1  1  2  3  4  5  6  7  8  8  9 10 10


 I hope this helps,
  John

 
 John Fox, Professor
 Department of Sociology
 McMaster University
 Hamilton, Ontario, Canada L8S 4M4
 905-525-9140x23604
 http://socserv.mcmaster.ca/jfox


   
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 project.org] On Behalf Of Mike Jones
 Sent: December-27-07 6:08 PM
 To: Peter Dalgaard
 Cc: [EMAIL PROTECTED]
 Subject: Re: [R] Conditionally incrementing a loop counter: Take 2

 Since I didn't want the i to increment in the loop when the condition
 is not met, then in my example I wanted the loop to actually run 14
 times instead of the 10 since I wanted 4 of the iterations to be thrown
 away, or ignored.  I still haven't been able to figure this out.  Going
 the while route doesn't seem to work for me either.


 nums - numeric(10)
 i - 1
 garbage - 0

 while (i = 10){
  x - runif(1)
  cat(x = ,x,\n)
  if (x  0.1){
  nums[i] - x
  i - i + 1
  }
  else{
  garbage - garbage+1
  }
 cat(i = ,i,garbage = ,garbage,\n)
 }

 -Original Message-
 From: Peter Dalgaard [mailto:[EMAIL PROTECTED]
 Sent: Thursday, December 27, 2007 5:36 PM
 To: Mike Jones
 Cc: [EMAIL PROTECTED]
 Subject: Re: [R] Conditionally incrementing a loop counter: Take 2


 Mike Jones wrote:
 
 My apologies for not including a working example.

 Here it is:

 for (i in 1:10){
cat(initial i = ,i,\n)
x - runif(1)
if (x  0.7){
   i - i-1
}
cat(second i = ,i,\n)
 }

 When I ran this i got what follows, so there were four cases where I
 wanted the i not to increment.

 initial i =  1
 second i =  1
 initial i =  2
 second i =  1
 initial i =  3
 second i =  3
 initial i =  4
 second i =  3
 initial i =  5
 second i =  4
 initial i =  6
 second i =  6
 initial i =  7
 second i =  7
 initial i =  8
 second i =  7
 initial i =  9
 second i =  9
 initial i =  10
 second i =  10


   
 Is this the kind of effect you want?

   x - runif(10)
   cbind(x, 1:10, cumsum(x  .7))
 x
  [1,] 0.384165631  1 1
  [2,] 0.392715845  2 2
  [3,] 0.895936431  3 2
  [4,] 0.910242185  4 2
  [5,] 0.689987301  5 3
  [6,] 0.237071326  6 4
  [7,] 0.225032680  7 5
  [8,] 0.001856286  8 6
  [9,] 0.392034868  9 7
 [10,] 0.655076045 10 8

 If you insist on using a loop, you need to separate the loop control
 from the manipulation of i, as in (e.g.)

 i - 0
 for (j in 1:10){
i - i + 1
cat(initial i = ,i,\n)
x - runif(1)
if (x  0.7){
   i - i-1
}
cat(second i = ,i,\n)
 }


 
  -Original Message-
 From:  Mike Jones
 Sent:  Thursday, December 27, 2007 4:35 PM
 To:'[EMAIL PROTECTED]'
 Subject:   Conditionally incrementing a loop counter

 Hi,
 I am trying a for loop from 1 to 10 by 1. However, if a condition
 does not get met, I want to throw away that iteration. So if my
 loop is for (i in 1:10) and i is say, 4 and the condition is not met
 then I don't want i to go up to 5.  Is there a way to do that? I
 can't seem to manually adjust i because from what I understand, R
 creates 10 long vector and uses that to loops thru and I'm not
 
 sure
 
 how to get at the index of that vector. Any suggestions? Thanks in
 advance.










 Mike Jones
 Westat
 1650 Research Blvd. RE401
 Rockville, MD 20850
 Ph: 240.314.2312


 
 [[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
 ~~ - ([EMAIL PROTECTED])  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, 

Re: [R] Efficiency of for-loop in R

2007-12-27 Thread Tong Wang
HI,
   The question is meant to be a general one, I am trying to find out if there 
is new development in R that I might have missed. 

but here's a trivial example, 
   
To compute  y=sin(x) , x = 1,2,... 10
 x=1:10, 
1.  y =sin(x)
2.  for(i in 1:10) y=sin(x[i])

1 is much faster than 2.  
Old Matlab also had this problem, but in new versions, 1 and 2 are mostly the 
same. 
I am just wondering if the same improvement has happened or will happen to R. 


Thanks . 

 

- Original Message -
From: jim holtman [EMAIL PROTECTED]
Date: Thursday, December 27, 2007 4:39 pm
Subject: Re: [R] Efficiency of for-loop in R
To: Tong Wang [EMAIL PROTECTED]
Cc: R help [EMAIL PROTECTED]

 Exactly what is the problem you are trying to solve?  Could you
 provide commented, minimal, self-contained, reproducible code?
 
 A lot depends on what you are trying to do,  There might be other
 ways, in R, than a 'for' loop to solve your problems.
 
 On Dec 27, 2007 6:44 PM, Tong Wang [EMAIL PROTECTED] wrote:
  Hi,
I just realized that in Matlab, as long as memory is pre-
 allocated, doing for-loop doesn't cost more time than doing things 
 in vector form.
But it seems in R, it still cost a lot to do for-loop.  Is 
 there any improvement in R that I missed. Thanks a lot.
 
  Merry Xmas Everyone !
 
  __
  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.
 
 
 
 
 -- 
 Jim Holtman
 Cincinnati, OH
 +1 513 646 9390
 
 What is the problem you are trying to solve?


__
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] Efficiency of for-loop in R

2007-12-27 Thread jim holtman
I will venture a guess in that in the case of the 'for' loop, you are
calling 'sin' 100,000 times incurring the cost of individual function
calls at the interpreter level plus evaluating 'for' loop.  In the
vectorized case, you are only interpreting a single 'sin' call and
then internally evaluating the 'sin' function, which is a lot faster.
Also the results are different in the two cases.  In case 1) you get
10 values back in 'y' and in 2) you only get the value of the last
loop through the 'for' loop.

 system.time(for (i in 1:10) y - sin(i))
   user  system elapsed
   0.170.000.28
 str(y)
 num 0.0357
 system.time(y - sin(1:10))
   user  system elapsed
   0.010.000.02
 str(y)
 num [1:10]  0.841  0.909  0.141 -0.757 -0.959 ...


R is typically optimized for vector type operations.

On Dec 27, 2007 8:39 PM, Tong Wang [EMAIL PROTECTED] wrote:
 HI,
   The question is meant to be a general one, I am trying to find out if there 
 is new development in R that I might have missed.

 but here's a trivial example,

 To compute  y=sin(x) , x = 1,2,... 10
  x=1:10,
 1.  y =sin(x)
 2.  for(i in 1:10) y=sin(x[i])

 1 is much faster than 2.
 Old Matlab also had this problem, but in new versions, 1 and 2 are mostly the 
 same.
 I am just wondering if the same improvement has happened or will happen to R.


 Thanks .




 - Original Message -
 From: jim holtman [EMAIL PROTECTED]
 Date: Thursday, December 27, 2007 4:39 pm
 Subject: Re: [R] Efficiency of for-loop in R
 To: Tong Wang [EMAIL PROTECTED]
 Cc: R help [EMAIL PROTECTED]

  Exactly what is the problem you are trying to solve?  Could you
  provide commented, minimal, self-contained, reproducible code?
 
  A lot depends on what you are trying to do,  There might be other
  ways, in R, than a 'for' loop to solve your problems.
 
  On Dec 27, 2007 6:44 PM, Tong Wang [EMAIL PROTECTED] wrote:
   Hi,
 I just realized that in Matlab, as long as memory is pre-
  allocated, doing for-loop doesn't cost more time than doing things
  in vector form.
 But it seems in R, it still cost a lot to do for-loop.  Is
  there any improvement in R that I missed. Thanks a lot.
  
   Merry Xmas Everyone !
  
   __
   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.
  
 
 
 
  --
  Jim Holtman
  Cincinnati, OH
  +1 513 646 9390
 
  What is the problem you are trying to solve?
 




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

What is the problem you are trying to solve?

__
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] Help with lm and multiple linear regression? (Plain Text version)

2007-12-27 Thread Aaron Barzilai
Tim (and others who responded privately),

Thanks for the help, this approach did work.  I have also reread ?lm a little 
more closely, I do see the weights functionality.

I have one last question: Now that I understand how to call this function and 
review the results, I want to extend it to my much larger real problem, with 
100s of columns.  Is there a way to call the function in more of a matrix 
algebra syntax, where I would list the matrix(e.g. personcoeff) rather than the 
individual column names?  It seems like I might need to use lm.wfit, but per 
the help I'd rather use lm.

Thanks,
Aaron




- Original Message 
From: Tim Calkins [EMAIL PROTECTED]
To: Aaron Barzilai [EMAIL PROTECTED]
Cc: r-help@r-project.org
Sent: Thursday, December 27, 2007 6:55:57 PM
Subject: Re: [R] Help with lm and multiple linear regression? (Plain Text 
version)

consider merging everything into a singe dataframe.  i haven't tried
it, but something like the following could work:

 reg.data - cbind(margin, personcoeff)
 names(reg.data) - c('margin', 'p1', 'p2')
 lm(margin~p1+p2, data = reg.data)

the idea here is that by specifying the data frame with the data
argument in lm, R looks for the columns of the names specified in the
formula.

for weights, see ?lm and look for the weights argument.

cheers,
tc

On Dec 28, 2007 10:22 AM, Aaron Barzilai [EMAIL PROTECTED] wrote:
 (Apologies the previous version was sent as rich text)

 Hello,
 I'm new to R, but I've read the intro to R and successfully connected it to 
 an instance of mysql.  I'm trying to perform multiple linear regression, but 
 I'm having trouble using the lm function.  To start, I have read in a simply 
 y matrix of values(dependent variable) and x matrix of independent variables. 
  It says both are data frames, but lm is giving me an error that my y 
 variable is a list.

 Any suggestions on how to do this?  It's not clear to me what the problem is 
 as they're both data frames.  My actual problem will use a much wider matrix 
 of coefficients, I've only included two for illustration.

 Additionally, I'd actually like to weight the observations.  How would I go 
 about doing that?  I also have that as a separate column vector.

 Thanks,
 Aaron

 Here's my session:
  margin
margin
 166.67
 2  -58.33
 3  100.00
 4  -33.33
 5  200.00
 6  -83.33
 7  -100.00
 80.00
 9  100.00
 10  -18.18
 11  -55.36
 12 -125.00
 13  -33.33
 14 -200.00
 150.00
 16 -100.00
 17  75.00
 180.00
 19 -200.00
 20  35.71
 21  100.00
 22  50.00
 23  -86.67
 24  165.00
  personcoeff
Person1 Person2
 1  -1  1
 2  -1  1
 3  -1  1
 4  -1  1
 5  -1  1
 6  -1  1
 70  0
 80  0
 90  1
 10  -1  1
 11  -1  1
 12  -1  1
 13  -1  1
 14  -1  0
 15  0  0
 16  0  0
 17  0  1
 18  -1  1
 19  -1  1
 20  -1  1
 21  -1  1
 22  -1  1
 23  -1  1
 24  -1  1
  class(margin)
 [1] data.frame
  class(personcoeff)
 [1] data.frame
  lm(margin~personcoeff)
 Error in model.frame(formula, rownames, variables, varnames, extras, 
 extranames,  :
invalid type (list) for variable 'margin'


  
 
 Be a better friend, newshound, and

 __
 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.




-- 
Tim Calkins
0406 753 997


  

Be a better friend, newshound, and

__
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 catch data from the different dataframes and lm problem?

2007-12-27 Thread leeznar


Dear all: 


I am a new R-user and I have 2 questions
about it.  


1) I have a dataframe.  Based on “formulation” and “subject”, a
dataframe is split into 4 dataframes.  The
example is as follows.  Moreover, I want
to calculate “test” value for these 4 dataframes.  My question is that the 
“test” values not
correct and I do not know where the problem is.




2) There are 12 “test” (y) values from 1).  Then, I want to model the 
relationship
between “concentration” (X) and “test” (Y) by fitting the linear regression,
such lm(Y~X) and this is my target.  I
think that if I can catch “test” (Y) values and “concentration” (X) values into
a dataframe, then I can carry out regression.  So, how to catch all “test” 
values from
different dataframes?  Or does anyone
have better way to get this target?


 


Example: 


w-(c(1,1,1,2,2,2,1,1,1,2,2,2))


y-(c(1,1,1,1,1,1,2,2,2,2,2,2))


z-(c(1,2,3,1,2,3,1,2,3,1,2,3))


c-(c(0.1,10,20,0.3,2.5,6,20,25,60,35,40,45))


df-data.frame(formulation=y, subject=w,
time=z, concentration=c)


A.split-split(df, list(df$formulation,
df$subject) )


 


for (j in 1:length(A.split)){


test - 0


for(i in
2:length(A.split[[j]][[time]])){


   
test[i] - (A.split[[1]][[time]][i] -
A.split[[1]][[time]][i-1]) *
(A.split[[1]][[concentration]][i] -
A.split[[1]][[concentration]][i-1])* 0.5


   
test[i]-test[i]+test[i-1]


 }


output-data.frame(A.split[[j]][[subject]],A.split[[j]][[formulation]],A.split[[j]][[time]],A.split[[j]][[concentration]],test)


colnames(output)-list(subject,formulation,time,concentration,test)


show(output) 


}


Best regards,
Hsin-Ya Lee 







  
_
馬上體驗全新Yahoo!奇摩電子信箱2.0。 http://tw.mg0.mail.yahoo.com/dc/landing

__
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] Help with lm and multiple linear regression? (Plain Text version)

2007-12-27 Thread Charilaos Skiadas
Hi Aaron,

if I understand your question correctly, you can use the . in the  
formula, like so:

dat - data.frame(x=1:10,y=rnorm(10),z=10:1)
lm(x~., data=dat)


The dot there stands for everything not already specified, so in this  
case that would be y and z (since x is already on the lhs). You can  
even omit things from . with the minus operator:

lm(x~.-y, data=dat)

This will do a regression of x on z only (and a constant of course).

You can see another approach in the examples section of the help  
entry on ?formula (I was led to that entry from reading the Details  
section of ?lm).

Haris Skiadas
Department of Mathematics and Computer Science
Hanover College


On Dec 27, 2007, at 9:20 PM, Aaron Barzilai wrote:

 Tim (and others who responded privately),

 Thanks for the help, this approach did work.  I have also reread ? 
 lm a little more closely, I do see the weights functionality.

 I have one last question: Now that I understand how to call this  
 function and review the results, I want to extend it to my much  
 larger real problem, with 100s of columns.  Is there a way to call  
 the function in more of a matrix algebra syntax, where I would list  
 the matrix(e.g. personcoeff) rather than the individual column  
 names?  It seems like I might need to use lm.wfit, but per the help  
 I'd rather use lm.

 Thanks,
 Aaron




 - Original Message 
 From: Tim Calkins [EMAIL PROTECTED]
 To: Aaron Barzilai [EMAIL PROTECTED]
 Cc: r-help@r-project.org
 Sent: Thursday, December 27, 2007 6:55:57 PM
 Subject: Re: [R] Help with lm and multiple linear regression?  
 (Plain Text version)

 consider merging everything into a singe dataframe.  i haven't tried
 it, but something like the following could work:

 reg.data - cbind(margin, personcoeff)
 names(reg.data) - c('margin', 'p1', 'p2')
 lm(margin~p1+p2, data = reg.data)

 the idea here is that by specifying the data frame with the data
 argument in lm, R looks for the columns of the names specified in the
 formula.

 for weights, see ?lm and look for the weights argument.

 cheers,
 tc

 On Dec 28, 2007 10:22 AM, Aaron Barzilai [EMAIL PROTECTED]  
 wrote:
 (Apologies the previous version was sent as rich text)

 Hello,
 I'm new to R, but I've read the intro to R and successfully  
 connected it to an instance of mysql.  I'm trying to perform  
 multiple linear regression, but I'm having trouble using the lm  
 function.  To start, I have read in a simply y matrix of values 
 (dependent variable) and x matrix of independent variables.  It  
 says both are data frames, but lm is giving me an error that my y  
 variable is a list.

 Any suggestions on how to do this?  It's not clear to me what the  
 problem is as they're both data frames.  My actual problem will  
 use a much wider matrix of coefficients, I've only included two  
 for illustration.

 Additionally, I'd actually like to weight the observations.  How  
 would I go about doing that?  I also have that as a separate  
 column vector.

 Thanks,
 Aaron

 Here's my session:
 margin
margin
 166.67
 2  -58.33
 3  100.00
 4  -33.33
 5  200.00
 6  -83.33
 7  -100.00
 80.00
 9  100.00
 10  -18.18
 11  -55.36
 12 -125.00
 13  -33.33
 14 -200.00
 150.00
 16 -100.00
 17  75.00
 180.00
 19 -200.00
 20  35.71
 21  100.00
 22  50.00
 23  -86.67
 24  165.00
 personcoeff
Person1 Person2
 1  -1  1
 2  -1  1
 3  -1  1
 4  -1  1
 5  -1  1
 6  -1  1
 70  0
 80  0
 90  1
 10  -1  1
 11  -1  1
 12  -1  1
 13  -1  1
 14  -1  0
 15  0  0
 16  0  0
 17  0  1
 18  -1  1
 19  -1  1
 20  -1  1
 21  -1  1
 22  -1  1
 23  -1  1
 24  -1  1
 class(margin)
 [1] data.frame
 class(personcoeff)
 [1] data.frame
 lm(margin~personcoeff)
 Error in model.frame(formula, rownames, variables, varnames,  
 extras, extranames,  :
invalid type (list) for variable 'margin'

__
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.