Displaying 20 results from an estimated 11000 matches similar to: "modifying arrays within functions"
2008 Jul 11
1
Subsetting an array by a vector of dimensions
Hi
Is it possible to subset an n-dimensional array by a vector of n dimensions? E.g. assume I have
> x <- array(1:24, dim=2:4)
> x[1,1,2]
[1] 7
> dims <- c(1,1,2)
I would like a function that I can supply x and dims as parameters to, and have it return 7. Also, I would like to do something like:
> x[1,1,]
[1] 1 7 13 19
> dims2<- c(1,1,NA)
And have a function of x and
2008 Jun 04
2
array of arrays
Dear R users,
I want to calculate the bias and variance of an estimator for several values
of two parameters a and b.
For example :
b1 b2
a1 bias bias
variance variance
a2 bias bias
variance variance
Can one do array of arrays ? I have tried and it did not work.
Actually I would like to get this array for several values of the number of
observations. That
2008 May 18
2
*apply function for arrays?
Hi all,
I've recently been writing functions which may deal with very large
arrays. And I hope to use *apply functions in the program so that the
code may look nicer and the performance may be better in the following
two situations.
The first situation is:
I'm having an array A with dim(A)==c(m,n,p). And I want to apply a
function F to a group of elements in A like:
1) F is applied to
2007 Jan 03
2
accessing arrays
hi all. how can i adress a array directly. for example i wanna give array 1
other labels than array 2. How can I overcome this problem?
...this doesn't work
tab <- array(1:8, c(2, 2, 2))
dimnames(tab[,,1]) <- list(c("No","Yes"), c("No","Yes"),c("ARRAY1"))
dimnames(tab[,,2]) <- list(c("big","small"),
2008 Dec 23
1
Ordered Multidimensional Arrays
Hi,
I am inquiring as to what are the best practices with respect to storing and
manipulating ordered multi-dimensional arrays. For example, suppose I have
a sequence of time-varying covariance matrices of asset returns. The data
is ordered, but the ordering is not necessarily regular (e.g. daily data
omitting weekends and holidays, etc.). The data array is say, N x N x T.
For example, the
2003 Jul 18
3
Problem indexing into array
Hi Folks,
Can anyone give me the tip I've been groping for with the
following question:?
mu: kx2x2x2 array of reals corresponding to means of k RVs
at the combinations of values (1,2)x(1,2)x(1,2)
of dichotomous variables F1,F2,F3
mu prints out as k rows (one for each Xi) of 8 numbers
M: N x (3+k) matrix of cases. The first 3 cols are values
of
2005 Jan 03
3
spreadsheet addiction
There's a new page on the Burns Statistics website
http://www.burns-stat.com/pages/Tutor/spreadsheet_addiction.html
that looks at spreadsheets from a quality assurance perspective. It
presents R as a suitable alternative to spreadsheets. Also there are
several specific problems with Excel that are highlighted, including
the status of statistical functionality in Excel.
Patrick Burns
Burns
2006 Nov 07
1
S-poetry as book
Hi,
Is there a printed version of S-poetry which can purchased or would I have
to print out and bind it myself?
Regards,
Benjamin
--
Benjamin Otto
Universitaetsklinikum Eppendorf Hamburg
Institut fuer Klinische Chemie
Martinistrasse 52
20246 Hamburg
[[alternative HTML version deleted]]
2005 Aug 10
5
how to write assignment form of function
Dear All,
where can I find information about how to write an assigment form of a
function?
For curiosity I tried to write a different form of the levels()-function,
since the original method for factor deletes all other attributes of a factor.
Of course, the simple method would be to use instead of levels(x) <-
newlevels, attr(x, 'levels') <- newlevels.
I tried the following:
##
2008 Jul 13
2
multiple names to assign
'assign' does not give a warning if 'x' has length
greater than 1 -- it just uses the first element:
assign(c('a1', 'a2'), 1:2)
One way of thinking about this is that people using
'assign' get what they deserve. The other is that it is
used seldom enough that adding a warning isn't going
to slow things down appreciably.
Patrick Burns
patrick at
2005 Oct 07
2
Assign references
Folks,
I've run into trouble while writing functions that I hope will create
and modify a dataframe or two. To that end I've written a toy function
that simply sets a couple of variables (well, tries but fails).
Searching the archives, Thomas Lumley recently explained the <<-
operator, showing that it was necessary for x and y to exist prior to
the function call, but I haven't
2008 Feb 06
2
Multivariate Maximum Likelihood Estimation
Hi,
I am trying to perform Maximum Likelihood estimation of a Multivariate
model (2 independent variables + intercept) with autocorrelated errors of
1st order (ar(1)).
Does R have a function for that? I could only find an univariate option
(ar.mle function) and when writing my own I find that it is pretty
memory-consuming (and sometimes wrong) so there must be a better way.
Thanks,
KB
2006 May 16
1
variable row names
Hy all,
I wish to use a variable as rownames for a set of datas.
By example :
> nom<-"toto"
> prenom<-"tutu"
> res<-c(1,2)
> res<-t(res)
> res
[,1] [,2]
[1,] 1 2
> colnames(res)<-c(nom,prenom)
> res
toto tutu
[1,] 1 2
> nom
[1] "toto"
>
I wish to call the rowname by the
2006 May 29
2
Analog to matlab repmat function
Hello,
I'm trying to switch from Matlab to R-project, and having some difficulties.
I make a use of multidimensional matrices. For example, I need to extract
mean from one of the dimensions:
% we have matrix data of size: 130 x 11 x 350 x 2
data = data - repmat(mean(data,3),[130 1 1 1]);
In R project I managed to do that in a very pervarsive way:
# mean(data,3) in R
base <-
2007 Jan 19
4
Vectorize rearrangement within each column
Consider a matrix like
> ma = matrix(10:15, nr = 3)
> ma
[,1] [,2]
[1,] 10 13
[2,] 11 14
[3,] 12 15
I want to rearrange each column according to row indexes (1 to 3)
given in another matrix, as in
> idx = matrix(c(1,3,2, 2,3,1), nr = 3)
> idx
[,1] [,2]
[1,] 1 2
[2,] 3 3
[3,] 2 1
The new matrix mb will have for each column the
2005 Sep 21
2
MGARCH estimation
Hi R-users
Can the users let me know how to do MGARCH estimate (Bivariate GARCH)
and volatility forecast for 2 variables in R.
thanks and regards
snvk
2006 Jan 27
3
draft of Comment on UCLA tech report
You may recall that there was a discussion of a technical
report from the statistical consulting group at UCLA.
I have a draft of a comment on that report, which you
can get from
http://www.burns-stat.com/pages/Flotsam/uclaRcomment_draft1.pdf
I'm interested in comments: corrections, additions, deletions.
Patrick Burns
patrick at burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
2006 Feb 23
2
Problem with List() Inside Function
I have a function declared thus.
FirstEigenvectorBoundary.Training <-
function(InputFileName='C:/Samples2/PT_Amp.txt',
Header=TRUE, Colour="red")
Inside the function, I have the following call
out<-list(x=Eigenvectors[2:(NumMetricsSelected+1),1],
y=-0.8, z=NumMetricsSelected);
NumMetricsSelected has the value 2 and Eigenvectors
has the following form
[,1]
2005 Oct 31
2
How can I test temporal autocorrelation of binary data?
Hi,
I have a binary (o/1 - coded) data set and want to test it's autocorrelation
structure. Is that function implemented in R?
Can I use the ACF - funtion with binary data?
Thanks for your help,
Daniel
2008 Jul 15
2
Regression problem
Hello all,
I am new to r programmeand need help. I want to do
multiple linear regression analysis. say, I have two matrix 'x' and 'y'. I
want, 'x' as my response variable and 'y' as predictor.
Each time one column of 'x' will be the response, say x[,1], then next x[,2]
and so on. And also I need to store the coefficients in a matrix form.