[R] Add group name in barchart

2014-12-02 Thread Silong Liao
Dear ALL,
 
I have a dataset contains 2 variables: mate (mating groups) and ratio (ratio of 
number of mothers and fathers). And mate is an identifer which consists three 
components: year, flock (flk), and tag.
 
I am using command "barchart" under package "lattice" to generate plots of 
ratio against mate divided by each flock (See attachment). I want to put flock 
names onto the corresponding plots, but don't know how.
 
Cheers, Sid
 
load("ratiodata.Rdata")
attach(ratiodata)
head(ratiodata)
 
materatio1 2007.102.A 21.285712 2007.102.B 68.23 2007.102.C 
59.54 2007.102.D 19.35 2007.102.E 72.36 2007.102.F 35.5 
str(ratiodata$mate) #factor
str(ratiodata$ratio) #num
unique(ratiodata$flk)
 
[1]  1022 2744 2747 2749  391 4357 4880 3001 3003 3004 3855 3658 4588 4591 
4631 
library("lattice")
ratiodata$flk=read.table(text=as.character(ratiodata$mate),sep=".")[,2]
barchart(ratiodata$ratio~ratiodata$mate|ratiodata$flk)
 
 
  
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] plot for "survreg" and "intcox" (rewritten)

2014-08-26 Thread Silong Liao
Dear R users,

I'm trying to plot survival probability against time(in years) using "survreg" 
and "intcox". Please can you help me with this problem? (I have rewritten using 
plain text.) I tried to use "curve" function but have no clue.

For survreg,
>mod.reg1=survreg(s_new~type+sex+eye+preopiop+preopva,dist="weibull")
>summary(mod.reg1)
Call:
survreg(formula = s_new ~ type + sex + eye + preopiop + preopva, dist = 
"weibull")
Value Std. Error z p
(Intercept) 40.539 20.582 1.970 4.89e-02
typeTrab -6.606 4.279 -1.544 1.23e-01
sexM -1.055 3.765 -0.280 7.79e-01
eyeR -2.112 3.587 -0.589 5.56e-01
preopiop -0.308 0.269 -1.147 2.52e-01
preopva -0.461 1.771 -0.260 7.95e-01
Log(scale) 2.058 0.285 7.222 5.12e-13

Scale= 7.83
Weibull distribution
Loglik(model)= -78.7 Loglik(intercept only)= -81.4
Chisq= 5.37 on 5 degrees of freedom, p= 0.37
Number of Newton-Raphson Iterations: 10
n= 339

For intcox,
>cox.fit=intcox(s_new~type+eye+sex+age+preopiop+preopva,data=glaucoma_new)
>summary(cox.fit)
Call:
intcox(formula = s_new ~ type + eye + sex + age + preopiop +preopva, data = 
glaucoma_new)

n= 339

coef exp(coef) se(coef) z Pr(>|z|)
typeTrab 0.59391 1.81106 NA NA NA
eyeR 0.28419 1.32868 NA NA NA
sexM -0.11597 0.89050 NA NA NA
age -0.06556 0.93655 NA NA NA
preopiop 0.03903 1.03980 NA NA NA
preopva -0.05517 0.94632 NA NA NA

exp(coef) exp(-coef) lower .95 upper .95
typeTrab 1.8111 0.5522 NA NA
eyeR 1.3287 0.7526 NA NA
sexM 0.8905 1.1230 NA NA
age 0.9365 1.0678 NA NA
preopiop 1.0398 0.9617 NA NA
preopva 0.9463 1.0567 NA NA

Rsquare= NA (max possible= 0.327 )
Likelihood ratio test= NA on 6 df, p=NA
Wald test = NA on 6 df, p=NA
Score (logrank) test = NA on 6 df, p=NA
  
__
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] Plot survreg and intcox

2014-08-26 Thread Silong Liao
Dear R users,
I'm trying to plot survival probability against time(in years) using "survreg" 
and "intcox". Please can you help me with this problem?
My code shows 
below:>mod.reg1=survreg(s_new~type+sex+eye+preopiop+preopva,dist="weibull")>summary(mod.reg1)
Call:survreg(formula = s_new ~ type + sex + eye + preopiop + preopva, dist 
= "weibull") Value Std. Error  zp(Intercept) 40.539 
20.582  1.970 4.89e-02typeTrab-6.606  4.279 -1.544 1.23e-01sexM
-1.055  3.765 -0.280 7.79e-01eyeR-2.112  3.587 -0.589 
5.56e-01preopiop-0.308  0.269 -1.147 2.52e-01preopva -0.461  
1.771 -0.260 7.95e-01Log(scale)   2.058  0.285  7.222 5.12e-13
Scale= 7.83 
Weibull distributionLoglik(model)= -78.7   Loglik(intercept only)= -81.4
Chisq= 5.37 on 5 degrees of freedom, p= 0.37 Number of Newton-Raphson 
Iterations: 10 n= 339
->cox.fit=intcox(s_new~type+eye+sex+age+preopiop+preopva,data=glaucoma_new)>summary(cox.fit)Call:intcox(formula
 = s_new ~ type + eye + sex + age + preopiop + preopva, data = glaucoma_new)
  n= 339
 coef exp(coef) se(coef)  z Pr(>|z|)typeTrab  0.59391   1.81106 
  NA NA   NAeyeR  0.28419   1.32868   NA NA   NAsexM 
-0.11597   0.89050   NA NA   NAage  -0.06556   0.93655   NA NA  
 NApreopiop  0.03903   1.03980   NA NA   NApreopva  -0.05517   
0.94632   NA NA   NA
 exp(coef) exp(-coef) lower .95 upper .95typeTrab1.8111 0.5522  
  NANAeyeR1.3287 0.7526NANAsexM
0.8905 1.1230NANAage 0.9365 1.0678NA
NApreopiop1.0398 0.9617NANApreopva 0.9463 
1.0567NANA
Rsquare= NA   (max possible= 0.327 )Likelihood ratio test= NA  on 6 df,   
p=NAWald test= NA  on 6 df,   p=NAScore (logrank) test = NA  on 6 
df,   p=NA


Kind regards,Sid

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