Re: [R] Insert elements into a vector in a defined positions

2009-11-26 Thread Manuel Ramon

That's good . Your solution works for me.
Than you Rolf.



Rolf Turner-3 wrote:
 
 
 On 26/11/2009, at 10:46 AM, Manuel Ramon wrote:
 

 Dear R users,
 I have a vector of length n and I want to insert some elements (in  
 my case
 the NA string) into a defined positions. For example, my vector is  
 z1 and I
 want to add NA's in positions 4, 6 y 7 so after that, my new  
 vector, z2,
 should have a length of 10+3.

   z1 - 1:10
   id - c(4,6,7)

   # And z2 should be:
   z2 - c(1,2,3,NA,4,5,NA,NA,6,7,8,9,10)

 Anyone knows how can I do that?
 
 At first I thought append() might work ... but the after
 argument to append seems to have to be of length 1.
 
 How about:
 
   z2 - numeric(length(z1)+length(id))
   z2[id] - NA
   z2[!is.na(z2)] - z1
 
 A bit kludgy, but it appears to work.
 
   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.
 
 


-
Manuel Ramón Fernández
Group of Reproductive Biology (GBR)
University of Castilla-La Mancha (Spain)
mra...@jccm.es
-- 
View this message in context: 
http://old.nabble.com/Insert-elements-into-a-vector-in-a-defined-positions-tp26520841p26532643.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] Insert elements into a vector in a defined positions

2009-11-25 Thread Manuel Ramon

Dear R users,
I have a vector of length n and I want to insert some elements (in my case
the NA string) into a defined positions. For example, my vector is z1 and I
want to add NA's in positions 4, 6 y 7 so after that, my new vector, z2,
should have a length of 10+3. 

  z1 - 1:10
  id - c(4,6,7)

  # And z2 should be: 
  z2 - c(1,2,3,NA,4,5,NA,NA,6,7,8,9,10)

Anyone knows how can I do that?
Thank you.

-
Manuel Ramón Fernández
Group of Reproductive Biology (GBR)
University of Castilla-La Mancha (Spain)
mra...@jccm.es
-- 
View this message in context: 
http://old.nabble.com/Insert-elements-into-a-vector-in-a-defined-positions-tp26520841p26520841.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] How to deal with this random variable?

2009-07-28 Thread Manuel Ramon

Thank you for your replay Bert. You are right, is complicated to get a good
response when people do not know how the experiment was conducted, etc. The
main problem, maybe, is that this experiment has a wrong design being
complicated to get some good conclusion from it. I read this forum
frequently and I found a lot of useful information on it. For that reason I
decided to ask to the forum; maybe someone can help us.
Thank you again for your response Bert.



Bert Gunter wrote:
 
 This sounds way too complicated for this forum, which is designed to
 provide
 help to users on the  use of the R language, not remote statistical
 consulting. While you may receive replies, I would argue that you would do
 better to find a local statistical expert with whom to work -- not least
 because they should probably have a deep understanding of how your
 experiment was conducted, data gathered, measurements made, etc. to be
 able
 to give you worthwhile advice.
 
 Long distance consulting based on incomplete understanding is very risky.
 Caveat emptor!
 
 Bert Gunter
 Genentech Nonclinical Biostatistics
 
 
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On
 Behalf Of Manuel Ramon
 Sent: Monday, July 27, 2009 9:54 AM
 To: r-help@r-project.org
 Subject: [R] How to deal with this random variable?
 
 
 Hello to everybody,
 I have a data frame with 100 measures of quality for 3 variables: A, B and
 C. These quality variables are measured in diferent times along the
 productive process. My data comes from 5 experiments (5 replicates with 20
 measures for replicate). I also have a final measure (Z) but just one
 measure for each unit, that is, for the 20 units that are measured on each
 replica. 
 
 My objetive is to study the relationships between the 3 quality parameters
 with the last measure, that is:
  
   lm(Z ~ A+B+C, data=mydata)
 
 I have found significant differences between replicas for each qualite
 parameters (A, B and C) and I would like to include the replica effect as
 a
 random effect:
 
   lme(Z ~ A+B+C, data=mydata, random=~1|replica)
 
 And here is my problem. I know that there are signifficant diferences
 between replicas but since the final measure, Z, is the same for each
 replica I do not know how to deal with. 
 
 Can you help me? How could I take into account the variability due to the
 replica when I want to study the effects of variables A, B and C on the
 final result of a productive process?
 
 Thank you in advance.
 
 -
 Manuel Ramón Fernández
 Group of Reproductive Biology (GBR)
 University of Castilla-La Mancha (Spain)
 mra...@jccm.es
 -- 
 View this message in context:
 http://www.nabble.com/How-to-deal-with-this-random-variable--tp24684341p2468
 4341.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-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 


-
Manuel Ramón Fernández
Group of Reproductive Biology (GBR)
University of Castilla-La Mancha (Spain)
mra...@jccm.es
-- 
View this message in context: 
http://www.nabble.com/How-to-deal-with-this-random-variable--tp24684341p24695050.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] How to deal with this random variable?

2009-07-27 Thread Manuel Ramon

Hello to everybody,
I have a data frame with 100 measures of quality for 3 variables: A, B and
C. These quality variables are measured in diferent times along the
productive process. My data comes from 5 experiments (5 replicates with 20
measures for replicate). I also have a final measure (Z) but just one
measure for each unit, that is, for the 20 units that are measured on each
replica. 

My objetive is to study the relationships between the 3 quality parameters
with the last measure, that is:
 
  lm(Z ~ A+B+C, data=mydata)

I have found significant differences between replicas for each qualite
parameters (A, B and C) and I would like to include the replica effect as a
random effect:

  lme(Z ~ A+B+C, data=mydata, random=~1|replica)

And here is my problem. I know that there are signifficant diferences
between replicas but since the final measure, Z, is the same for each
replica I do not know how to deal with. 

Can you help me? How could I take into account the variability due to the
replica when I want to study the effects of variables A, B and C on the
final result of a productive process?

Thank you in advance.

-
Manuel Ramón Fernández
Group of Reproductive Biology (GBR)
University of Castilla-La Mancha (Spain)
mra...@jccm.es
-- 
View this message in context: 
http://www.nabble.com/How-to-deal-with-this-random-variable--tp24684341p24684341.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] Principal components vs. raw variables

2009-04-01 Thread Manuel Ramon

Hello to everyone,

I am starting to work on classification procedures. I usualy do a principal
component analysis (PCA) as a previous step in order to reduce variables and
after I apply a cluster procedure. My question is if it will be better to
use raw variables instead of use principal components obtained from these
variables since the original variables keep all the variability.

Now i am thinking to use a variable group analysis (VGA) and a correlation
analysis together in order to identify which of my original variables could
explain differences on my data better, and after apply a cluster analysis on
selected variables. 

What do you think about it? What would be better: work with PCA or with raw
variables.

Thanks in advance.

Manuel



-
Manuel Ramón Fernández
Group of Reproductive Biology (GBR)
University of Castilla-La Mancha (Spain)
mra...@jccm.es
-- 
View this message in context: 
http://www.nabble.com/Principal-components-vs.-raw-variables-tp22824280p22824280.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] Re siduals from a linear model

2008-11-18 Thread Manuel Ramon

I'm working with a linear model with four factors as explicatory variables,
being all of them significally (e.g. y ~ a + b + c + d). I thought that the
residuals of a linear model keep the variance not explained by the model, so
if I use my model with just three factors (y ~ a + b + c) and keep the
residuals is expected that in a new model with the residuals as dependent
variable and the four factor as independent (residuals ~ d) that factor (d)
will be significally. Is that truth or not? 



-
Manuel Ramón Fernández
Group of Reproductive Biology (GBR)
University of Castilla-La Mancha (Spain)
[EMAIL PROTECTED]
-- 
View this message in context: 
http://www.nabble.com/Residuals-from-a-linear-model-tp20556033p20556033.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] Anyone can help me with a model I have looking for?

2008-09-16 Thread Manuel Ramon

Hello to everyone.
I don't know if that forum is the rigth place to post my question but I
would be greatful for your help.
My problem is as follow: I have a performance trait as a dependent variable
and measures of temperature in different days as a covariate. I assume that
there is an accumulative effect of the temperature and heat load is faster
than heat loss, that is, is necessary more time to drop the accumulative
heat load. The question is that over a accumulative heat load threshold my
performance trait stars to fall and i would like to estimate this threshold.
How could i do that?

Thanks again. 

-
Manuel Ramón Fernández
Group of Reproductive Biology (GBR)
University of Castilla-La Mancha (Spain)
[EMAIL PROTECTED]
-- 
View this message in context: 
http://www.nabble.com/Anyone-can-help-me-with-a-model-I-have-looking-for--tp19509373p19509373.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] how to calculate the mode of a continuous variable

2008-08-29 Thread Manuel Ramon

Is there any R funtion that allow the estimation of mode in a continuous
variable?
Thank you
-- 
View this message in context: 
http://www.nabble.com/how-to-calculate-the-mode-of-a-continuous-variable-tp19214243p19214243.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] how to calculate the mode of a continuous variable

2008-08-29 Thread Manuel Ramon

Thanks Peter, it's a good solution. 
Finding on RSiteSearch I found a similar solution and I wrote a function to
obtain the mode. That function is as follows.

  mode - function(data) {
  # Function for mode estimation of a continuous variable
  # Kernel density estimation by Ted Harding  Douglas Bates (found on
RSiteSearch)

x-data
lim.inf=min(x)-1; lim.sup=max(x)+1

hist(x,freq=FALSE,breaks=seq(lim.inf,lim.sup,0.2))
s-density(x,from=lim.inf,to=lim.sup,bw=0.2)
n-length(s$y)
v1-s$y[1:(n-2)];
v2-s$y[2:(n-1)];
v3-s$y[3:n]
ix-1+which((v1v2)(v2v3))

lines(s$x,s$y,col=red)
points(s$x[ix],s$y[ix],col=blue)

md - s$x[which(s$y==max(s$y))] 

md
  }

Thanks for your help,

Manuel Ramon


Peter Dalgaard wrote:
 
 Henrique Dallazuanna wrote:
 Try:

 as.numeric(names(which.max(table(x

 On Fri, Aug 29, 2008 at 3:13 AM, Manuel Ramon [EMAIL PROTECTED] wrote:
   
 
 You missed the word continuous there...
 x - rnorm(10)
 table(x)
 x
  -1.64244637710945 -0.836534097622312 -0.810292826933485
 -0.721008996586432
  1  1  1 
 1
 -0.679702422788255 -0.667735659553467 -0.263432175981501
 0.0795699932826675
  1  1  1 
 1
  0.387151850978792  0.761964511475389
  1  1
 as.numeric(names(which.max(table(x
 [1] -1.642446
 
 
 Instead, how about
 
 
 dd - density(x)
 which.max(dd$y)
 [1] 227
 dd$x[which.max(dd$y)]
 [1] -0.6938049
 plot(dd)
 rug(x)
 abline(v=dd$x[which.max(dd$y)])
 
   
 Is there any R funtion that allow the estimation of mode in a continuous
 variable?
 Thank you
 --
 View this message in context:
 http://www.nabble.com/how-to-calculate-the-mode-of-a-continuous-variable-tp19214243p19214243.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-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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.
 
 

-- 
View this message in context: 
http://www.nabble.com/how-to-calculate-the-mode-of-a-continuous-variable-tp19214243p19218548.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] Is there a model like that in R?

2007-10-01 Thread Manuel Ramon
Thanks for your response Gustav,

 

The dots in the models mean that there are other effects in the models.

In relation to the model, it would be like this:

 

Q(i) = Q(i-1) + b*max(s(i) - s(0), 0) + c*min(s(i) - s(0), 0) If( s(i) 
s(0)) then

   max(s(i) - s(0), 0) = s(i)-s(0) 

   min(s(i) - s(0), 0) = 0

   There is an accumulative positive effect and Q(1) is greater than Q(0)

  

If( s(1)  s(0)) then

   max(s(i) - s(0), 0) = 0

   min(s(i) - s(0), 0) = s(i)-s(0)

   There is an accumulative negative effect and Q(1) is lower than Q(0)

 

 

For i=1:

 

Q(1) = Q(0) + b*max(s(1) - s(0), 0) + c*min(s(1) - s(0), 0) If( s(1)  s(0))
then

   max(s(1) - s(0), 0) = s(1)-s(0) 

   min(s(1) - s(0), 0) = 0

  

If( s(1)  s(0)) then

   max(s(1) - s(0), 0) = 0

   min(s(1) - s(0), 0) = s(1)-s(0)

   

In the model the value of Q depends on the value of s. If that value is
above a threshold, Q increases and if the value of s is below the threshold
Q decreases. Then, when Q is above a threshold (different that the threshold
of s) it has an effect.

In my particular case, s is temperature and Q would be the amount of
temperature (or something similar) that is accumulated.

 

 

-Original Message-

From: Gustaf Rydevik [mailto:[EMAIL PROTECTED]

Sent: Friday, September 28, 2007 11:13 AM

To: Manuel Ramon

Cc: r-help@r-project.org

Subject: Re: [R] Is there a model like that in R?

 

On 9/28/07, Manuel Ramon [EMAIL PROTECTED] wrote:

 Hi to everyone,

 

 

 

 I am starting to work with a model that is not familiar to me.

 

 The model would be like that:

 

 

 

y = . - a*max(Q(i) - Q(0), 0) + .

 

 

 

 where Q(i) is the accumulated effect of a variable at time i and Q(0) 

 a threshold above it there is effect on y.  The value of Q(i) could be 

 estimated as:

 

 

 

   Q(i+1) = Q(i) + b*max(s(i) - s(0), 0) + c*min(s(i) - s(0), 0) + .

 

 

 

 Where s would be the effect that produces the accumulate effect of Q, 

 s(i) would be this effect at time i and s(0) another threshold above 

 it the accumulative effect is produced. The coefficient b would be the 

 rate of accumulation and c the rate of decay.

 

 

 

 What kind of model is it? Is it somewhat similar to time series?

 

 

 

 I appreciate your help.

 

 

 

 Manuel Ramon

 

 

I'm not sure what you're describing, but something is wrong for your
definition of Q(i).

 

For i=1:

 

Q(1) = Q(0) + b*max(s(0) - s(0), 0) + c*min(s(0) - s(0), 0) +
.=Q(0)+b*0+c*0=Q(0).

Thus, Q(n)=Q(n-1)=...=Q(0)

 

In addition, what is intended by the dots and the final plus in y = .

- a*max(Q(i) - Q(0), 0) + .?

 

I think you have to describe things a bit more careful, if we are to
understand what's happening.

 

Best,

 

Gustaf

 

 

--

Gustaf Rydevik, M.Sci.

tel: +46(0)703 051 451

address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik

 

 

 

 

Manuel

 


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