[R] how to categorize continuous variable when useing regression

2009-09-16 Thread Manli Yan
  assume dependent variable y( continuous),independent variable x (
continuous),I try to  categorize x with some interval,such that,those
intervals would has most significant different effect on y.
   any one knows which method I should apply,I know it will cause the loss
of information,but can I really do that?or by using what mehod ,I will keep
the loss minimal,all I want just some key words,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.


[R] how to categorize continuous variable when useing regression

2009-08-20 Thread Manli Yan
   assume dependent variable y( continuous),independent variable x (
continuous),I try to  categorize x with some interval,such that,those
intervals would has most significant different effect on y.
   any one knows which method I should apply,I really need some hints,thanks
so much~

[[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] who happenly read these two paper Mohsen Pourahmadi (biometrika1999, 2000)

2009-04-11 Thread Manli Yan
http://biomet.oxfordjournals.org/cgi/reprint/86/3/677   biometrika1999
http://biomet.oxfordjournals.org/cgi/reprint/94/4/1006  biometrika2000

Hi All:
  I just want to try some luck.
  I am currenly working on my project,one part of my project is to
reanalysis the kenward cattle data by using the method in Mohsen's paper,but
I found I really can get the same or close output as he did,so,any one who
have happenly read his paper,got any idea how he got the LS estimates of
gamma.
   he assumed the autoregressive phi_tj satisfy the cubic function on lag of
time,where t is from 1 to 11,j from 1 to t-1,his model is:
  phi_tj=gamma1+gamma2*(t-j)+gamma3*(t-j)^2+gamma4*(t-j)^3, #biometrika
1999,page685
 at first moment ,I thougt my design matrix should be
  1  1   1  1
  1  2  4  8
  1  3  9  27.
but I found this is wrong,actually I should(I think) use a polynomial design
matirx with level of 10,degree=3
here is my rocode~~
y1=c(1,0.9,0.98,1.06,0.83,1.00,0.41,0.93,1.01,0.86)
y2=c(0.05,0.16,0,0.26,0.15,0.61,0.33,0.31,0.33)
y3=c(-0.23,0,0.16,-0.03,0.22,-0.03,-0.17,-0.05)
y4=c(0.04,-0.21,-0.04,-0.26,-0.03,-0.04,-0.05)
y5=c(-0.02,-0.34,0.06,-0.22,-0.11,-0.31)
y6=c(0.20,0.01,0.01,-0.26,0.01)
y7=c(-0.06,-0.14,0.39,0.23)
y8=c(0.21,0.10,0.09)
y9=c(-0.24,-0.23)
y10=c(0.13)
y=c(y1,y2,y3,y4,y5,y6,y7,y8,y9,y10) ## autoregressive paramters ,table 1
biometrika 1999,page 685
om2=matrix(0,nrow=55,ncol=3)
om1=poly(c(1:10),degree=3) ##polynomial  design matirx  with
level =11,cubic
 om2[1:10,]=t(matrix(rep(om1[1,],10),ncol=10))
 om2[11:19,]=t(matrix(rep(om1[2,],9),ncol=9))
 om2[20:27,]=t(matrix(rep(om1[3,],8),ncol=8))
 om2[28:34,]=t(matrix(rep(om1[4,],7),ncol=7))
 om2[35:40,]=t(matrix(rep(om1[5,],6),ncol=6))
 om2[41:45,]=t(matrix(rep(om1[6,],5),ncol=5))
 om2[46:49,]=t(matrix(rep(om1[7,],4),ncol=4))
 om2[50:52,]=t(matrix(rep(om1[8,],3),ncol=3))
 om2[53:54,]=t(matrix(rep(om1[9,],2),ncol=2))
 om2[55,]=t(matrix(rep(om1[10,],1),ncol=1))
## so om2 is my orthogonal design matirx
 ## for example ,for y1=c(1,0.9,0.98,1.06,0.83,1.00,0.41,0.93,1.01,0.86),
since t-j=1,so the design matrix should be the first row of om1,and repeat
for 10 times.

t1=om2[,1]
t2=om2[,2]
t3=om2[,3]
fit-lm(y~(t1+t2+t3))
summary(fit)


### the estimate I got is
Estimate Std. Error t value Pr(|t|)
(Intercept)  0.091860.02980   3.083   0.0033 **
t1  -0.541430.10970  -4.936 8.94e-06 ***
t2   0.489550.10417   4.700 2.01e-05 ***
t3   0.560250.08771   6.387 5.05e-08 **

which is total different from the author's(0.18,-1.71,1.64,-1.11)

I have been tried contact the author,but he only point out that the I might
need to pay close attention to design matrix,but did not say how,I really
run out of the idea how to construct another suitable design matrix ,since
basing the paper,this should be the correct design matrix,so ,any one has
any idea???

  GREAT THANKS~~

[[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] who happenly read these two paper Mohsen Pourahmadi (biometrika1999, 2000)

2009-04-10 Thread Manli Yan
http://biomet.oxfordjournals.org/cgi/reprint/86/3/677  biometrika1999
http://biomet.oxfordjournals.org/cgi/reprint/94/4/1006 biometrika2000

  Hi All:
  I just want to try some luck.
  I am currenly working on my project,one part of my project is to
reanalysis the kenward cattle data by using the method in Mohsen's paper,but
I found I really can get the same or close output as he did,so,any one who
have happenly read his paper,got any idea how he got the LS estimates of
gamma.
   he assumed the autoregressive phi_tj satisfy the cubic function on lag of
time,where t is from 1 to 11,j from 1 to t-1,his model is:
  phi_tj=gamma1+gamma2*(t-j)+gamma3*(t-j)^2+gamma4*(t-j)^3, #biometrika
1999,page685
 at first moment ,I thougt my design matrix should be
  1  1   1  1
  1  2  4  8
  1  3  9  27.
but I found this is wrong,actually I should(I think) use a polynomial design
matirx with level of 11,degree=3
here is my rocode~~
y1=c(1,0.9,0.98,1.06,0.83,1.00,0.41,0.93,1.01,0.86)
y2=c(0.05,0.16,0,0.26,0.15,0.61,0.33,0.31,0.33)
y3=c(-0.23,0,0.16,-0.03,0.22,-0.03,-0.17,-0.05)
y4=c(0.04,-0.21,-0.04,-0.26,-0.03,-0.04,-0.05)
y5=c(-0.02,-0.34,0.06,-0.22,-0.11,-0.31)
y6=c(0.20,0.01,0.01,-0.26,0.01)
y7=c(-0.06,-0.14,0.39,0.23)
y8=c(0.21,0.10,0.09)
y9=c(-0.24,-0.23)
y10=c(0.13)
y=c(y1,y2,y3,y4,y5,y6,y7,y8,y9,y10) ## autoregressive paramters ,table 1
biometrika 1999,page 685
om2=matrix(0,nrow=55,ncol=3)
om1=poly(c(1:10),degree=3) ##polynomial  design matirx
with level =11,cubic
 om2[1:10,]=t(matrix(rep(om1[1,],10),ncol=10))
 om2[11:19,]=t(matrix(rep(om1[2,],9),ncol=9))
 om2[20:27,]=t(matrix(rep(om1[3,],8),ncol=8))
 om2[28:34,]=t(matrix(rep(om1[4,],7),ncol=7))
 om2[35:40,]=t(matrix(rep(om1[5,],6),ncol=6))
 om2[41:45,]=t(matrix(rep(om1[6,],5),ncol=5))
 om2[46:49,]=t(matrix(rep(om1[7,],4),ncol=4))
 om2[50:52,]=t(matrix(rep(om1[8,],3),ncol=3))
 om2[53:54,]=t(matrix(rep(om1[9,],2),ncol=2))
 om2[55,]=t(matrix(rep(om1[10,],1),ncol=1))
## so om2 is my orthogonal design matirx
 ## for example ,for y1=c(1,0.9,0.98,1.06,0.83,1.00,0.41,0.93,1.01,0.86),
since t-j=1,so the design matrix should be the first row of om1,and repeat
for 10 times.

t1=om2[,1]
t2=om2[,2]
t3=om2[,3]
fit-lm(y~(t1+t2+t3))
summary(fit)


### the estimate I got is
Estimate Std. Error t value Pr(|t|)
(Intercept)  0.091860.02980   3.083   0.0033 **
t1  -0.541430.10970  -4.936 8.94e-06 ***
t2   0.489550.10417   4.700 2.01e-05 ***
t3   0.560250.08771   6.387 5.05e-08 **

which is total different from the author's(0.18,-1.71,1.64,-1.11)

I have been tried contact the author,but he only point out that the I might
need to pay close attention to design matrix,but did not say how,I really
run out of the idea how to construct another suitable design matrix ,since
basing the paper,this should be the correct design matrix,so ,any one has
any idea???

  GREAT THANKS~~

[[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] Cholesky Decomposition in R

2009-03-10 Thread Manli Yan
  Hi everyone:
  I try to use r to do the Cholesky Decomposition,which is A=LDL',so far I
only found how to decomposite A in to  LL' by using chol(A),the function
Cholesky(A) doesnt work,any one know other command to decomposte A in to
LDL'

  My r code is:
library(Matrix)
A=matrix(c(1,1,1,1,5,5,1,5,14),nrow=3)

 chol(A)
 [,1] [,2] [,3]
[1,]111
[2,]022
[3,]003

 Cholesky(A)
Error in function (classes, fdef, mtable)  :
  unable to find an inherited method for function Cholesky, for signature
matrix

whatz wrong???
thanks~

[[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] anyone can help me with Cholesky Decomposition

2009-03-10 Thread Manli Yan
   Hi:
what I want to do is decompose the a symmetric  matrix A into this form
A=LDL'
hence TAT'=D,T is inverse of (L)and T is a lower trangular matrix,and D is
dignoal matrix

for one case
A=1 1 1
1 5 5
1 5 14
T=inverse(L)= 1 0 0
-1 1 0
 0 -1 1
D=(1,4,9)

I tried to use chol(A),but it returns only trangular, anyone know
the function can return both L and D?
thank you very much~

[[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] how to omit NA without using ifelse

2009-03-05 Thread Manli Yan
   I have a 50*50 matrix,some entry are NAs,I want to replace these NA by
0,so can I use some syntax to do so other than using ifelse?
   I tried to use replace(a,NA,0),it didnt work~~(a is matrix name)

  Thanks~

[[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] how to create many variables at one time?

2009-03-04 Thread Manli Yan
  Hi:
  I need to create many variables at one time,how to do this in R?
  for eg ,X1,X2...X100?

 Thanks~

[[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] problem in R for Linear mixed model~

2008-06-22 Thread Manli Yan
   Dear R users:
  I just got confused some R code used in linear mixed model~
  example,two factors,A, B,C,A is fixed ,B,C are random,and B is nested in
C,if I wannt to use linear mixed model,are the following code correct for
each case?
case1:want to know random effect of B,
   case1-lme(y~A*B*C,random=~B|C) where B|C stand for what?,mean B is
nested in C?

case2: how to wirte random effect of C?
   case2-lme(y~A*B*C,random=~C)? this doesnt work out,it seem it must have
somehing like #|$

case3.omitting the random effect for B from case1
  case3-update(case1,random=~1|C),so I just type 1,so the random effect of
B will be removed from the model,there only left random effect of c ,the
random effect I removed ,which include both random intercept and slope
,correct??

   case4:omitting the random  intercept
  case4-update(case1,random=B-1|C)
  this code I got from some paper,it said by inputing B-1|C,then the random
intercept  is removed,so,if I want to remove random slode,I input B-2|C,it
doesnt work out.

   case5 :how to know the both random effect of B,and C,I dont know how to
wirtie this in R
.
  And I am a little confused of these R code,especially the #|#
part,what deos this syntax really mean in LME package,

  Thank you for your time~

[[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] problem in R for Linear mixed model~

2008-06-22 Thread Manli Yan
  Hi:
  Thank you very much,and for your case
  if I wirte as
 regress=lme(yield~nitro*Variety,data=Oats,random=~Variety|Block)

what this mean?
 Regards


2008/6/22 Daniel Malter [EMAIL PROTECTED]:

 Hi,

 random=~1|B/C
 C is nested in B

 ##Example
 data=Oats
 regress=lme(yield~nitro*Variety,data=Oats,random=~1|Block/Variety)
 ##i.e. variety is nested in block
 summary(regress)
 ##End of example

 Best,
 Daniel


 -
 cuncta stricte discussurus
 -

 -Ursprüngliche Nachricht-
 Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im
 Auftrag von Manli Yan
 Gesendet: Sunday, June 22, 2008 9:30 PM
 An: r-help@r-project.org
 Betreff: [R] problem in R for Linear mixed model~

   Dear R users:
  I just got confused some R code used in linear mixed model~
  example,two factors,A, B,C,A is fixed ,B,C are random,and B is nested in
 C,if I wannt to use linear mixed model,are the following code correct for
 each case?
 case1:want to know random effect of B,
   case1-lme(y~A*B*C,random=~B|C) where B|C stand for what?,mean B is
 nested in C?

 case2: how to wirte random effect of C?
   case2-lme(y~A*B*C,random=~C)? this doesnt work out,it seem it must have
 somehing like #|$

 case3.omitting the random effect for B from case1
  case3-update(case1,random=~1|C),so I just type 1,so the random effect of
 B will be removed from the model,there only left random effect of c ,the
 random effect I removed ,which include both random intercept and slope
 ,correct??

   case4:omitting the random  intercept
  case4-update(case1,random=B-1|C)
  this code I got from some paper,it said by inputing B-1|C,then the random
 intercept  is removed,so,if I want to remove random slode,I input B-2|C,it
 doesnt work out.

   case5 :how to know the both random effect of B,and C,I dont know how to
 wirtie this in R .
  And I am a little confused of these R code,especially the #|# part,what
 deos this syntax really mean in LME package,

  Thank you for your time~

[[alternative HTML version deleted]]

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



[[alternative HTML version deleted]]

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


Re: [R] try to find the MLE of a function

2008-06-19 Thread Manli Yan
Yes,thats it,thank you guys so much~

2008/6/18 Moshe Olshansky [EMAIL PROTECTED]:

 Hi,

 mle caused me some confusion too.

 Anyway, first of all, your x should not contain 0, so make it, let say,
 (1:10)/10.
 Secondly, f should not be the density, but -log(density), so in your case
 it should be
 f -function(theta) -sum(log(theta) + (theta-1)*log(x))

 and finally you must specify a start value, i.e. your call should be
 mle(f,start=list(thetha=1))


 --- On Thu, 19/6/08, Manli Yan [EMAIL PROTECTED] wrote:

  From: Manli Yan [EMAIL PROTECTED]
  Subject: [R] try to find the MLE of a function
  To: r-help@r-project.org r-help@r-project.org
  Received: Thursday, 19 June, 2008, 1:49 PM
   Hi everyone:
  I have a density function
  f(x|theta)=theta*x^(theta-1),where
  0x1,0thetainfinite
 
  I want to pratice on R to find the MLE of this
  function,here is my code:
  x - (0:10)/10
  f-function(theta) prod(theta*x^(theta-1))
  mle(f)
  and r gave me :Error in eval(expr, envir, enclos) :
  argument is missing,
  with no default
 
  what mistake I just made?and how to add a constraint of
  theta0 in my
  function.
 
  Great thanks for your time~
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html
  and provide commented, minimal, self-contained,
  reproducible code.


[[alternative HTML version deleted]]

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


[R] multiple multiplication in R

2008-06-18 Thread Manli Yan
  hi: just a very simple quesion,how to do multiple multiplication in R
  x-c(1,2,3,4,5,6)
  how to get 1*2*3*4*5*6?

  I checked the Arithmetic Operators in R,but did not found the operators
for this function,anyway can do this except the loop?

[[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] try to find the MLE of a function

2008-06-18 Thread Manli Yan
Hi everyone:
I have a density function f(x|theta)=theta*x^(theta-1),where
0x1,0thetainfinite

I want to pratice on R to find the MLE of this function,here is my code:
x - (0:10)/10
f-function(theta) prod(theta*x^(theta-1))
mle(f)
and r gave me :Error in eval(expr, envir, enclos) : argument is missing,
with no default

what mistake I just made?and how to add a constraint of theta0 in my
function.

Great thanks for your time~

[[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] some R code of linear mixed model

2008-06-17 Thread Manli Yan
   Hello everyone:
  I have some quesions about the R code for linear mixed model,hope some one
can give me some hints,thanks a lot~
  Say:
  we have A B C three factors
  (i)A is fixed ,B and C are random,and B is nested in C,so the R code for
this case would be:
   case1-lme(y~A+B+C+..,random=~B|C)
where B|C actually mean B is nested in C, is it correct?
  (ii)and if I update the case as:
  updatedcase1-update(case1,random=~1|C), did I just remove the random
effect of B, and only random effect of C left in the model? is it correct?

 (iii)A ,B,is fixed ,but C is random,no nested case,how am I gonna write the
R code,since
  lme(y~A+B+C+.,random=~C) lead to error,

(iv)for the case1,if I wirte this
   updatedcase2-update(case1,random=B-1|C)
where,B-1|C,what this syntax stand for in R?


thank you guys very much~

[[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] some r code for linear mixed model

2008-06-16 Thread Manli Yan
   Hello everyone:
  I have some quesions about the R code for linear mixed model,hope some one
can give me some hints,thanks a lot~
  Say:
  we have A B C three factors
  (i)A is fixed ,B and C are random,and B is nested in C,so the R code for
this case would be:
   case1-lme(y~A+B+C+..,random=~B|C)
where B|C actually mean B is nested in C, is it correct?
  (ii)and if I update the case as:
  updatedcase1-update(case1,random=~1|C), did I just remove the random
effect of B, and only random effect of C left in the model? is it correct?

 (iii)A ,B,is fixed ,but C is random,no nested case,how am I gonna write the
R code,since
  lme(y~A+B+C+.,random=~C) lead to error,

(iv)for the case1,if I wirte this
   updatedcase2-update(case1,random=B-1|C)
where,B-1|C,what this syntax stand for in R?


thank you guys very much~

[[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] linear model with the repeated data type~

2008-06-04 Thread Manli Yan
here is the data:
 y-c(5,2,3,7,9,0,1,4,5)
id-c(1,1,6,6,7,8,15,15,19)
t-c(50,56,50,56,50,50,50,60,50)
table1-data.frame(y,id,t)//longitudinal data

the above is only part of data.
what  I want to do is to use the linear model for each id ,then get the
estimate value,like:

fit1-lm(y~t,data=table1,subset=(id==1))

but ,you can see the variable id is quite irregular,they are not arranaged
in order and many number missing,if I write a loop by using for,it will
give me a lot NA,
and for sure ,I dont want to type id=## for about 500 times
so,how to get all the esimates for each id,and exclude the NA,then record
those estimate in one table?

great thanks ~~

[[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] create many variables at one time~

2008-06-04 Thread Manli Yan
  I need to create 100 variable ,whose name is id.1,id.2id.100
  then I need to let a vector say id-c(id.1,id.2id.100)
  any easy way to do this?
  thanks a lot~

[[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] quite complicated case(the repeated data arranage~)

2008-06-04 Thread Manli Yan
 Hi everyone:
 I have been struggling with this repeated data type for whole afternoon,I
sent two emails to server for help,many people kindly responded , hereby
thank you so much,but since I dont want to write to much in email,so I
divide the problem in parts,so far this seem did not work out very well,so
this is my whole problem~

 first I have example of data here:
treatment-c(low,high,high,high,high,low,low,low,low)
age-c(50,60,50,50,60,50,60,50,60)
y-c(20,40,30,11,23,24,56,65,60)
id-c(1,1,3,4,4,6,8,9,9)
table1-cbind(treatment,id,age,y)

*the actual data are way more than this*,the id is from 1~500,and not in
regular ,some number missing~
all I want to do is
put the cases to variable according the id
for example when id =1
we have
treatment1  age1   y
low   5020
high  6040
this will generate a new matrix
for this example I will have 6 new matrix,according to id.
it is reasonable to do this in loop for,but the I met some problem:
1:how to automatically generate the new title such as treatment1 and age1
until treatment 500,age500
2:as you see,id is not strictly from 1 to 500,some time it jump from 15
to19,skip 16,17,18, if I write a loop,it will give me lot NA,certainly I
need a way to avoid this

and one more,say I have 100 vectors like
x1x100,x1-c(1,3),x2-x(2,2),...x100-(number,number)
I want to combine all this 100 vectors in one new vector say Xall
which is Xall-cbind(x1,x2,...x100) //this need to type in 100
variables,take alot time
  so Xall will be
x1x2  x3 .x100
  1   2number
  3   2number
is here any easy way to do this,instead of inputting them one by one?

*and Great Thanks for your time~~*

[[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] sorting the data~

2008-06-04 Thread Manli Yan
   id-c(1,1,1,1,3,3,3,7,7,7,7,11,11,11)

how to sort  this kind of data to
   id:(1,1,1,1,2,2,2,3,3,3,3,4,4,4.)

thanks~

[[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] sorting the data~

2008-06-04 Thread Manli Yan
  no,the id is  variable of a table,such as:
  treatment id  age response
low 1   50   20
low 1   60   30
high5   50   30
high5   60  40

...

I want to rearranage the table according the id (increasing),since id is not
strictly from 1~n,it is in increasing order but sometime jump through many
number like 1 1 5 5,I like them to be 1 1 2 2~



2008/6/4 Erik Iverson [EMAIL PROTECTED]:

 Are these the ranks of the data?

 help.search(rank)



 Manli Yan wrote:

id-c(1,1,1,1,3,3,3,7,7,7,7,11,11,11)

 how to sort  this kind of data to
   id:(1,1,1,1,2,2,2,3,3,3,3,4,4,4.)

 thanks~

[[alternative HTML version deleted]]

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



[[alternative HTML version deleted]]

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


Re: [R] linear model in the repeated data type~

2008-06-04 Thread Manli Yan
hi:lot thanks,how to use list to extract,I type  allFit$coefficents,it came
to nothing,
such as I need to extract the estimates,how to do it by using list

2008/6/3 Austin, Matt [EMAIL PROTECTED]:

 How about


 library(nlme)
 allFits - lmList(y ~ t|id, data=table1, pool=FALSE)

 or

 allFits - by(table1, table1$id, function(x) lm(y ~ t, data=x))

 Both ways store the results as a list, so you can access individual results
 using list extraction.


 --Matt

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 On Behalf Of Manli Yan
 Sent: Tuesday, June 03, 2008 9:07 PM
 To: r-help@r-project.org
 Subject: [R] linear model in the repeated data type~

  here is the data:
  y-c(5,2,3,7,9,0,1,4,5)
 id-c(1,1,6,6,7,8,15,15,19)
 t-c(50,56,50,56,50,50,50,60,50)
 table1-data.frame(y,id,t)//longitudinal data

 what  I want to do is to use the linear model for each id ,then get the
 estimate value,like:

 fit1-lm(y~t,data=table1,subset=(id==1))

 but ,you can see the variable id is quite irregular,they are not
 arranaged in order and many number missing,if I write a loop by using
 for,it will give me a lot NA, and for sure ,I dont want to type id=##
 for about 500 times,any one know how to deal with it?

[[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


[R] column and row

2008-06-03 Thread Manli Yan
-fit1$coefficients

 y.control y.lowy.high
(Intercept)19.628713 21.883999 20.023814
log(1 + (age - 45)/10) -7.383725 -6.017342 -5.084431

here is my outcome,I need one vector say b1=first row without the intercept
,like:(19.628713, 21.883999, 20.023814)
and  another b2=second row without the log(1 + (age - 45)/10),only the
data,how to do this in R?

[[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] how to extract a specific group of data from a table?

2008-06-03 Thread Manli Yan
   a table with three varialbe:treatment
(low,high),size(large,small),response y
  I want all response y with treatment=low and size=large,
  I try to write as :
treatment-c(low,low,high,high)
size-c(small,large,small,large)
y-c(1,2,4,5)
table1-data.frame(treatment,size,y)
x=table1$y(treatment==low size==large)

this does not work out~

thank you for the help~

[[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] linear model in the repeated data type~

2008-06-03 Thread Manli Yan
  here is the data:
 y-c(5,2,3,7,9,0,1,4,5)
id-c(1,1,6,6,7,8,15,15,19)
t-c(50,56,50,56,50,50,50,60,50)
table1-data.frame(y,id,t)//longitudinal data

what  I want to do is to use the linear model for each id ,then get the
estimate value,like:

fit1-lm(y~t,data=table1,subset=(id==1))

but ,you can see the variable id is quite irregular,they are not arranaged
in order and many number missing,if I write a loop by using for,it will
give me a lot NA,
and for sure ,I dont want to type id=## for about 500 times,any one know how
to deal with it?

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