[R] Correlation question

2015-02-21 Thread Jonathan Thayn
I recently compared two different approaches to calculating the correlation of two variables, and I cannot explain the different results: data(cars) model - lm(dist~speed,data=cars) coef(model) fitted.right - model$fitted fitted.wrong - -17+5*cars$speed When using the OLS fitted values, the

Re: [R] Correlation question

2015-02-21 Thread Jonathan Thayn
cor(cars$dist,fitted.right)^2 and cor(x=cars$dist,y=fitted.wrong)^2 must be the same. HTH d Feladó: R-help [r-help-boun...@r-project.org] ; meghatalmaz#243;: Jonathan Thayn [jth...@ilstu.edu] Küldve: 2015. február 21. 22:42 To: r-help@r

Re: [R] Using PCA to filter a series

2014-10-04 Thread Jonathan Thayn
This is exactly what I was looking for. Thank you. Jonathan Thayn On Oct 3, 2014, at 10:32 AM, David L Carlson wrote: You can reconstruct the data from the first component. Here's an example using singular value decomposition on the original data matrix: d - cbind(d1, d2, d3, d4

[R] Using PCA to filter a series

2014-10-02 Thread Jonathan Thayn
I have four time-series of similar data. I would like to combine these into a single, clean time-series. I could simply find the mean of each time period, but I think that using principal components analysis should extract the most salient pattern and ignore some of the noise. I can compute

Re: [R] Using PCA to filter a series

2014-10-02 Thread Jonathan Thayn
a long time since I've played with PCA. Jonathan Thayn On Oct 2, 2014, at 4:59 PM, David L Carlson wrote: I think you want to convert your principal component to the same scale as d1, d2, d3, and d4. But the original space is a 4-dimensional space in which d1, d2, d3, and d4 are the axes

[R] Multimodal multidimensional optimization

2013-10-18 Thread Jonathan Thayn
Hello all I've been performing a series of multidimensional optimizations (3 variables) using the optima() function. Recently, I noticed that the solution is rarely unimodal. Is there a package or function that handles multimodal multidimensional optimizations? I really appreciate any

[R] Discrepancy with p.value from t.test

2011-11-01 Thread Jonathan Thayn
Sometimes the p.value returned by t.test() is the same that I calculate using pt() and sometimes it's not. I don't understand the difference. I'm sure there is a simple explanation but I haven't been able to find it, even after looking at the code for t.test.default. I apologize if this is a