Dear friends.
I believe this problem has been discussed in various forms now and then, so
I hope you will forgive me I ask how to do a truncated model like this,
where the observed y is recorded as 10 whenever it is higher or equal to
that value
x <- rnorm(1000)
y <- 10*x + rnorm(1000)
y[which(y>10)] <- 10
and recover the "true" model ?
Best wishes
Troels
Troels Ring, MD
Department of Nephrology
Aalborg Hospital, Denmark
tring at gvdnet.dk
fax 00 45 99 32 22 34
tlf 00 45 99 32 22 42
00 45 98 14 05 82 (home)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://stat.ethz.ch/pipermail/r-help/attachments/20020426/a72d3ed5/attachment.html
truncated observed
3 messages · Troels Ring, Brian Ripley, Thomas Lumley
On Fri, 26 Apr 2002, Troels Ring wrote:
Dear friends. I believe this problem has been discussed in various forms now and then, so I hope you will forgive me I ask how to do a truncated model like this, where the observed y is recorded as 10 whenever it is higher or equal to that value x <- rnorm(1000) y <- 10*x + rnorm(1000) y[which(y>10)] <- 10 and recover the "true" model ?
That's more commonly known as censored not truncated. (In a truncated model the observations larger than 10 are lost.) In your specific case I believe you can fit the model by survreg in package survival. Something like survreg(Surv(y, y < 10) ~ x, dist="gaussian") In general you need to write a likelihood function and optimize it, e.g. with optim, or make use of the ability to add your own distributions to survreg.
Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Fri, 26 Apr 2002 ripley at stats.ox.ac.uk wrote:
In your specific case I believe you can fit the model by survreg in package survival. Something like survreg(Surv(y, y < 10) ~ x, dist="gaussian") In general you need to write a likelihood function and optimize it, e.g. with optim, or make use of the ability to add your own distributions to survreg.
The ability to add your own distributions to survreg() doesn't actually work. It will work with the new version of "survival" coming out with R1.5.0 and as it is now tested in an example it should keep working in the future. -thomas Thomas Lumley Asst. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._