Displaying 20 results from an estimated 40000 matches similar to: "return value in function"
2005 Sep 28
3
is it possible to form matrix of matrices...and multiple arrays
Dear sirs,
1...........Kindly tell me is it possible to form a matrix which contains a no of matrices..
for eg..
if a,b,c,d are matrices....
and e is a matrix which contains a,b,c,d as rows and columns..
2..........Is it possible to form array of array of arrays
for eg..
"A" contains two set of arrays (1,2)...and each A[1] and A[2] individually contains two set of arrays
I tried like
2012 Aug 14
2
Communative Matrix Multiplcation
Friends
I'm not seeing why the following occurs:
> T1 <- (A1 - A2) %*% D
> T2 <- (A1 %*% D) - (A2 %*% D)
> identical(T1, T2)
[1] FALSE
Harold
> dput(A1)
new("dsCMatrix"
, i = c(0L, 1L, 2L, 3L, 0L, 1L, 4L, 2L, 3L, 5L)
, p = c(0L, 1L, 2L, 3L, 4L, 7L, 10L)
, Dim = c(6L, 6L)
, Dimnames = list(NULL, NULL)
, x = c(5, 5, 5, 5, 5, 5, 10, 5, 5, 10)
2010 Mar 27
1
R runs in a usual way, but simulations are not performed
Dear addresses, I need perform a batch of 10 000 simulations for each of
4 options considered. (The idea is to obtain the parameter estimates in
a heteroskedastic linear regression model - with additive or mixed
heteroskedasticity - via the Kenward-Roger small-sample adjusted
covariance matrix of disturbances). For this purpose I wrote an R
program which would capture all possible options (true
2012 Jul 03
2
EM algorithm to find MLE of coeff in mixed effects model
I have a general question about coefficients estimation of the mixed model.
I simulated a very basic model: Y|b=X*\beta+Z*b +\sigma^2* diag(ni);
b follows
N(0,\psi) #i.e. bivariate normal
where b is the latent variable, Z and X are ni*2 design matrices, sigma is
the error variance,
Y are longitudinal data, i.e. there are ni
2013 Feb 23
1
how to calculate left kronecker product?
For an application, I have formulas defined in terms of a left Kronecker
product of matrices,
A,B, meaning
A \otimes_L B = {A * B[i,j]} -- matrix on the left multiplies each
element on the right.
The standard kronecker() function is the right Kronecker product,
A \otimes_R B = {A[i,j] * B} -- matrix on the right multiplies each
element on the left.
The example below shows the result of
2009 Jan 11
4
How to get solution of following polynomial?
Hi, I want find all roots for the following polynomial :
a <- c(-0.07, 0.17); b <- c(1, -4); cc <- matrix(c(0.24, 0.00, -0.08,
-0.31), 2); d <- matrix(c(0, 0, -0.13, -0.37), 2); e <- matrix(c(0.2, 0,
-0.06, -0.34), 2)
A1 <- diag(2) + a %*% t(b) + cc; A2 <- -cc + d; A3 <- -d + e; A4 <- -e
fn <- function(z)
{
y <- diag(2) - A1*z - A2*z^2 - A3*z^3 - A4*z^4
2011 Aug 08
2
2 questions on matrix manipulation in R
Hi there,
I have two questions on matrix manipulation. For the first one, I
want to calculate the product of each column of a matrix (say A) with
another vector (say b). That is, if A has 5 columns (a1, a2, a3, a4,
a5), I want to obtain a matrix with columns (a1*b, a2*b, aA3*b, a4*b,
a5*b). Can I do it directly, without using "for" loop?
For the second one, I have a matrix A of
2012 Apr 12
3
writing spdiags function for R
Dear R-list,
I am in the process of translating a long function written in Matlab
into R (mainly because I am a big of fan of R, and folks will not
have to pay to use it :). In the translation of this function
I got stack because they use spdiags, which, as far as I can tell
it is not available in R. I have explored the Matrix package, from
which I borrowed some of the functions (e.g.,
2004 Jul 21
2
Rose Diagrams
Hi,
Is it possible to create Rose Diagrams of wind data (speed & direction) with
R??
Best regards,
Lars Peters
-----
Lars Peters
University of Konstanz
Limnological Institute
D-78457 Konstanz
Germany
phone: +49 (0)7531 88-2930
fax: +49 (0)7531 88-3533
e-mail: Lars.Peters@Uni-Konstanz.de
web: Lars Peters
<http://www.uni-konstanz.de/sfb454/tp_eng/A1/doc/peters/peters.html>
2003 May 20
1
How to use pakcage SEM
Hi.
I have tried to use Package "SEM".
As a learning, I try to convert a program running well of EQS
which is as follows to SEM:
### EQS ###
/SPECIFICATION
CAS=100; VAR=5 MAT=COR; ANA=COR;
/EQUATIONS
V1=*F1+E1; V2=*F1+E2; V3=*F1+*F2+E3; V4=**F1+*F2*E4;
V5=*F2+E5;
/VAR
E1 TO E5=*; F1*1.0; F2=1.0;
/COV
E1,E2=*; F1,F2=*:
/PRINT
FIT ALL;
/MATRIX ......
/END
This is the converted SEM
2011 Jul 19
2
Taking all "complete" diagonals of a matrix
Hi R-Help!
I am trying to find a nicer way of extracting all the "complete" diagonals
of a matrix. I am working with very large matrices that have many more rows
than columns. I want to be able to extract each of the diagonals that are
as long as the number of columns in the matrix. I have written a rather
ugly function that presently does the job. It illustrates what I am trying
to
2003 May 20
2
Extending %*%
I have lists of matrices stored in various ways. I'd like to extend
%*% to work on these. Is this possible, or should I create my own new
operator?
A simplified example would be as follows:
A <- list( A1, A2, A3)
B <- list( B1, B2, B3)
where A1,...,B3 are all matrices, and I'd like A %*% B to return
list( A1 %*% B1, A2 %*% B2, A3 %*% B3)
In the real case A and B are sometimes
2012 Oct 13
1
DCC help
hi all,
i am using a dcc model for my senior thesis, it looks at stock returns
during times of market uncertainty.
my current rfile is below.
library(SparseM)
library(quantreg)
library(zoo)
library(nortest)
library(MASS)
library(fEcofin)
library(mvtnorm)
library(ccgarch)
library(stats)
library(foreign)
#dataset<-read.csv(file="xxxx",header=FALSE)
attach(dataset);
2010 Sep 19
1
Problem with "list"
Dear all, I have following list object:
dat <- vector("list", length=4)
for(i in 1:4) dat[[i]] <- diag(rnorm(5)^2)
names(dat) <- paste("A", 1:4, sep="")
It is ok upto this point. However if I want apply, suppose chol()
function on any of it's element, I am getting error:
> chol(dat['A1'])
Error in chol.default(dat["A1"]) :
2010 Jun 15
2
Integration problem: error in invoking an outside function
Dear all,
Currently I am trying to integrate a function which depends on four
variables, two of which are given, one is given in the integrate function,
so there is one variable to integrate on.
The code is as follows:
Pmatrix =
function(th) {
P = matrix(nrow=6, ncol=6, data=0)
P[1,1] = P[2,1]=P[3,2]=P[4,3]=P[5,4]=P[6,5]= exp(-th)
P[,6] = 1-exp(-th)
return(P)}
lim.verd =
2005 Apr 15
5
Pearson corelation and p-value for matrix
Hi,
I was trying to evaluate the pearson correlation and the p-values for an nxm matrix, where each row represents a vector. One way to do it would be to iterate through each row, and find its correlation value( and the p-value) with respect to the other rows. Is there some function by which I can use the matrix as input? Ideally, the output would be an nxn matrix, containing the p-values
2014 Nov 10
1
ambiguity in the documented return value of Null() from package MASS
Hi,
Function Null from package MASS seems to return a matrix with zero columns and the expected number of rows when
the null space of the argument contains only the zero vector, e.g.
> library(MASS)
> diag(nrow=3)
[,1] [,2] [,3]
[1,] 1 0 0
[2,] 0 1 0
[3,] 0 0 1
> Null(diag(nrow=3))
[1,]
[2,]
[3,]
But the documentation of Null seems to imply that
2006 Sep 08
2
Multiple matrix multiplication with two 3-dimensional arrays
Hi,
I need to do several matrix multiplications with
the corresponding matrices forming two
3-dimentional arrays. To illustrate my problem,
let's say I have the following 3-dimensional arrays:
array1 <- array(1:30,dim=c(3,2,5))
array2 <- array(1:20,dim=c(2,2,5))
I know that I can get what I want with the following computation :
result <- array(dim=c(dim(array1)[1],
2006 Feb 21
1
call row names
Hi R users.
I have a table like that:
table
var
A1
A2
A3
v1
41203
3.69
2.31
v2
20577
4.51
8.60
v3
20625
2.87
3.50
v4
6115
8.92
2.97
v5
3160
1.49
2.21
v6
2954
2.62
5.98
v7
4731
1.83
7.53
v8
2435
7.68
3.50
v9
2296
3.03
4.84
v10
6153
1.06
4.28
v11
3157
1.07
1.15
v12
2996
1.06
1.01
v13
6084
2.65
2.63
v14
3115
2.42
2006 Dec 10
4
sample "n" random positions from a matrix
Hi there,
I have a binary matrix (dim 100x100) filled with values 0 and 1. I need select a record "n" positions of that matrix when values are 1. How can I do that?
Thanks for all,
Miltinho
Brazil
---------------------------------
[[alternative HTML version deleted]]