メイン intraclass-corr.html Last modified: Sep 01, 2009
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;CHARSET=EUC-JP">
<link rel="shortcut icon" href="../favicon.ico">
<title>JavaScript</title>
<script src="fxp.js">document.write("fxp.js ファイルが見つかりません??<br>")</script>
<script src="io.js">document.write("io.js ファイルが見つかりません??<br>")</script>
<script language="JavaScript">
<!--
function compareNumbers(a, b) {
// return a - b
if (a > b) return 1
else if (a == b) return 0
else return -1
}
function getmean(ng, nc, ns, means, group, datax)
{
var i, j, gmean = 0
for (i = 0; i < ng; i++) {
ns[i] = means[i] = 0
}
for (i = 0; i < nc; i++) {
j = group[i]
ns[j]++
means[j] += datax[i]
gmean += datax[i]
}
for (j = 0; j < ng; j++) {
means[j] /= ns[j]
}
return gmean/nc
}
function anova(ng, nc, key, group, datax)
{
var ns = new Array(ng)
var means = new Array(ng)
var vars = new Array(ng)
var gmean, gvar = 0, sw = 0, sb, st, vb, vw, dfb, dfw, f, p, term1, term2, chi, zerovar = false, i, j, rep, rep2
gmean = getmean(ng, nc, ns, means, group, datax)
for (j = 0; j < ng; j++) {
vars[j] = 0
}
for (i = 0; i < nc; i++) {
j = group[i]
vars[j] += Math.pow(datax[i]-means[j], 2)
gvar += Math.pow(datax[i]-gmean, 2)
}
for (j = 0; j < ng; j++) {
sw += vars[j]
if ((vars[j] = (ns[j] <= 1) ? 0 : vars[j]/(ns[j]-1)) == 0) {
zerovar = true
}
}
st = gvar
sb = st-sw
dfb = ng-1
dfw = nc-ng
vb = sb/dfb
if (dfw < 1) {
printf("各群に一個ずつのデータしかないので,計算できません。\n\n")
return
}
vw = sw/dfw
if (vw <= 0) {
printf("計算できません。データが変です。\n\n")
return
}
f = vb/vw
p = fxp(f, dfb, dfw)
printf("%10s %13s %12s %15s %15s\n", "群変数の値", "データの個数", "平均値", "不偏分散", "標準偏差")
for (j = 0; j < ng; j++) {
printf("%10s %10i %15.6g %15.6g %15.6g\n", key[j], ns[j], means[j], vars[j], Math.sqrt(vars[j]))
}
printf("%10s %10i %15.6g %15.6g %15.6g\n\n", "全体", nc, gmean, gvar/(nc-1), Math.sqrt(gvar/(nc-1)))
sep(50)
printf("分散分析表\n\n")
printf("%4s %10s %7s %10s %10s %9s\n", "要因", "平方和", "自由度", "平均平方", "F 値", "P 値")
printf("%4s %10.6g %7i %10.6g %10.5f %9.5f\n", "群間", sb, dfb, vb, f, p)
printf("%4s %10.6g %7i %10.6g\n", "群内", sw, dfw, vw)
printf("%4s %10.6g %7i %10.6g\n", "全体", st, nc-1, gvar/(nc-1))
sep(50)
rep = rep2 = 0
for (j = 0; j < ng; j++) {
rep += ns[j]
rep2 += ns[j] * ns[j]
}
rep = (rep - rep2 / rep) / (ng - 1)
printf("級内相関係数 = %g\n", (vb - vw) / (vb + (rep - 1) * vw))
sep2(50)
}
function calc(data_string)
{
var data, nc, i, j, ng = 0
var group = new Array()
var datax = new Array()
var key = new Array()
printf("★ 一元配置分散分析 ★\n\n")
if ((data = getdata(data_string, 2)) == false) return
nc = data.length
for (i = 0; i < nc; i++) {
key[ng++] = group[i] = data[i][0]
for (j = 0; j < ng; j++) {
if (key[j] == group[i]) {
if (j < ng-1) {
ng--
}
break
}
}
datax[i] = data[i][1]
}
if ((key.length = ng) == 1) {
printf("群の数が1です。検定できません。\n")
return
}
key.sort(compareNumbers)
for (i = 0; i < nc; i++) {
for (j = 0; j < ng; j++) {
if (group[i] == key[j]) {
group[i] = j
break
}
}
}
anova(ng, nc, key, group, datax)
}
//-->
</script>
</head>
<body bgcolor="#ffffff">
<font size="+2"><b>生データに基づく級内相関係数</b></font> <a href="src/intraclass-corr.html"><img src="png/src.png" width=35 height=11 alt="src" align=top></a> Last modified: Jun 01, 2006<hr noshade><p>
<font color="#ff0000" size="+2">以下のプログラムのサポートは終了しました。自己責任でお使い下さい。</font>
<form name=Result>
<script language="JavaScript">
<!--
//-->JavaScript がサポートされていないブラウザですか?
</script>
入力データに基づき,級内相関係数を計算する。<br>
<img src="../gra/button3.png" width=9 height=9 alt="・"> <a href="exa/intraclass-corr.html">使用法</a>
<hr>
<table><tr>
<td><input type="button" name="calcurate" value="計算開始" onClick="calc(this.form.data.value)"> </td>
<td><input type="button" name="clear" value="入力欄クリア" onClick="this.form.data.value=''"> </td>
<td><input type="button" name="clear" value="出力欄クリア" onClick="this.form.result.value=''"></td>
</tr></table>
<p>
<table><tr>
<td>入力欄<br><textarea name="data" ROWS=25 COLS=15></textarea></td>
<td>出力欄<br><textarea name="result" ROWS=25 COLS=80></textarea></td>
</tr></table>
</form>
<p><hr noshade>
<img src="../gra/button3.png" width=9 height=9 alt="・"> <A HREF="javascript:history.go(-1)">直前のページへ戻る</A> <img src="../gra/button3.png" width=9 height=9 alt="・"> <a href="../mail.html">E-mail to Shigenobu AOKI</a>
<p><IMG SRC="../gra/ume5.png" width=121 height=37 ALT="Made with Macintosh">
</body>
</html>
サブ fxp.js Last modified: Mar 25, 2004
サブ io.js Last modified: Mar 25, 2004
直前のページへ戻る E-mail to Shigenobu AOKI