Displaying 20 results from an estimated 4000 matches similar to: "How to calculte the power of a matrix"
2009 Dec 11
1
How could I find the inverse of a matrix?
Dear R family
I have a following question.
Suppose I have a matrix as follows, for instance:
tau=
0 0 0 0 1
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
I want to have the inverse of the above matrix and then add some
exponent to it. That is, I want to calculate tau to the (-m). For
example, m=893.
Thanks in advance
Best regards
Moohwan Kim
2009 Dec 13
1
too large dimension problem
Dear R family
When I run the command below, the error message came up. It seems like
the problem is about computer capacity.
It would be appreciated if anyone could give me a solution.
###########
> N <- 415884
> tau <- diag(1, N)[c(N, 1:(N - 1)),]
Error in array(0, c(n, p)) : 'dim' specifies too large an array
Best
Moohwan
2009 Dec 11
3
how to creat a matrix
Dear R family
I am attempting to create a matrix. e.g.,
0 0 0 0 1
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
How could I write a R program?
Later I want to extend it to a N by N case.
Thanks in advance
best
Moohwan
2010 Jul 05
4
To detect the location of duplicate values
Dear R family,
I have a question about how to detect some duplicate numeric observations.
Suppose that I have two variables dataset.
order value
1 0.52
2 0.23
3 0.43
4 0.21
5 0.32
6 0.32
7 0.32
8 0.32
9 0.32
10 0.12
11 0.46
12 0.09
13 0.32
14 0.25
;
Could you help me indicate where the duplicate observations in a row
(e.g., 0.32) are?
best,
moohwan
2009 Aug 19
1
BUGS
I am running a BUGS function with following
schools.sim <-bugs(data,inits,
parameters,
model.file="schools.txt",
n.chains=3,
n.iter=1000,
bugs.directory="E:/Rprograms")
My model.file IS in the directory
2008 Jul 23
1
R2WinBUGS problem
Dear friends - I'm on winXP, R 2.71 - I have with some help dveloped
this multivariate normal model, which gives very plausible results in
WinBUGS even without any
initial values specified. However, when I then try to run the same model
via the bugs function in R2WinBUGS with inits specified as inits=NULL
the program stops in a dead end. So I have tried to make inits for the
bugs function
2009 Jul 16
1
Error with r2winbugs
Hi,
I am trying to do run the following model saved in "C:/bugs/sus.bug"
model {
for (i in 1:n){
y[i] ~ dpois(lamdba[i])
log(lambda[i]) <- mu+bmale[male[i]]+bschn[schn[i]]+epsilon[i] #
epsilon[i] ~ dnorm(0,tau.epsilon)
}
mu ~ dnorm(0,.0001)
bmale ~ dnorm(0,.0001)
tau.epsilon <- pow(sigma.epsilon, -2)
sigma.epsilon ~ dunif(0,100)
for (j in
2009 Dec 18
1
to remove an error with log(zero)
Dear R family
I have an arbitrary column vector.
1
2
4
0
7
5
0
0
0
9
11
12
When I attempt to take natural logarithm of the series, as you guess
there is an error message. To overcome this problem, my idea is to
replace a zero or zeros in a row with appropriate numbers.
In order to implement it, I need to detect where zeros are.
Then I am going to take the average of two adjacent neighbors. In the
2007 May 14
1
Hierarchical models in R
Is there a way to do hierarchical (bayesian) logistic regression in R, the
way we do it in BUGS? For example in BUGS we can have this model:
model
{for(i in 1:N) {
y[i] ~ dbin(p[i],n[i])
logit(p[i]) <- beta0+beta1*x1[i]+beta2*x2[i]+beta3*x3[i]
}
sd ~ dunif(0,10)
tau <- pow(sd, -2)
beta0 ~ dnorm(0,0.1)
beta1 ~ dnorm(0,tau)
beta2 ~ dnorm(0,tau)
beta3 ~
2006 Dec 09
1
WinBUGS14 and R
I'm trying to call BUGS from R. But it's not working. R freezes up and
BUGS gives me a strange output in the log. Just to know, BUGS is
registered. The modified date on the keys file is today (Dec. 9th). It
should be fully registered so that I can use it fully. And, the BUGS model
is syntactically correct. Any suggestions would be very helpful.
Here is my BUGS model:
model {
2008 Dec 15
3
R2winbugs : vectorization
I'm new to bugs, so please bear with me. Can someone tell me if the
following two models are doing the same thing? The reason I ask is
that with the same data, the first (based on 4 separate coeffs
a1--a4) takes about 50 secs, while the second (based on a vectorized
form, a[]) takes about 300. The means are about the same, though
R-hat's in the second version are quite a bit better.
2009 Dec 03
2
Help R2WinBUGS
Hello,
I have problem running WinBUGS from R.
The following example works in WinBUGS but it does not work in R through
package R2WinBUGS.
Does anyone know what the problem is?
x <- c(0.2, 1.1, 1, 2.2, 2.5, 2.9, 2.9, 3.6, 3.8, 0.6, 1, 2, 2.4, 2.6, 2.8,
3.2, 3.9, 3.5)
y <- c(0.5, 1.3, 0.1, 0.7, -0.4, 0.5, -0.9, -0.3, -0.3, 0.6, 0.4, 0.9, -0.1,
-0.4, -0.5, -0.2, 0.3, -1.5)
eco <- c(1, 3,
2006 Apr 27
1
State space AR models in R: some examples
Hi all,
Does anyone have an example of an autoregressive (AR) time-series model
specified as a state space model in R? That is, I want to go beyond the
locally linear (constant) model, and fit the following Gaussian AR state
process model:
Xt = a + (1+b)*Xt-1 + epsilon
,where the model for the observation process is
Yt = Xt + tau
I have information of the tau's (observation variance)
2010 Jul 05
2
to remove duplicate values
Dear R family,
Suppose I have two series.
order value
1 0.52
2 0.23
3 0.43
4 0.21
5 0.32
6 0.32
7 0.32
8 0.32
9 0.32
10 0.12
11 0.46
12 0.09
13 0.32
14 0.25
For these two series, I figured out the way to detect the locations of
duplicate values.
The next thing to do is remove the repeated values except for a value
that would not be next to each other.
In other words, while keeping the
2005 Jun 29
6
x*x*x*... vs x^n
Hi
I have been wondering if there one can speed up calculating small powers
of numbers such as x^8 using multiplication.
In addition, one can be a bit clever and calculate x^8 using only 3
multiplies.
look at this:
> f1 <- function(x){x*x*x*x*x*x*x*x}
> f2 <- function(x){x^8}
> f3 <- function(x){x2 <- x*x;x4 <- x2*x2;return(x4*x4)}
[so f1() and f2() and f3() are
2010 Jul 21
1
Question about allocMatrix error message
Dear R family,
I faced a technical problem in r coding.
#s=t(dev)%*%dev/(nr-1) # dev (100,000 by 2) stands for
deviation from the mean
#sinv=solve(s)
#t2=diag(dev%*%sinv%*%t(dev))
I got an error message at t2 statement:
Error in diag(dev %*% si %*% t(dev)) : allocMatrix: too many elements specified
Please let me know if there is a way to overcome this problem.
best
moohwan
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
2011 Jun 18
1
double integral calculation
a=[0.1,0.2,0.1,0.3,0.4]
b=[0.2,0.3,0.1,0.2,0.5]
c=[1,1,1,1,1]
log(c+a-x*b) where x=unknown scale variable.
int=$$log(c+a-x*b)dadb, where $ denotes integral sign.
Actually, how could I calculate the integral's approximation?
double summation?
best,
moohwan
2010 Jun 04
2
Convolution vector to be derived
I want to generate the following outcome using convolution of two sequences.
x <- c(1,2,3,4,5)
y <- c(6,7,8,9)
The resulting convolution vector is
6
19
40
70
100
94
76
45
When using convolve(), it is hard to produce the result above.
Would you help me out to get that?
Best regards
Moohwan Kim
2008 Feb 05
1
Got *** caught segfault *** with Quantreg on Mac (PR#10699)
Full_Name: Edward Huang
Version: 2.6.1
OS: Mac OS 10.5.1 Leopard
Submission from: (NULL) (71.198.106.232)
I'm trying to run quantile regression on my data. I just couldn't make it work.
The same dataset ran okay on STATA 10, tho.
Would you please take a look at it?
Here is the error message:
*** caught segfault ***
address 0x3ff00008, cause 'memory not mapped'
Traceback: