[R] truncated observed

ripley@stats.ox.ac.uk ripley at stats.ox.ac.uk
Fri Apr 26 10:51:57 CEST 2002


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



More information about the R-help mailing list