[R] Variable Length Differ

2014-11-02 Thread TJUN KIAT TEO
This is my code BSUPred-(forecast(BSU,h=h)[[2]]) PressurePred-(forecast(Pressure,h=h)[[2]]) Placer-(rep(1,h)) test-as.data.frame(cbind(BSUPred,PressurePred)) test$Placer-rep(1:2,h/12) test$Placer-i test-as.data.frame((test[c(Placer,BSUPred,PressurePred)]))

Re: [R] Variable Length Differ

2014-11-02 Thread Jeff Newmiller
This is not reproducible (see for example [1]), so it is very difficult to know exactly what the problem is. Also, you need to post on this list using the plain text format option in your email software, since the HTML format you used can mess up your code. I can say that using [ indexing on a

[R] Finding MLE

2014-11-02 Thread li li
Hi all, I am trying to use the mle function in R to find the maximum likelihood estimator. The ll function below is the negative of the log likelihood. Suppose x0 is the observed values, I want to find the maximum likelihood for a and b. After running the code below, I get the error message

Re: [R] Finding MLE

2014-11-02 Thread Bert Gunter
You do not appear to provide initial values for a and b , i.e. the start argument for mle. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. Clifford Stoll On Sun, Nov 2,

[R] How to calculate correlation of a vector in R?

2014-11-02 Thread C W
Hi list, I have trying to calculate the covariance/correlation of three elements. I have vector say, v - c(700, 800, 1000) I want to have a 3 by 3 correlation matrix, meaning cor(v1, c2), cor(v1, c3), cor(v2, v3), etc... So far I get, cor(v) Error in cor(v) : supply both 'x' and 'y' or a

[R] CRAN (and crantastic) updates this week

2014-11-02 Thread Crantastic
CRAN (and crantastic) updates this week New packages * addreg (1.2) Maintainer: Mark Donoghoe Author(s): Mark Donoghoe mark.donog...@mq.edu.au License: GPL (= 2) http://crantastic.org/packages/addreg Methods for fitting identity-link GLMs and GAMs to discrete data. The

Re: [R] How to calculate correlation of a vector in R?

2014-11-02 Thread Jeff Newmiller
What is your question? The matrix form is probably what you are looking for, but you put the same vector in three times so if course it is all ones. I don't know what you expected to happen when you entered cor(v) since there is nothing to correlate if you only have one vector. Please post in

Re: [R] How to calculate correlation of a vector in R?

2014-11-02 Thread C W
Thanks, Jeff. I had some misunderstanding. So, I want to calculate the squared exponential of vector v v = c(700, 800, 1029) formula is: k(x_i, x_j)=sigma^2 * exp(-1/(2*l^2) * (x_i - x_j) ^2) where, sigma=7, l=100 I used, v - c(700, 800, 1029) corr.matrix(cbind(v),scales=0.5) [,1]

Re: [R] How to calculate correlation of a vector in R?

2014-11-02 Thread Jeff Newmiller
k - sigma^2 * exp( -1/(2*l^2) * outer( v,v,FUN=function(x,y){(x-y)^2})) but perhaps you should look at the e1071 package instead? --- Jeff NewmillerThe . . Go Live...

Re: [R] Finding MLE

2014-11-02 Thread li li
Thanks Bert for the reply. I still get a message when adding the start argument. n - 8 x0 - c(2,3) ll- function(a,b,x=x0,size=n){ + -sum(log(gamma((n-1)/2+a-1)/(gamma((n-1)/2)*gamma(a))*1/(2*b^a)*(x/2)^((n-1)/2-1)*(1/b+x/2)^(-((n-1)/2+a-1} fit - mle(ll, start=list(a=3, b=1), nobs =

Re: [R] Finding MLE

2014-11-02 Thread li li
I think I made an error in my funciton. Now it works. library(stats4) n - 8 ll- function(a,b,x){ -sum(log(gamma((n-1)/2+a-1)/(gamma((n-1)/2)*gamma(a))*1/(2*b^a)*(x/2)^((n-1)/2-1)*(1/b+x/2)^(-((n-1)/2+a-1} fit - mle(ll, start=list(a=3, b=1), fixed=list(x=c(2,3))) 2014-11-02 22:04

Re: [R] treating missing values in timeSeries package

2014-11-02 Thread David Winsemius
On Nov 1, 2014, at 2:58 AM, Upananda Pani wrote: Dear All, I am getting the following error when i am using interpNA function from timeSeries package # Missing Value Treatment (Linear Interpolation) spt = interpNA(spt, method = c(linear)) Error in interpNA(spt, method = c(linear)) :