Friday, September 23, 2005

using R : regression test - 회귀분석에 대한 모의실험

y=a+bx+e
x=1:n
y=alpha+beta*x+rnorm(n)
>lm.out=lm(y~x)
#lm.out 은 lm()에 의해 생성된 객체, 적합된 결과는 객체인 lm.out을 summary()함수의 매개변수로 지정함으로써 확인가능
>summary(lm.out)
#회귀계수들의 추정값은 lm.out$coefficients
>lm.out$coefficients
#추정된 회귀계수들의 분산값은 vcov()함수를 이용
>var=vcov(lm.out)
>var
>var[1,1]

#Reg.confidence=function(nt,n,beta)
#beta = vector of true regression coeff
#nt=No.of replication
#n=sample size
{win.graph()
par(mfrow=c(2,1))
mtitle=c("Intercept","Slope")
x=1:n
Exb=beta[1]+beta[2]*x
t.val=qt(0.975,n-2)
trial.a=trial.b=rep(0,nt)

for(i in 1:nt)
{ y=Exb+rnorm(n)
lm.out=lm(y~x)
std=sqrt(diag(vcov(lm.out))
if(abs(lm.out$coefficients[1]-beta[1])if(abs(lm.out$coefficients[2]-beta[2])}
trial.a=cumsum(trial.a)/1:nt
plot(trial.a,type="l",main=mtitle[1],ylim=c(0.9,1))
abline(0.95,0)
trial.b=cumsum(trial.b)/1:nt
plot(trial.b,type="l",main=mtitle[2],ylim=c(0.9,1))
abline(0.95,0)
}

Thursday, September 22, 2005

R로 Least Square Means 구현하기

sas에서는 lsmeans가 함수처럼 주어지는데 R에서는 gls()가 사용할 수 없게 되어있다.
source를 어디서 구한담...
r-project로 가봐야 한다는 말인가?

Monday, September 12, 2005

Luke 18 : A rich and young ruler came to Jesus

A certain ruler asked him, "Good teacher, what must I do to inherit eternal life?"
"Why do you call me good?" Jesus answered. "No one is good--except God alone.
You know the commandments: 'Do not commit adultery, do not murder, do not steal, do not give false testimony, honor your father and mother.'"
"All these I have kept since I was a boy," he said.
When Jesus heard this, he said to him, "You still lack one thing. Sell everything you have and give to the poor, and you will have treasure in heaven. Then come, follow me."
When he heard this, he became very sad, because he was a man of great wealth.
Jesus looked at him and said, "How hard it is for the rich to enter the kingdom of God!
Indeed, it is easier for a camel to go through the eye of a needle than for a rich man to enter the kingdom of God."
Those who heard this asked, "Who then can be saved?"
Jesus replied, "What is impossible with men is possible with God."

Friday, September 09, 2005

I want to Leave, ...

The world is a book, and those who do not travel, read only a page.
(Saint Augustine)

Thursday, September 08, 2005

國家

플라톤
2권을 막 넘기다