On Nov 12, 2008, at 8:48 AM, Tom La Bone wrote:


I figured it out. In case anyone else ever has this question -- given the
following output from cenmle:

fit.cen <- cenmle(obs, censored, groups)
fit.cen
              Value Std. Error        z         p
(Intercept)  1.19473     0.0772  15.4695  5.58e-54
groups1      0.00208     0.0789   0.0263  9.79e-01
Log(scale)  -0.40221     0.0168 -23.9034 2.82e-126

Scale= 0.669

Log Normal distribution
Loglik(model)= -3908.9   Loglik(intercept only)= -3908.9
Loglik-r:  0.0006265534

Chisq= 0 on 1 degrees of freedom, p= 0.98
Number of Newton-Raphson Iterations: 1
n = 1766

The p-value is (for example):

p.value <- summary(fit.cen)[[9]][[11]]

An approach that may yield somewhat more self-documenting code would be to examine either the fit object or the summary object with str and then to access results by extracting named elements. Since I don't have the package in question, let me use the lm object on its help page as an example:

 ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
 trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
 group <- gl(2,10,20, labels=c("Ctl","Trt"))
 weight <- c(ctl, trt)
 lm.D9 <- lm(weight ~ group)

 str(lm.D9)
 str(summary(lm.D9))
 summary(lm.D9)$coefficients
 summary(lm.D9)$coefficients["groupTrt", "Pr(>|t|)"]

# to get the p-value
> summary(lm.D9)$coefficients["groupTrt","Pr(>|t|)"]
[1] 0.2490232

You had originally asked for a method to extract coefficients and for that purpose you may want to look at:

?coefficients

> slope <- coefficients(lm.D9)["groupTrt"]
> slope
groupTrt
  -0.371

--
David Winsemius
Heritage Labs


Tom




Tom La Bone wrote:

The cenmle function is used to fit two sets of censored data and test if
they are significantly different. I can print out the results of the
analysis on the screen but can't seem to figure out how to access these
results in R and assign them to new variables, e.g., assign the slope
calculated with cenmle to the variable m. Any suggestions?

Tom


--
View this message in context: 
http://www.nabble.com/Accessing-Results-from-cenmle-function-in-NADA-package-tp20437420p20460676.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.

Reply via email to