Publications by anspiess

Don’t recycle me!

19.06.2012

For me, one of the most annoying features of R is that by default, rbind,  cbind  and data.frame recycle the shorter vector to the length of the longer vector. I still don’t understand why the standard generics don’t have a parameter like cbind(1:10, 1:5, fill = TRUE) to fill up with ‘NA’s. There may be a deeper reason… > cbind(1:10, ...

1158 sym R (14393 sym/6 pcs) 4 img

A better ‘nls’ (?)

05.07.2012

Those that do a lot of nonlinear regression will love the nls function of R. In most of the cases it works really well, but there are some mishaps that can occur when using bad starting values for the parameters. One of the most dreaded is the “singular gradient matrix at initial parameter estimates” which brings the function to a stop becaus...

3453 sym R (1042 sym/5 pcs) 4 img

A weighting function for ‘nls’ / ‘nlsLM’

19.07.2012

Standard nonlinear regression assumes homoscedastic data, that is, all response values are distributed normally.  In case of heteroscedastic data (i.e. when the variance is dependent on the magnitude of the data), weighting the fit is essential. In nls (or nlsLM of the minpack.lm package), weighting can be conducted by two different methods: 1)...

2210 sym R (2647 sym/5 pcs) 26 img

Peer-reviewed R packages?

22.11.2012

Dear R-Users, a question: I am the author of the ‘qpcR’ package. Within this, there is a function ‘propagate’ that does error propagation based on Monte Carlo Simulation, permutation-based confidence intervals and Taylor expansion. For the latter I recently implemented a second-order Taylor expansion term that can correct for nonlinearity...

3215 sym 4 img

The magic empty bracket

30.01.2013

I have been working with R for some time now, but once in a while, basic functions catch my eye that I was not aware of… For some project I wanted to transform a correlation matrix into a covariance matrix. Now, since cor2cov does not exist, I thought about “reversing” the cov2cor function (stats:::cov2cor). Inside the code of this function...

1075 sym R (547 sym/5 pcs) 8 img

bigcor: Large correlation matrices in R

22.02.2013

As I am working with large gene expression matrices (microarray data) in my job, it is sometimes important to look at the correlation in gene expression of different genes. It has been shown that by calculating the Pearson correlation between genes, one can identify (by high values, i.e. > 0.9) genes that share a common regulation mechanism such...

3282 sym R (4930 sym/4 pcs) 10 img

wapply: A faster (but less functional) ‘rollapply’ for vector setups

23.04.2013

For some cryptic reason I needed a function that calculates function values on sliding windows of a vector. Googling around soon brought me to ‘rollapply’, which when I tested it seems to be a very versatile function. However, I wanted to code my own version just for vector purposes in the hope that it may be somewhat faster. This is what tur...

1362 sym R (1282 sym/4 pcs) 4 img

Trivial, but useful: sequences with defined mean/s.d.

31.07.2013

O.k., the following post may be (mathematically) trivial, but could be somewhat useful for people that do simulations/testing of statistical methods. Let’s say we want to test the dependence of p-values derived from a t-test to a) the ratio of means between two groups, b) the standard deviation or c) the sample size(s) of the two groups. For th...

1775 sym R (272 sym/3 pcs) 14 img

predictNLS (Part 1, Monte Carlo simulation): confidence intervals for ‘nls’ models

14.08.2013

Those that do a lot of nonlinear fitting with the nls function may have noticed that predict.nls does not have a way to calculate a confidence interval for the fitted value. Using confint you can obtain the error of the fit parameters, but how about the error in fitted values? ?predict.nls says: “At present se.fit and interval are ignored.” W...

4617 sym R (3091 sym/1 pcs) 58 img

predictNLS (Part 2, Taylor approximation): confidence intervals for ‘nls’ models

26.08.2013

Initial Remark: Reload this page if formulas don’t display well! As promised, here is the second part on how to obtain confidence intervals for fitted values obtained from nonlinear regression via nls or nlsLM (package ‘minpack.lm’). I covered a Monte Carlo approach in http://rmazing.wordpress.com/2013/08/14/predictnls-part-1-monte-carlo-si...

3895 sym R (6484 sym/4 pcs) 32 img