Re: [R] How to compute time interval?

2011-11-10 Thread Lao Meng
as.numeric() is work Settled! 2011/11/11 Lao Meng > t2-t1 is ok,but only can get"Time difference of 786 days",but I wanna get > the "786" only.How can I do then? > > Thanks! > > > 2011/11/11 Lao Meng > >> time1 = 2008-03-09 >> time2

Re: [R] How to compute time interval?

2011-11-10 Thread Lao Meng
t2-t1 is ok,but only can get"Time difference of 786 days",but I wanna get the "786" only.How can I do then? Thanks! 2011/11/11 Lao Meng > time1 = 2008-03-09 > time2 = 2010-9-10 > > How to compute how many years between time1 and time2? > > Thanks! &g

[R] How to compute time interval?

2011-11-10 Thread Lao Meng
time1 = 2008-03-09 time2 = 2010-9-10 How to compute how many years between time1 and time2? Thanks! best [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the

Re: [R] a question about lm on t-test.

2011-08-17 Thread Lao Meng
ot the same test. The concept of linear regression applies here > (and you might take any introductory at your hand to refresh that > concept). The intercept is estimated from the whole sample not just > group==1, dfs are 20-2, not sum(group==1)-1! > > best regards > > Am 17.08.2

[R] How to get the descriptive statistic of the whole dataframe?

2011-08-17 Thread Lao Meng
Hi all: If I have a dataframe of N columns.If I wanna get the min(or max,or mean...etc)of the whole dataframe,how to do it quickly? What I can do is only: min(data[,1:ncol(data)]) Any other suggestion? Thanks! best [[alternative HTML version deleted]] __

Re: [R] a question about lm on t-test.

2011-08-17 Thread Lao Meng
st 0 (one sample t-test), > so the t-statistic is (mean-0)/sd, having n-k (sample size - number of > parameters) degrees of freedom. > > cc<-s1$coef["(Intercept)",1:2] > 2*(1-pt(cc[1]/cc[2],df=18)) > > > hth. > > Am 16.08.2011 07:25, schrieb Lao Meng: >

Re: [R] how to get the result in "short cut" manner?

2011-08-17 Thread Lao Meng
Yes, you remind me of this! Thanks! 2011/8/16 Eik Vettorazzi > Hi Lao, > you tried to reinvent the wheel. Have a look at ?tapply > > tapply(sleep$extra,sleep$group,mean) > > Cheers > > Am 16.08.2011 09:41, schrieb Lao Meng: > > Hi all: > > My data:data(slee

Re: [R] how to get the result in "short cut" manner?

2011-08-16 Thread Lao Meng
Sorry,I miss a word:"If I wanna calculate each group's mean extra" 2011/8/16 Lao Meng > Hi all: > My data:data(sleep) > > If I wanna calculate each group's extra,what I can do is: > #method1 > attach(sleep) > mean(extra[group==1]) > mean(extra[gro

[R] how to get the result in "short cut" manner?

2011-08-16 Thread Lao Meng
Hi all: My data:data(sleep) If I wanna calculate each group's extra,what I can do is: #method1 attach(sleep) mean(extra[group==1]) mean(extra[group==1]) #method2 result<-matrix(,0,2) g<-split(sleep,sleep$group) for(i in 1:length(g)) { result<-rbind(result,data.frame(unique(g[[i]]$group),mean(g[[

Re: [R] a question about lm on t-test.

2011-08-15 Thread Lao Meng
Software/Embedded Controllers) .OO#. .OO#. rocks...1k > --- > > Sent from my phone. Please excuse my brevity. > > Lao Meng wrote: >> >> The mean of group1 is 0.75,just the same as intercept. >> Acturally,R trea

Re: [R] a question about lm on t-test.

2011-08-15 Thread Lao Meng
d Controllers) .OO#. .OO#. rocks...1k > --- > > Sent from my phone. Please excuse my brevity. > > Lao Meng wrote: > >> Hi all: >> I have a question about lm on t-test. >> >> data(sleep)

[R] a question about lm on t-test.

2011-08-15 Thread Lao Meng
Hi all: I have a question about lm on t-test. data(sleep) I wanna perform t-test to test the difference between the 2 groups: I can use: t.test(extra~group) The t.test result shows that:t = -1.8608; mean1=0.75,mean2=2.33 But I still wanna use: summary(lm(extra~group)) Intercept=0.75,which is

Re: [R] a question about glht function

2011-07-27 Thread Lao Meng
Here's another question: What's kind of difference does glht tests? In other words, If I get 4 intercepts and 4 slopes for all levels of GROUP,then glht tests for the difference of the 4 intercepts or 4 slopes,or something else? Thanks. 2011/7/27 Lao Meng > Yes. > A

Re: [R] a question about glht function

2011-07-26 Thread Lao Meng
Yes. According to your suggestion,I modified my code.It works well. Thanks you very much. My best. 2011/7/26 Peter Ehlers > On 2011-07-26 00:16, Lao Meng wrote: > >> Hi all: >> There's a question about glht function. >> >> My data:data_ori,which inclu

[R] a question about glht function

2011-07-26 Thread Lao Meng
Hi all: There's a question about glht function. My data:data_ori,which inclue CD4, GROUP,time. f_GROUP<-factor(data_ori$GROUP) f_GROUP is a factor of 3 levels(0,1,2,3) result <- lme(sqrt(CD4) ~ f_GROUP*time ,random = ~time|ID,data=data_ori) glht(result, linfct = mcp(f_GROUP="Tukey") ) Error

[R] question about linear mixed model

2011-07-17 Thread Lao Meng
Hi all: I have a question about linear mixed model. my linear mixed model with randomized slope and intercept with interaction of time and group(g1,g2,g3): model<- glmmPQL(log10(CD4) ~ time + factor(group)+ time:factor(group), random = ~time|id) What I get is only the main and interaction of time

[R] How to compare ratio from multiple groups?

2011-07-05 Thread Lao Meng
If I have 3 groups,and for each group,I get the ratio(e.g. incidence rate). Now I wanna compare 3 ratio pairwise,and get the corresponding p values,i.e: group1 vs group2 ,p value=? group1 vs group3 ,p value=? group2 vs group3 ,p value=? Which statistical test should be used? Thanks a lot for yo

Re: [R] About the covariant

2011-06-27 Thread Lao Meng
ow),M(median),H(High). 2011/6/28 David Winsemius > > On Jun 27, 2011, at 10:02 PM, Lao Meng wrote: > > Hi all,I have some questions about the covariants of regression. >> >> My target: To explore the trend of CD4 level through a period of time. >> >> Respon

[R] About the covariant

2011-06-27 Thread Lao Meng
Hi all,I have some questions about the covariants of regression. My target: To explore the trend of CD4 level through a period of time. Response variable: CD4 count Explanatory variable:time Also, the demology information is available,such as gender,occupation,income level... Q1,Are these varia

Re: [R] A better way to do this

2011-05-20 Thread Lao Meng
You may try "xyplot" 2011/5/20 1Rnwb > Hello gurus, > > I have a dataframe containing two groups viz., 'control' and 'case', each > of > these groups contains longitudinal data for 100 subjects. I have to plot > all > these subjects on a single chart and then put a regression line for each of >

[R] "competitive risk model"

2011-04-28 Thread Lao Meng
Hi all: Which function or package can perform "competitive risk model"? Thanks a lot! My best [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting gui

Re: [R] is this an ANOVA ?

2011-04-12 Thread Lao Meng
You may try the following to perform anova: anova(lm(y~x)) or summary(aov(y~x)) 2011/4/13 Ubuntu Diego > Hi all, >I have a very easy questions (I hope). I had measure a property of > plants, growing in three different substrates (A, B and C). The rest of the > conditions remained con

Re: [R] qcc.overdispersion-test

2011-04-06 Thread Lao Meng
hi: Another question abour overdispersion test. I wanna make sure that: if p value<0.05,then the data is NOT overdispersion; if p value>=0.05,then the data IS overdispersion. I'm not sure whether it's true,just get the above conclusion from simulated data. Thanks for your help. 2011/4/2 > H

[R] Sample size of longitudinal and skewed data

2011-03-21 Thread Lao Meng
Hi all: I have a question about the sample size calculation. It's a pilot study,which includes 2 groups(low,high),3 time point(3,6,9 monthes).Each person has 3 results which according to the 3 time points.So it's a longitudinal study. I want to calculate the minimum sample size from the pilot st

[R] sample size of 2 groups of skewed data

2011-03-14 Thread Lao Meng
Hi all: I have a question on sample size calculation of 2 groups of data. If 2 groups of data are all normal distribution, then I can use the function "n.indep.t.test.eq" from samplesize package.But if 2 groups of data are all skewed distribution, but not normal distribution,how can I calculate the

Re: [R] Boxplot problem

2011-03-09 Thread Lao Meng
No,even there's only one observation,boxplot can still be drawn. x<-1 boxplot(x) or x<-1:3 boxplot(x) ... 2011/3/9 Dennis Murphy > Hi: > > A box plot is based on a five number summary, so you need at a minimum five > observations (and preferably at least twice that) to make a box plot a > v

Re: [R] regression with categorical nuisance variable

2011-02-28 Thread Lao Meng
You may try analysis of covariance. But,as you say"There are no gender differences in age ",then why not combine 2 gender's age and ignore the gender? 2011/3/1 Jonathan DuBois > Hi, > > I am new to R, so I am unsure of the formula to set up this analysis. > I would like to run a linear model wit

Re: [R] How to change dataframe to tables

2011-02-20 Thread Lao Meng
Well,it's my daily work on duty,not homework:) 2011/2/18 Dennis Murphy > This is a built-in dataset in R - see ?HairEyeColor and str() it. I smell > homework... > > Dennis > > On Thu, Feb 17, 2011 at 11:50 PM, Lao Meng wrote: > >> The data is in the attac

Re: [R] How to change dataframe to tables

2011-02-20 Thread Lao Meng
Thanks! It works well. 2011/2/18 Henrique Dallazuanna > Try this: > > xtabs(Freq ~ Hair + Eye + Sex, Dat) > > Using Dimitri's Dat example. > > On Fri, Feb 18, 2011 at 5:50 AM, Lao Meng wrote: > >> The data is in the attachment. >> >> What

Re: [R] How to change dataframe to tables

2011-02-20 Thread Lao Meng
Thanks! It works well. 2011/2/18 Dimitris Rizopoulos > say, 'Dat' is your data frame, then one way to do it is: > > with(Dat, tapply(freq, list(hair, eye, sex), c)) > > > I hope it helps. > > Best, > Dimitris > > > > > On 2/18/2011 8:50 AM,

[R] How to change dataframe to tables

2011-02-17 Thread Lao Meng
The data is in the attachment. What I wanna get is: , , Sex = Male Eye HairBrown Blue Hazel Green Black32 1110 3 Brown53 502515 Red 10 10 7 7 Blond 3 30 5 8 , , Sex = Female Eye HairBrown Blue Hazel Green Blac

[R] 3 questions about the poisson regression of contingency table

2011-02-16 Thread Lao Meng
Hi all: I have 3 questions about the poisson regression of contingency table. Q1¡¢How to understand the "independent poisson process"as many books or paper mentioned? For instance: Table1 --- treat canernon-cancersum -

[R] 3 questions about the poisson regression of contingency table

2011-02-16 Thread Lao Meng
Hi all: I have 3 questions about the poisson regression of contingency table. Q1¡¢How to understand the "independent poisson process"as many books or paper mentioned? For instance: Table1 --- treat canernon-cancersum ---

[R] Fwd: question about result of loglinear analysis

2011-01-18 Thread Lao Meng
-- Forwarded message -- From: Lao Meng Date: 2011/1/19 Subject: Re: [R] question about result of loglinear analysis To: David Winsemius My command and result are : > result_sat<-summary(glm_sat) > result_coe<-result_sat$coefficients > result_coe

[R] question about result of loglinear analysis

2011-01-18 Thread Lao Meng
Hi all: Here's a question about result of loglinear analysis. There're 2 factors:area and nation.The raw data is in the attachment. I fit the saturated model of loglinear with the command: glm_sat<-glm(fre~area*nation, family=poisson, data=data_Analysis) After that,I extract the coefficients: res

[R] How to find out the trend during a time period?

2010-10-27 Thread Lao Meng
Hi all: I have a dataset which contains two variables: Y and time y<-c(228,189,232,198,252,315) time<-2003:2008 How can I find out the trend(increase/decrease) of y along the time period? If I use: lm(y~time) The "lm" command treats time as natural number,but not date. So maybe "lm" isn't approp