OLSããé²ãã çµ±è¨ææ³ã§æåã«è¦ããã®ã¯æå°¤æ³ã ã¨æãã¾ãã大åã®äººã¯ãã¼ã«ã¨ãã¦ç¥ã£ã¦ãã¦ããã¾ãä¸èº«ãæèãã¦ããªãæ°ãããã®ã§ãããã尤度ãã®èª¬æç¡ãã§ã尤度ãæ大ã«ãªããã©ã¡ã¼ã¿ã¼ãæ±ããæ¹æ³ãã¨è¨ã説æã横è¡ãã¦ããã®ã¯ãåé¡ãããããç¥ãã¾ããã
æå°¤æ³ã¯ãããåå¸ãã観測å¤ãåãåºãããã¨ãã¦ãâãããªã確çâãæãé«ããªãããã«åå¸ã®å
·ä½çãªå½¢ç¶ã決ããããæ¹ã§ããâãããªã確çâã尤度ã¨è¨ãã¾ããããæ¸ãã¨æããäºãªã®ãé£ããäºãªã®ãå¤å¥ãã¤ããªãã¨æãã®ã§ãå®éã«æå°¤æ³ã解ãã¦ã¿ã¾ãããã
ã¾ããä½ãèããã«ãã©ã¤ï¼ã¨ã©ã¼ã§æå°¤æ³ã試ã¿ãããæ¹ã説æããå¾ã«ãæç§æ¸çãªæå°¤æ³ã®è§£æ³ã説æãã¾ãã
1. ä½ãèããã«ãã©ã¤ï¼ã¨ã©ã¼ã§æå°¤æ³ã試ã¿ã
ããæ£è¦åå¸ããå¤ã3ã¤åãåºãããã11 13 23ã ã£ãã¨ãã¾ãããããã®ãµã³ãã«ãâãã£ã¨ããããâæ£è¦åå¸ã®å¹³åã¨åæ£ã¯ä½ã«ãªãã§ãããããâãã£ã¨ããããâç¨åº¦ãå観測å¤ãæ½åºããã確çãä¹ããåæ確çã ã¨å®ç¾©ããããã尤度ã¨å¼ã¶ãã¨ã«ãã¾ãã
Rã§å¹³å15ãåæ£40ã®æ£è¦åå¸ã®å°¤åº¦ãè¨ç®ããã¨ã次ã®ããã«ãªãã¾ãã
# 観測å¤ã®ã»ãã x <- c(11, 13, 23) # å¹³å15ãåæ£40ã®æ£è¦åå¸ãã観測å¤ããããã観測ããã確çãè¨ç® p <- dnorm(x, mean=15, sd=sqrt(40)) # 確çãä¹ãã¦ãåæ確çã«ãã print(paste("尤度:", prod(p)))
å¹³åã¨åæ£ãå±±åã§æ±ºãã¦å°¤åº¦ãæ±ãã¦ããã¾ãããã
å¹³å | åæ£ | 11ã®ç¢ºç | 13ã®ç¢ºç | 23ã®ç¢ºç | 尤度ï¼ï¼åæ確çï¼ |
---|---|---|---|---|---|
15 | 40 | 0.053 | 0.061 | 0.027 | 0.000085708 |
15 | 41 | 0.053 | 0.060 | 0.027 | 0.000084767 |
15 | 42 | 0.052 | 0.059 | 0.027 | 0.000083807 |
16 | 40 | 0.048 | 0.058 | 0.032 | 0.000088955 |
16 | 41 | 0.048 | 0.057 | 0.032 | 0.000087899 |
16 | 42 | 0.047 | 0.056 | 0.032 | 0.000086830 |
17 | 40 | 0.042 | 0.053 | 0.038 | 0.000085708 |
17 | 41 | 0.042 | 0.053 | 0.038 | 0.000084767 |
17 | 42 | 0.042 | 0.052 | 0.038 | 0.000083807 |
ããã§ã®å°¤åº¦ã¯(11ã®ç¢ºç)Ã(13ã®ç¢ºç)Ã(23ã®ç¢ºç)ã«ãªãäºã«æ³¨æãã¦ãã ãããå¹³åã15ã§åæ£ã40ã®æ£è¦åå¸ã§ããã°ã11ã¯0.053ã13ã¯0.061ã23ã¯0.027ã®ç¢ºçã§çºçããã®ã§ã尤度ã¯ããããä¹ãã¦0.000085708ã«ãªãã¾ãã
å¹³åã16ãåæ£ã40ã®æã§å°¤åº¦ãæ大ã«ãªãã¾ããã試ããç¯å²ã§ã¯ããããâãã£ã¨ããããâæ£è¦åå¸ã®å¹³åã¨åæ£ã¨ãªãã¾ãã観測ããããµã³ãã«ã®å¤ã¯åºå®ï¼11ã13ã23ï¼ã«ãªãã®ã§ã尤度é¢æ°ã¯å¹³åã¨åæ£ã®é¢æ°ã«ãªãã¾ãã
2. 尤度é¢æ°ã対æ°å°¤åº¦é¢æ°ãä¸éæ¡ä»¶ããæå°¤æ³ã試ã¿ã
å®éã¯æå½ãã次第ã«ãã©ã¡ã¼ã¿ã¼ï¼å¹³åã¨åæ£ï¼ã®çµã¿åããã試ãããã«ã¯ãããªãã®ã§ã尤度é¢æ°ã®å¯¾æ°ãã¨ã£ã¦å¯¾æ°å°¤åº¦é¢æ°ã«ããå¾ã«ã対æ°å°¤åº¦é¢æ°ããã©ã¡ã¼ã¿ã¼ã§ããããå¾®åãã¦é£ç«æ¹ç¨å¼ã«ããå¾ã«ãæ°å¤è§£æã¢ã«ã´ãªãºã ã使ã£ã¦ãã£ãã¨è¨ç®ãã¾ãã
尤度é¢æ°ã¯å¹³åã¨åæ£ããã©ã¡ã¼ã¿ã¼ã¨ããåæ確çã¨ãªãã¾ãããã以ä¸ã®ããã«ãªãã¾ãï¼ãçµæ¸çµ±è¨è£è¶³è³æ#27ï¼æå°¤æ¨å®éã®å°åºããã転è¼ï¼ãè¦ããã«æ£è¦åå¸ã«ããåæ確çã®è¨ç®å¼ã§ããã
ãã®ã¾ã¾ã ã¨è¨ç®ãé£ããã®ã§å¯¾æ°åãã¾ãã
対æ°åããã¾ã¾ã ã¨ã³ã³ãã¥ã¼ã¿ã¼ã¯è¨ç®ã§ããªãã®ã§ãåå¾®åãã¦ä¸éã®æ¡ä»¶ãæ´çãã¾ãã
ãã®é£ç«æ¹ç¨å¼ããã¥ã¼ãã³ã»ã©ãã½ã³æ³ã®ãããªæ°å¤è§£æã¢ã«ã´ãªãºã ã§è§£ãã¾ããæ£è¦åå¸ã®å ´åã¯ãæ´çããã¨æè¨ç®å¯è½ãªãããã·ã³ãã«ãªæ¹ç¨å¼ã«ãªãã¾ããã試ãã«ã³ã¼ããæ¸ãã¦ã¿ã¾ãããã
# ãµã³ãã« x <- c(11, 13, 23) # x <- rnorm(300, mean=15, sd=10) çã§ãè¨ç®ã§ãã n <- length(x) # é£ç«æ¹ç¨å¼ãè¨å® f1 <- expression(-sum(x-mu)/s2) f2 <- expression(-n/(2*s2) + sum((x-mu)^2)/(2*(s2^2))) # muã¨s2ã§ä¸éå¾®åãä½ã£ã¦ãã g11 <- expression(n/s2) g12 <- expression(sum(x - mu)/(s2^2)) g21 <- expression(sum(mu - x)/(s2^2)) g22 <- expression(n/(2*(s2^2)) - sum( (x - mu)^2 )/(s2^3)) # åæå¤ãè¨å® mu <- 10 # æ£è¦åå¸ã®å¹³åå¤ s2 <- 10 # æ£è¦åå¸ã®åæ£ for(i in 1:10){ # (mu, s2)ã2x1è¡åã«ãã m <- matrix(c(mu, s2), 2, 1) # (mu, s2)ã§è©ä¾¡ããf1ã¨f2ã®å¤ã2x1è¡åã«ãã f <- matrix(c(eval(f1), eval(f2)), 2, 1) # ã¤ã³ãã¢ã³ã«(mu, s2)ãä»£å ¥ããè¡åãä½ã j <- matrix(c(eval(g11), eval(g21), eval(g12), eval(g22)), 2, 2) # è¡åmãããã¤ã³ãã¢ã³ã®éè¡åã¨è©ä¾¡å¼ãä¹ãããã®ãå¼ã m <- m - solve(j)%*%f # è¡åmã(x, y)ã«å±éãã¦ãã mu <- m[1]; s2 <- m[2] print(sprintf("[%d] (mu,s2)=(%f,%f)", i, mu, s2)) } print(sprintf("å¹³å%2.3fãåæ£%2.3fï¼æ¨æºåå·®%2.3fï¼ã®æ£è¦åå¸", mu, s2, sqrt(s2)))
å®è¡ããã¨ä»¥ä¸ã®è¡¨ã®ããã«9é ç®ãããã§åæãã¾ããåæå¤ãä¾ãã°0ä»è¿ã«ããã¨åæããªããªãã®ã§æ³¨æãã¦ãã ããã
ã¹ããã | å¹³å | åæ£ | 11ã®ç¢ºç | 13ã®ç¢ºç | 23ã®ç¢ºç | 尤度ï¼ï¼åæ確çï¼ |
---|---|---|---|---|---|---|
1 | 17.5 | 6.8 | 0.007 | 0.034 | 0.016 | 0.000003844 |
2 | 16.3 | 9.2 | 0.028 | 0.072 | 0.012 | 0.000023852 |
3 | 15.9 | 12.8 | 0.043 | 0.080 | 0.016 | 0.000054561 |
4 | 15.8 | 17.3 | 0.050 | 0.077 | 0.021 | 0.000080688 |
5 | 15.7 | 21.9 | 0.052 | 0.072 | 0.025 | 0.000093919 |
6 | 15.7 | 25.7 | 0.051 | 0.069 | 0.028 | 0.000097562 |
7 | 15.7 | 27.3 | 0.051 | 0.067 | 0.029 | 0.000097937 |
8 | 15.7 | 27.6 | 0.051 | 0.067 | 0.029 | 0.000097943 |
9 | 15.7 | 27.6 | 0.051 | 0.067 | 0.029 | 0.000097943 |
対æ°å°¤åº¦é¢æ°ã®å°åºã¯çµ±è¨å¦ã®è«æä¸æ¬åã®å¦è¡çè²¢ç®ã«ãªãã®ã§ã大åã®å¿ç¨çµæ¸å¦è ã¯åã«å¯¾æ°å°¤åº¦é¢æ°ãã³ãã¼ãã¦å©ç¨ãã¦ãã¾ããRã®å ´åã¯å¯¾æ°å°¤åº¦é¢æ°ãå°åºããããå¾ã¯nlm()é¢æ°ããã£ã¦ããã¾ããããã«ããããã/ãã¸ããã»ã¢ãã«ãªã©ã®å©ç¨ä¾ãå¤ãã¢ãã«ã¯ãããã±ã¼ã¸ãç¨æããã¦ããã®ã§æå°¤æ³ã対æ°å°¤åº¦é¢æ°ãæèããå¿ è¦ã¯ããã¾ããã
3. å¶ç´æ¡ä»¶ãã¤ãã¦å¤å¤éå帰åæã«ããå ´å
ä¸ã®ä¾ã§ã¯å¶ç´æ¡ä»¶ãããã¾ããã§ãããã¤ã¾ãéå帰åæã®ä¿æ°ã¯ç¡ããåã«å¹³åã¨åæ£ãæ±ããã ãã«ãªãã¾ããéå帰åæã®å ´åã§ãã対æ°å°¤åº¦é¢æ°ã®x-muã®é¨åãy-b0-b1*x1-b2*x2ãªã©ã¨ç½®ãæããã ããªã®ã§ãæ¦å¿µçã«ã¯ç°¡åã§ãããã ãæ¨å®ãããã©ã¡ã¼ã¿ã¼æ°ã¨åãã ãä¸éæ¡ä»¶ã®å¼ãå¢ããã¤ã³ãã¢ã³ã¯ãã®äºä¹ã®å¤§ããã«ãªãäºã«æ³¨æãã¦ãã ããã
ã¨ã¦ãã§ã¯ç¡ãã§ãããä¸ã®ä¾ã®ããã«ããã±ã¼ã¸ç¡ãã§è¨ç®ããã®ã«ã¯ç¡çãããã¾ãã
4. tå¤ãPå¤ãªã©ã®è¨ç®
ããã¹ããè¦ãã°æ¸ãã¦ããã¾ãããæå°¤æ³ã®ããã»è¡åã®éè¡åã®å¯¾è§æåã¯æ¨å®ãããã©ã¡ã¼ã¿ã¼ã®åæ£ã«çãããªãã¾ããããã§è¨ãããã»è¡åã¯ãæå°¤æ³ã®å¯¾æ°å°¤åº¦é¢æ°ã®äºéå¾®åãæ¨å®éã§è©ä¾¡ãããã®ã§ãã
SEs <- sqrt(abs(diag(solve(j))))
ããããã®ä¿æ°ããããããã®æ¨æºèª¤å·®ã§å²ãã¨ã帰ç¡ä»®èª¬ï¼H0ï¼ã0ã®tå¤ãåºã¦æ¥ã¾ãã
tv <- m / SEs
両å´æ¤å®ãè¡ãã°ãããã±ã¼ã¸ã表示ããPå¤ã«ãªãã¾ããèªç±åº¦ã¯(ãµã³ãã«ãµã¤ãºâãã©ã¡ã¼ã¿ã¼ã®æ°)ã«ãªãã¾ãã
tp <- 2*(1 - pt(abs(tv), n - length(tv))) sprintf("tå¤%2.3f På¤%2.3f",tv,tp)
å¹³åå¤ã¯12.2%ææãåæ£ã¯34.6%ææã§ãã観測æ°ã3ãããªãã®ã§ãçµ±è¨çæææ§ãé«ããªãã¨è¨ãäºã®ããã§ãã2å¤æ°ã§ããã10ãã20ã®ãµã³ãã«ã¯å¿ è¦ãªããã§ãã
5. çµããã«
尤度é¢æ°ã対æ°å°¤åº¦é¢æ°ãééããã¨æ£ãããªãæ¨å®ã«ãªã£ãããã¯ãã¾ããã®å¾®åãééããã¨åæããªãã¨è¨ãç¾è±¡ãçºçãã¾ããå®ç¨ä¸ã¯ããªãã¹ãçµ±è¨è§£æããã±ã¼ã¸ãå©ç¨ããæ¹ãè¯ãã§ãããããããè£å´ã§ä½ããã£ã¦ããããç¥ã£ã¦ããäºã¯ã大åãªäºã ã¨æãã¾ãã