search for: expm

Displaying 20 results from an estimated 58 matches for "expm".

Did you mean: exim
2017 Feb 09
2
R CMD check error
Martyn, No, that didn't work. One other thing in the mix (which I don't think is the issue) is that I call one of the C-entry points of expm. So the DESCRIPTION file imports expm, the NAMESPACE file imports expm, and the init.c file is #include "R.h" #include "R_ext/Rdynload.h" /* Interface to expm package. */ typedef enum {Ward_2, Ward_1, Ward_buggy_octave} precond_type; void (*expm)(double *x, int n, double *z,...
2011 Aug 17
2
An example of very slow computation
This message is about a curious difference in timing between two ways of computing the same function. One uses expm, so is expected to be a bit slower, but "a bit" turned out to be a factor of >1000. The code is below. We would be grateful if anyone can point out any egregious bad practice in our code, or enlighten us on why one approach is so much slower than the other. The problem arose in an acti...
2007 Mar 15
1
expm() within the Matrix package
Hi Could anybody give me a bit of advice on some code I'm having trouble with? I've been trying to calculate the loglikelihood of a function iterated over a data of time values and I seem to be experiencing difficulty when I use the function expm(). Here's an example of what I am trying to do y<-c(5,10) #vector of 2 survival times p<-Matrix(c(1,0),1,2) #1x2 matrix Q<-Matrix(c(1,2,3,4),2,2) #2x2 matrix q<-Matrix(c(1,2),2,1) #2x1 matrix Loglik<-rep(0,length(y)) #creating empty vector of same length a...
2017 Feb 09
2
R CMD check error
...e/biostat2/therneau/Rlib So, per the manual R CMD check inherits the path. The question is why does it ignore it? Terry T. On 02/09/2017 02:54 AM, Martyn Plummer wrote: > On Wed, 2017-02-08 at 15:51 -0600, Therneau, Terry M., Ph.D. wrote: >> I have a local library which depends on the expm library. The expm library is loaded into >> my personal space and I have the environment variable R_LIBS_USER set appropriately. The >> command "library(expm)" works just fine from the command line, and in fact the package >> works if I do the source() and dyn.load() c...
2017 Feb 10
0
R CMD check error (interfacing to C API of other pkg)
...rneau, Terry M , Ph D <therneau at mayo.edu> >>>>> on Thu, 9 Feb 2017 12:56:17 -0600 writes: > Martyn, > No, that didn't work. > One other thing in the mix (which I don't think is the issue) is that I call one of the > C-entry points of expm. So the DESCRIPTION file imports expm, the NAMESPACE file imports > expm, and the init.c file is > #include "R.h" > #include "R_ext/Rdynload.h" > /* Interface to expm package. */ > typedef enum {Ward_2, Ward_1, Ward_buggy_octave} precond_ty...
2007 Mar 06
1
expm()
Can the expm function be used to calculate the exponential of a matrix where the matrix is multiplied by a vector in a data frame? For example for (i in 1:length(y)){ expmN<-expm(Q*y[i]) Q<-Matrix(c(1, 2, 3, 4), 2, 2) return(expmN) } Sorry I am new to R and I have been finding it d...
2007 Mar 06
2
Estimating parameters of 2 phase Coxian using optim
...ta[1] mu2<-theta[2] lambda1<-theta[3] p<-Matrix(c(1, 0), nrow=1, ncol=2) Q<-Matrix(c(-(lambda1 + mu1), 0, lambda1, -mu2), nrow=2, ncol=2) q<-Matrix(c(mu1, mu2), nrow=2, ncol=1) for (i in 1:length(y)){ loglik<-log(p %*% expm(Q * y(i)) %*% q) return(loglik)} sumloglik<-sum(loglik) return(-sumloglik) } I have installed the Matrix package. y is a vector of 240 survival times. In the R console I typed > source("/private/var/automount/users/lhill07/Desktop/cox2.lik.R") > o...
2017 Feb 08
2
R CMD check error
I have a local library which depends on the expm library. The expm library is loaded into my personal space and I have the environment variable R_LIBS_USER set appropriately. The command "library(expm)" works just fine from the command line, and in fact the package works if I do the source() and dyn.load() commands by hand. The fo...
2006 Sep 21
2
Exponentiate a matrix
Suppose I have a square matrix P P <- matrix(c(.3,.7, .7, .3), ncol=2) I know that > P * P Returns the element by element product, whereas > P%*%P Returns the matrix product. Now, P^2 also returns the element by element product. But, is there a slick way to write P %*% P %*% P Obviously, P^3 does not return the result I expect. Thanks, Harold [[alternative HTML version
2017 May 09
2
registering Fortran routines in R packages
...dDef FortEntries[] = { {"halton", (DL_FUNC) &F77_NAME(HALTON), 7}, {"sobol", (DL_FUNC) &F77_NAME(SOBOL), 11}, {NULL, NULL, 0} }; But I got error messages when building : use of undeclared identifier ?SOBOL_?. I also tried in lower case sobol and halton. Looking at expm package https://r-forge.r-project.org/scm/viewvc.php/pkg/src/init.c?view=markup&revision=94&root=expm, I try static const R_FortranMethodDef FortEntries[] = { {"halton", (DL_FUNC) &F77_SUB(HALTON), 7}, {"sobol", (DL_FUNC) &F77_SUB(SOBOL), 11}, {NULL, NULL...
2017 Feb 09
0
R CMD check error
On Wed, 2017-02-08 at 15:51 -0600, Therneau, Terry M., Ph.D. wrote: > I have a local library which depends on the expm library.??The expm library is loaded into? > my personal space and I have the environment variable R_LIBS_USER set appropriately.??The? > command "library(expm)" works just fine from the command line, and in fact the package? > works if I do the source() and dyn.load() commands b...
2017 Feb 09
0
R CMD check error
...? $ export R_CHECK_ENVIRON= $ R CMD check hmm.gz Martyn > Terry T. > > > On 02/09/2017 02:54 AM, Martyn Plummer wrote: > > > > On Wed, 2017-02-08 at 15:51 -0600, Therneau, Terry M., Ph.D. wrote: > > > > > > I have a local library which depends on the expm library.??The expm library is loaded into > > > my personal space and I have the environment variable R_LIBS_USER set appropriately.??The > > > command "library(expm)" works just fine from the command line, and in fact the package > > > works if I do the source(...
2007 Mar 13
0
multiplying matrix by vector of times
...;>>>> Q<-Matrix(c(-(lambda1 + mu1), 0, lambda1, -mu2), nrow=2, ncol=2) >>>>> >>>>> q<-Matrix(c(mu1, mu2), nrow=2, ncol=1) >>>>> >>>>> for (i in 1:length(y)){ >>>>> loglik<-log(p %*% expm(Q * y(i)) %*% q) >>>>> return(loglik)} >>>>> >>>>> sumloglik<-sum(loglik) >>>>> >>>>> return(-sumloglik) >>>>> } >> >> >> >> Hi Gad, >> >> Yes that...
2007 May 06
7
A function for raising a matrix to a power?
Hi, Is there a function for raising a matrix to a power? For example if you like to compute A%*%A%*%A, is there an abbreviation similar to A^3? Atte Tenkanen > A=rbind(c(1,1),c(-1,-2)) > A [,1] [,2] [1,] 1 1 [2,] -1 -2 > A^3 [,1] [,2] [1,] 1 1 [2,] -1 -8 But: > A%*%A%*%A [,1] [,2] [1,] 1 2 [2,] -2 -5
2011 Apr 14
2
Krylov subspace computations of matrix exponentials
I use the very nice expm functions available from the expm and Matrix packages. My understanding is that for large sparse matrices the currently best methods available are Krylov subspace methods, but they are as far as I can tell not implemented in either of the packages mentioned, nor in any other R package I have found....
2020 Apr 17
3
Demo for linking native routines between R packages
Dear Davis, Thank you a lot for sharing this, and I am happy that I was not the only one who need to do it once to learn:) I proposed to add my repo to the manual. I think it makes sense to add both of ours, if possible, or we could merge them together and add that to the manual. Long-term URL stability is apparently an issue, but I think we may find a solution there. Anyway, thanks a lot for
2011 Sep 22
1
Error in as.vector(data) optim() / fkf()
...rray(0, c(d,n)) for(t in n:1){ a[,n-(t+1)] <- -phi_13/(n-(t+1))*log(2*phi_11*exp(phi_12*(n-(t+1))/2)/phi_14)-phi_23/(n-(t+1))*log(2*phi_21*exp(phi_22*(n-(t+1))/2)/phi_24) } b <- array(c(1,0,0,1,0), c(d,m,n)) j <- -array(c(K_1, 0, 0, K_2), c(2,2))*h explh <- expm(j) Tt <- array(explh, c(m,m,n)) #array giving the factor of the transition equation Zt <- b #array giving the factor of the measurement equation ct <- a #matrix giving the intercept of the measurement equation dt <- (diag(m)-expm(-array(c(K_1, 0, 0, K_2), c(2,2))*h))*the...
2009 Nov 23
1
R: Re: chol( neg.def.matrix ) WAS: Re: Choleski and Choleski with pivoting of matrix fails
...eigen >>> decomposition but i did no get far. >>> >>> Any clue on how to do it?! >> >> >> If you want to take the square root of a negative definite matrix, you >> could use >> >> sqrtm( neg.def.mat ) >> >> from the expm package on rforge: >> >> http://r-forge.r-project.org/projects/expm/ > >But that matrix is not negative definite! It has 2 positive and one >negative eigenvalue. It is non-positive definite. > >It is fairly easy in any case to get a matrix square root from the eigen...
2020 Apr 17
1
Demo for linking native routines between R packages
...lowed early by the CRAN packages > > zoo <-> xts > > upon which I built > > xts <-> RcppXts > > with a write-up (from 2013 !!) here: > https://gallery.rcpp.org/articles/accessing-xts-api/ > > Via private mail, I helped then-maintainer Vincent connect expm: > > expm <-> Matrix > > and built two packages on CRAN _for the very purpose of exporting API > functions to be called_ (which in both cases are from base R as R Core is > very careful not get tied into exporting APIs, which is both understandable > and a source of add...
2012 Dec 12
4
Matrix multiplication
Hi, I have a transition matrix T for which I want to find the steady state matrix for. This could be approximated by taking T^n , for large n. T= [ 0.8797 0.0382 0.0527 0.0008 0.0212 0.8002 0.0041 0.0143 0.0981 0.0273 0.8802 0.0527 0.0010 0.1343 0.0630 0.9322] According to a text book I have T^200 should have reached the steady state L L