Skip to content

{ Author Archives }

DV predicted by two IVs, vs. triangular pyramid

-- Diagram from Wiki
It is easier to imagine relation in three spatial vectors by their angles, than by their correlations. For standardized and s , , cosines of three angles of the triangular pyramid determinate the correlation matrix, thus, all statistics of the regressions and . Unexpected but imaginative results on [...]

Tagged , ,

Correction: the convenient radius for 95% confidence interval of t-test

-- What do you call a tea party with more than 30 people? 
-- A Z party!!! 
Joke #123 on http://www.ilstu.edu/~gcramsey/Gallery.html
2*SE is a popular convenient radius to eye 95% CI for t-test. Statisticians take t with df>=30 as z. However, I was incorrect to teach that 1.96*SE could be the precise radius when df>=30.
Guess what is [...]

Tagged

R: str(…) 与 getS3method(…,…)

感谢R专家XIE Yihui同学在线答疑

me: 请教两个R的技术:1.R中有没有对象浏览器之类的工具?一举看完一个对象的子子孙孙 2.怎么看深入的源代码> prcomp
function (x, ...)
UseMethod("prcomp")
<environment: namespace:stats>
Yihui: 1. str()是很常用的一个函数,它可以充分查看对象的子子孙孙 2. 很多函数要么是S3 method,要么是调用C code,所以一般不能直接看源代码
S3 method可以用getS3method()去查看,比如prcomp就是S3方法,那么可以看它的default方法是什么:
> getS3method('prcomp','default')
function (x, retx = TRUE, center = TRUE, scale. = FALSE, tol = NULL,
...)
{
x <- as.matrix(x)
x <- scale(x, center = center, scale = scale.)
cen <- attr(x, "scaled:center")
sc <- attr(x, "scaled:scale")
if (any(sc == 0))
stop("cannot rescale a constant/zero [...]

Tagged ,

Unexpectedly, the theoretically best reject-region of T-test is bounded.

For NHST vs , theoretically, is s.t. , rather than zero. Nevertheless, pratically a large t, rejecting both and , should not be counted as any evidence to retain or reject .
To verify the shape of --

x<- 0.1*(-1000:1000);
plot(x,y=dt(x-1,df=5,ncp=0)/dt(x,df=5,ncp=0),type="l");
###compare to the noncetrality case--
plot(x,y=dt(x,df=5,ncp=1)/dt(x,df=5,ncp=0),type="l",col='green');

Tagged

Confidence Region and Not-reject Region

Either Confidence Interval (CI) or Null Hypothesis Significance Test (NHST) has the same business, to advise whether some sample is or is not disliked by some hypothesized parameter .
NHST.com manages a database. For each Miss , NHST spies out all she dislikes. Mr X logs in NHST.com and inputs a girl name [...]

Tagged

Automatize LISREL jobs

LISREL routine can run in DOS or in command line mode of windows (windows-key + R -> CMD) . The command line is just like --
D:\My Documents>"C:\Program Files\lisrel87\lisrel87.exe" "C:\Program Files\lisrel87\LS8EX\EX61.LS8" D:\myOutput.out
1. You only need edit and input the bold part.
2. Quotation marks are used wherever the paths or filenames include blanks.
3. The 2nd argument is [...]

Tagged ,

Developing normal pdf from symmetry & independence

When I was in the 3rd grade of my middle school, I enjoyed my town bookstore as a standing library. There a series of six math-story books by Zhang Yuan-Nan impressed me a lot. I cited a case from one in my PPT when I taught the normal distribution -- the normal pdf [...]

Tagged

[二度更新并推荐]愉快地发现SciTE和LyX在WinXP下都支持中文

愉快地发现我在WinXP上最常用的编辑工具SciTE(当前版本1.75) 和 LyX(当前版本1.5.3) 都支持unicode(也就是说,支持中文)。之前不了解,只因为缺省设置不支持中文。需要手工操作修改设置。
SciTE的设置是Options->Open Global Options File,编辑SciTEGlobal.properties,找到如下段落
# Unicode
#code.page=65001
code.page=0
#character.set=204
# Required for Unicode to work on GTK+:
#LC_CTYPE=en_US.UTF-8
#output.code.page=65001
修改为
# Unicode
code.page=65001
#code.page=0
character.set=204
# Required for Unicode to work on GTK+:
LC_CTYPE=en_US.UTF-8
output.code.page=65001
保存。然后关闭再打开SciTE,就会发现不再出现中文被切一半的现象。如果编辑的文档格式不是utf-8而是ucs-2 ,还可以在File->Encoding 里临时选。
[update] 除了utf-8, SciTE 还支持国内更常用的GBK码,设置如下:
code.page=936
output.code.page=936
character.set=134
此外,我还推荐把SciTEGlobal.properties文件中的line.margin.visible=1 和 wrap=1 两处的注释#号去掉,效果是缺省显示行号,并使超长的行折行显示。SciTE的优点太多了--开源免费;轻巧,启动快;支持Ctrl+鼠标中轮滚动无级缩放;支持Ctrl+回车 前文已出现过的拼写自动补齐选项;支持Alt键方形选段;...
LyX(版本>=1.5.1)在winXP已经可以在.lyx文件正文和公式框中录入中文。麻烦的是输出中文的pdf。[UPDATED update]LyX的最新版本(1.6.2)捆绑MikTeX的安装包已经对中文(unicode)支持得很好了。感谢楼下joomlagate先生email给我的情报:http://cohomo.blogbus.com/logs/31361739.html 的后半篇介绍了通过XeTeX输出pdf的简单设置。我今天试了一下,效果非常理想。
[update]公式框中的中文只需要再ctrl-M一次即可。例如,\frac{\mbox{分子}}{\mbox{分母}}可以输出,而\frac{分子}{分母}不行。
新版本LyX已经引入了文档版本控制,相当于word中的revision功能,有待深入试用。目前LyX仍不[update]已经支持Ctrl+鼠标中轮滚动无级缩放,如果公式显得太小,需要在菜单设置中修改显示缩放比例:Tools->Preferences->Look and feel->Screen fonts->Zoom %。这可能是比较容易在后续版本中实现的功能。
相关网址:
SciTE主页 http://www.scintilla.org/SciTE.html
LyX主页 http://lyx.org/
南开MiKTeX中文插件 http://miktex.math.nankai.edu.cn/

LyX中设置XeTeX中文支持的介绍: http://cohomo.blogbus.com/logs/31361739.html
我为Wordpress / Wordpress MU 系列平台制作的支持暗背景LaTeX小插件 http://lixiaoxu.lxxm.com/latex_math_cgi

Tagged , ,

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 ,