label = substitute(italic(p) == a, list(a=0.371) )
ggplot() + annotate('text', label=as.character(as.expression(label)), x=10, y=10, parse=T)
MATLAB applications, tutorials, examples, tricks, resources,...and a little bit of everything I learned ...
Tuesday, May 19, 2015
Wednesday, April 29, 2015
Relationship between Pearson correlation coefficient and the r-squared from linear regression
Simply put, if you take the square root of the r-squared value, which can be easily obtained in Excel, the outcome equals to the Pearson correlation coefficient.
Here's my R code to test this:
x<-rnorm c="" font="" nbsp="">-rnorm>
y<-rnorm c="" font="">-rnorm>
mdl <- font="" lm="" x="" y=""># linear regression model->
r = summary(mdl)$r.squared # the r-squared value from linear regression
rp = cor.test(x,y, method='pearson')$estimate # rp is the Pearson correlation coefficient
sqrt(r) == rp
Here's my R code to test this:
x<-rnorm c="" font="" nbsp="">-rnorm>
y<-rnorm c="" font="">-rnorm>
mdl <- font="" lm="" x="" y=""># linear regression model->
r = summary(mdl)$r.squared # the r-squared value from linear regression
rp = cor.test(x,y, method='pearson')$estimate # rp is the Pearson correlation coefficient
sqrt(r) == rp
Wednesday, February 11, 2015
Monday, October 13, 2014
R figure label expression with superscripts and greek letters
ylab=expression("UFP number concentration (# " ~ cm^{-3} ~ ")")
ylab=expression(paste (PM[2.5], "mass concentration (", mu, "g " ~ m^{-3} ~ ")"))
+labs(y=ylab)
ylab=expression(paste (PM[2.5], "mass concentration (", mu, "g " ~ m^{-3} ~ ")"))
+labs(y=ylab)
Monday, June 23, 2014
Annotating subscript in R plots
I need to annotate one of my figure like this:
(b) PM2.5
And this is a way to do it in R with ggplot2 package:
b <- b="" font="">->
annotate("text", x=-3.5, y=0.12, label=deparse(b),parse=TRUE)
Not sure about the details behind all the parameters though. Thanks to BondedDust for answering this question.
(b) PM2.5
And this is a way to do it in R with ggplot2 package:
b <- b="" font="">->
annotate("text", x=-3.5, y=0.12, label=deparse(b),parse=TRUE)
Not sure about the details behind all the parameters though. Thanks to BondedDust for answering this question.
Monday, January 13, 2014
Differentiate time-series data
Aim: to differentiate time-series data
and to check the effects of choosing different time interval
Contents
Initialization
clear all; close all; clc;
differentiate symbolic equation
syms x f=sin(x); fd=diff(f); ezplot(f,[0 2*pi]) hold on, h=ezplot(fd,[0 2*pi]); set(h,'Color','g') ylim([-1 1]) legend('sin(x)', 'deriv of sin(x)')
differentiate discret time-series data
Suppose these are measured data
timeInterval=0.01; t=0:timeInterval/pi:2*pi; y=sin(t); yd=diff(y)./(0.01/pi); figure(2),plot(t,y,'b.',t(1:end-1),yd,'g.') legend('sin(x)', 'deriv of sin(x)')
discret data, use larger time interval
Suppose these are measured data
timeIntervalL=0.2; tL=0:timeIntervalL/pi:2*pi; yL=sin(tL); ydL=diff(yL)./(timeIntervalL/pi); figure(3),plot(tL,yL,'b.',tL(1:end-1),ydL,'g.') legend('sin(x)', 'deriv of sin(x)')
overlay different simulations
figure(4) ezplot(fd),hold on plot(t(1:end-1),yd,'bo'); plot(tL(1:end-1),ydL,'ro'); xlim([0 2*pi])
Saturday, January 4, 2014
Data and Questions: regression with factor variables
I was taking the Data Analysis course by Jeff Leek on CourseEra.org. The video ' Regression with Factor Variables' was very useful to me. However, I am a Matlab guy and don't like R very much. So I did all the analysis in Matlab. The code is published here:
http://matlabnewbie.blogspot.com/2014/01/matlab-code-regression-with-factor.html
and here's the video.
http://matlabnewbie.blogspot.com/2014/01/matlab-code-regression-with-factor.html
and here's the video.
Subscribe to:
Posts (Atom)
my-alpine and docker-compose.yml
``` version: '1' services: man: build: . image: my-alpine:latest ``` Dockerfile: ``` FROM alpine:latest ENV PYTH...
-
It took me a while to figure out how to insert a space in Mathtype equations. This is especially useful when you write an equation with mult...
-
In this post, I am trying to solve the problem given in the comments of one of the old post. Here's the problem, if I understand it co...
-
Recently I got a very long column of data and it contains lots of NaN. I found the finite function very useful to help me remove all the NaN...