similar to: why is sd(numeric(1))==NA (and not NaN)?

Displaying 20 results from an estimated 10000 matches similar to: "why is sd(numeric(1))==NA (and not NaN)?"

2005 Aug 13
1
retrieving large columns using RODBC
Hi, I have a large table in Postgresql (result of an MCMC simulation, with 1 million rows) and I would like to retrive colums (correspond to variables) using RODBC. I have a column called "index" which is used to order rows. Unfortunately, sqlQuery can't return all the values from a column at once (RODBC complains about lack of memory). So I am using the following code:
2004 Sep 15
3
getting started on Bayesian analysis
I am an economist who decided it's high time that I learned some Bayesian statistics. I am following An Introduction to Modern Bayesian Econometrics by T. Lancaster. The book recommends using BUGS, but I wonder if there are any alternatives which are free software and fully integrated to R (which I have been using for more than two years for numerical computations.) I would like to learn
2004 Jul 05
1
general questions about R on debian/powerpc
Hi, I am about to but a laptop, and have narrowed the choices down to a Dell Latitude 600 and an Apple Powerbook G4 Aluminium (Princeton provides these models at a discount for grad students). I am biased towards the Powerbook, and would like to run Debian on it. I have only used debian on i386 platforms so far. I use R quite frequently, so I would be interested in your experience of running R
2003 Apr 23
1
Setting up Xemacs + Sweave
Dear list, I have tried to setup my Xemacs for use with Sweave, which I indend to learn. I have followed the instructions in the Sweave FAQ, that is to say, I put (defun Rnw-mode () (require 'ess-noweb) (noweb-mode) (if (fboundp 'R-mode) (setq noweb-default-code-mode 'R-mode))) (add-to-list 'auto-mode-alist '("\\.Rnw\\'" . Rnw-mode)) (add-to-list
2006 Nov 19
2
good practice for values not provided
Hi, I am writing a collection of functions which I plan to share as a package later (when they are tested thoroughly), so I would like to do things "right" from the beginning... I encountered a minor question of style. Consider a function f <- function(a,b,x=NULL) { ## ... } if !is.null(x), f will use x to calculate the result, but if is.null(x), it will do something else not
2004 Sep 14
2
as.integer(TRUE)
The fact that as.integer(TRUE) is 1 (and that for FALSE, it gives zero) is a really nice feature, eg when constructing piecewise functions (for example, as in -x*(x<0)+x*(x>=0)) and for many other things. Since I haven't found a reference about this, I just wanted to ask whether this is officialy part of the language or just a side effect (ie I want to know whether it is here to stay
2006 Oct 27
1
making uniroot a bit more robust?
Hi, I wonder if it would make sense to make uniroot detect zeros at the endpoints, eg if f(lower)==0, return lower as the root, else if f(upper)==0, return upper as the root, else stop if f(upper)*f(lower) > 0 (currently it stops if >=), else proceed to the algorithm proper. Currently I am using a wrapper function to implement this, and I found it useful. But I didn't want to send a
2006 Nov 13
1
wishlist: xlim in lines.polynomial (PR#9362)
Full_Name: Tamas K Papp Version: 2.4.0 OS: linux Submission from: (NULL) (140.180.166.160) I was using the lines.polynomial method for plotting piecewise polynomials (parts of splines). I needed a feature to limit the range of plotting using a parameter given to the function (as opposed to par("usr")). I think that the following changes would be a nice addition: lines.polynomial
2003 Apr 17
1
Testing for whole numbers
Is there a way in R to test if a given number is an integer, ie a whole number? I am not referring to the data type of a number, but to its value. That is to say, is.whole(pi-pi+2) would be TRUE, whereas is.whole(4/3) would be false. At the moment I am using is.whole <- function(a) { floor(a)==a } which is OK for real numbers, but not for complex ones (a+bi would be a whole number if both a
2006 Dec 19
1
preserving sparse matrices (Matrix)
Hi, I have sparse (tridiagonal) matrices, and I use the Matrix package for handling them. For certain computations, I need to either set the first row to zero, or double the last row. I find that neither operation preserves sparsity, eg > m <- Diagonal(5) > m 5 x 5 diagonal matrix of class "ddiMatrix" [,1] [,2] [,3] [,4] [,5] [1,] 1 . . . . [2,] . 1
2004 Apr 07
1
eigenvalues for a sparse matrix
Hi, I have the following problem. It has two parts. 1. I need to calculate the stationary probabilities of a Markov chain, eg if the transition matrix is P, I need x such that xP = x in other words, the left eigenvectors of P which have an eigenvalue of one. Currently I am using eigen(t(P)) and then pick out the vectors I need. However, this seems to be an overkill (I only need a single
2006 Nov 10
2
R and Fortran 9x -- advice
Hi, I found some bottlenecks in my R code with Rprof. First I wanted to rewrite them in C, but a colleague keeps suggesting that I learn Fortran, so maybe this is the time to do it... I like to learn new languages and do it fairly quickly. I would appreciate the advice of others about these questions: 1) I hear bad things about Fortran. Sure, F77 looks archaic, but F90/95 seems nicer. Is it
2003 Jul 12
2
using cut on matrices
Dear list, I'd like to use the function cut() on matrices, ie that when I apply it to a matrix, it would return a matrix of the same dimensions instead of a vector. I wonder if there is a better (more elegant) solution than matrix(cut(a, ...), ncol=ncol(a), nrow=nrow(a)) because I would like to use cut on both vectors and matrices and avoid testing whether a is a matrix. Thanks, Tamas
2004 Apr 10
4
(offtopic) I need two sets of 5 different color scales
Hi, I am plotting a policy function (result from a dynamic stochastic optimization problem, discretized approximation). The policy function maps from an 2 x 2 x 2 x 3 x B x F state space to a B x F state space (B and F are usually between 4-6, and represent domestic and foreign savings. The other variables are income (Y), inflation (Pi), domestic and foreign interest rates (R and Z)). I
2003 Oct 01
3
fitting Markov chains
I need to find a computationally simple process for the movement of interest rates. In this simplified model, an interest rate can have 3--5 possible values, and its movement is characterized by a matrix of transition probabilities (ie, it is a Markov process). I would like to estimate this process from a given set of data. For example, let the interest rate time series be: 7 3 8 2 5 9 6
2003 Oct 06
1
visualizing transition probability matrices
Dear List, I have a couple of (~200) 3x3 transition probability matrices (ie each defines a Markov chain). They are all estimated from the same underlying process, so it ie meaningful to take their elemetwise mean and standard deviation. [1] First question: supposing that they are given in a list l, how do I get their elementwise mean and standard deviation? Fortunately, the mean of trans. prob.
2006 Nov 29
1
Matrix*vector: coercing sparse to dense matrix for arithmetic
Hi, I have a sparse Matrix (kronecker product of spline design matrices), and I need to multiply each row by a number to get another matrix. If the matrix is A and the numbers are stored in a vector k, with plain vanilla matrices I would do A*k But when using the Matrix package (class of A is "dgCMatrix"), I get the warning "coercing sparse to dense matrix for arithmetic".
2005 Aug 08
1
modifying argument of a .C call (DUP=FALSE)
I have a huge matrix on which I need to do a simple (elementwise) transformation. Two of these matrices cannot fit in the memory, so I cannot do this in R. I thought of writing some C code to do this and calling it using .C with DUP=FALSE. All I need is a simple for loop that replaces elements with their new value, something like void transform(double *a, int *lengtha) { int i; for (i=0;
2004 Apr 26
1
need settings for the listings package
Hi, I am typesetting R code in TeX using the listings package. I have experimented with various settings for the text, but all look a bit ugly. This might be because I have no typographic experience ;-) I would really appreciate if people sent me the settings they use for the listings package (eg in the \usepackage line, or \lstset, I am thinking about choices for basicstyle, ... etc). I
2004 Mar 31
2
array addition doesn't recycle!
Hi, I have noticed the following: > a <- array(1:4, c(2, 2)) > A <- array(1:4, c(2,2,2)) > A + a Error in A + a : non-conformable arrays It works with a matrix + a vector, why doesn't it work with arrays? Am I missing something? How would you do the above operation efficiently (ie I need to add a matrix to each "plane" of 3-dim array)? At the moment I am using