[R] about the Choleski factorization

2009-03-27 Thread 93354504
Hi there, 

Given a positive definite symmetric matrix, I can use chol(x) to obtain U where 
U is upper triangular
and x=U'U. For example,

x=matrix(c(5,1,2,1,3,1,2,1,4),3,3)
U=chol(x)
U
# [,1]  [,2]  [,3]
#[1,] 2.236068 0.4472136 0.8944272
#[2,] 0.00 1.6733201 0.3585686
#[3,] 0.00 0.000 1.7525492
t(U)%*%U   # this is exactly x

Does anyone know how to obtain L such that L is lower triangular and x=L'L? 
Thank you.

Alex

__
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] for posterior distribution for Gamma GLM

2008-09-12 Thread 93354504
Dear all,

There are some R package that provide posterior
distribution of logit, probit models. Does anyone know any R package that can 
provide posterior distribution for Gamma-GLM ? 

Thank you.

Alex

__
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] Question for help

2008-09-08 Thread 93354504
clotting - data.frame(u = c(5,10,15,20,30,40,60,80,100), lot1 =
c(118,58,42,35,27,25,21,19,18), lot2 = c(69,35,26,21,18,16,13,12,12));
lot=c(clotting$lot1,clotting$lot2);
uu=c(clotting$u,clotting$u);
x=uu;
y=lot;
n=length(y);
x=cbind(rep(1,n),x);
c=2;
neg_loglikehood=function(theta){
   -1*(c*sum(log(x%*%theta))+(c-1)*sum(log(y))-c*sum(y*(x%*%theta)));
}
g=glm(lot ~ log(uu),  family=Gamma);
optimization=optim(g$coef,neg_loglikehood)




and got the warning message:

Warning messages:
1: In log(x %*% theta) : NaNs produced
2: In log(x %*% theta) : NaNs produced
3: In log(x %*% theta) : NaNs produced
4: In log(x %*% theta) : NaNs produced
5: In log(x %*% theta) : NaNs produced
6: In log(x %*% theta) : NaNs produced
7: In log(x %*% theta) : NaNs produced
8: In log(x %*% theta) : NaNs produced


However,  everything in the x %*% theta matrix is positive:

x %*% theta
   [,1]
[1,] 0.01515921
[2,] 0.01909599
[3,] 0.02303277
[4,] 0.02696955
[5,] 0.03484312
[6,] 0.04271668
[7,] 0.05846380
[8,] 0.07421093
[9,] 0.08995805
[10,] 0.01515921
[11,] 0.01909599
[12,] 0.02303277
[13,] 0.02696955
[14,] 0.03484312
[15,] 0.04271668
[16,] 0.05846380
[17,] 0.07421093
[18,] 0.08995805

and it also gave me the minimizer below:

theta=optimization$par
theta
(Intercept)  log(uu) 
0.0112224301 0.0007873562 

Can anyone tell me why the I that warning message?
Thank you very much.

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