[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)]))
resp-predict(fit,newdata=test,type=response)
Pred-ifelse((predict(fit,newdata=test,type=response)0.5),1,0)

But I get this error message

Error in model.frame.default(Terms, newdata, na.action = na.action, xlev = 
object$xlevels) : 
  variable lengths differ (found for 'Placer') 

Can anyone help?

Thanks

Tjun Kiat
  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 data frame will give you back a data 
frame as long as you have multiple result columns, and cbind converts that to a 
matrix. Since data frames typically have columns of a variety of types 
(storage modes) while matrices do not, you are likely damaging your data 
frames every time you use cbind. I recommend that you interactively execute 
(e.g. using copy/paste) one line at a time in your script and use the str() 
function after each line to learn the structure of the the objects you are 
creating and modifying. 

The best way to make a data frame from vector is:

test - data.frame( BSUPred, PressurePred )

or

test - data.frame( BSUPred=BSUPred, PressurePred=PressurePred )

A couple of ways to add columns to data frames that don't damage the data frame 
are:

test$Placer - i

or (an example where specifying only one column identifies a vector rather than 
the usual data frame result)

test[ , Placer ] - i

or even (not recommended for efficiency reasons):

test - data.frame( test, Placer=i )

If this is not enough help, make your example reproducible using the advice in 
[1] and try posting again.

[1] 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

On November 2, 2014 3:19:45 AM PST, TJUN KIAT TEO teotj...@hotmail.com wrote:
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)]))
resp-predict(fit,newdata=test,type=response)
Pred-ifelse((predict(fit,newdata=test,type=response)0.5),1,0)

But I get this error message

Error in model.frame.default(Terms, newdata, na.action = na.action,
xlev = object$xlevels) : 
  variable lengths differ (found for 'Placer') 

Can anyone help?

Thanks

Tjun Kiat
 
   [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[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 Error
in eval(expr, envir, enclos) : argument is missing, with no default.
  Could anyone familiar with this function give some suggetion? Thanks very
much!
 Hanna

 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, nobs = length(x0))

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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, 2014 at 10:36 AM, li li hannah@gmail.com wrote:
 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 Error
 in eval(expr, envir, enclos) : argument is missing, with no default.
   Could anyone familiar with this function give some suggetion? Thanks very
 much!
  Hanna

 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, nobs = length(x0))

 [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[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 matrix-like 'x'

 vvv - cbind(v, v, v)
 cor(vvv)
  v v v
v 1 1 1
v 1 1 1
v 1 1 1


I am calculating squared exponential kernel as seen here.
http://mlg.eng.cam.ac.uk/duvenaud/cookbook/index.html

Thanks a bunch,

Mike

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[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
  package uses EM-type algorithms with more stable convergence
  properties than standard methods.

* CateSelection (1.0)
  Maintainer: Yi Xu
  Author(s): Yi Xu and Jixiang Wu
  License: GPL (= 2)
  http://crantastic.org/packages/CateSelection

  A multi-factor dimensionality reduction based forward selection method
  for genetic association mapping.

* DAMOCLES (1.0)
  Maintainer: Rampal S. Etienne
  Author(s): Rampal S. Etienne  Alex L. Pigot
  License: GPL-2
  http://crantastic.org/packages/DAMOCLES

  Simulates and computes (maximum) likelihood of a dynamical model of
  community assembly that takes into account the phylogenetic history

* exCon (0.1-0)
  Maintainer: Bryan A. Hanson
  Author(s): Bryan Hanson [aut, cre], Kristina Mulry [ctb]
  License: GPL-3
  http://crantastic.org/packages/exCon

  exCon is an interactive tool to explore topographic-like data sets. 
  Such data sets take the form of a matrix in which the rows and
  columns provide location/frequency information, and the matrix
  elements contain altitude/response information.  Such data is found
  in cartography, 2D spectroscopy and chemometrics.  exCon creates an
  interactive web page showing the contoured data set along with
  slices from the original matrix parallel to each dimension. The page
  is written in d3/javascript.

* genpathmox (0.1)
  Maintainer: quot;Giuseppe Lambertiquot;
  Author(s): Giuseppe Lamberti [aut, cre]
  License: GPL-3
  http://crantastic.org/packages/genpathmox

  genpathmox provides a very interesting solution for handling
  segmentation variables in complex statistical methodology. It
  contains en extended version of the PATHMOX algorithm in the context
  of partial least square path modeling (Sanchez, 2009) including the
  F-block test (to detect the responsible latent endogenous equations
  of the difference), the F-coefficient (to detect the path
  coefficients responsible of the difference) and the invariance test
  (to realize a comparison between the sub-models#39; latent variables).
  Furthermore, the package contains a generalized version of the
  PATHMOX algorithm to approach different methodologies: linear
  regression and least absolute regression models.

* hermite (1.0)
  Maintainer: David Moriña Soler
  Author(s): David Moriña (Centre for Research in Environmental Epidemiology,
 CREAL), Manuel Higueras (Universitat Autònoma de
 Barcelona and Public Health England) and Pedro Puig
 (Universitat Autònoma de Barcelona)
  License: GPL (= 2)
  http://crantastic.org/packages/hermite

  Probability functions for the generalized Hermite distribution

* MfUSampler (0.9)
  Maintainer: Alireza S. Mahani
  Author(s): Alireza S. Mahani, Mansour T.A. Sharabiani
  License: GPL (= 2)
  http://crantastic.org/packages/MfUSampler

  Convenience Functions for Multivariate MCMC Using Univariate Samplers,
  including Slice Sampler with Stepout and Shrinkage (Neal, 2003), and
  Adaptive Rejection Sampler (Gilks and Wild, 1992).

* myTAI (0.0.1)
  Maintainer: Hajk-Georg Drost
  Author(s): Hajk-Georg Drost
  License: GPL-3
  http://crantastic.org/packages/myTAI

  The present collection of functions can be used to perform
  phylotranscriptomics analyses to investigate phenomena within the
  field of Evolutionary Developmental Biology

* PrevMap (1.0)
  Maintainer: Emanuele Giorgi
  Author(s): Emanuele Giorgi, Peter J. Diggle
  License: GPL (= 2)
  http://crantastic.org/packages/PrevMap

  The PrevMap package provides functions for both likelihood-based and
  Bayesian analysis of spatially referenced prevalence data. #39;PrevMap#39;
  is also an extension of the #39;geoR#39; package which should be installed
  first together with the #39;maxLik#39;, #39;raster#39; and 
#39;pdist#39; packages.

* qdm (0.1-0)
  Maintainer: Nora Umbach
  Author(s): Nora Umbach [aut, cre], Florian Wickelmaier [aut]
  License: GPL (= 2)
  http://crantastic.org/packages/qdm

  This package provides different specifications of a Quadrilateral
  Dissimilarity Model which can be used to fit same-different
  judgments in order to get a predicted matrix that satisfies regular
  minimality [Colonius amp; Dzhafarov, 2006, Measurement and
  representations of sensations, Erlbaum]. From such a matrix,
  Fechnerian distances can be computed.

* RealVAMS (0.3-1)
  Maintainer: Andrew Karl
  Author(s): Andrew Karl, Jennifer Broatch, and Jennifer Green
  License: GPL-2
  http://crantastic.org/packages/RealVAMS

  The RealVAMs package fits a multivariate value-added model (VAM) (see
  Broatch and Lohr 2012) with normally distributed test scores and a
  binary outcome indicator. This material is based upon work supported
  

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 plain text as the footer and Posting Guide request.
---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

On November 2, 2014 3:30:14 PM PST, C W tmrs...@gmail.com wrote:
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 matrix-like 'x'

 vvv - cbind(v, v, v)
 cor(vvv)
  v v v
v 1 1 1
v 1 1 1
v 1 1 1


I am calculating squared exponential kernel as seen here.
http://mlg.eng.cam.ac.uk/duvenaud/cookbook/index.html

Thanks a bunch,

Mike

   [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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] [,2] [,3]
[1,]100
[2,]010
[3,]001

the output should be covariance matrix = [49, 29.7, 0.02; 29.7, 49, 3.6;
0.2,  3.6, 49]



On Sun, Nov 2, 2014 at 7:04 PM, Jeff Newmiller jdnew...@dcn.davis.ca.us
wrote:

 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 plain text as the footer and Posting Guide request.
 ---
 Jeff NewmillerThe .   .  Go Live...
 DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live
 Go...
   Live:   OO#.. Dead: OO#..  Playing
 Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
 /Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
 ---
 Sent from my phone. Please excuse my brevity.

 On November 2, 2014 3:30:14 PM PST, C W tmrs...@gmail.com wrote:
 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 matrix-like 'x'
 
  vvv - cbind(v, v, v)
  cor(vvv)
   v v v
 v 1 1 1
 v 1 1 1
 v 1 1 1
 
 
 I am calculating squared exponential kernel as seen here.
 http://mlg.eng.cam.ac.uk/duvenaud/cookbook/index.html
 
 Thanks a bunch,
 
 Mike
 
[[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

On November 2, 2014 4:19:56 PM PST, C W tmrs...@gmail.com wrote:
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] [,2] [,3]
[1,]100
[2,]010
[3,]001

the output should be covariance matrix = [49, 29.7, 0.02; 29.7, 49,
3.6;
0.2,  3.6, 49]



On Sun, Nov 2, 2014 at 7:04 PM, Jeff Newmiller
jdnew...@dcn.davis.ca.us
wrote:

 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 plain text as the footer and Posting Guide request.

---
 Jeff NewmillerThe .   .  Go
Live...
 DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live
 Go...
   Live:   OO#.. Dead: OO#.. 
Playing
 Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
 /Software/Embedded Controllers)   .OO#.   .OO#. 
rocks...1k

---
 Sent from my phone. Please excuse my brevity.

 On November 2, 2014 3:30:14 PM PST, C W tmrs...@gmail.com wrote:
 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 matrix-like 'x'
 
  vvv - cbind(v, v, v)
  cor(vvv)
   v v v
 v 1 1 1
 v 1 1 1
 v 1 1 1
 
 
 I am calculating squared exponential kernel as seen here.
 http://mlg.eng.cam.ac.uk/duvenaud/cookbook/index.html
 
 Thanks a bunch,
 
 Mike
 
[[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 = length(x0))
Error in validObject(.Object) :
  invalid class “mle” object: invalid object for slot fullcoef in class
mle: got class list, should be or extend class numeric








2014-11-02 14:57 GMT-05:00 Bert Gunter gunter.ber...@gene.com:

 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, 2014 at 10:36 AM, li li hannah@gmail.com wrote:
  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 Error
  in eval(expr, envir, enclos) : argument is missing, with no default.
Could anyone familiar with this function give some suggetion? Thanks
 very
  much!
   Hanna
 
  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, nobs = length(x0))
 
  [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 http://www.r-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 GMT-05:00 li li hannah@gmail.com:

 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 = length(x0))
 Error in validObject(.Object) :
   invalid class “mle” object: invalid object for slot fullcoef in class
 mle: got class list, should be or extend class numeric
 
 






 2014-11-02 14:57 GMT-05:00 Bert Gunter gunter.ber...@gene.com:

 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, 2014 at 10:36 AM, li li hannah@gmail.com wrote:
  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
 Error
  in eval(expr, envir, enclos) : argument is missing, with no default.
Could anyone familiar with this function give some suggetion? Thanks
 very
  much!
   Hanna
 
  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, nobs = length(x0))
 
  [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 http://www.r-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.




[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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)) : spt is not a tis object

It puzzles me why you have not investigated an error message that seems quite 
informative. When I looked at the code of timeSeries::interpNA I was puzzled 
that the package seems to use timeSeries as the class name. This error 
reports a different class name, but it does seem that the function is designed 
to take only a particular set of intputs and yours fails that test.


 fut = interpNA(fut, method = c(linear))
 Error in interpNA(fut, method = c(linear)) : fut is not a tis object
 spt = ts(spt, start=c(2006,4), frequency=305)
 fut = ts(fut, start=c(2006,4), frequency=305)
 spt = interpNA(spt, method = c(linear))

So the lack of an error here suggests that a ts-object might be acceptable to 
the same function that you were asking about.


-- 
David.

 
 Would you please help me in this regard.
 
 With sincere regards,
 Upananda
 
 -- 
 
 
 You may delay, but time will not.
 
 
 Research Scholar
 alternative mail id: up...@iitkgp.ac.in
 Department of HSS, IIT KGP
 KGP
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.