This is a matrix algebra problem, not an R problem. ej fails because betaligne and ZIcolone are not conformable matrices.
dim(betaligne) 1 2 dim(ZIcolone) 76 1 Let a matrix be m x n, then you can only matrix multiply it with a matrix that is n x k (where m and k are arbitrary positive integers, but n must be the same). The resulting matrix will be m x k. So you can postmultiply t(betaligne) with t(ZIcolone) or ZIcolone with betaligne. Everything else is not conformable. HTH, Daniel > > Hi, > >> I have a problem with the final results fj ; >>fj must firstly be a vector indexed by j = 8, and the same avoire Chifre (9.5), > >>> beta0=64.91151 >> beta1=17.70393 >> beta=c(beta0, beta1) >> j=1:8 >> n=76 >> i=1:n >> zi<-c(26, 26, 26, 28, 28, 28, 28, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, >> 30, 30, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 34, >> 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, >> 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 38, 38, 38, >> 38, 38, 38, 38, 38) >> Xi<-c(5.79, 1579.52, 2323.7, 68.85, 426.07, 110.29, 108.29, 1067.6, >> 17.05, 22.66, 21.02, 175.88, 139.07, 144.12, 20.46, 43.4, 194.9, 47.3, >> 7.74, 0.4, 82.85, 9.88, 89.29, 215.1, 2.75, 0.79, 15.93, 3.91, 0.27, >> 0.69, 100.58, 27.8, 13.95, 53.24, 0.96, 4.15, 0.19, 0.78, 8.01, 31.75, >> 7.35, 6.5, 8.27, 33.91, 32.52, 3.16, 4.85, 2.78, 4.67, 1.31, 12.06, >> 36.71, 72.89, 1.97, 0.59, 2.58, 1.69, 2.71, 25.5, 0.35, 0.99, 3.99, 3.67, >> 2.07, 0.96, 5.35, 2.9, 13.77, 0.47, 0.73, 1.4, 0.74, 0.39, 1.13, 0.09, >> 2.38) >> ZI<-log(zi) >> betaligne<-t(as.matrix(-beta)) >> ZIcolone<-as.matrix(ZI) >> k=8 >> ej<-1/k*sum(exp(betaligne %*% ZIcolone)*Xi) > Error in betaligne %*% ZIcolone : non-conformable arguments >> > > PLEASE HELP ME > THANKS > Goual > -- View this message in context: http://r.789695.n4.nabble.com/Help-a-matrix-exponential-tp4642585p4642589.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.