Skip to content

{ Category Archives } English

My first wp plugin work: LaTeX_Math_cgi 1.0

Download: LaTeX_Math_cgi.zip
Install: Download  and unzip it to your wordpress’ /wp-content/plugins/ directory.
Activate it in Plugins menu. View its options in Options > LaTeX tab –
It is actually used as a mimeTeX plugin rather than just a plugin. My contribution is technically trivial. But, you must need it if you change from a light theme to [...]

Tagged ,

Understanding QQ plots

## Try distributions like rchisq, rt, runif, rf to view its heavy, or light, left, or right tail.

n <- 30;
ry <- rnorm(n);
qqnorm(ry);qqline(ry);
max(ry)
min(ry)
##view and guess what are x(s) and y(s)
I <- rep(1,n);
qr <- ((ry%*%t(I) > I %*% t(ry))+.5*(ry %*% t(I) == I%*%t(ry)))%*%I *(1/n);##qr are the sample quantiles
points(qr,ry,col=”blue”); ##to view the fact, try the following
points(qr,qr*0,col=”green”,pch=”|”);
rx <- qnorm(qr);
points(rx,ry,col=”red”,pch=”O”);
##Red [...]

Tagged ,

03DEC2007 R-workshop sponsored by dept of psy, ZSU(=SYSU, Guang-Zhou)

Here is the updated PPT for the talk in the afternoon–which includes the zipped example codes and set-up steps for the workshop in the evening within the 3rd page. The listed anonymous on-line test (result statistics) on p-value interpretation was cited indirectly From Gigerenzer, Krauss, & Vitouch (2004).
There is an advert on http://www.psy.sysu.edu.cn/detail_news.asp?id=258 and a [...]

Tagged

Classic Neyman-Pearson approach demo

It notes here that N-P approach does not utilize the information in the accurate p value. Actually, at the time N-P approach was firstly devised, the accurate p value was not available usually. Now almost all statistic softwares provide accurate p values and the N-P approach becomes obsolete. Wilkinson & APA TFSI (1999) [...]

Tagged ,

Different corr(s) of different IV scopes with same regression coef

With known in the linear relationship, can the correlation in the scatter plot of Y against X be estimated from the linear formula?
You may recall in Hierarchical Linear Model class, the scopes of the W dramatically impact the regression coefficients of F~W in the following R demo (hlm.jpg). While this time the regression [...]

Tagged ,

“Effect Size” — same data, different interpretations

d<-32; ## Try d<-20 !
## to reduce the death rate by d%, From (50+d/2)% to (50-d/2)%
y<-c(rep(”Live”,50+d/2),rep(”Death”,50-d/2));
y<-c(y,rep(”Live”,50-d/2),rep(”Death”,50+d/2));
y<-(y==”Live”); ## TRUE vs FALSE
x<-c(rep(”Treatment”,100),rep(”Control”,100));
x<-(x==”Treatment”);
## correlation^2
cor(x,y,method=”pearson”)^2
cor(x,y,method=”spearman”)^2
cor(x,y,method=”kendall”)^2
## R^2 of linear regression with norminal IV
## should we use logistic regression?
## However, R^2 is not available in GLM.
## summary(lm(y~x))
## names(summary(lm(y~x)))
summary(lm(y~x))$r.squared
## anova
## anova(lm(y~x))
## names(anova(lm(y~x)))
s<-anova(lm(y~x))$”Sum Sq”;s[1]/sum(s)

Just a short R-script note to embody the 3-page-paper of [...]

Tagged , ,

Anscombe’s 4 Regressions — A Trivially Updated Demo

##———-
## This is a trivially updated version based on the R document “?anscombe”.
require(stats); require(graphics)
anscombe
##– now some “magic” to do the 4 regressions in a loop:##< -
ff = y ~ x
for(i in 1:4) {
ff[2:3] = lapply(paste(c(”y”,”x”), i, sep=””), as.name)
assign(paste(”lm.”,i,sep=””), lmi <- lm(ff, data= anscombe))
}
## See how close they are (numerically!)
sapply(objects(pattern=”lm\\.[1-4]$”), function(n) coef(get(n)))
lapply(objects(pattern=”lm\\.[1-4]$”),
function(n) [...]

Tagged , ,

Understanding the nominal IV

n=10000;r=0.6;r_e=(1-r*r)^.5;
X=rnorm(n);
Y=X*r+r_e*rnorm(n);
Z=as.integer(X>0);
Y=Y*Z+(-Y)*(1-Z);
Z=as.factor(X>0); ## norminal IV
##Red (totally covered by Green) : Y~X
##Green: Y~X+Z Blue: Y~X+Z+X:Z
##Brown: X~Y+Z Yellow: X~Y+Z+Y:Z
plot(X,Y);
points(X,predict(lm(Y~X)),col=”red”);
points(X,predict(lm(Y~X+Z)),col=”green”);
points(X,predict(lm(Y~X+Z+X:Z)),col=”blue”);
points(predict(lm(X~Y+Z)),Y,col=”brown”);
points(predict(lm(X~Y+Z+Y:Z)),Y,col=”yellow”);

Tagged ,

R: Simulating multiple normal distribution with any given corr matrix

For example , we have a corr matrix for five standardized factors (Hau, Chinese Textbook, pp. 49-50).
m_corr=c(1, .42, .41, .55, .42);
m_corr=cbind(m_corr, c(.42, 1,.48, .47, .46));
m_corr=cbind(m_corr, c(.41, .48,1, .48, .44));
m_corr=cbind(m_corr, c(.55, .47,.48, 1, .50));
m_corr=cbind(m_corr, c(.42, .46,.44, .50, 1));
m_corr;
## show the original corr matrix
dp=svd(m_corr);
plot(dp$d,type=”o”); ## show the scree plot if there is a PC analysis
diag(dp$d); ## [...]

Tagged , ,

The tail(s) of p value

For any given vs , the p value of any given point x is , Where
– See R. Weber’s Statistics Note (Chap 6.2 & 7.1)
I made some wrong comment on the pdf Null Ritual (Gigerenzer, Krauss, & Vitouch, 2004) Where three types of significance level (rather than p value) were discussed. I had [...]

Tagged ,