I want to dynamically populate a vector by iteratively applying a
function to its previous element, without using a 'for' cycle. My
solution, based on a question I posted some times ago for a more
complicated problem (see "updating elements of a list of matrixes
without 'for' cycles") was to define
I wish to simulate the following stochastic process, for i = 1...N
individuals and t=1...T periods:
y_{i,t} = y_0 + lambda Ey_{t-1} + epsilon_{i,t}
where Ey_{t-1} is the average of y over the N individuals computed at time
t-1.
My solution (below) works but is incredibly slow. Is there a faster
I have several estimated time series, running from 2013 to 2050. 'y' values
are constrained between 0 and 1. I would like to plot them using shaded
colours of decreasing intensity, depending on an estimated density at each
point x in 2013-2050.
This is what I have done:
require(denstrip)
x <- 201
33708 0.5612197 0.6882252 0.8183746 0.7687452
This is the error I get:
Error in rank(x, ties.method = "min", na.last = "keep") :
unimplemented type 'list' in 'greater'
Matteo
On 3 October 2015 at 09:16, Matteo Richiardi
wrote:
> I have several est
I apologise for this very basic question, but I found no answers on the web.
I want to create a data.table with n columns, named i1 ... i'n', with only
one row with value = 100 for every variable.
I can do it "by hand":
M.dt <- data.table(i1=100,i2=100,i3=100)
but I would like to make it in a lo
Hi,
thanks a lot to everybody for your help. Very nice suggestions!
Matteo
On 16 December 2015 at 12:53, Matteo Richiardi
wrote:
> I apologise for this very basic question, but I found no answers on the
> web.
> I want to create a data.table with n columns, named i1 ... i'n
I have to evolve each element of a matrix W
W <- matrix(0,2,3)
according to some function which uses the indices of the matrix [i,j] as
arguments:
w.fun = function(i,j) {
return A[i]*B[j]/(C[i,j])
}
where
A<-c(100,100)
B<-c(200,200,200)
C <- matrix( rnorm(6,mean=0,sd=1), 2, 3)
How can I do it
;
> On December 16, 2015 4:18:56 PM PST, Matteo Richiardi <
> matteo.richia...@gmail.com> wrote:
>
>> I have to evolve each element of a matrix W
>>
>> W <- matrix(0,2,3)
>>
>> according to some function which uses the indices of the matrix [i,j] as
>&g
>
> >
> >> On Dec 16, 2015, at 4:18 PM, Matteo Richiardi <
> matteo.richia...@gmail.com> wrote:
> >>
> >> I have to evolve each element of a matrix W
> >>
> >> W <- matrix(0,2,3)
> >>
> >> according to some function wh
I am following the example I find on ?assign:
a <- 1:4
assign("a[1]", 2)
This appears to create a new variable named "a[1]" rather than
changing the value of the vector.
Am I missing something here? How can I assign a value to a specified
element of a vector/matrix?
Of course, my problem is sli
ot;"))
> M[i,j] = value
> assign(paste("M_",s,sep=""),M, envir = .GlobalEnv)
> }
>
> foo2("a",1,2,15)
>
> cheers
> Peter
>
> > On 23 Dec 2015, at 09:44, Matteo Richiardi
> wrote:
> >
> > I am following the ex
What is the best way to store data in a cube? That is, I need to create a
data structure D with three indexes, say i,j,h, so that I can access each
data point D[i,j,h], and visualise sections like D[i,j,] or D[,,h].
I have tried to create an array of matrixes:
D <-matrix(matrix(NA,i,j),h)
but th
5, 2016 at 2:20 PM, Matteo Richiardi
> wrote:
>>
>> What is the best way to store data in a cube? That is, I need to create a
>> data structure D with three indexes, say i,j,h, so that I can access each
>> data point D[i,j,h], and visualise sections like D[i,j,] or D[,,h].
>
Hi, following an earlier suggestion from the list, I am storing my
data in a "cube", i.e. an array of matrixes.
Is there any smarter way of updating the elements of the cube through
a function, other than the three 'for' cycles in the example below?
(please note that the example is simplistic; in p
Dear R-users,
a very easy one for you, I guess. I need to extract the indexes of the
elements corresponding to different quantiles of a vector. When a
quantile is an interpolation between two adjacent values, I need the
index of the value which is closer (the lower value - or the higher
value for w
of the various ways to get the entire set:
>
>> xq <- quantile(x)
>> sapply(xq, function(y)which.min(abs(x - y)))
> 0% 25% 50% 75% 100%
>34 7 18
>
> Sarah
>
> On Tue, Nov 22, 2016 at 7:21 AM, Matteo Richiardi
> wrote:
>> Dear
I've two data.tables as shown below:
***
N = 10
A.DT <- data.table(a1 = c(rnorm(N,0,1)), a2 = NA))
B.DT <- data.table(b1 = c(rnorm(N,0,1)), b2 = 1:N)
setkey(A.DT,a1)
setkey(B.DT,b1)
***
I tried to change my previous data.frame implementation to a
data.table implementation by changing the for-loop
I've two data.tables as shown below:
***
N = 10
A.DT <- data.table(a1 = c(rnorm(N,0,1)), a2 = NA))
B.DT <- data.table(b1 = c(rnorm(N,0,1)), b2 = 1:N)
setkey(A.DT,a1)
setkey(B.DT,b1)
***
I tried to change my previous data.frame implementation to a
data.table implementation by changing the for-loop
Hello,
I'm a newby in R. I have created a data.frame holding panel data, with
the following columns: "id","time","y", say:
periods = 100
numcases = 100
df = data.frame(
id = rep(1:numcases,periods),
time = rep(1:periods, each = numcases)
)
df = transform(df,y=c(rnorm(numcases*periods)+id)
I wan
I don't want to go for
a matrix, because I'd loose the column names and everything will
become too much error-prone.
Any suggestions on how to do it?
Thanks in advance,
Matteo
--
Matteo Richiardi
University of Turin
Faculty of Law
Department of Economics "Cognetti De Mart
Hi,
I'm trying to use StatEt IDE for Eclipse as my R editor, but I'm completely
lost. I've read all I could find online, made apparently all I had to do
(installing rj, configuraing StatEt, etc.) but still cannot make R running.
Below is the error log file.
Thank you so much for assistance.
Matteo
Hi,
I'm trying to use StatEt IDE for Eclipse as my R editor, but I'm completely
lost. I've read all I could find online, made apparently all I had to do
(installing rj, configuraing StatEt, etc.) but still cannot make R running.
Below is the error log file.
Thank you so much for assistance.
Matteo
22 matches
Mail list logo