Re: [R] hessian in solnp

2022-05-03 Thread CAMARDA Carlo Giovanni via R-help
the second (partial) derivatives of the loss function. Or do I miss something? Moreover, I would expect smaller standard errors of the estimated parameters when additional constraints are included, and it is not the case in the given example. De: "Ivan Krylov" À: "CAMARDA Car

[R] hessian in solnp

2022-04-27 Thread CAMARDA Carlo Giovanni via R-help
In the commented snippet below, a behavior of the solnp() I cannot fully explain: when a constraint is added, hessian matrix is obviously changing, but in a way I don't understand. I know that the model below could be estimated differently and in a much efficient way. However I wanted to pres

[R] Reproducing lm outcomes with mixed effect model on augmented dataset

2015-05-01 Thread CAMARDA Carlo Giovanni
Dear R-users, let's assume a simple linear model in which to each original observation one attaches random response and covariate, but with weights that are practically zero. If one runs a linear model to both original and augmented data, one obtains the same estimates, but obviously differe

[R] matrix built by diagonal matrices with a given structure

2014-06-24 Thread CAMARDA Carlo Giovanni
Dear R-users, I have a matrix with a series of "not-overlapping in a row dimension" vectors in a given structure. Something like: |a1, 0, 0, 0| | 0, a2, a3, 0| |a4, 0, 0, a5| where "ai" are column-vectors of the equal length, m. My aim is to construct a new matrix formed by diagona

Re: [R] extracting the diagonal of an inverse matrix

2013-04-23 Thread Camarda, Carlo Giovanni
2.14.1 (2011-12-22) From: William Dunlap [wdun...@tibco.com] Sent: Monday, April 22, 2013 6:25 PM To: Camarda, Carlo Giovanni; Greg Snow Cc: r-h...@stat.math.ethz.ch Subject: RE: [R] extracting the diagonal of an inverse matrix You could save the space required to store t

Re: [R] extracting the diagonal of an inverse matrix

2013-04-22 Thread Camarda, Carlo Giovanni
1) P2a <- kronecker(t(P2)%*%P2, diag(m)) P <- 1000 * P1a + 1000 * P2a ## final matrix A A <- D + P ## solving A B <- solve(A) ## what I just actually need diag(B) From: Greg Snow [538...@gmail.com] Sent: Saturday, April 20, 2013 12:16 AM To

[R] extracting the diagonal of an inverse matrix

2013-04-19 Thread Camarda, Carlo Giovanni
Dear R-users, I would like to know whether there is a way to extract a diagonal of an inverse matrix without computing the inverse of the matrix itself. The size of my matrices are really huge and, also using sparse matrix, computing the inverse leads to storage problems and low speed. In othe

[R] linear model with equality and inequality (redundant) constraints

2013-03-19 Thread Camarda, Carlo Giovanni
Dear R-users, in the last days I have been trying to estimate a normal linear model with equality and inequality constraints. Please find below a simple example of my problem. Of course, one could easily see that, though the constraints are consistent, there is some redundancy in the specific

Re: [R] impossible to invert a spam-object, but possible when it's a matrix-object

2013-02-11 Thread Camarda, Carlo Giovanni
ize other parts of my model. Thanks again, Giancarlo From: Uwe Ligges [lig...@statistik.tu-dortmund.de] Sent: Saturday, February 09, 2013 8:04 PM To: Camarda, Carlo Giovanni Cc: r-h...@stat.math.ethz.ch Subject: Re: [R] impossible to invert a spam-object,

[R] impossible to invert a spam-object, but possible when it's a matrix-object

2013-02-05 Thread Camarda, Carlo Giovanni
Dear R-users, a question concerning sparse matrices in package "spam" (spam_0.29-2). On one hand I have a spam object (n X n) from which I cannot compute the inverse. On the other hand, if I convert this object in a plain matrix, I can find the inverse without any problem. Specifically I get t

[R] matrix algebra for constructing a special matrix?

2012-10-26 Thread Camarda, Carlo Giovanni
Dear R-users, would it be a better way to construct the matrix below without using any for-loop or model.matrix? preferably with some matrix algebra? Thanks in advance, Carlo Giovanni Camarda ## dimensions m <- 3 n <- 4 mn <- m*n k <- m+n-1 ## with a for-loop X <- matrix(0, mn, k) for(i in 1:

[R] xyplot with different pch and col in each panel and additional line

2012-04-05 Thread Camarda, Carlo Giovanni
Dear R-users, I'd like to use an xyplot(lattice) in which in each panel I have points with different point-character and color, and additional lines with the same color. Please find below a toy example in which I did not manage to change such parameters, and the associated basic plot() in which

[R] generalized additive mixed models for ordinal data

2010-09-29 Thread Camarda, Carlo Giovanni
Dear R-users, Is there any R-function for fitting generalized additive mixed models for ordinal data? Do they actually make some sense? I can fit a generalized linear mixed model for ordinal data using the function clmm(ordinal) and I'm able to cope with generalized additive model for ordi

Re: [R] persp3d and rgl.viewpoint for rotating 3D plots

2009-04-08 Thread Camarda, Carlo Giovanni
- From: Duncan Murdoch [mailto:murd...@stats.uwo.ca] Sent: Wednesday, April 08, 2009 5:13 PM To: Camarda, Carlo Giovanni Cc: r-h...@stat.math.ethz.ch Subject: Re: [R] persp3d and rgl.viewpoint for rotating 3D plots On 4/8/2009 11:01 AM, Camarda, Carlo Giovanni wrote: > Dear R-users,

[R] persp3d and rgl.viewpoint for rotating 3D plots

2009-04-08 Thread Camarda, Carlo Giovanni
Dear R-users, within the rgl-package, I would have a question about the usage of persp3d in combination of rgl.viewpoint. I am not able to figure out how to let a 3D plot rotating around likewise the example in ?rgl.viewpoint. It seems that when I use persp3d(...) I see something on my scr

[R] two plots side-by-side with persp3d(rgl)

2009-03-19 Thread Camarda, Carlo Giovanni
Dear R-users, I would like to place two 3D plots side-by-side in a rgl-setting. It would nice to have something like "par(mfrow=c(1,2))" for basic plots, or an array framework for wireframe(lattice) (see example below). I only managed to overlap two persp3d plots. My final idea would be

Re: [R] matrix multiplication, tensor product, block-diagonal and fast computation

2009-03-16 Thread Camarda, Carlo Giovanni
Thursday, March 12, 2009 4:25 PM To: Camarda, Carlo Giovanni Cc: r-h...@stat.math.ethz.ch Subject: Re: [R] matrix multiplication, tensor product, block-diagonal and fast computation On Wed, 11 Mar 2009, Camarda, Carlo Giovanni wrote: > Dear R-users, > > I am searching to the "bes

[R] matrix multiplication, tensor product, block-diagonal and fast computation

2009-03-11 Thread Camarda, Carlo Giovanni
Dear R-users, I am searching to the "best" way to compute a series of n matrix multiplications between each matrix (mXm) in an array (mXmXn), and each column of a matrix (mXn). Please find below an example with four possible solutions. The first is a simple for-loop which one might avoid; the se

[R] trade-off between speed and storage in matrix multiplications

2009-02-23 Thread Camarda, Carlo Giovanni
Dear R-users, I coded two equivalent ways to perform (in a simplified version) some matrix multiplications I would like to use in a more general framework. In the first case I used Kronecker product and vectorization of a certain matrix. This approach takes less time, but, as you may guess

[R] multiplication between a matrix and a block-diagonal matrix (without vectorization)

2009-02-20 Thread Camarda, Carlo Giovanni
Dear R-users, I would have a question regarding the multiplication between a matrix (A, mXn) and a block-diagonal matrix, B, (m*n)X(m*n). The easy solution would be to, first, vectorize A and use simple matrix multiplication, but my aim is to avoid such vectorization. Is it possible? Pleas

[R] match.call in a function

2008-09-24 Thread Camarda, Carlo Giovanni
Dear UseRs, please find below a simple example which exemplifies my question. In words, I'd like to write a function which prints formula and outcomes only when results are not assigned or recalling the already assigned object, as e.g. glm. I'm sure a solution is rather simple and straightforwa

[R] Summing up diagonals w/o for-loop

2008-02-26 Thread Camarda, Carlo Giovanni
Dear R-users, is there any way to sum up the elements of the "diagonals" of a matrix without using a for-loop? While there is a simple way over rows and columns, I don't see a straightforward multiplication for the diagonals, am I too demanding? Or, more likely, I'm lack some algebra trick? Is the