# [R] Different length of objects

voodooochild@gmx.de voodooochild at gmx.de
Sat Jan 14 17:02:25 CET 2006

```ok, thank you, in my problem i want to solve the following equation
numericaly for b , t_n indicates the last value of t

(t_n*exp(-b*t_n)*sum_{i=1}^{n} f_i) / (1-exp(-b*t_n)) - (sum_{i=1}^{n}
(f_i*(t_i*exp(-b*t_i)-t_{i-1}*exp(-b*t_{i-1}))) /
(exp(-b*t_{i-1})-exp(-b*t_i)) )  = 0

b is then the mle.

jim holtman wrote:

> If you type
>
> t[0]
>
> you will get the value
>
> numeric(0)
>
> Which is a numeric vector of lenght 0; this is not the same a the
> value of 0.
>
> t[0] does not select any value.  If you expect this to happen in your
> code, then check against it and assign whatever value you want:
>
> ifelse(length(t[i]) == 0, 0, t[i])
>
>
>
> On 1/14/06, *voodooochild at gmx.de <mailto:voodooochild at gmx.de>*
> <voodooochild at gmx.de <mailto:voodooochild at gmx.de>> wrote:
>
>     Hello,
>
>     i got an warning message in the following code:
>
>     f<-1:100
>     t<-1:100
>     b<-100
>
>     ll2 <- function(b,f,t) {
>     t<-cumsum(t)
>     tn<-t[length(t)]
>     i<-seq(along=f)
>     s1<-(tn*exp(-b*tn)*sum(f[i]))/(1-exp(-b*tn))
>
>     s2<-sum((f[i]*(t[i]*exp(-b*t[i])-t[i-1]*exp(b*t[i-1])))/(exp(-b*t[i-1])-exp(-b*t[i])))
>
>     s1-s2
>     }
>
>     ll2(b,f,t)
>
>     i think, the problem here is, that t[0] doesn't exist and so i got
>     different length of objects. want can i do to avoid this error?
>     the assumption is that t[0] should be 0.
>
>     best regards
>     andreas
>
>     ______________________________________________
>     R-help at stat.math.ethz.ch <mailto:R-help at stat.math.ethz.ch> mailing
>     list
>     https://stat.ethz.ch/mailman/listinfo/r-help
>     http://www.R-project.org/posting-guide.html
>
>
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 247 0281
>
> What the problem you are trying to solve?

```