Re: [R] Joining Histograms Into a Figure

2008-05-25 Thread Dieter Menne
Edward Wijaya  gmail.com> writes:

> 
> I have two histograms created separately using
> the following code. It creates two separate figures.
> 
> dat <- read.table(file="GDS1096.modelout", head = FALSE )
> 
> __BEGIN__
> dat <- read.table(file="GDS1096.modelout", head = FALSE )
> 
> hist(dat$V2, main="AIC Freq", xlab = "\# Component", breaks = 36, xlim =
> c(0,max(dat$V2)), col = "dark red", freq = TRUE)
> hist(dat$V3, main="BIC Freq", xlab = "\# Component", breaks = 36, xlim =
> c(0,max(dat$V2)), col = "blue", freq = TRUE)
> __END__
> 
> How can I joint this two histograms into one figure?

You could use par(mfcol), and if you want the plots closely spaced, play with
the margin parameters documented under par(). In most cases, the result is not
that satisfactory, so I would recommend using lattice graphics instead, where
the pairing is a build-in feature.
Dieter


par(mfcol=c(1,2))
a = rnorm(100)
b = rnorm(100)
hist(a)
hist(a)

library(lattice)
dt = data.frame(val =c(a,b),group=rep(c("A","B"),each=100))
histogram(~val|group,data=dt)

__
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] Joining Histograms Into a Figure

2008-05-25 Thread Edward Wijaya
Hi,

I have two histograms created separately using
the following code. It creates two separate figures.

dat <- read.table(file="GDS1096.modelout", head = FALSE )

__BEGIN__
dat <- read.table(file="GDS1096.modelout", head = FALSE )

hist(dat$V2, main="AIC Freq", xlab = "\# Component", breaks = 36, xlim =
c(0,max(dat$V2)), col = "dark red", freq = TRUE)
hist(dat$V3, main="BIC Freq", xlab = "\# Component", breaks = 36, xlim =
c(0,max(dat$V2)), col = "blue", freq = TRUE)
__END__

How can I joint this two histograms into one figure?

Regards,
Edward

__
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] does nnet package already have normalization function??

2008-05-25 Thread Handayani Situmorang
Hi..
I'm trying to build a model with neural network through nnet package.  I'm just 
wondering, if there normalization procedure in this package? i must normalize 
my data with my own code outside this package?

Thank you before
Handa

   
-
Kunjungi halaman depan Yahoo! Indonesia yang baru!
[[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] nls diagnostics?

2008-05-25 Thread Spencer Graves

Hi, Gabor:  Thanks very much.  Spencer

Gabor Grothendieck wrote:

On Sun, May 25, 2008 at 9:32 PM, Katharine Mullen <[EMAIL PROTECTED]> wrote:
  

Dear Spencer,

I just saw your post.

If the singular gradient happens during or after iteration one (that is,
not at the initial estimates), then calling summary on the nls output
would give standard error estimates on the parameters useful for
diagnostics.  You could also call chol2inv(xx$m$Rmat())  where xx is the
object returned by nls to get an estimate of the inverse of the hessian;
you could use this estimate to proceed with the diagnostics you were
discussing.



Try this:

  

library(nls2)
DF1 <- data.frame(y=1:9, one=rep(1,9))
xx <- nls2(y~(a+2*b)*one, DF1, start = c(a=1, b=1), algorithm = "brute-force")
eigen(chol2inv(xx$m$Rmat()))


$values
[1] 5.070602e+31 0.00e+00

$vectors
   [,1]   [,2]
[1,] -0.8944272 -0.4472136
[2,]  0.4472136 -0.8944272

__
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] nls diagnostics?

2008-05-25 Thread Gabor Grothendieck
On Sun, May 25, 2008 at 9:32 PM, Katharine Mullen <[EMAIL PROTECTED]> wrote:
> Dear Spencer,
>
> I just saw your post.
>
> If the singular gradient happens during or after iteration one (that is,
> not at the initial estimates), then calling summary on the nls output
> would give standard error estimates on the parameters useful for
> diagnostics.  You could also call chol2inv(xx$m$Rmat())  where xx is the
> object returned by nls to get an estimate of the inverse of the hessian;
> you could use this estimate to proceed with the diagnostics you were
> discussing.

Try this:

> library(nls2)
> DF1 <- data.frame(y=1:9, one=rep(1,9))
> xx <- nls2(y~(a+2*b)*one, DF1, start = c(a=1, b=1), algorithm = "brute-force")
> eigen(chol2inv(xx$m$Rmat()))
$values
[1] 5.070602e+31 0.00e+00

$vectors
   [,1]   [,2]
[1,] -0.8944272 -0.4472136
[2,]  0.4472136 -0.8944272

__
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] nls diagnostics?

2008-05-25 Thread Katharine Mullen
Dear Spencer,

I just saw your post.

If the singular gradient happens during or after iteration one (that is,
not at the initial estimates), then calling summary on the nls output
would give standard error estimates on the parameters useful for
diagnostics.  You could also call chol2inv(xx$m$Rmat())  where xx is the
object returned by nls to get an estimate of the inverse of the hessian;
you could use this estimate to proceed with the diagnostics you were
discussing.

It would be possible (and in my opinion, desirable)  to modify nls to
return an object that contains the information above even if the singular
gradient is at the intial estimates, but I don't think this can be
accomplished without quite a few changes.

You could also use nls.lm from the package minpack.lm to get a hessian
estimate.

By the way, I liked your idea from a while back
(https://stat.ethz.ch/pipermail/r-devel/2008-April/048984.html) to do some
diagnostics to identify problems with overparameterization automatically.

best,
Kate

On Fri, 23 May 2008, Spencer Graves wrote:

> Hi, All:
>
>   What tools exist for diagnosing singular gradient problems with
> 'nls'?  Consider the following toy example:
>
> DF1 <- data.frame(y=1:9, one=rep(1,9))
> nlsToyProblem <- nls(y~(a+2*b)*one, DF1, start=list(a=1, b=1),
>   control=nls.control(warnOnly=TRUE))
> Error in nlsModel(formula, mf, start, wts) :
>   singular gradient matrix at initial parameter estimates
>
>   This example is obviously stupid, but other singular gradient
> problems are not so obvious.
>
>   If we transfer this problem to 'optim', we can get diagnostics
> from an eigen analysis of the hessian:
>
> dumfun <- function(x, y, one){
>   d <- y-(x[1]+2*x[2])*one
>   sum(d^2)
> }
> optimToyProblem <- optim(c(a=1, b=1), dumfun, hessian=TRUE,
>  y=DF1$y, one=DF1$one)
> eigen(optimToyProblem$hessian, symmetric=TRUE)
> $values
> [1]  9.00e+01 -7.105427e-10
>
> $vectors
>   [,1]   [,2]
> [1,] 0.4472136 -0.8944272
> [2,] 0.8944272  0.4472136
>
>   The smallest eigenvalue is essentially numerically zero relative
> to the largest,confirming the 'singular gradient' message.  The
> corresponding eigenvector helps diagnose the problem:  Adding (-0.9,
> 0.45)*z to any solution gives another equally good solution, for any z.
>
>   I've used this technique to diagnose many subtle convergence
> problems with 'optim'.  Are tools of this nature available for 'nls'?
>
>   Thanks,
>   Spencer Graves
>
> __
> 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] plotting bootstrapped confidence intervals regression

2008-05-25 Thread Geertje van der Heijden
Hi all,

I have done a simple linear regression and have calculated
bootstrapped confidence intervals for the intercept and the slope
using the boot package - i.e with the boot.ci command. I want to plot
my regression line and confidence intervals, but here is where I am a
bit stuck.

Can anyone point me in the direction of a package, which I can use to
plot my bootstrapped confidence intervals?

All help is greatly appreciated!

Thanks in advance,
Geertje

--
Dr. Geertje van der Heijden

__
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] naming components of a list

2008-05-25 Thread Duncan Mackay

If there is a lot of names perhaps sprintf(format, 1:length(L), sep="")

where format is the appropriate format for sprintf so that it is easier to 
read


Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
ARMIDALE NSW 2351
Email [EMAIL PROTECTED]
Home [EMAIL PROTECTED]

At 07:11 26/05/2008, you wrote:

Content-Type: text/plain
Content-Disposition: inline
Content-length: 1857

And if you have "thousands of names" like this:
names(L) <- paste ("names", 1:length(L), sep="")

Nael

On Sun, May 25, 2008 at 10:38 PM, Erin Hodgess <[EMAIL PROTECTED]>
wrote:

> try this:
>
> > names(L) <- c("name1","name2","name3")
> > L
> $name1
> [1] "Fred"
>
> $name2
> [1] "Mary"
>
> $name3
> [1] "SAM"
>
> >
> >
> HTH,
> Sincerely,
> Erin
>
>
> On Sun, May 25, 2008 at 2:42 PM, joseph <[EMAIL PROTECTED]> wrote:
> > Hi
> > I have a character vector with thousands of names which looks like this:
> >> V=c("Fred", "Mary", "SAM")
> >> V
> > [1] "Fred" "Mary" "SAM"
> >> class(V)
> > [1] "character"
> >
> > I would like to change it to a list:
> >> L=as.list(V)
> >> L
> > [[1]]
> > [1] "Fred"
> > [[2]]
> > [1] "Mary"
> > [[3]]
> > [1] "SAM"
> >
> > but I need to name the components as name1, name2, name3, …
> > so it should look like this:
> > $name1
> > [1] "Fred"
> > $name2
> > [1] "Mary"
> > $name3
> > [1] "SAM"
> >
> > Any help will be much appreciated
> > Joseph
> >
> >
> >
> >[[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.
> >
> >
>
>
>
> --
> Erin Hodgess
> Associate Professor
> Department of Computer and Mathematical Sciences
> University of Houston - Downtown
> mailto: [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.
>

[[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] Solving 100th order equation

2008-05-25 Thread Rolf Turner


On 26/05/2008, at 10:38 AM, Hans W. Borchers wrote:


Rolf Turner  auckland.ac.nz> writes:



  [...]

However uniroot(p,c(1.995,2.005)) gives

$root
[1] 1.93

$f.root
[1] -4.570875e+24


Whoops!  I read that e+24 as e-24, so scrub all that I said.
(You'd think, that having seen Bill Venables make a similar
 error --- which he corrected in the follow-up posting to which
 I was replying --- I would've been more careful.  Well, you'd
 think wrong.  Actually it *was* e-24 when I posted; then the
 Gremlins got in and changed everything. :-) )


$iter
[1] 4

$estim.prec
[1] 6.103516e-05

What a difference 7.214144e-06 makes!  When you're dealing with
polynomials of degree 100.



I don't think R is the right tool to solve this kind of questions  
that belong to
the realm of Computer Algebra Systems. Yacas is much to weak for  
such high-order
polybomials, but we can apply more powerful CASystems, for instance  
the free

Maxima system. Applying

(%i)nroots(x^100 - 2*x^99 + 10*x^50 + 6*x - 4000, minf, inf)

immediately shows that there are only *two* real solutions, and then

(%i)a: realroots(x^100 - 2*x^99 + 10*x^50 + 6*x - 4000, 1e-15);
(%i)float(a)

(%o)[x=-1.074126672042147,x=1.982]

will provide real solutions with 15 decimals (does not change when  
more decimals

are used). So the difference that counts is actually much smaller.

The complex roots -- if needed -- will require special treatment.

I believe it would be fair to point such questions to Computer  
Algebra mailing
lists and not try to give the appearance they could be solved  
satisfyingly with
R. The same as a complicated statistics question in a Matlab or  
Mathematica

mailing list should be pointed to R-help.



Be that as it were, it doesn't look like Maxima is doing so wonderfully
either. Consider:

 > library(PolynomF)
 > x <- polynom()
 > p <- x^100-2*x^99+10*x^50+6*x-4000
 > a <- 1.982
 > p(a)
[1] -1.407375e+14

And notice the + sign in the exponent. :-)

I tried doing

> uniroot(p,c(1.9995,2.0005),tol=.Machine$double.eps)

and got

$root
[1] 2

$f.root
[1] 912

$iter
[1] 5

$estim.prec
[1] 8.881784e-16

	Well, 912 is a lot closer to 0 than -4.570875e+24, or even -1.407375e 
+14.

But it still ain't 0.  Also that ``2'' of course isn't really 2.

I set r <- uniroot(p,c(1.9995,2.0005),tol=.Machine$double.eps)$root
I get p(r) = 912.

But print(r,digits=22) gives  1.982.
And print(a,digits=22) gives the identical result.
Although p(r) and p(a) are wildly different.

I guess it's possible that p(a) --- where ``a'' is as it appears,
written out to 14 decimal places --- really is quite close to zero,
and that -1.407375e+14 is due to round-off error in the calculation
process.  But it's also possible that p(a) really is pretty close to
	-1.407375e+14, i.e. Maxima isn't really finding the correct root  
either.

Or something in between.

I guess that to get a really ``correct'' answer, and check it properly,
	you need a system that will do ``arbitrary precision arithmetic''.   
Which
	isn't R.  I don't know if Maxima was using arbitrary precision  
arithmetic

in the calculations shown.

	Anyhow, I think the real point is that solving 100-th degree  
polynomials
	is a pretty silly thing to do, whatever package or system or  
language you use.

That is, R may be the wrong tool for the job, but it's the wrong job.

	And if you *must* do it, then you should do some careful checking  
and investigation
	of the results --- again irrespective of whatever package or system  
or language

you use.

cheers,

Rolf Turner


##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

__
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] Solving 100th order equation

2008-05-25 Thread Hans W. Borchers
Rolf Turner  auckland.ac.nz> writes:

>
>   [...]
> 
>   However uniroot(p,c(1.995,2.005)) gives
> 
>   $root
>   [1] 1.93
> 
>   $f.root
>   [1] -4.570875e+24
> 
>   $iter
>   [1] 4
> 
>   $estim.prec
>   [1] 6.103516e-05
> 
>   What a difference 7.214144e-06 makes!  When you're dealing with  
> polynomials of degree 100.
> 

I don't think R is the right tool to solve this kind of questions that belong to
the realm of Computer Algebra Systems. Yacas is much to weak for such high-order
polybomials, but we can apply more powerful CASystems, for instance the free
Maxima system. Applying

(%i)nroots(x^100 - 2*x^99 + 10*x^50 + 6*x - 4000, minf, inf)

immediately shows that there are only *two* real solutions, and then

(%i)a: realroots(x^100 - 2*x^99 + 10*x^50 + 6*x - 4000, 1e-15);
(%i)float(a)

(%o)[x=-1.074126672042147,x=1.982]

will provide real solutions with 15 decimals (does not change when more decimals
are used). So the difference that counts is actually much smaller.

The complex roots -- if needed -- will require special treatment.

I believe it would be fair to point such questions to Computer Algebra mailing
lists and not try to give the appearance they could be solved satisfyingly with
R. The same as a complicated statistics question in a Matlab or Mathematica
mailing list should be pointed to R-help.

Hans Werner

>   Bozhemoi!
> 
>   cheers,
> 
>   Rolf Turner

__
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] naming components of a list

2008-05-25 Thread N. Lapidus
And if you have "thousands of names" like this:
names(L) <- paste ("names", 1:length(L), sep="")

Nael

On Sun, May 25, 2008 at 10:38 PM, Erin Hodgess <[EMAIL PROTECTED]>
wrote:

> try this:
>
> > names(L) <- c("name1","name2","name3")
> > L
> $name1
> [1] "Fred"
>
> $name2
> [1] "Mary"
>
> $name3
> [1] "SAM"
>
> >
> >
> HTH,
> Sincerely,
> Erin
>
>
> On Sun, May 25, 2008 at 2:42 PM, joseph <[EMAIL PROTECTED]> wrote:
> > Hi
> > I have a character vector with thousands of names which looks like this:
> >> V=c("Fred", "Mary", "SAM")
> >> V
> > [1] "Fred" "Mary" "SAM"
> >> class(V)
> > [1] "character"
> >
> > I would like to change it to a list:
> >> L=as.list(V)
> >> L
> > [[1]]
> > [1] "Fred"
> > [[2]]
> > [1] "Mary"
> > [[3]]
> > [1] "SAM"
> >
> > but I need to name the components as name1, name2, name3, …
> > so it should look like this:
> > $name1
> > [1] "Fred"
> > $name2
> > [1] "Mary"
> > $name3
> > [1] "SAM"
> >
> > Any help will be much appreciated
> > Joseph
> >
> >
> >
> >[[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.
> >
> >
>
>
>
> --
> Erin Hodgess
> Associate Professor
> Department of Computer and Mathematical Sciences
> University of Houston - Downtown
> mailto: [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.
>

[[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] R-Excel Macro Problem

2008-05-25 Thread nmarti

Ok, so I'm embarrassed to admit I made a really dumb mistake.  My VBA page
was declared as "Sheet1" code when it should have been "Module1" code.
I knew it was something stupid.  Sorry for the inconvenience.



Yasir Kaheil wrote:
> 
> hi Nate,
> could you please email me your excel workbook. thanks
> y
> 
> nmarti wrote:
>> 
>> I'm trying to write R functions into VBA code.  I've done this many other
>> times in other documents and everything has run great.  But today I keep
>> recieving an error message "Run-time error '1004': Application-defined or
>> object-defined error."
>> 
>> Has anyone else encountered this same error message?
>> 
>> I do not recieve this error in the document when running regular VBA
>> code.  But when I try to run,
>> Call Rinterface.PutDataframe("Data", Range("Sheet1!A1:E2000"))
>> I receive the error.
>> I have the VBA "References" RExcelVBAlib checked.
>> 
>> Any suggestions would be appreiciated,
>> Nate
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/R-Excel-Macro-Problem-tp17450757p17460474.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] Solving 100th order equation

2008-05-25 Thread Rolf Turner


On 25/05/2008, at 1:10 PM, <[EMAIL PROTECTED]>  
<[EMAIL PROTECTED]> wrote:


Oops!  Actually spectacularly bad.  I didn't see the positive  
exponent!


Curiously, there appears to be just one bad apple:


sort(Mod(p(z)))

  [1] 1.062855e-10 1.062855e-10 1.328999e-10 1.328999e-10 2.579625e-10
  [6] 2.579625e-10 3.834721e-10 3.834721e-10 3.875288e-10 3.875288e-10
 [11] 5.287459e-10 5.287459e-10 5.306241e-10 5.306241e-10 6.678424e-10
 [16] 6.678424e-10 6.876300e-10 6.876300e-10 8.519089e-10 8.519089e-10
 [21] 9.345531e-10 9.345531e-10 9.369015e-10 9.369015e-10 9.789510e-10
 [26] 9.789510e-10 1.041601e-09 1.041601e-09 1.046996e-09 1.046996e-09
 [31] 1.149073e-09 1.149073e-09 1.209875e-09 1.209875e-09 1.232793e-09
 [36] 1.232793e-09 1.244167e-09 1.244167e-09 1.388979e-09 1.388979e-09
 [41] 1.556354e-09 1.556354e-09 1.596424e-09 1.596424e-09 1.610661e-09
 [46] 1.610661e-09 1.722577e-09 1.722577e-09 1.727842e-09 1.727842e-09
 [51] 1.728728e-09 1.728728e-09 1.769644e-09 1.769644e-09 1.863983e-09
 [56] 1.863983e-09 1.895296e-09 1.895296e-09 1.907509e-09 1.907509e-09
 [61] 1.948662e-09 1.948662e-09 2.027021e-09 2.027021e-09 2.061063e-09
 [66] 2.061063e-09 2.116735e-09 2.116735e-09 2.185764e-09 2.185764e-09
 [71] 2.209158e-09 2.209158e-09 2.398479e-09 2.398479e-09 2.404217e-09
 [76] 2.404217e-09 2.503279e-09 2.503279e-09 2.643436e-09 2.643436e-09
 [81] 2.654788e-09 2.654788e-09 2.695735e-09 2.695735e-09 2.921933e-09
 [86] 2.921933e-09 2.948185e-09 2.948185e-09 2.953596e-09 2.953596e-09
 [91] 3.097433e-09 3.097433e-09 3.420593e-09 3.420593e-09 3.735880e-09
 [96] 3.735880e-09 4.190042e-09 4.554964e-09 4.554964e-09 1.548112e+15





library(PolynomF)
x <- polynom()
p <- x^100 - 2*x^99 + 10*x^50 + 6*x - 4000
z <- solve(p)
z
  [1] -1.0741267+0.000i -1.073-0.0680356i -1.073 
+0.0680356i -1.0655699-0.1354644i
  [5] -1.0655699+0.1354644i -1.0568677-0.2030274i -1.0568677 
+0.2030274i -1.0400346-0.2687815i

  ...
 [93]  1.0595174+0.2439885i  1.0746575-0.1721335i  1.0746575 
+0.1721335i  1.0828132-0.1065591i
 [97]  1.0828132+0.1065591i  1.0879363-0.0330308i  1.0879363 
+0.0330308i  2.000+0.000i




Now to check how good they are:



range(Mod(p(z)))

[1] 1.062855e-10 1.548112e+15


	It is fascinating to muck about with curve(p,from=a,t=b) for various  
values

of a and b.

	One eventually discerns that there is a real root just a tad less  
than 2.


	Doing uniroot(p,c(1.5,2.5)) gives a root of just *over* 2 with a  
function

value of about 1.9e25.

However uniroot(p,c(1.995,2.005)) gives

$root
[1] 1.93

$f.root
[1] -4.570875e+24

$iter
[1] 4

$estim.prec
[1] 6.103516e-05

	What a difference 7.214144e-06 makes!  When you're dealing with  
polynomials of degree 100.


Bozhemoi!

cheers,

Rolf Turner

P.S.  I suspect that this was a numerical analysis homework question  
designed to teach

a salutary lesson to the nonchalant neophytes.

R. T.


##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

__
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-Excel Macro Problem

2008-05-25 Thread Yasir Kaheil

glad to hear things worked out. 
y

nmarti wrote:
> 
> Ok, so I'm embarrassed to admit I made a really dumb mistake.  My VBA page
> was declared as "Sheet1" code when it should have been "Module1" code.
> I knew it was something stupid.  Sorry for the inconvenience.
> 
> 
> 
> Yasir Kaheil wrote:
>> 
>> hi Nate,
>> could you please email me your excel workbook. thanks
>> y
>> 
>> nmarti wrote:
>>> 
>>> I'm trying to write R functions into VBA code.  I've done this many
>>> other times in other documents and everything has run great.  But today
>>> I keep recieving an error message "Run-time error '1004':
>>> Application-defined or object-defined error."
>>> 
>>> Has anyone else encountered this same error message?
>>> 
>>> I do not recieve this error in the document when running regular VBA
>>> code.  But when I try to run,
>>> Call Rinterface.PutDataframe("Data", Range("Sheet1!A1:E2000"))
>>> I receive the error.
>>> I have the VBA "References" RExcelVBAlib checked.
>>> 
>>> Any suggestions would be appreiciated,
>>> Nate
>>> 
>> 
>> 
> 
> 


-
Yasir H. Kaheil
Catchment Research Facility
The University of Western Ontario 

-- 
View this message in context: 
http://www.nabble.com/R-Excel-Macro-Problem-tp17450757p17462407.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] R-Excel Macro Problem

2008-05-25 Thread nmarti

Yasir, I couldn't find your email address, I'm new to the forum.  Here's the
code,

Sub Run_ModelT()

Call Rinterface.StartRServer
Call Rinterface.PutDataframe("DataSet", Range("Peram!A1:E2000"))
Call Rinterface.RRun("attach(DataSett)")
Call Rinterface.RRun("model <- lm(Ch_Close_1 ~ Ch_Gold_1)")
Call Rinterface.GetArray("coeftest(model)", Range("OutPut!D7"))
Call Rinterface.GetArray("summary(lm(model))$r.squared",
Range("OutPut!G3"))
Call Rinterface.GetArray("summary(lm(model))$adj.r.squared",
Range("OutPut!G4"))

End Sub

I'm still looking for the problem.  I'm beginning to think it dosen't have
anything to do with code.  I think there's a problem with the com server or
something else.
Thanks for the help.



Yasir Kaheil wrote:
> 
> hi Nate,
> could you please email me your excel workbook. thanks
> y
> 
> nmarti wrote:
>> 
>> I'm trying to write R functions into VBA code.  I've done this many other
>> times in other documents and everything has run great.  But today I keep
>> recieving an error message "Run-time error '1004': Application-defined or
>> object-defined error."
>> 
>> Has anyone else encountered this same error message?
>> 
>> I do not recieve this error in the document when running regular VBA
>> code.  But when I try to run,
>> Call Rinterface.PutDataframe("Data", Range("Sheet1!A1:E2000"))
>> I receive the error.
>> I have the VBA "References" RExcelVBAlib checked.
>> 
>> Any suggestions would be appreiciated,
>> Nate
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/R-Excel-Macro-Problem-tp17450757p17459745.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] installing source package RGtk2 on mac os x 10.4.11

2008-05-25 Thread Corrado Giannasca
Dear All,

I'm trying to install the source package RGtk2  
(RGtk2_2.12.5-3.tar.gz) on a i-Mac running os x 10.4.11:
   Nome modello:iMac
   Identificatore modello:  iMac6,1
   Nome processore: Intel Core 2 Duo
   Velocità processore: 2.16 GHz
   Numero di processori:1
   Numero totale di nuclei: 2
   L2 Cache (per processore):   4 MB
   Memoria: 2 GB
   Velocità bus:667 MHz
   Versione Boot ROM:   IM61.0093.B07
   Versione SMC:1.10f3

This is a step needed to use Rattle package, as detailed in:

http://datamining.togaware.com/survivor/Installation_Details.html:
"...Mac/OSX: download the source package from ggobi,2.12 and run the  
command line install:
Mac/OSX: $ R CMD INSTALL RGtk2_2.8.6.tar.gz   (30 minutes)

You may not be able to compile RGtk2 via the R GUI on Mac/OSX as the  
GTK libraries can not be found when gcc is called. Once installed  
though, R will detect the package--don't try to load it within the  
GUI as GTK is not a native Mac/OSX application and it will fail. On  
Mac/OSX be sure to run R from the X11 environment. ..."

The installation is performed in a Terminal window with the following  
command:

corradogiannasca$ R CMD INSTALL RGtk2_2.12.5-3.tar.gz

There is a long listing in output and the installation fails with the  
following statement:


/usr/bin/libtool: internal link edit command failed
make: *** [RGtk2.so] Error 1
chmod: /Library/Frameworks/R.framework/Versions/2.7/Resources/library/ 
RGtk2/libs/i386/*: No such file or directory
ERROR: compilation failed for package 'RGtk2'
** Removing '/Library/Frameworks/R.framework/Versions/2.7/Resources/ 
library/RGtk2'

CAN ANYONE HELP IN RESOLVING THIS ERROR?

Thank you very much for your support.

Corrado Giannasca


[[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] RSPerl & OS X

2008-05-25 Thread DavidM.UK

Hi Duncan,

That fix worked I tested it with plot.pl and test2.pl, but I think a similar
problem is occurring with RGtk, which I need to install before I can use
RGtkviewers which in turn I need before I install IDocs :) I'm hoping the
combination of those modules will allow me to produce interactive pages with
data processed by Perl and passed to R via RSPerl?

$ R CMD INSTALL RGtk_*
* Installing to library '/Library/Frameworks/R.framework/Resources/library'
* Installing *source* package 'RGtk' ...
checking for pkg-config... no
checking for gtk-config... no
checking for gnome-config... no
configure: creating ./config.status
config.status: creating src/Makevars
config.status: creating cleanup
** libs
** arch - i386
make: --cflags: Command not found
gcc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk
-mmacosx-version-min=10
.4 -std=gnu99 -no-cpp-precomp
-I/Library/Frameworks/R.framework/Resources/includ
e -I/Library/Frameworks/R.framework/Resources/include/i386 -I. -D_R_=1
-DUSE_R=1
  -I/Library/Frameworks/R.framework/Resources/include   -msse3-fPIC 
-g 
-O2 -march=nocona -c GdkManual.c -o GdkManual.o
GdkManual.c:1:21: error: gdk/gdk.h: No such file or directory
In file included from GdkManual.c:3:
gtkUtils.h:6:21: error: gtk/gtk.h: No such file or directory
In file included from gtkUtils.h:8,
 from GdkManual.c:3:
RGtk.h:20: error: parse error before 'guint'
RGtk.h:20: warning: no semicolon at end of struct or union
RGtk.h:21: warning: type defaults to 'int' in declaration of
'R_gtk_CallbackData
'
RGtk.h:21: warning: data definition has no type or storage class
RGtk.h:23: error: parse error before '*' token
RGtk.h:24: error: parse error before '*' token
RGtk.h:27: error: parse error before 'type'
In file included from GdkManual.c:3:
gtkUtils.h:30: warning: parameter names (without types) in function
declaration
gtkUtils.h:32: error: parse error before 'arg'
gtkUtils.h:33: error: parse error before 'GtkArg'
gtkUtils.h:35: error: parse error before 'type'
GdkManual.c: In function 'S_gdk_window_get_size':
GdkManual.c:8: error: 'GdkWindow' undeclared (first use in this function)
GdkManual.c:8: error: (Each undeclared identifier is reported only once
GdkManual.c:8: error: for each function it appears in.)
GdkManual.c:8: error: 'window' undeclared (first use in this function)
GdkManual.c:8: error: parse error before ')' token
GdkManual.c:12: warning: implicit declaration of function
'gdk_window_get_size'
GdkManual.c: In function 'S_getGdkEventButtonX':
GdkManual.c:33: error: 'GdkEventButton' undeclared (first use in this
function)
GdkManual.c:33: error: 'obj' undeclared (first use in this function)
GdkManual.c:33: error: parse error before ')' token
make: *** [GdkManual.o] Error 1
chmod:
/Library/Frameworks/R.framework/Versions/2.6/Resources/library/RGtk/libs/
i386/*: No such file or directory
ERROR: compilation failed for package 'RGtk'
** Removing
'/Library/Frameworks/R.framework/Versions/2.6/Resources/library/RGtk

Cheers

David M

Duncan Temple Lang wrote:
> 
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
> 
> 
> 
> That will need the architecture-specific directory, e.g. etc/i386/Makeconf
> or etc/ppc/Makeconf
> 
> There is an updated version at
> ~ http://www.omegahat.org/RSPerl/RSPerl_0.92-2.tar.gz
> 
> that will hopefully bypass that issue. (It is a rapid
> fix that may have other issues.)
> 
> As for finding R.pm, use the appropriate shell script
> in /RSPerl/scripts/ to set the relevant
> environment variables to find the Perl code, etc.
> 
> 
> Thanks for letting me know
> ~ D.
> 
> 
> | `/Library/Frameworks/R.framework/Resources/etc/Makeconf'.  Stop.
> | calling make -f Makefile.perl install
> | make: Makefile.perl: No such file or directory
> | make: *** No rule to make target `Makefile.perl'.  Stop.
> | chmod: blib/lib/R.pm: No such file or directory
> | Finished configuration
> | ** libs
> | ** arch - i386
> | gcc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk
> | -mmacosx-version-min=10.4 -std=gnu99 -no-cpp-precomp
> | -I/Library/Frameworks/R.framework/Resources/include
> | -I/Library/Frameworks/R.framework/Resources/include/i386 -I.  -g -pipe
> | -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing
> | -I/usr/local/include
> | -I/System/Library/Perl/5.8.6/darwin-thread-multi-2level/CORE 
> -DPERL_POLLUTE
> | -D_R_=1 -DUSE_R=1 -DUSE_TOPLEVEL_EXEC=1 -DWITH_R_IN_PERL=1 -msse3   
> -fPIC
> | -g -O2 -march=nocona -c Converters.c -o Converters.o
> | gcc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk
> | -mmacosx-version-min=10.4 -std=gnu99 -no-cpp-precomp
> | -I/Library/Frameworks/R.framework/Resources/include
> | -I/Library/Frameworks/R.framework/Resources/include/i386 -I.  -g -pipe
> | -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing
> | -I/usr/local/include
> | -I/System/Library/Perl/5.8.6/darwin-thread-multi-2level/CORE 
> -DPERL_POLLUTE
> | -D_R_=1 -DUSE_R=1 -DUSE_TOPLEVEL_EXEC=1 -DWITH_R_IN_PERL=1 -msse3   
> -fPIC
> | -g -O2 -m

Re: [R] Emacs Bundle...

2008-05-25 Thread Daniel Nordlund


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
> Of Peter Dalgaard
> Sent: Sunday, May 25, 2008 1:18 PM
> To: Atul Kulkarni
> Cc: R-help@r-project.org
> Subject: Re: [R] Emacs Bundle...
> 
> Atul Kulkarni wrote:
> > Hi List,
> >
> > I remember someone mentioning a R-specific bundle of Emacs. Can you please
> > post link again?
> >
> > Regards,
> > Atul.
> >
> By the "teach a man to fish" principle,
> 
> http://www.r-project.org/search.html
> 
> search for: emacs ess windows
> 
> 2nd hit, 4th bullet from the end.
> 
> --

For emacs-ess on windows here is a recent post from Vincent Goulet that 
provided me with a very simple install on both WinXP and Vista.

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/125362.html

Hope this is helpful,

Dan

Daniel Nordlund
Bothell, WA USA

__
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] naming components of a list

2008-05-25 Thread Erin Hodgess
try this:

> names(L) <- c("name1","name2","name3")
> L
$name1
[1] "Fred"

$name2
[1] "Mary"

$name3
[1] "SAM"

>
>
HTH,
Sincerely,
Erin


On Sun, May 25, 2008 at 2:42 PM, joseph <[EMAIL PROTECTED]> wrote:
> Hi
> I have a character vector with thousands of names which looks like this:
>> V=c("Fred", "Mary", "SAM")
>> V
> [1] "Fred" "Mary" "SAM"
>> class(V)
> [1] "character"
>
> I would like to change it to a list:
>> L=as.list(V)
>> L
> [[1]]
> [1] "Fred"
> [[2]]
> [1] "Mary"
> [[3]]
> [1] "SAM"
>
> but I need to name the components as name1, name2, name3, …
> so it should look like this:
> $name1
> [1] "Fred"
> $name2
> [1] "Mary"
> $name3
> [1] "SAM"
>
> Any help will be much appreciated
> Joseph
>
>
>
>[[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.
>
>



-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: [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] Need help for nlme

2008-05-25 Thread Andrew Robinson
My advice is to try to simplify this as much as possible.  When it is
as simple as possible, it will either work or not work.  If it works,
then you have learned something useful.  If it does not work, then
send your question again.  Right now there is a great deal of detail
that may or may not be extraneous.  

Andrew.


On Sun, May 25, 2008 at 01:36:49PM -0500, [EMAIL PROTECTED] wrote:
> Hi everyone,
> I try to write a module based on nlme however R always shows me the  
> error message
> Error in eval(expr, envir, enclos) : object "y" not found. Does anyone  
> know how to solve this? There is no problem in nls at all.
> 
> require(nlme)
> AMPmixed<-function(y, x, S1=c("asymptotic","logistic"),  
> S2=c("asymptotic","logistic"), data, start,random)
>  {
>   logist.logist<-function(x,alpha,delta,psi.l,tau.l,gamma,h){
>   
> delta+(alpha-delta+gamma*(x-(h-1))/exp(x))/(1+exp(-(x-tau.l)/psi.l))}
>   logist.asymp<-function(x,alpha,delta,psi.l,tau.l,lpsi.a,gamma,h){
>   
> delta+(alpha-delta)/(1+exp(-(x-tau.l)/psi.l))+(gamma*(x-(h-1))/exp(x))*exp(-exp(1/lpsi.a)*x)}
>   asymp.asymp<-function(x,alpha,delta,lpsi.a,gamma,h){
>   
> delta+(alpha-delta)*exp(-exp(1/lpsi.a)*x)+(gamma*(x-(h-1))/exp(x))*exp(-exp(1/lpsi.a)*x)}
>   asymp.logist<-function(x,alpha,delta,psi.l,tau.l,lpsi.a,gamma,h){
>   
> delta+(alpha-delta)*exp(-exp(1/lpsi.a)*x)+(gamma*(x-(h-1))/exp(x))/(1+exp(-(x-tau.l)/psi.l))}
> 
>(logistic.logistic<-function(y, x, data, start, random){
> 
> nlme.out<-nlme(y~logist.logist(x,alpha,delta,psi.l,tau.l,gamma,h),  
> data=data, start=start,
>   fixed=alpha+delta+psi.l+tau.l+gamma+h~1,  
> random=random)
>list(nlme.out=summary(nlme.out))
>})
>(logistic.asymptotic<-function(y, x, data, start, random){
>  
> nlme.out<-nlme(y~logist.asymp(x,alpha,delta,psi.l,tau.l,lpsi.a,gamma,h),  
> data=data, start=start,
>  
> fixed=alpha+delta+psi.l+tau.l+lpsi.a+gamma+h~1, random=random)
>  list(nlme.out=summary(nlme.out))
>})
>(asymptotic.logistic<-function(y, x, data, start,random){
> 
> nlme.out<-nlme(y~asymp.logist(x,alpha,delta,psi.l,tau.l,lpsi.a,gamma,h),  
> data=data, start=start,
> 
> fixed=alpha+delta+psi.l+tau.l+lpsi.a+gamma+h~1, random=random)
> list(nlme.out=summary(nlme.out))
>})
>(asymptotic.asymptotic<-function(y, x, data, start, random){
> 
> nlme.out<-nlme(y~asymp.asymp(x,alpha,delta,lpsi.a,gamma,h), data=data,  
> start=start,
>  fixed=alpha+delta+lpsi.a+gamma+h~1,random=random)
>list(nlme.out=summary(nlme.out))
>})
> 
>if(S1=="logistic" && S2=="logistic")  
> {(AMPmixed=logistic.logistic(y, x, data, start, random))}
>else if(S1=="logistic" &&  
> S2=="asymptotic"){(AMPmixed=logistic.asymptotic(y, x, data, start,  
> random))}
>else if(S1=="asymptotic" &&  
> S2=="logistic"){(AMPmixed=asymptotic.logistic(y, x, data, start,  
> random))}
>else if(S1=="asymptotic" &&  
> S2=="asymptotic"){(AMPmixed=asymptotic.asymptotic(y, x, data, start,  
> random))}
>}
> 
> #
>   con rep biomass
> 10.00   1   1.126
> 20.32   1   1.096
> 31.00   1   1.163
> 43.20   1   0.985
> 5   10.00   1   0.716
> 6   32.00   1   0.560
> 7  100.00   1   0.375
> 80.00   2   0.833
> 90.32   2   1.106
> 10   1.00   2   1.336
> 11   3.20   2   0.754
> 12  10.00   2   0.683
> 13  32.00   2   0.488
> 14 100.00   2   0.344
> 
> iso<-read.table(file="E:\\Hormesis\\data\\isobutanol.txt", header=T)
> aa<-groupedData(biomass~con|rep, data=iso)
> van2<-AMPmixed(y=biomass, x=con, S1="asymptotic", S2="asymptotic", data=aa,
>random=pdDiag(alpha+delta+lpsi.a+gamma+h~1),
>start=c(alpha= 0.7954, delta= 0.3231,  lpsi.a=-0.2738,  
> gamma= 1.0366, h=0.8429))
> van2
> 
> Thank you very much in advance.
> Chunhao
> 
> __
> 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.

-- 
Andrew Robinson  
Department of Mathematics and StatisticsTel: +61-3-8344-6410
University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599
http://www.ms.unimelb.edu.au/~andrewpr
http://blogs.mbs.edu/fishing-in-the-bay/

__
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, reproducib

Re: [R] naming the components of a list

2008-05-25 Thread Rolf Turner


On 26/05/2008, at 7:54 AM, joseph wrote:


Hi
I have a character vector with thousands of names which looks like  
this:

V=c("Fred", "Mary", "SAM")
V

[1] "Fred" "Mary" "SAM"

class(V)

[1] "character"

I would like to change it to a list:

L=as.list(V)
L

[[1]]
[1] "Fred"
[[2]]
[1] "Mary"
[[3]]
[1] "SAM"

but I need to name the components as name1, name2, name3,

so it should look like this:
$name1
[1] "Fred"
$name2
[1] "Mary"
$name3
[1] "SAM"


names(L) <- paste("name",1:3,sep="")

cheers,

Rolf Turner

##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

__
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] Emacs Bundle...

2008-05-25 Thread Peter Dalgaard

Atul Kulkarni wrote:

Hi List,

I remember someone mentioning a R-specific bundle of Emacs. Can you please
post link again?

Regards,
Atul.
  

By the "teach a man to fish" principle,

http://www.r-project.org/search.html

search for: emacs ess windows

2nd hit, 4th bullet from the end.

--
  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] naming the components of a list

2008-05-25 Thread joseph
Hi
I have a character vector with thousands of names which looks like this:
> V=c("Fred", "Mary", "SAM")
> V
[1] "Fred" "Mary" "SAM" 
> class(V)
[1] "character"

I would like to change it to a list:
> L=as.list(V)
> L
[[1]]
[1] "Fred"
[[2]]
[1] "Mary"
[[3]]
[1] "SAM"

but I need to name the components as name1, name2, name3, …
so it should look like this:
$name1
[1] "Fred"
$name2
[1] "Mary"
$name3
[1] "SAM"

Any help will be much appreciated
Joseph


  
[[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] Emacs Bundle...

2008-05-25 Thread Atul Kulkarni
Hi List,

I remember someone mentioning a R-specific bundle of Emacs. Can you please
post link again?

Regards,
Atul.

-- 
Atul S. Kulkarni
Graduate Student,
Department of Computer Science,
University Of Minnesota,
Duluth, MN 55812.
www.d.umn.edu/~kulka053
-
"Before you start some work, always ask yourself three questions - Why am I
doing it, What the results might be and Will I be successful. Only when you
think deeply and find satisfactory answers to these questions, go ahead."
Chanakya quotes (Indian politician, strategist and writer, 350 BC-275 BC)

[[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] naming components of a list

2008-05-25 Thread joseph
Hi
I have a character vector with thousands of names which looks like this:
> V=c("Fred", "Mary", "SAM")
> V
[1] "Fred" "Mary" "SAM" 
> class(V)
[1] "character"

I would like to change it to a list:
> L=as.list(V)
> L
[[1]]
[1] "Fred"
[[2]]
[1] "Mary"
[[3]]
[1] "SAM"

but I need to name the components as name1, name2, name3, …
so it should look like this:
$name1
[1] "Fred"
$name2
[1] "Mary"
$name3
[1] "SAM"

Any help will be much appreciated
Joseph


  
[[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] n Realizations of a Stochastic Process assigned to dynamically generated variable names?

2008-05-25 Thread Vishal Belsare
I am interested in creating multiple (say 1000) time series, from a
given stochastic process, of length 250. I want to refer to each
realization with its own variable name, of the format say, tsn, where
n is the n'th simulation. i.e. ts1, ts2, ts3, ts4,  , ts1000

The way I am thinking of doing this is placing the following code
within another loop, and the 'tsn' assignment should happen as ts1 and
so on, the n being taken from the iteration of the outer loop.
However, crucially, I don't know how/whether I can create variable
names dynamically and assign values to them.

#begin

tsn <- (10);

for (i in 1:250) {

  tsn <- c(tsn, tsn[i] + rnorm(1, mean=0.01, sd=0.025))

 };

plot.ts(tsn, lwd=2, col="maroon");

#end


Thanks in anticipation.


Best Regards

Vishal Belsare

__
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] Need help for nlme

2008-05-25 Thread ctu

Hi everyone,
I try to write a module based on nlme however R always shows me the  
error message
Error in eval(expr, envir, enclos) : object "y" not found. Does anyone  
know how to solve this? There is no problem in nls at all.


require(nlme)
AMPmixed<-function(y, x, S1=c("asymptotic","logistic"),  
S2=c("asymptotic","logistic"), data, start,random)

 {
  logist.logist<-function(x,alpha,delta,psi.l,tau.l,gamma,h){
  
delta+(alpha-delta+gamma*(x-(h-1))/exp(x))/(1+exp(-(x-tau.l)/psi.l))}

  logist.asymp<-function(x,alpha,delta,psi.l,tau.l,lpsi.a,gamma,h){
  
delta+(alpha-delta)/(1+exp(-(x-tau.l)/psi.l))+(gamma*(x-(h-1))/exp(x))*exp(-exp(1/lpsi.a)*x)}

  asymp.asymp<-function(x,alpha,delta,lpsi.a,gamma,h){
  
delta+(alpha-delta)*exp(-exp(1/lpsi.a)*x)+(gamma*(x-(h-1))/exp(x))*exp(-exp(1/lpsi.a)*x)}

  asymp.logist<-function(x,alpha,delta,psi.l,tau.l,lpsi.a,gamma,h){
  
delta+(alpha-delta)*exp(-exp(1/lpsi.a)*x)+(gamma*(x-(h-1))/exp(x))/(1+exp(-(x-tau.l)/psi.l))}


   (logistic.logistic<-function(y, x, data, start, random){

nlme.out<-nlme(y~logist.logist(x,alpha,delta,psi.l,tau.l,gamma,h),  
data=data, start=start,
  fixed=alpha+delta+psi.l+tau.l+gamma+h~1,  
random=random)

   list(nlme.out=summary(nlme.out))
   })
   (logistic.asymptotic<-function(y, x, data, start, random){
 
nlme.out<-nlme(y~logist.asymp(x,alpha,delta,psi.l,tau.l,lpsi.a,gamma,h),  
data=data, start=start,
 
fixed=alpha+delta+psi.l+tau.l+lpsi.a+gamma+h~1, random=random)

 list(nlme.out=summary(nlme.out))
   })
   (asymptotic.logistic<-function(y, x, data, start,random){

nlme.out<-nlme(y~asymp.logist(x,alpha,delta,psi.l,tau.l,lpsi.a,gamma,h),  
data=data, start=start,

fixed=alpha+delta+psi.l+tau.l+lpsi.a+gamma+h~1, random=random)

list(nlme.out=summary(nlme.out))
   })
   (asymptotic.asymptotic<-function(y, x, data, start, random){

nlme.out<-nlme(y~asymp.asymp(x,alpha,delta,lpsi.a,gamma,h), data=data,  
start=start,

 fixed=alpha+delta+lpsi.a+gamma+h~1,random=random)
   list(nlme.out=summary(nlme.out))
   })

   if(S1=="logistic" && S2=="logistic")  
{(AMPmixed=logistic.logistic(y, x, data, start, random))}
   else if(S1=="logistic" &&  
S2=="asymptotic"){(AMPmixed=logistic.asymptotic(y, x, data, start,  
random))}
   else if(S1=="asymptotic" &&  
S2=="logistic"){(AMPmixed=asymptotic.logistic(y, x, data, start,  
random))}
   else if(S1=="asymptotic" &&  
S2=="asymptotic"){(AMPmixed=asymptotic.asymptotic(y, x, data, start,  
random))}

   }

#
  con rep biomass
10.00   1   1.126
20.32   1   1.096
31.00   1   1.163
43.20   1   0.985
5   10.00   1   0.716
6   32.00   1   0.560
7  100.00   1   0.375
80.00   2   0.833
90.32   2   1.106
10   1.00   2   1.336
11   3.20   2   0.754
12  10.00   2   0.683
13  32.00   2   0.488
14 100.00   2   0.344

iso<-read.table(file="E:\\Hormesis\\data\\isobutanol.txt", header=T)
aa<-groupedData(biomass~con|rep, data=iso)
van2<-AMPmixed(y=biomass, x=con, S1="asymptotic", S2="asymptotic", data=aa,
   random=pdDiag(alpha+delta+lpsi.a+gamma+h~1),
   start=c(alpha= 0.7954, delta= 0.3231,  lpsi.a=-0.2738,  
gamma= 1.0366, h=0.8429))

van2

Thank you very much in advance.
Chunhao

__
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] need help for building R in Ubuntu 8.04

2008-05-25 Thread Marianne Promberger
On 05/25/08 12:12, Nitesh Agrawal wrote:
> Hi everyone
> I have been trying to build R in ubuntu 8.04 from its source code but am
> getting the following error.
> 
> configure: error: --with-x=yes (default) and X11 headers/libs are not
> available
> 
> Please help me and consider me a newbie in linux


Is there a reason why you want to install from source?

sudo aptitude install r-base 

should work, AFAIK, or, if you prefer the GUI, look for R in synaptic.

You may have to add an extra repository first; I had to:
http://promberger.info/linux/2007/09/04/installing-and-updating-r-with-aptitude/


I'm currently using 7.10 so not 100 percent sure if this works in 8.04.

m.


-- 
Marianne Promberger
Graduate student in Psychology
http://www.psych.upenn.edu/~mpromber

__
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] need help for building R in Ubuntu 8.04

2008-05-25 Thread Erin Hodgess
Try:

./configure --with-x=no




On Sun, May 25, 2008 at 1:20 PM, Roland Rau <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Nitesh Agrawal wrote:
>>
>> Hi everyone
>> I have been trying to build R in ubuntu 8.04 from its source code but am
>> getting the following error.
>>
>> configure: error: --with-x=yes (default) and X11 headers/libs are not
>> available
>>
>
>
> I am currently sitting in front of a Windows machine but I built R on my
>  laptop at home running Ubuntu 8.04. So hopefully, I don't make a mistake.
> What I guess you have to do, is to install the
>
> xorg-dev
>
> package.
> You could do this by:
> sudo apt-get install xorg-dev
> in a terminal window.
>
> And then you can start again with ./configure and so on.
>
> Does this help?
> Roland
>
> __
> 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.
>



-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: [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] need help for building R in Ubuntu 8.04

2008-05-25 Thread Dirk Eddelbuettel
On Sun, May 25, 2008 at 12:12:56PM -0600, Nitesh Agrawal wrote:
> Hi everyone
> I have been trying to build R in ubuntu 8.04 from its source code but am
> getting the following error.
> 
> configure: error: --with-x=yes (default) and X11 headers/libs are not
> available
> 
> Please help me and consider me a newbie in linux

Well, some kind folks are doing the work for you. So as mentioned in the R FAQ,
why don't you use what the CRAN mirrors provide under bin/linux/ubuntu and just 
install
the binary packages?

Start here:

http://cran.r-project.org/bin/linux/ubuntu/

or use your country mirror as e.g. cran.us.r-project.org, 
cran.ca.r-project.org, ...

Dirk

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


Re: [R] need help for building R in Ubuntu 8.04

2008-05-25 Thread Roland Rau

Hi,

Nitesh Agrawal wrote:

Hi everyone
I have been trying to build R in ubuntu 8.04 from its source code but am
getting the following error.

configure: error: --with-x=yes (default) and X11 headers/libs are not
available




I am currently sitting in front of a Windows machine but I built R on my 
 laptop at home running Ubuntu 8.04. So hopefully, I don't make a 
mistake. What I guess you have to do, is to install the


xorg-dev

package.
You could do this by:
sudo apt-get install xorg-dev
in a terminal window.

And then you can start again with ./configure and so on.

Does this help?
Roland

__
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] marginality principle / selecting the right type of SS for an interaction hypothesis

2008-05-25 Thread hadley wickham
> BTW, although I didn't read it carefully, the your web-page description of a
> main effect in the presence of an interaction appears to imply that this
> averages across all individuals, when in fact it averages across the levels
> of the other factor; the result is different when there are unequal numbers
> of observations in the cells. As well, you describe the model in your email
> as an ANCOVA, when in fact it appears to be a two-way ANOVA.

And why not show the raw data on the model summary plots?  That way
you could spot potential outliers, or skewness etc.

Hadley


-- 
http://had.co.nz/

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


[R] need help for building R in Ubuntu 8.04

2008-05-25 Thread Nitesh Agrawal
Hi everyone
I have been trying to build R in ubuntu 8.04 from its source code but am
getting the following error.

configure: error: --with-x=yes (default) and X11 headers/libs are not
available

Please help me and consider me a newbie in linux

thanks in advance

[[alternative HTML version deleted]]

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


Re: [R] Configuring emacs/ess on Ubuntu

2008-05-25 Thread Roland Rau

Hi Wade,

Wade Wall wrote:
I first installed through the package manager, but was unable to start R 
without opening a script file.  So I installed from the tarball, but am 
still unable to open R using any commands;  ESS loads into a buffer; but 
I can't use M-x-R to open R.   the only way I can open R is to open a 


are you sure R is installed?


script file first.  Maybe my question is, how do I create a new script 
file, type some commands, open R, and run script from the file?


this is a simple session which should work to create a new script file, 
typing some commands, opening R and run the whole content from the 
buffer in R. Please note that there might be a message like Cannot read 
history file /your/file/path

"C" refers to the CTRL key and "M" to the Meta key (-> ALT)

C-x C-f myscript.r
rnorm(100)
C-x 2
C-x o
M-x R
C-x o
C-c M-b



I hope this helps you further,
Roland

__
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] Configuring emacs/ess on Ubuntu

2008-05-25 Thread Dirk Eddelbuettel
On Sun, May 25, 2008 at 11:40:07AM -0400, Dale Steele wrote:
>  $ sudo apt-get install
> 
> Installs  installs  ESS version 5.3.0.  Is there a repository for more
> recent version?

As it happens, "yes and no".  There is now a small group working on
Ess for Debian/Ubuntu, but there is no Ubuntu repository.  

But as the package is not binary, you can just fetch the most current
Debian version (by hand). The package tracking (PTS) page is at

  http://packages.qa.debian.org/e/ess.html

and the pool is at 

  http://ftp.debian.org/debian/pool/main/e/ess/

Just grab the file from there; if you install with my favourite frontend wajig 
you can just do

  $ wajig install 
http://ftp.debian.org/debian/pool/main/e/ess/ess_5.3.8~svn3902-1_all.deb

Hth, Dirk


> 
> Thanks.  --Dale
> 
> On Sun, May 25, 2008 at 11:24 AM, Roland Rau <[EMAIL PROTECTED]> wrote:
> > Hi Wade,
> >
> > Wade Wall wrote:
> >>
> >> Hi all,
> >>
> >> I don't know if this is the proper place to ask this, but I am trying to
> >> configure emacs/ess on Ubuntu 8.04 to run the way described for ESS and
> >
> > I think the easiest way to install emacs/ess on Ubuntu 8.04 is via the
> > repositories.
> > Simply use your favorite package manager (I use synaptic) and choose the ess
> > package. If Emacs hasn't been installed yet, it will do so automatically.
> >
> > I hope this helps,
> > Roland
> >
> > __
> > 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.

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


Re: [R] marginality principle / selecting the right type of SS for an interaction hypothesis

2008-05-25 Thread John Fox
Dear Bertolt,

Since you have specific hypotheses in mind, why not just test them directly
as contrasts? That is, test for (1) the difference between men and women in
the absence of stereotype threat; (2) the difference between men and women
in the presence of stereotype threat; and (3) the difference in these
differences (i.e., the interaction).

The fact that you expect a positive difference in (1) and (2) doesn't make
the test for the gender "main effect" sensible, because you're averaging
simple effects of different magnitude. 

BTW, although I didn't read it carefully, the your web-page description of a
main effect in the presence of an interaction appears to imply that this
averages across all individuals, when in fact it averages across the levels
of the other factor; the result is different when there are unequal numbers
of observations in the cells. As well, you describe the model in your email
as an ANCOVA, when in fact it appears to be a two-way ANOVA.

I hope this helps,
 John

--
John Fox, Professor
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
web: socserv.mcmaster.ca/jfox

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On
> Behalf Of Bertolt Meyer
> Sent: May-25-08 10:51 AM
> To: r-help@r-project.org
> Subject: [R] marginality principle / selecting the right type of SS for an
> interaction hypothesis
> 
> Hello,
> 
> I have a problem with selecting the right type of sums of squares for
> an ANCOVA for my specific experimental data and hypotheses. I do have
> a basic understanding of the differences between Type-I, II, and III
> SSs, have read about the principle of marginality, and read Venable's
> "Exegeses on Linear Models"
> (http://www.stats.ox.ac.uk/pub/MASS3/Exegeses.pdf). I am pretty new to R
> and a search of the R-help archive did not
> answer my question (although I found some good pointers).
> 
> In brief, leaving my covariates aside, I hypothesize that women (a)
> generally perform lower then men in a specific task (microworld
> performance, MWP) and that they (b) perform especially poor if a
> certain situational condition exists ("stereotype threat"). N = 160,
> 80 female & 80 male participants, 82 under stereotype threat and 78 not.
> 
> I realize that it makes no sense to report/interpret a main effect of
> stereotype threat in the confirmed presence of the interaction effect
> GENDER:STTHREAT, because a main effect of stereotype threat would
> actually be caused by the interaction (an error-bar plot illustrating
> this can be found here if one scrolls a little downwars:
> http://myowelt.blogspot.com/2008/05/obtaining-same-anova-results-in-r-as-
> in.html)
> 
> . I thus tend to use Type-II SSs and calculate my ANOVA with
> 
> > library(car)
> > Anova(lm(MWP ~ GENDER * STTHREAT), type="II")
> Anova Table (Type II tests)
> 
> Response: MWP
>   Sum Sq  Df F valuePr(>F)
> GENDER   23.939   1 32.3672 6.139e-08 ***
> STTHREAT 12.684   1 17.1489 5.644e-05 ***
> GENDER:STTHREAT   4.997   1  6.7557   0.01024 *
> Residuals   115.380 156
> ---
> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
> 
> However, it would make sense to report the main effect of GENDER in
> the presence of the interaction and thus violate the marginality
> principle, because of hypothesis (a) above. Would that mean that Type-
> III SSs are desirable for the analysis of the main effect of GENDER,
> and Type-II SSs are desirable for the main effect of STTHREAT and the
> interaction? Or would it be better to specify a model that only
> includes the interaction term and the main effect of gender with Type-
> III SSs? Like this:
> 
> > options(contrasts=c("contr.sum", "contr.poly"))
> > fit <- aov(MWP ~ GENDER:STTHREAT + GENDER)
> > drop1(fit,~.,test="F")
> Single term deletions
> 
> Model:
> MWP ~ GENDER:STTHREAT + GENDER
>  Df Sum of Sq RSS AIC F value Pr(F)
>115.380 -44.310
> GENDER   123.381 138.761 -16.787  31.612 8.475e-08 ***
> GENDER:STTHREAT  217.680 133.061 -25.499  11.952 1.481e-05 ***
> ---
> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
> 
> If this has been answered before and I was just too blind to find it,
> I apologize and would appreciate a link to the post.
> 
> Another question that arises from the use of Type-III SSs: If every
> factor is corrected for the other factors, the SSs of all factors plus
> the RSS do not sum up to the total SS of the model. But doesn't that
> lead to a situation where the standard way of calculating eta-square
> for a factor by dividing its SS by the total SS cannot be applied?
> 
> Regards,
> Bertolt
> 
> --
> Bertolt Meyer
> Senior Assistant
> Psychological Institute, University of Zurich
> Social Psychology
> Binzmuehlestr. 14, Box 15
> CH-8050 Zurich
> Switzerland
> 
> [EMAIL PROTECTED]
> tel:   +41446357282
> fax:   +41446357279
> 
> __

Re: [R] Configuring emacs/ess on Ubuntu

2008-05-25 Thread Wade Wall
I first installed through the package manager, but was unable to start R
without opening a script file.  So I installed from the tarball, but am
still unable to open R using any commands;  ESS loads into a buffer; but I
can't use M-x-R to open R.   the only way I can open R is to open a script
file first.  Maybe my question is, how do I create a new script file, type
some commands, open R, and run script from the file?

Wade

[[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] Configuring emacs/ess on Ubuntu

2008-05-25 Thread Dale Steele
 $ sudo apt-get install

Installs  installs  ESS version 5.3.0.  Is there a repository for more
recent version?

Thanks.  --Dale

On Sun, May 25, 2008 at 11:24 AM, Roland Rau <[EMAIL PROTECTED]> wrote:
> Hi Wade,
>
> Wade Wall wrote:
>>
>> Hi all,
>>
>> I don't know if this is the proper place to ask this, but I am trying to
>> configure emacs/ess on Ubuntu 8.04 to run the way described for ESS and
>
> I think the easiest way to install emacs/ess on Ubuntu 8.04 is via the
> repositories.
> Simply use your favorite package manager (I use synaptic) and choose the ess
> package. If Emacs hasn't been installed yet, it will do so automatically.
>
> I hope this helps,
> Roland
>
> __
> 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] Configuring emacs/ess on Ubuntu

2008-05-25 Thread Roland Rau

Hi Wade,

Wade Wall wrote:

Hi all,

I don't know if this is the proper place to ask this, but I am trying to
configure emacs/ess on Ubuntu 8.04 to run the way described for ESS and


I think the easiest way to install emacs/ess on Ubuntu 8.04 is via the 
repositories.
Simply use your favorite package manager (I use synaptic) and choose the 
ess package. If Emacs hasn't been installed yet, it will do so 
automatically.


I hope this helps,
Roland

__
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] Configuring emacs/ess on Ubuntu

2008-05-25 Thread Dirk Eddelbuettel
On Sun, May 25, 2008 at 10:07:52AM -0400, Wade Wall wrote:
> I don't know if this is the proper place to ask this, but I am trying to
> configure emacs/ess on Ubuntu 8.04 to run the way described for ESS and
> Xemacs in Windows (John Fox's guide).  I installed ess as directed at
> http://ess.r-project.org/Manual/ .  Under Windows I could use Emacs/ess fine
> (but I am obviously a novice at emacs), but am having trouble doing so in
> Ubuntu.  At present I have loaded ess, and it opens as a buffer when emacs
> opens.  But I can't open an R session with M-x-R, and can only open R if I
> have a pre-existing .R file.  Also, I would like to have emacs, either by
> default or with a hot key, open up a file in the upper window and R in the
> lower.  Any hints on how I can do this?

If you install ess on Debian/Ubuntu via

$ sudo apt-get install ess

it should start automatically as an emacs startup file is registered.

Dirk

-- 
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] marginality principle / selecting the right type of SS for an interaction hypothesis

2008-05-25 Thread Bertolt Meyer

Hello,

I have a problem with selecting the right type of sums of squares for
an ANCOVA for my specific experimental data and hypotheses. I do have
a basic understanding of the differences between Type-I, II, and III
SSs, have read about the principle of marginality, and read Venable's
"Exegeses on Linear Models" 
(http://www.stats.ox.ac.uk/pub/MASS3/Exegeses.pdf). I am pretty new to R 
and a search of the R-help archive did not

answer my question (although I found some good pointers).

In brief, leaving my covariates aside, I hypothesize that women (a)
generally perform lower then men in a specific task (microworld
performance, MWP) and that they (b) perform especially poor if a
certain situational condition exists ("stereotype threat"). N = 160,
80 female & 80 male participants, 82 under stereotype threat and 78 not.

I realize that it makes no sense to report/interpret a main effect of
stereotype threat in the confirmed presence of the interaction effect
GENDER:STTHREAT, because a main effect of stereotype threat would
actually be caused by the interaction (an error-bar plot illustrating
this can be found here if one scrolls a little downwars: 
http://myowelt.blogspot.com/2008/05/obtaining-same-anova-results-in-r-as-in.html) 


. I thus tend to use Type-II SSs and calculate my ANOVA with


library(car)
Anova(lm(MWP ~ GENDER * STTHREAT), type="II")

Anova Table (Type II tests)

Response: MWP
 Sum Sq  Df F valuePr(>F)
GENDER   23.939   1 32.3672 6.139e-08 ***
STTHREAT 12.684   1 17.1489 5.644e-05 ***
GENDER:STTHREAT   4.997   1  6.7557   0.01024 *
Residuals   115.380 156
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

However, it would make sense to report the main effect of GENDER in
the presence of the interaction and thus violate the marginality
principle, because of hypothesis (a) above. Would that mean that Type-
III SSs are desirable for the analysis of the main effect of GENDER,
and Type-II SSs are desirable for the main effect of STTHREAT and the
interaction? Or would it be better to specify a model that only
includes the interaction term and the main effect of gender with Type-
III SSs? Like this:


options(contrasts=c("contr.sum", "contr.poly"))
fit <- aov(MWP ~ GENDER:STTHREAT + GENDER)
drop1(fit,~.,test="F")

Single term deletions

Model:
MWP ~ GENDER:STTHREAT + GENDER
Df Sum of Sq RSS AIC F value Pr(F)
   115.380 -44.310
GENDER   123.381 138.761 -16.787  31.612 8.475e-08 ***
GENDER:STTHREAT  217.680 133.061 -25.499  11.952 1.481e-05 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

If this has been answered before and I was just too blind to find it,
I apologize and would appreciate a link to the post.

Another question that arises from the use of Type-III SSs: If every
factor is corrected for the other factors, the SSs of all factors plus
the RSS do not sum up to the total SS of the model. But doesn't that
lead to a situation where the standard way of calculating eta-square
for a factor by dividing its SS by the total SS cannot be applied?

Regards,
Bertolt

--
Bertolt Meyer
Senior Assistant
Psychological Institute, University of Zurich
Social Psychology
Binzmuehlestr. 14, Box 15
CH-8050 Zurich
Switzerland

[EMAIL PROTECTED]
tel:   +41446357282
fax:   +41446357279

__
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] Vector Product question

2008-05-25 Thread Dimitris Rizopoulos

try this:

x <- c(3, 3, 1)
y <- c("x","h","y")

paste(rep(y, x), unlist(sapply(x, seq_len)), sep = "")


I hope it helps.

Best,
Dimitris


Dimitris Rizopoulos
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
 http://www.student.kuleuven.be/~m0390867/dimitris.htm


Quoting Rory Winston <[EMAIL PROTECTED]>:


Hi

Ive looked around but I cant figure out how to do this without a for
loop. I have a vector of neural net weights from coef.nnet(), which
looks like c(3,3,1). I also have a list of weight prefixes, which are
c("x","h","y"). I would like to obtain a vector that looks like
c("x1","x2","x3","h1","h2","h3","y1") - i.e. if we think of the numeric
weight vector as a matrix B ([1 2 3],[1 2 3], [1 0 0]), its like a
paste() of the element in vector A[i] with each element in the row i:
B[i][j]. I can see that Ripley & Venables use the following, using
seq_len and paste() :

 wts <- object$wts
 wm <- c("b", paste("i", seq_len(object$n[1]), sep=""))
 if(object$n[2] > 0)
 wm <- c(wm, paste("h", seq_len(object$n[2]), sep=""))
 if(object$n[3] > 1)  wm <- c(wm,
 paste("o", seq_len(object$n[3]), sep=""))

Is it possible to compress this to a one-liner?

Cheers
Rory

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




Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

__
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] Configuring emacs/ess on Ubuntu

2008-05-25 Thread Wade Wall
Hi all,

I don't know if this is the proper place to ask this, but I am trying to
configure emacs/ess on Ubuntu 8.04 to run the way described for ESS and
Xemacs in Windows (John Fox's guide).  I installed ess as directed at
http://ess.r-project.org/Manual/ .  Under Windows I could use Emacs/ess fine
(but I am obviously a novice at emacs), but am having trouble doing so in
Ubuntu.  At present I have loaded ess, and it opens as a buffer when emacs
opens.  But I can't open an R session with M-x-R, and can only open R if I
have a pre-existing .R file.  Also, I would like to have emacs, either by
default or with a hot key, open up a file in the upper window and R in the
lower.  Any hints on how I can do this?

Forgive me if these questions are too elementary.

Wade

[[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] Vector Product question

2008-05-25 Thread Rory Winston

Hi

Ive looked around but I cant figure out how to do this without a for 
loop. I have a vector of neural net weights from coef.nnet(), which 
looks like c(3,3,1). I also have a list of weight prefixes, which are 
c("x","h","y"). I would like to obtain a vector that looks like 
c("x1","x2","x3","h1","h2","h3","y1") - i.e. if we think of the numeric 
weight vector as a matrix B ([1 2 3],[1 2 3], [1 0 0]), its like a 
paste() of the element in vector A[i] with each element in the row i: 
B[i][j]. I can see that Ripley & Venables use the following, using 
seq_len and paste() :


 wts <- object$wts
 wm <- c("b", paste("i", seq_len(object$n[1]), sep=""))
 if(object$n[2] > 0)
 wm <- c(wm, paste("h", seq_len(object$n[2]), sep=""))
 if(object$n[3] > 1)  wm <- c(wm,
 paste("o", seq_len(object$n[3]), sep=""))

Is it possible to compress this to a one-liner?

Cheers
Rory

__
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 write a package based on nlme

2008-05-25 Thread ctu

Dear R Helpers,
I try to write a small package that based on nlme however my code does  
not work.

R always appears this message:
Error in eval(expr, envir, enclos) : object "y" not found
where y is the response variable. Please help me out!
This is my code:
require(nlme)
AMPmixed<-function(y, x, S1=c("asymptotic","logistic"), random,data,  
S2=c("asymptotic","logistic"), start)

 {
  logist.logist<-function(x,alpha,delta,psi.l,tau.l,gamma,h){
  
delta+(alpha-delta+gamma*(x-(h-1))/exp(x))/(1+exp(-(x-tau.l)/psi.l))}

  logist.asymp<-function(x,alpha,delta,psi.l,tau.l,lpsi.a,gamma,h){
  
delta+(alpha-delta)/(1+exp(-(x-tau.l)/psi.l))+(gamma*(x-(h-1))/exp(x))*exp(-exp(1/lpsi.a)*x)}

  asymp.asymp<-function(x,alpha,delta,lpsi.a,gamma,h){
  
delta+(alpha-delta)*exp(-exp(1/lpsi.a)*x)+(gamma*(x-(h-1))/exp(x))*exp(-exp(1/lpsi.a)*x)}

  asymp.logist<-function(x,alpha,delta,psi.l,tau.l,lpsi.a,gamma,h){
  
delta+(alpha-delta)*exp(-exp(1/lpsi.a)*x)+(gamma*(x-(h-1))/exp(x))/(1+exp(-(x-tau.l)/psi.l))}


   (logistic.logistic<-function(y, x, data, start, random){

nlme.out<-nlme(y~logist.logist(x,alpha,delta,psi.l,tau.l,gamma,h),  
data=data, start=start, na.action)

   list(nlme.out=summary(nlme.out))
   })
(logistic.asymptotic<-function(y, x, data, start, random){
  
nlme.out<-nlme(y~logist.asymp(x,alpha,delta,psi.l,tau.l,lpsi.a,gamma,h),  
data=data, start=start, na.action)

 list(nlme.out=summary(nlme.out))
   })
   (asymptotic.logistic<-function(y, x, data, start,random){
   xy<-sortedXyData(x,y,data=data)
   if(nrow(xy)<8){stop("Too few factor levels to fit an  
asymptotic.logistic")}

nlme.out<-nlme(y~asymp.logist(x,alpha,delta,psi.l,tau.l,lpsi.a,gamma,h),  
data=data, start=start, na.action)

list(nlme.out=summary(nlme.out))
   })
   (asymptotic.asymptotic<-function(y, x, data, start, random){

nlme.out<-nlme(y~asymp.asymp(x,alpha,delta,lpsi.a,gamma,h), data=data,  
start=start,

 fixed=alpha+delta+lpsi.a+gamma+h~1,random=random)
   list(nlme.out=summary(nlme.out))
   })

   if(S1=="logistic" && S2=="logistic")  
{(AMPmixed=logistic.logistic(y, x, data, start, random))}
   else if(S1=="logistic" &&  
S2=="asymptotic"){(AMPmixed=logistic.asymptotic(y, x, data, start,  
random))}
   else if(S1=="asymptotic" &&  
S2=="logistic"){(AMPmixed=asymptotic.logistic(y, x, data, start,  
random))}
   else if(S1=="asymptotic" &&  
S2=="asymptotic"){(AMPmixed=asymptotic.asymptotic(y, x, data, start,  
random))}

   }

  con rep biomass
10.00   1   1.126
20.32   1   1.096
31.00   1   1.163
43.20   1   0.985
5   10.00   1   0.716
6   32.00   1   0.560
7  100.00   1   0.375
80.00   2   0.833
90.32   2   1.106
10   1.00   2   1.336
11   3.20   2   0.754
12  10.00   2   0.683
13  32.00   2   0.488
14 100.00   2   0.344


iso<-read.table(file="E:\\Hormesis\\data\\isobutanol.txt", header=T)
aa<-groupedData(biomass~con|rep, data=iso)
van2<-AMPmixed(y=biomass, x=con, S1="asymptotic", S2="asymptotic", data=aa,
+  start=c(alpha= 0.7954, delta= 0.3231,  lpsi.a=-0.2738,  
gamma= 1.0366, h=0.8429))

Error in eval(expr, envir, enclos) : object "y" not found

Thank you very much~~
Chunhao

__
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] gray grid on quartz()

2008-05-25 Thread Prof Brian Ripley

On Sun, 25 May 2008, Angel Berihuete Macías wrote:


Hello everybody.

Recently I update from R6.3 to R7.0 on Mac OS X,  and an ugly gray grid 
appear when I use the function image() or pdf()


What I am doing wrong?


- there is a list r-sig-mac for MacOS enquiries.
- There is no R7.0 nor R6.3.  We can guess you meant 2.7.0, but there is
  no 2.6.3 either.  The posting guide specifically asks for accurate
  version information. 
- there is no reproducible example here.


Now, considering the use of image() on quartz() in R 2.7.0, there is a 
(equally vague) bug report and thread at


https://stat.ethz.ch/pipermail/r-devel/2008-May/049650.html

that seems similar to your comments.  Simon Urbanek has made some changes 
to quartz() to alleviate this, so please try a current R-patched build.


But this does not apply to pdf(), although the effect is seen in some PDF 
viewers (and is a bug in those viewers).



Thank's for your help,

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


--
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] SVD on a matix

2008-05-25 Thread Yasir Kaheil

the variance is the eigen values of the correlation matrix of yoru matrix
X.cor <- cor(X)
X.e <- eigen(X.cor)
X.e$values# Eigenvalues of cor(X) = variances you're asking about




kayj wrote:
> 
> Hi All,
> 
> I performed an svd on a matrix X and saved the first three column of the
> left singular matrix U. ( I assume that they correspond to the projection
> of the matrix on the first three  eigen vectors that corresponds to the
> first three largest eigenvalues). I would like to know how much variance
> is explained by the first eigenvectors? how can I find that.
> 
> Thanks for your help
> 


-
Yasir H. Kaheil
Catchment Research Facility
The University of Western Ontario 

-- 
View this message in context: 
http://www.nabble.com/SVD-on-a-matix-tp17441337p17455129.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] R-Excel Macro Problem

2008-05-25 Thread Yasir Kaheil

hi Nate,
could you please email me your excel workbook. thanks
y

nmarti wrote:
> 
> I'm trying to write R functions into VBA code.  I've done this many other
> times in other documents and everything has run great.  But today I keep
> recieving an error message "Run-time error '1004': Application-defined or
> object-defined error."
> 
> Has anyone else encountered this same error message?
> 
> I do not recieve this error in the document when running regular VBA code. 
> But when I try to run,
> Call Rinterface.PutDataframe("Data", Range("Sheet1!A1:E2000"))
> I receive the error.
> I have the VBA "References" RExcelVBAlib checked.
> 
> Any suggestions would be appreiciated,
> Nate
> 


-
Yasir H. Kaheil
Catchment Research Facility
The University of Western Ontario 

-- 
View this message in context: 
http://www.nabble.com/R-Excel-Macro-Problem-tp17450757p17455095.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] IDE

2008-05-25 Thread Michael Lawrence
emacs + ess

On Fri, May 23, 2008 at 8:54 AM, Alexandra Almeida <[EMAIL PROTECTED]>
wrote:

> People,
>
> I'm a ubunto user and I used to write my scipts in "Java Gui for R", but it
> is a very slow tool to run my scripts...
> Do you know some efficient IDE for R?
> Thank!!!
>
> Alexandra Almeida
>
>
> --
> Alexandra R M de Almeida
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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