idx
int64
1
56k
question
stringlengths
15
155
answer
stringlengths
2
29.2k
βŒ€
question_cut
stringlengths
15
100
answer_cut
stringlengths
2
200
βŒ€
conversation
stringlengths
47
29.3k
conversation_cut
stringlengths
47
301
41,301
Big-O Scaling of R's cmdscale()
You should be able to test this on your system via Monte Carlo. For example: try.cmdscale <- function(n) { x <- matrix(rnorm(n*n) ** 2,nrow=n,ncol=n); took.time <- system.time(cmdscale(x)) } #repeat multiple times and take the median of the user.self + sys.self #probably a better way to do timing? multi.cmdscale <- function(n,ntrial = 11) { all.times <- replicate(ntrial,try.cmdscale(n)) median(all.times[1,] + all.times[2,]) } nvals <- c(8,16,32,64,128,256,512,1024) tvals <- sapply(nvals,multi.cmdscale) #ack! wish I could do a fit plot in logspace plot(nvals,tvals,log="xy") not so informative yet: If I could do some kind of fit on this plot, I could estimate the big O. (not so proficient in R yet, but learning).
Big-O Scaling of R's cmdscale()
You should be able to test this on your system via Monte Carlo. For example: try.cmdscale <- function(n) { x <- matrix(rnorm(n*n) ** 2,nrow=n,ncol=n); took.time <- system.time(cmdscale(x)) }
Big-O Scaling of R's cmdscale() You should be able to test this on your system via Monte Carlo. For example: try.cmdscale <- function(n) { x <- matrix(rnorm(n*n) ** 2,nrow=n,ncol=n); took.time <- system.time(cmdscale(x)) } #repeat multiple times and take the median of the user.self + sys.self #probably a better way to do timing? multi.cmdscale <- function(n,ntrial = 11) { all.times <- replicate(ntrial,try.cmdscale(n)) median(all.times[1,] + all.times[2,]) } nvals <- c(8,16,32,64,128,256,512,1024) tvals <- sapply(nvals,multi.cmdscale) #ack! wish I could do a fit plot in logspace plot(nvals,tvals,log="xy") not so informative yet: If I could do some kind of fit on this plot, I could estimate the big O. (not so proficient in R yet, but learning).
Big-O Scaling of R's cmdscale() You should be able to test this on your system via Monte Carlo. For example: try.cmdscale <- function(n) { x <- matrix(rnorm(n*n) ** 2,nrow=n,ncol=n); took.time <- system.time(cmdscale(x)) }
41,302
Big-O Scaling of R's cmdscale()
Ironically, the MDS actually wasn't my problem. The preprocessing I was doing was the issue. I'm used to coding in lower-level languages and forgot how slow looping is in R. I rewrote the preprocessing code using vector ops and the MDS actually only takes a few seconds.
Big-O Scaling of R's cmdscale()
Ironically, the MDS actually wasn't my problem. The preprocessing I was doing was the issue. I'm used to coding in lower-level languages and forgot how slow looping is in R. I rewrote the preproces
Big-O Scaling of R's cmdscale() Ironically, the MDS actually wasn't my problem. The preprocessing I was doing was the issue. I'm used to coding in lower-level languages and forgot how slow looping is in R. I rewrote the preprocessing code using vector ops and the MDS actually only takes a few seconds.
Big-O Scaling of R's cmdscale() Ironically, the MDS actually wasn't my problem. The preprocessing I was doing was the issue. I'm used to coding in lower-level languages and forgot how slow looping is in R. I rewrote the preproces
41,303
Maximum likelihood estimation of dlmModReg
I think your setup is not correct. Try this: set.seed(1234) r <- rnorm(100) X <- r u <- -1*X + 0.5*rnorm(100) MyModel <- function(x) dlmModReg(X, FALSE, dV = x[1]^2) fit <- dlmMLE(u, parm = c(0.3), build = MyModel) mod <- MyModel(fit$par) dlmFilter(u,mod)$a You recover the estimate of the observation variance from the only element of fit$par: > fit $par [1] 0.4431803 $value [1] -20.69313 $counts function gradient 17 17 $convergence [1] 0 $message [1] "CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH" while your estimate of the coefficient (should be around -1 in your case) can be obtained as the last element of dlmFilter(u,mod)$a, which gives the values of the state as new observations are processed: > dlmFilter(u,mod)$m [1] 0.0000000 -1.1486921 -1.2123431 -1.1172783 -1.1231454 -1.1170222 [7] -1.0974931 -1.1377114 -1.0378758 -1.0927136 -1.0955372 -1.0120210 [13] -0.9874791 -1.0036429 -1.0765513 -1.0678725 -1.0795124 -1.1568597 [19] -1.2044821 -1.2056687 -1.2102896 -1.2938958 -1.2922945 -1.2670604 [25] -1.1789594 -1.1570172 -1.1601590 -1.1417200 -1.1585501 -1.1608675 [31] -1.1616278 -1.1744861 -1.1717561 -1.1715025 -1.1568086 -1.1451311 [37] -1.1520867 -1.1379211 -1.1270897 -1.1048035 -1.1015793 -1.1054597 [43] -1.0621750 -1.0621218 -1.0696813 -1.0807651 -1.0816893 -1.0647963 [49] -1.0643440 -1.0667282 -1.0626404 -1.0623697 -1.0586265 -1.0571205 [55] -1.0569135 -1.0579224 -1.0607623 -1.0582257 -1.0495232 -1.0494288 [61] -1.0539632 -1.0555427 -1.0553468 -1.0491239 -1.0488604 -1.0491036 [67] -1.0510551 -1.0576294 -1.0611296 -1.0628612 -1.0626451 -1.0573650 [73] -1.0629577 -1.0647724 -1.0658052 -1.0823839 -1.0753808 -1.0747229 [79] -1.0747762 -1.0615243 -1.0630352 -1.0697431 -1.0666448 -1.0617227 [85] -1.0585460 -1.0583981 -1.0563544 -1.0567715 -1.0544349 -1.0573228 [91] -1.0588404 -1.0639155 -1.0625845 -1.0578004 -1.0571034 -1.0602645 [97] -1.0604838 -1.0586019 -1.0580891 -1.0587096 -1.0577559 Hope this helps.
Maximum likelihood estimation of dlmModReg
I think your setup is not correct. Try this: set.seed(1234) r <- rnorm(100) X <- r u <- -1*X + 0.5*rnorm(100) MyModel <- function(x) dlmModReg(X, FALSE, dV = x[1]^2) fit <- dlmMLE(u, parm = c(0.3), b
Maximum likelihood estimation of dlmModReg I think your setup is not correct. Try this: set.seed(1234) r <- rnorm(100) X <- r u <- -1*X + 0.5*rnorm(100) MyModel <- function(x) dlmModReg(X, FALSE, dV = x[1]^2) fit <- dlmMLE(u, parm = c(0.3), build = MyModel) mod <- MyModel(fit$par) dlmFilter(u,mod)$a You recover the estimate of the observation variance from the only element of fit$par: > fit $par [1] 0.4431803 $value [1] -20.69313 $counts function gradient 17 17 $convergence [1] 0 $message [1] "CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH" while your estimate of the coefficient (should be around -1 in your case) can be obtained as the last element of dlmFilter(u,mod)$a, which gives the values of the state as new observations are processed: > dlmFilter(u,mod)$m [1] 0.0000000 -1.1486921 -1.2123431 -1.1172783 -1.1231454 -1.1170222 [7] -1.0974931 -1.1377114 -1.0378758 -1.0927136 -1.0955372 -1.0120210 [13] -0.9874791 -1.0036429 -1.0765513 -1.0678725 -1.0795124 -1.1568597 [19] -1.2044821 -1.2056687 -1.2102896 -1.2938958 -1.2922945 -1.2670604 [25] -1.1789594 -1.1570172 -1.1601590 -1.1417200 -1.1585501 -1.1608675 [31] -1.1616278 -1.1744861 -1.1717561 -1.1715025 -1.1568086 -1.1451311 [37] -1.1520867 -1.1379211 -1.1270897 -1.1048035 -1.1015793 -1.1054597 [43] -1.0621750 -1.0621218 -1.0696813 -1.0807651 -1.0816893 -1.0647963 [49] -1.0643440 -1.0667282 -1.0626404 -1.0623697 -1.0586265 -1.0571205 [55] -1.0569135 -1.0579224 -1.0607623 -1.0582257 -1.0495232 -1.0494288 [61] -1.0539632 -1.0555427 -1.0553468 -1.0491239 -1.0488604 -1.0491036 [67] -1.0510551 -1.0576294 -1.0611296 -1.0628612 -1.0626451 -1.0573650 [73] -1.0629577 -1.0647724 -1.0658052 -1.0823839 -1.0753808 -1.0747229 [79] -1.0747762 -1.0615243 -1.0630352 -1.0697431 -1.0666448 -1.0617227 [85] -1.0585460 -1.0583981 -1.0563544 -1.0567715 -1.0544349 -1.0573228 [91] -1.0588404 -1.0639155 -1.0625845 -1.0578004 -1.0571034 -1.0602645 [97] -1.0604838 -1.0586019 -1.0580891 -1.0587096 -1.0577559 Hope this helps.
Maximum likelihood estimation of dlmModReg I think your setup is not correct. Try this: set.seed(1234) r <- rnorm(100) X <- r u <- -1*X + 0.5*rnorm(100) MyModel <- function(x) dlmModReg(X, FALSE, dV = x[1]^2) fit <- dlmMLE(u, parm = c(0.3), b
41,304
Maximum likelihood estimation of dlmModReg
Below is code which implements my solution and Paramonov's solution (a slight edit: I have changed dlmFilter(u,mod)$a in the orginally posted answer by dlmFilter(u,mod)$m). library(dlm) set.seed(1234) reps <- 100 MyEstimates <- YourEstimates <- matrix(0,reps,2) for (i in (1:reps) ) { X <- r <- rnorm(100) u <- -1*r + 0.5*rnorm(100) # fit <- dlmMLE(u, parm = c(1, sd(u)), build = function(x) dlmModReg(r, FALSE, dV = x[2]^2, m0 = x[1], C0 = matrix(0))) YourEstimates[i,] <- fit$par # MyModel <- function(x) dlmModReg(X, FALSE, dV = x[1]^2) fit <- dlmMLE(u, parm = c(0.3), build = MyModel) mod <- MyModel(fit$par) MyEstimates[i,] <- c(dlmFilter(u,mod)$m[101],fit$par[1]) } When I run the above code, this is what I get: > summary(YourEstimates) V1 V2 Min. :-9.5284 Min. :-0.5747 1st Qu.:-1.4280 1st Qu.: 0.4710 Median :-0.9795 Median : 0.4937 Mean :-0.9737 Mean : 0.4369 3rd Qu.:-0.5636 3rd Qu.: 0.5215 Max. : 4.5222 Max. : 0.5980 > summary(MyEstimates) V1 V2 Min. :-1.1099 Min. :-0.6010 1st Qu.:-1.0266 1st Qu.: 0.4736 Median :-0.9974 Median : 0.4961 Mean :-0.9938 Mean : 0.4469 3rd Qu.:-0.9635 3rd Qu.: 0.5158 Max. :-0.8390 Max. : 0.5776 While the first set of estimates gives similar estimates for the second parameter, it occasionally gives values well off the mark for the first. I think the reason is that "tying" the state to its initial value with C0=matrix(0) leads to numerical instability, but I am not sure. In any case, you may want to look at the issue.
Maximum likelihood estimation of dlmModReg
Below is code which implements my solution and Paramonov's solution (a slight edit: I have changed dlmFilter(u,mod)$a in the orginally posted answer by dlmFilter(u,mod)$m). library(dlm) set.seed(1234
Maximum likelihood estimation of dlmModReg Below is code which implements my solution and Paramonov's solution (a slight edit: I have changed dlmFilter(u,mod)$a in the orginally posted answer by dlmFilter(u,mod)$m). library(dlm) set.seed(1234) reps <- 100 MyEstimates <- YourEstimates <- matrix(0,reps,2) for (i in (1:reps) ) { X <- r <- rnorm(100) u <- -1*r + 0.5*rnorm(100) # fit <- dlmMLE(u, parm = c(1, sd(u)), build = function(x) dlmModReg(r, FALSE, dV = x[2]^2, m0 = x[1], C0 = matrix(0))) YourEstimates[i,] <- fit$par # MyModel <- function(x) dlmModReg(X, FALSE, dV = x[1]^2) fit <- dlmMLE(u, parm = c(0.3), build = MyModel) mod <- MyModel(fit$par) MyEstimates[i,] <- c(dlmFilter(u,mod)$m[101],fit$par[1]) } When I run the above code, this is what I get: > summary(YourEstimates) V1 V2 Min. :-9.5284 Min. :-0.5747 1st Qu.:-1.4280 1st Qu.: 0.4710 Median :-0.9795 Median : 0.4937 Mean :-0.9737 Mean : 0.4369 3rd Qu.:-0.5636 3rd Qu.: 0.5215 Max. : 4.5222 Max. : 0.5980 > summary(MyEstimates) V1 V2 Min. :-1.1099 Min. :-0.6010 1st Qu.:-1.0266 1st Qu.: 0.4736 Median :-0.9974 Median : 0.4961 Mean :-0.9938 Mean : 0.4469 3rd Qu.:-0.9635 3rd Qu.: 0.5158 Max. :-0.8390 Max. : 0.5776 While the first set of estimates gives similar estimates for the second parameter, it occasionally gives values well off the mark for the first. I think the reason is that "tying" the state to its initial value with C0=matrix(0) leads to numerical instability, but I am not sure. In any case, you may want to look at the issue.
Maximum likelihood estimation of dlmModReg Below is code which implements my solution and Paramonov's solution (a slight edit: I have changed dlmFilter(u,mod)$a in the orginally posted answer by dlmFilter(u,mod)$m). library(dlm) set.seed(1234
41,305
Maximum likelihood estimation of dlmModReg
After reading help for dlmFilter, I could come up with the following code: r <- rnorm(100) u <- -1*r + 0.5*rnorm(100) fit <- dlmMLE(u, parm = c(1, sd(u)), build = function(x) dlmModReg(r, FALSE, dV = x[2]^2, m0 = x[1], C0 = matrix(0))) fit$par [1] -1.1330088 0.4788357
Maximum likelihood estimation of dlmModReg
After reading help for dlmFilter, I could come up with the following code: r <- rnorm(100) u <- -1*r + 0.5*rnorm(100) fit <- dlmMLE(u, parm = c(1, sd(u)), build = function(x)
Maximum likelihood estimation of dlmModReg After reading help for dlmFilter, I could come up with the following code: r <- rnorm(100) u <- -1*r + 0.5*rnorm(100) fit <- dlmMLE(u, parm = c(1, sd(u)), build = function(x) dlmModReg(r, FALSE, dV = x[2]^2, m0 = x[1], C0 = matrix(0))) fit$par [1] -1.1330088 0.4788357
Maximum likelihood estimation of dlmModReg After reading help for dlmFilter, I could come up with the following code: r <- rnorm(100) u <- -1*r + 0.5*rnorm(100) fit <- dlmMLE(u, parm = c(1, sd(u)), build = function(x)
41,306
Naive Bayes classification for "That's what she said" problem
You are not using Naive Bayes, you are actually using something I'd call "Multiplicative Decision Stump"-Classifer ;). You can do that, but I'd recommend in this case to calculate the micro or macro-average across all words in the sentence (instead of multiplying them). E.g. macro-average: $p(Positive|sentence)=\frac{1}{n}\sum_{word\in sentence}p(Positive|word)$ I'd set $p$ to $\frac{Positive}{Positive+Negative}$ for calculating the $p(Positive|.)$ and $\frac{Negative}{Positive+Negative}$ for calculating the $p(Negative|.)$ respectively $m$ is the weight of the prior meanwhile the word-count is the weight of the occuring word. The lower $m$ the more importance the probability calculated by word-frequency gets and vice versa. Let's say for example $m$=8 and word-count=2 (for a certain word), than the resulting score will contain of 80% prior-information and 20% non-prior-information. Hence I'd always compare $m$ to the word-count of important words (i.e. those whose yes/no-probability differs strongly from the prior). Unfortunately, there is no "golden hammer"-value for this variable, so I suggest to play around a little bit. If you want to try out Naive Bayes, I suggest the section "Documentation classification" in the wiki-article about Naive Bayes
Naive Bayes classification for "That's what she said" problem
You are not using Naive Bayes, you are actually using something I'd call "Multiplicative Decision Stump"-Classifer ;). You can do that, but I'd recommend in this case to calculate the micro or macro-a
Naive Bayes classification for "That's what she said" problem You are not using Naive Bayes, you are actually using something I'd call "Multiplicative Decision Stump"-Classifer ;). You can do that, but I'd recommend in this case to calculate the micro or macro-average across all words in the sentence (instead of multiplying them). E.g. macro-average: $p(Positive|sentence)=\frac{1}{n}\sum_{word\in sentence}p(Positive|word)$ I'd set $p$ to $\frac{Positive}{Positive+Negative}$ for calculating the $p(Positive|.)$ and $\frac{Negative}{Positive+Negative}$ for calculating the $p(Negative|.)$ respectively $m$ is the weight of the prior meanwhile the word-count is the weight of the occuring word. The lower $m$ the more importance the probability calculated by word-frequency gets and vice versa. Let's say for example $m$=8 and word-count=2 (for a certain word), than the resulting score will contain of 80% prior-information and 20% non-prior-information. Hence I'd always compare $m$ to the word-count of important words (i.e. those whose yes/no-probability differs strongly from the prior). Unfortunately, there is no "golden hammer"-value for this variable, so I suggest to play around a little bit. If you want to try out Naive Bayes, I suggest the section "Documentation classification" in the wiki-article about Naive Bayes
Naive Bayes classification for "That's what she said" problem You are not using Naive Bayes, you are actually using something I'd call "Multiplicative Decision Stump"-Classifer ;). You can do that, but I'd recommend in this case to calculate the micro or macro-a
41,307
Naive Bayes classification for "That's what she said" problem
Here is a Web site that uses a classifier to determine the gender of an author of text: http://bookblog.net/gender/genie.php There are a number of articles on the subject at the Web site and the composer of the site has written a number of articles on the subject as well. There are a number of good methods that can be used in the classification Bayesian Logistic Regression Linear Discriminant Analysis Quadratic Discriminant Analysis Bayes Classifiers Have fun
Naive Bayes classification for "That's what she said" problem
Here is a Web site that uses a classifier to determine the gender of an author of text: http://bookblog.net/gender/genie.php There are a number of articles on the subject at the Web site and t
Naive Bayes classification for "That's what she said" problem Here is a Web site that uses a classifier to determine the gender of an author of text: http://bookblog.net/gender/genie.php There are a number of articles on the subject at the Web site and the composer of the site has written a number of articles on the subject as well. There are a number of good methods that can be used in the classification Bayesian Logistic Regression Linear Discriminant Analysis Quadratic Discriminant Analysis Bayes Classifiers Have fun
Naive Bayes classification for "That's what she said" problem Here is a Web site that uses a classifier to determine the gender of an author of text: http://bookblog.net/gender/genie.php There are a number of articles on the subject at the Web site and t
41,308
Naive Bayes classification for "That's what she said" problem
An interesting source of suggestions for this problem might be the That's What She Said Quora thread. Specifically, the first comment identifies that it might make sense to use Twitter streams as a source of statements to which there has been a response of "That's What She Said". Another thing you could do would be to make a simple UI which would take input from twitter, and then ask a human annotator to decide whether "That's What She Said" is an appropriate response. The UW paper mentions their data sources; I assume (though you didn't mention it specifically) that you're already using this data? (It looks like you can slightly increase the size of the training set from that paper, but not a lot.) Another potential source of data to look at might be to analyze television show dialogue for positive examples. (The "A Computer That Knows When To Say β€œThat’s What She Said" Forbes Article mentions The Office, for example.) Using Hulu's Captions search (search for That's What she said) identifies 179 examples, though it looks like in the first 10, only 2 are positive training examples, so that may be a somewhat noisy source of data. Officequotes.net appears to have a larger source of potential data, though again, cleaning it up and using it may take some work.
Naive Bayes classification for "That's what she said" problem
An interesting source of suggestions for this problem might be the That's What She Said Quora thread. Specifically, the first comment identifies that it might make sense to use Twitter streams as a so
Naive Bayes classification for "That's what she said" problem An interesting source of suggestions for this problem might be the That's What She Said Quora thread. Specifically, the first comment identifies that it might make sense to use Twitter streams as a source of statements to which there has been a response of "That's What She Said". Another thing you could do would be to make a simple UI which would take input from twitter, and then ask a human annotator to decide whether "That's What She Said" is an appropriate response. The UW paper mentions their data sources; I assume (though you didn't mention it specifically) that you're already using this data? (It looks like you can slightly increase the size of the training set from that paper, but not a lot.) Another potential source of data to look at might be to analyze television show dialogue for positive examples. (The "A Computer That Knows When To Say β€œThat’s What She Said" Forbes Article mentions The Office, for example.) Using Hulu's Captions search (search for That's What she said) identifies 179 examples, though it looks like in the first 10, only 2 are positive training examples, so that may be a somewhat noisy source of data. Officequotes.net appears to have a larger source of potential data, though again, cleaning it up and using it may take some work.
Naive Bayes classification for "That's what she said" problem An interesting source of suggestions for this problem might be the That's What She Said Quora thread. Specifically, the first comment identifies that it might make sense to use Twitter streams as a so
41,309
Hot topics in mathematical statistics [closed]
Persi Diaconis wrote an article on "Mathematical Statistics" in the Princeton Companion of Mathematics. He discusses several ongoing research areas in mathematical statistics, including the search for high-dimensional admissible estimators (Stein's paradox).
Hot topics in mathematical statistics [closed]
Persi Diaconis wrote an article on "Mathematical Statistics" in the Princeton Companion of Mathematics. He discusses several ongoing research areas in mathematical statistics, including the search fo
Hot topics in mathematical statistics [closed] Persi Diaconis wrote an article on "Mathematical Statistics" in the Princeton Companion of Mathematics. He discusses several ongoing research areas in mathematical statistics, including the search for high-dimensional admissible estimators (Stein's paradox).
Hot topics in mathematical statistics [closed] Persi Diaconis wrote an article on "Mathematical Statistics" in the Princeton Companion of Mathematics. He discusses several ongoing research areas in mathematical statistics, including the search fo
41,310
Hot topics in mathematical statistics [closed]
Hopefully, modelling the dynamics of tumor progression qualifies for this: Anderson & Quaranta. Integrative mathematical oncology. Nature Reviews Cancer, 2008.
Hot topics in mathematical statistics [closed]
Hopefully, modelling the dynamics of tumor progression qualifies for this: Anderson & Quaranta. Integrative mathematical oncology. Nature Reviews Cancer, 2008.
Hot topics in mathematical statistics [closed] Hopefully, modelling the dynamics of tumor progression qualifies for this: Anderson & Quaranta. Integrative mathematical oncology. Nature Reviews Cancer, 2008.
Hot topics in mathematical statistics [closed] Hopefully, modelling the dynamics of tumor progression qualifies for this: Anderson & Quaranta. Integrative mathematical oncology. Nature Reviews Cancer, 2008.
41,311
Multiple regression with no origin and mix of directly entered and stepwise entered variables using R
I think you can set up your base model, that is the one with your 12 IVs and then use add1() with the remaining predictors. So, say you have a model mod1 defined like mod1 <- lm(y ~ 0+x1+x2+x3) (0+ means no intercept), then add1(mod1, ~ .+x4+x5+x6, test="F") will add and test one predictor after the other on top of the base model. More generally, if you know in advance that a set of variables should be included in the model (this might result from prior knowledge, or whatsoever), you can use step() or stepAIC() (in the MASS package) and look at the scope= argument. Here is an illustration, where we specify a priori the functional relationship between the outcome, $y$, and the predictors, $x_1, x_2, \dots, x_{10}$. We want the model to include the first three predictors, but let the selection of other predictors be done by stepwise regression: set.seed(101) X <- replicate(10, rnorm(100)) colnames(X) <- paste("x", 1:10, sep="") y <- 1.1*X[,1] + 0.8*X[,2] - 0.7*X[,5] + 1.4*X[,6] + rnorm(100) df <- data.frame(y=y, X) # say this is one of the base model we think of fm0 <- lm(y ~ 0+x1+x2+x3+x4, data=df) # build a semi-constrained stepwise regression fm.step <- step(fm0, scope=list(upper = ~ 0+x1+x2+x3+x4+x5+x6+x7+x8+x9+x10, lower = ~ 0+x1+x2+x3), trace=FALSE) summary(fm.step) The results are shown below: Coefficients: Estimate Std. Error t value Pr(>|t|) x1 1.0831 0.1095 9.888 2.87e-16 *** x2 0.6704 0.1026 6.533 3.17e-09 *** x3 -0.1844 0.1183 -1.558 0.123 x6 1.6024 0.1142 14.035 < 2e-16 *** x5 -0.6528 0.1029 -6.342 7.63e-09 *** --- Signif. codes: 0 β€˜***’ 0.001 β€˜**’ 0.01 β€˜*’ 0.05 β€˜.’ 0.1 β€˜ ’ 1 Residual standard error: 1.004 on 95 degrees of freedom Multiple R-squared: 0.814, Adjusted R-squared: 0.8042 F-statistic: 83.17 on 5 and 95 DF, p-value: < 2.2e-16 You can see that $x_3$ has been retained in the model, even if it proves to be non-significant (well, the usual caveats with univariate tests in multiple regression setting and model selection apply here -- at least, its relationship with $y$ was not specified).
Multiple regression with no origin and mix of directly entered and stepwise entered variables using
I think you can set up your base model, that is the one with your 12 IVs and then use add1() with the remaining predictors. So, say you have a model mod1 defined like mod1 <- lm(y ~ 0+x1+x2+x3) (0+ me
Multiple regression with no origin and mix of directly entered and stepwise entered variables using R I think you can set up your base model, that is the one with your 12 IVs and then use add1() with the remaining predictors. So, say you have a model mod1 defined like mod1 <- lm(y ~ 0+x1+x2+x3) (0+ means no intercept), then add1(mod1, ~ .+x4+x5+x6, test="F") will add and test one predictor after the other on top of the base model. More generally, if you know in advance that a set of variables should be included in the model (this might result from prior knowledge, or whatsoever), you can use step() or stepAIC() (in the MASS package) and look at the scope= argument. Here is an illustration, where we specify a priori the functional relationship between the outcome, $y$, and the predictors, $x_1, x_2, \dots, x_{10}$. We want the model to include the first three predictors, but let the selection of other predictors be done by stepwise regression: set.seed(101) X <- replicate(10, rnorm(100)) colnames(X) <- paste("x", 1:10, sep="") y <- 1.1*X[,1] + 0.8*X[,2] - 0.7*X[,5] + 1.4*X[,6] + rnorm(100) df <- data.frame(y=y, X) # say this is one of the base model we think of fm0 <- lm(y ~ 0+x1+x2+x3+x4, data=df) # build a semi-constrained stepwise regression fm.step <- step(fm0, scope=list(upper = ~ 0+x1+x2+x3+x4+x5+x6+x7+x8+x9+x10, lower = ~ 0+x1+x2+x3), trace=FALSE) summary(fm.step) The results are shown below: Coefficients: Estimate Std. Error t value Pr(>|t|) x1 1.0831 0.1095 9.888 2.87e-16 *** x2 0.6704 0.1026 6.533 3.17e-09 *** x3 -0.1844 0.1183 -1.558 0.123 x6 1.6024 0.1142 14.035 < 2e-16 *** x5 -0.6528 0.1029 -6.342 7.63e-09 *** --- Signif. codes: 0 β€˜***’ 0.001 β€˜**’ 0.01 β€˜*’ 0.05 β€˜.’ 0.1 β€˜ ’ 1 Residual standard error: 1.004 on 95 degrees of freedom Multiple R-squared: 0.814, Adjusted R-squared: 0.8042 F-statistic: 83.17 on 5 and 95 DF, p-value: < 2.2e-16 You can see that $x_3$ has been retained in the model, even if it proves to be non-significant (well, the usual caveats with univariate tests in multiple regression setting and model selection apply here -- at least, its relationship with $y$ was not specified).
Multiple regression with no origin and mix of directly entered and stepwise entered variables using I think you can set up your base model, that is the one with your 12 IVs and then use add1() with the remaining predictors. So, say you have a model mod1 defined like mod1 <- lm(y ~ 0+x1+x2+x3) (0+ me
41,312
Learning from unordered tuples?
For regression models, one way would be to generate derived variables that are invariant to permutation of the labelling of the $x_i$s. E.g. in your three-variable example, considering only polynomials of total order up to 3, such combinations would be: $w_1 = x_1 + x_2 + x_3$ $w_2 = x_1x_2 + x_1x_3 + x_2x_3$ $w_3 = x_1^2 + x_2^2 + x_3^2$ $w_4 = x_1x_2x_3$ $w_5 = x_1^2x_2 + x_1^2x_3 + x_2^2x_1 + x_2^2x_3 + x_3^2x_1 + x_3^2x_2$ $w_6 = x_1^3 + x_2^3 + x_3^3$ You could then use any any form of regression that includes some function $f(a_1w_1 + a_2w_2 + \cdots + a_8w_8)$ and find values for the $a_i$s by non-linear least squares, generalized linear modelling or other methods. The combination $a_1w_1 + a_2w_2 + \cdots + a_8w_8$ fits a response surface that's a polynomial of order 3 that is symmetric in permutation of $x_1, x_2, x_3$. Clearly there would be many more possibilities if you wished to allow functions other than polynomials such as logs, fractional powers... (EDIT I finished this post before I saw your edit to the answer with the link to the more specific question on mathoverflow. I was started to think there must be some mathematical framework for listing all such polynomials of a given total order, but it sounds you already know more than me about the relevant area of maths!)
Learning from unordered tuples?
For regression models, one way would be to generate derived variables that are invariant to permutation of the labelling of the $x_i$s. E.g. in your three-variable example, considering only polynomial
Learning from unordered tuples? For regression models, one way would be to generate derived variables that are invariant to permutation of the labelling of the $x_i$s. E.g. in your three-variable example, considering only polynomials of total order up to 3, such combinations would be: $w_1 = x_1 + x_2 + x_3$ $w_2 = x_1x_2 + x_1x_3 + x_2x_3$ $w_3 = x_1^2 + x_2^2 + x_3^2$ $w_4 = x_1x_2x_3$ $w_5 = x_1^2x_2 + x_1^2x_3 + x_2^2x_1 + x_2^2x_3 + x_3^2x_1 + x_3^2x_2$ $w_6 = x_1^3 + x_2^3 + x_3^3$ You could then use any any form of regression that includes some function $f(a_1w_1 + a_2w_2 + \cdots + a_8w_8)$ and find values for the $a_i$s by non-linear least squares, generalized linear modelling or other methods. The combination $a_1w_1 + a_2w_2 + \cdots + a_8w_8$ fits a response surface that's a polynomial of order 3 that is symmetric in permutation of $x_1, x_2, x_3$. Clearly there would be many more possibilities if you wished to allow functions other than polynomials such as logs, fractional powers... (EDIT I finished this post before I saw your edit to the answer with the link to the more specific question on mathoverflow. I was started to think there must be some mathematical framework for listing all such polynomials of a given total order, but it sounds you already know more than me about the relevant area of maths!)
Learning from unordered tuples? For regression models, one way would be to generate derived variables that are invariant to permutation of the labelling of the $x_i$s. E.g. in your three-variable example, considering only polynomial
41,313
Learning from unordered tuples?
To add to onestop's response, it was confirmed on math.SE that the polynomials $$w_1 = x_1 + \cdots + x_n$$ $$w_2 = x_1^2 + \cdots + x_n^2$$ $$\cdots$$ $$w_n = x_1^n + \cdots + x_n ^n$$ give you all the information needed to determine the original $X=(x_1, \cdots, x_n)$. This is a neat result because it also applies to moments of a discrete distribution with uniform probabilities.
Learning from unordered tuples?
To add to onestop's response, it was confirmed on math.SE that the polynomials $$w_1 = x_1 + \cdots + x_n$$ $$w_2 = x_1^2 + \cdots + x_n^2$$ $$\cdots$$ $$w_n = x_1^n + \cdots + x_n ^n$$ give you all t
Learning from unordered tuples? To add to onestop's response, it was confirmed on math.SE that the polynomials $$w_1 = x_1 + \cdots + x_n$$ $$w_2 = x_1^2 + \cdots + x_n^2$$ $$\cdots$$ $$w_n = x_1^n + \cdots + x_n ^n$$ give you all the information needed to determine the original $X=(x_1, \cdots, x_n)$. This is a neat result because it also applies to moments of a discrete distribution with uniform probabilities.
Learning from unordered tuples? To add to onestop's response, it was confirmed on math.SE that the polynomials $$w_1 = x_1 + \cdots + x_n$$ $$w_2 = x_1^2 + \cdots + x_n^2$$ $$\cdots$$ $$w_n = x_1^n + \cdots + x_n ^n$$ give you all t
41,314
Learning from unordered tuples?
Deep Sets and PointNet provide two (fairly recent) examples of permutation-invariant deep learning architectures. Both these methods provided state-of-the-art results at their time of introduction and are continuous (in senses described in their papers) with respect to perturbations of the underlying sets. The permutation-invariant Deep Sets neural architecture can be written as: $$ F_{DS}(A) = \rho\left( \sum_{a\in A} \phi(a) \right) $$ and a (simplified) PointNet architecture can be written as: $$ F_{PN}(A) = \rho\left( \max_{a\in A} \phi(a) \right) $$ where $\phi:\mathbb{R}^n\to\mathbb{R}^m$ creates features for each point in the set $A$ and $\rho:\mathbb{R}^m\to\mathbb{R}$ combines these features into a single real-valued output (here the $\max$ of a vector is taken to be the component-wise maximum and $\rho$ and $\phi$ are continuous). Since taking sums and max are permutation-invariant, so is the whole network. Ideally we would choose $\rho$ and $\phi$ to be the functions that together minimize the error among all such continuous functions, but that is monstrously intractable. Instead we model $\rho$ and $\phi$ as neural networks whose joint set of parameters $\Theta$ are chosen to minimize the regression error. With respect to your context and notation for $|X_i|=3$, these models look like: $$ F_{DS}(X_i) = \rho\Big(\phi(x_{i1}) + \phi(x_{i2}) + \phi(x_{i3})\Big) $$ $$ F_{PN}(X_i) = \rho\Big( \max\big\{\phi(x_{i1}),\phi(x_{i2}),\phi(x_{i3})\big\} \Big) $$ Bonus: Deep Sets actually also describes a permutation-equivariant architecture as well.
Learning from unordered tuples?
Deep Sets and PointNet provide two (fairly recent) examples of permutation-invariant deep learning architectures. Both these methods provided state-of-the-art results at their time of introduction and
Learning from unordered tuples? Deep Sets and PointNet provide two (fairly recent) examples of permutation-invariant deep learning architectures. Both these methods provided state-of-the-art results at their time of introduction and are continuous (in senses described in their papers) with respect to perturbations of the underlying sets. The permutation-invariant Deep Sets neural architecture can be written as: $$ F_{DS}(A) = \rho\left( \sum_{a\in A} \phi(a) \right) $$ and a (simplified) PointNet architecture can be written as: $$ F_{PN}(A) = \rho\left( \max_{a\in A} \phi(a) \right) $$ where $\phi:\mathbb{R}^n\to\mathbb{R}^m$ creates features for each point in the set $A$ and $\rho:\mathbb{R}^m\to\mathbb{R}$ combines these features into a single real-valued output (here the $\max$ of a vector is taken to be the component-wise maximum and $\rho$ and $\phi$ are continuous). Since taking sums and max are permutation-invariant, so is the whole network. Ideally we would choose $\rho$ and $\phi$ to be the functions that together minimize the error among all such continuous functions, but that is monstrously intractable. Instead we model $\rho$ and $\phi$ as neural networks whose joint set of parameters $\Theta$ are chosen to minimize the regression error. With respect to your context and notation for $|X_i|=3$, these models look like: $$ F_{DS}(X_i) = \rho\Big(\phi(x_{i1}) + \phi(x_{i2}) + \phi(x_{i3})\Big) $$ $$ F_{PN}(X_i) = \rho\Big( \max\big\{\phi(x_{i1}),\phi(x_{i2}),\phi(x_{i3})\big\} \Big) $$ Bonus: Deep Sets actually also describes a permutation-equivariant architecture as well.
Learning from unordered tuples? Deep Sets and PointNet provide two (fairly recent) examples of permutation-invariant deep learning architectures. Both these methods provided state-of-the-art results at their time of introduction and
41,315
What are the major machine learning theories that maybe used by Twitter for suggesting followers?
Three different approaches come to my mind decisions based solely on the following / follower lists. If a lot of people you are following, follow a particular person, the chance is high you might be interested in this persons tweet. using links and hashtags. Assuming you link very often to specific websites or use specific links you might be interested in people doing the same. doing some kind of document clustering approaches on the tweets, to figure out who's writing similar things and suggest him or her. The problem with recommender systems to me is that most machine learning algorithms are just using some kind of similarity measure to give suggestions. Check out "recommender systems" and "document clustering" as search keywords to get some more ideas.
What are the major machine learning theories that maybe used by Twitter for suggesting followers?
Three different approaches come to my mind decisions based solely on the following / follower lists. If a lot of people you are following, follow a particular person, the chance is high you might be
What are the major machine learning theories that maybe used by Twitter for suggesting followers? Three different approaches come to my mind decisions based solely on the following / follower lists. If a lot of people you are following, follow a particular person, the chance is high you might be interested in this persons tweet. using links and hashtags. Assuming you link very often to specific websites or use specific links you might be interested in people doing the same. doing some kind of document clustering approaches on the tweets, to figure out who's writing similar things and suggest him or her. The problem with recommender systems to me is that most machine learning algorithms are just using some kind of similarity measure to give suggestions. Check out "recommender systems" and "document clustering" as search keywords to get some more ideas.
What are the major machine learning theories that maybe used by Twitter for suggesting followers? Three different approaches come to my mind decisions based solely on the following / follower lists. If a lot of people you are following, follow a particular person, the chance is high you might be
41,316
Choice of weight function in Moran's I
Moran's I statistic is used to explore a specific type of spatial clustering: whether high values are located in proximity to other high values and whether low values are located in proximity to other low values. The trick then is 1st to get a sense of what you mean by proximity and 2nd formulating this mathematically. This idea of proximity will depend on the what type of observations (attributes) you are working with and what type of questions you have in mind. For example, for human beings proximity could mean the distance needed to have a chat. So, if you wanted to know whether high income people like to chat with other high income people at your cocktail party, you could formulate proximity by using binary weights where 1 is defined by 2 people being within 3 feet of each other. To see whether house prices are spatially correlated you could define proximity as when 2 houses are neighbors or perhaps if two houses are on the same block or if 2 houses are within sight of one another etc etc. Basically, you need a hypothesis of proximity that is based on some of your prior common sense ideas or expert knowledge of why 2 objects that are close to one another are more associated than 2 objects that are far from one another. Moran's I can then be seen as a test of your hypothesis of how your notion of proximity structures high values next to one another on the landscape.
Choice of weight function in Moran's I
Moran's I statistic is used to explore a specific type of spatial clustering: whether high values are located in proximity to other high values and whether low values are located in proximity to other
Choice of weight function in Moran's I Moran's I statistic is used to explore a specific type of spatial clustering: whether high values are located in proximity to other high values and whether low values are located in proximity to other low values. The trick then is 1st to get a sense of what you mean by proximity and 2nd formulating this mathematically. This idea of proximity will depend on the what type of observations (attributes) you are working with and what type of questions you have in mind. For example, for human beings proximity could mean the distance needed to have a chat. So, if you wanted to know whether high income people like to chat with other high income people at your cocktail party, you could formulate proximity by using binary weights where 1 is defined by 2 people being within 3 feet of each other. To see whether house prices are spatially correlated you could define proximity as when 2 houses are neighbors or perhaps if two houses are on the same block or if 2 houses are within sight of one another etc etc. Basically, you need a hypothesis of proximity that is based on some of your prior common sense ideas or expert knowledge of why 2 objects that are close to one another are more associated than 2 objects that are far from one another. Moran's I can then be seen as a test of your hypothesis of how your notion of proximity structures high values next to one another on the landscape.
Choice of weight function in Moran's I Moran's I statistic is used to explore a specific type of spatial clustering: whether high values are located in proximity to other high values and whether low values are located in proximity to other
41,317
Choice of weight function in Moran's I
Although not within the domain of geostatistics, for question #2, I would casually say the most frequent weighting function used in my field (Criminology) would be a a binary weighting scheme. Although I have rarely seen a good theoretical or empirical argument to use one weighting scheme over another (or how one defines a neighbor in a binary weighting scheme either). It may simply be because of historical preference and convienance that such a scheme is typically used. There is a distinction that should be drawn between data driven approaches to constructing spatial weights and the theory based approach to deriving spatial weights. You are currently performing the former, and in this approach you are implicitly treating the estimation of spatial weights as a problem of measurement error, and hence should use techniques to validate your measurements (which is considerably complicated due to the endogeneity of the spatial weights). Using a weighting scheme based on some of the chance variation in the data and using it in subsequent causal models is synonymous with other fallacies related to inference and data snooping. Unfortunately I have no good references of spatial weight models validated in any meaningful way besides the extent of the auto-correlation, which to be frank isn't all that convincing of an empirical argument. Spatial dependence can be the result of either causal processes (i.e. the value at one point in space affects the value at another point in space), or it can be the result of other measurement errors (i.e. the measured support of the data do not match the support of the processes that generate those phenomena). This is oppossed to theory based construction of spatial weights (or "model-driven" in Luc Anselin's terminology), in which one specifies the weight matrix a priori to estimating a model. I did not read the Fauchald paper you cited, but it appears in the abstract they have plausible theoretical explanations for the observed patterns based on some optimal foraging strategy. For readings I would suggest Luc Anselin's book, Spatial Econometrics: Methods and Models (1988), particularly chapters 2 and 3 will be of most interest. Also as another work with a similar viewpoint to mine (although it will likely be of less interest) is an essay piece by Gary King, "Why context should not count". I would also suggest another paper as it appears they had similar goals to yours, and defined the weights for a lattice system based on variogram estimates (Negreiros, 2010).
Choice of weight function in Moran's I
Although not within the domain of geostatistics, for question #2, I would casually say the most frequent weighting function used in my field (Criminology) would be a a binary weighting scheme. Althoug
Choice of weight function in Moran's I Although not within the domain of geostatistics, for question #2, I would casually say the most frequent weighting function used in my field (Criminology) would be a a binary weighting scheme. Although I have rarely seen a good theoretical or empirical argument to use one weighting scheme over another (or how one defines a neighbor in a binary weighting scheme either). It may simply be because of historical preference and convienance that such a scheme is typically used. There is a distinction that should be drawn between data driven approaches to constructing spatial weights and the theory based approach to deriving spatial weights. You are currently performing the former, and in this approach you are implicitly treating the estimation of spatial weights as a problem of measurement error, and hence should use techniques to validate your measurements (which is considerably complicated due to the endogeneity of the spatial weights). Using a weighting scheme based on some of the chance variation in the data and using it in subsequent causal models is synonymous with other fallacies related to inference and data snooping. Unfortunately I have no good references of spatial weight models validated in any meaningful way besides the extent of the auto-correlation, which to be frank isn't all that convincing of an empirical argument. Spatial dependence can be the result of either causal processes (i.e. the value at one point in space affects the value at another point in space), or it can be the result of other measurement errors (i.e. the measured support of the data do not match the support of the processes that generate those phenomena). This is oppossed to theory based construction of spatial weights (or "model-driven" in Luc Anselin's terminology), in which one specifies the weight matrix a priori to estimating a model. I did not read the Fauchald paper you cited, but it appears in the abstract they have plausible theoretical explanations for the observed patterns based on some optimal foraging strategy. For readings I would suggest Luc Anselin's book, Spatial Econometrics: Methods and Models (1988), particularly chapters 2 and 3 will be of most interest. Also as another work with a similar viewpoint to mine (although it will likely be of less interest) is an essay piece by Gary King, "Why context should not count". I would also suggest another paper as it appears they had similar goals to yours, and defined the weights for a lattice system based on variogram estimates (Negreiros, 2010).
Choice of weight function in Moran's I Although not within the domain of geostatistics, for question #2, I would casually say the most frequent weighting function used in my field (Criminology) would be a a binary weighting scheme. Althoug
41,318
What is the closed form solution for the inverse CDF for Epanechnikov
You mean for a random variable with a single Epanechnikov kernel as PDF? Well, the PDF is $\frac{3}{4}(1-u^2)$, so the CDF is $\frac{1}{4}(2 + 3 u - u^3)$. Inverting this in Maple leads to three solutions, of which $$u = -1/2\,{\frac { \left( 1-2\,t+2\,i\sqrt {t}\sqrt {1-t} \right) ^{2/3}+1 +i\sqrt {3} \left( 1-2\,t+2\,i\sqrt {t}\sqrt {1-t} \right) ^{2/3}-i \sqrt {3}}{\sqrt [3]{1-2\,t+2\,i\sqrt {t}\sqrt {1-t}}}}$$ seems to be the right one (where the third roots return the main branch). Of course this is a real value for real values of $t$ between 0 and 1; I currently don't have time to make this come out right but I'll try and revisit in a couple of days. If someone else sees it, it would be great if you could leave a comment. Note whuber's comment below for a much nicer formula: $$ u(z)=2\sin\left(\frac{1}{3}\arcsin(2z-1)\right) $$ for $z\in[0,1].$
What is the closed form solution for the inverse CDF for Epanechnikov
You mean for a random variable with a single Epanechnikov kernel as PDF? Well, the PDF is $\frac{3}{4}(1-u^2)$, so the CDF is $\frac{1}{4}(2 + 3 u - u^3)$. Inverting this in Maple leads to three solut
What is the closed form solution for the inverse CDF for Epanechnikov You mean for a random variable with a single Epanechnikov kernel as PDF? Well, the PDF is $\frac{3}{4}(1-u^2)$, so the CDF is $\frac{1}{4}(2 + 3 u - u^3)$. Inverting this in Maple leads to three solutions, of which $$u = -1/2\,{\frac { \left( 1-2\,t+2\,i\sqrt {t}\sqrt {1-t} \right) ^{2/3}+1 +i\sqrt {3} \left( 1-2\,t+2\,i\sqrt {t}\sqrt {1-t} \right) ^{2/3}-i \sqrt {3}}{\sqrt [3]{1-2\,t+2\,i\sqrt {t}\sqrt {1-t}}}}$$ seems to be the right one (where the third roots return the main branch). Of course this is a real value for real values of $t$ between 0 and 1; I currently don't have time to make this come out right but I'll try and revisit in a couple of days. If someone else sees it, it would be great if you could leave a comment. Note whuber's comment below for a much nicer formula: $$ u(z)=2\sin\left(\frac{1}{3}\arcsin(2z-1)\right) $$ for $z\in[0,1].$
What is the closed form solution for the inverse CDF for Epanechnikov You mean for a random variable with a single Epanechnikov kernel as PDF? Well, the PDF is $\frac{3}{4}(1-u^2)$, so the CDF is $\frac{1}{4}(2 + 3 u - u^3)$. Inverting this in Maple leads to three solut
41,319
Balanced sampling for network training?
Yes, it is reasonable to select a balanced dataset, however if you do your model will probably over-predict the minority class in operation (or on the test set). This is easily overcome by using a threshold probability that is not 0.5. The best way to choose the new threshold is to optimise on a validation sample that has the same class frequencies as encountered in operation (or in the test set). Rather than re-sample the data, a better thing to do would be to give different weights to the positive and negative examples in the training criterion. This has the advantage that you use all of the available training data. The reason that a class imbalance leads to difficulties is not the imbalance per se. It is more that you just don't have enough examples from the minority class to adequately represent its underlying distribution. Therefore if you resample rather than re-weight, you are solving the problem by making the distribution of the majority class badly represented as well. Some may advise simply using a different threshold rather than reweighting or resampling. The problem with that approach is that with ANN the hidden layer units are optimised to minimise the training criterion, but the training criterion (e.g. sum-of-squares or cross-entropy) depends on how the behaviour of the model away from the decision boundary rather than only near the decision boundary. As as result hidden layer units may be assigned to tasks that reduce the value of the training criterion, but do not help in accurate classification. Using re-weighted training patterns helps here as it tends to focus attention more on the decision boundary, and so the allocation of hidden layer resources may be better. For references, a google scholar search for "Nitesh Chawla" would be a good start, he has done a fair amount of very solid work on this.
Balanced sampling for network training?
Yes, it is reasonable to select a balanced dataset, however if you do your model will probably over-predict the minority class in operation (or on the test set). This is easily overcome by using a th
Balanced sampling for network training? Yes, it is reasonable to select a balanced dataset, however if you do your model will probably over-predict the minority class in operation (or on the test set). This is easily overcome by using a threshold probability that is not 0.5. The best way to choose the new threshold is to optimise on a validation sample that has the same class frequencies as encountered in operation (or in the test set). Rather than re-sample the data, a better thing to do would be to give different weights to the positive and negative examples in the training criterion. This has the advantage that you use all of the available training data. The reason that a class imbalance leads to difficulties is not the imbalance per se. It is more that you just don't have enough examples from the minority class to adequately represent its underlying distribution. Therefore if you resample rather than re-weight, you are solving the problem by making the distribution of the majority class badly represented as well. Some may advise simply using a different threshold rather than reweighting or resampling. The problem with that approach is that with ANN the hidden layer units are optimised to minimise the training criterion, but the training criterion (e.g. sum-of-squares or cross-entropy) depends on how the behaviour of the model away from the decision boundary rather than only near the decision boundary. As as result hidden layer units may be assigned to tasks that reduce the value of the training criterion, but do not help in accurate classification. Using re-weighted training patterns helps here as it tends to focus attention more on the decision boundary, and so the allocation of hidden layer resources may be better. For references, a google scholar search for "Nitesh Chawla" would be a good start, he has done a fair amount of very solid work on this.
Balanced sampling for network training? Yes, it is reasonable to select a balanced dataset, however if you do your model will probably over-predict the minority class in operation (or on the test set). This is easily overcome by using a th
41,320
When is a deviation statistically significant?
This question gets to the heart of statistical thinking by recognizing that both (a) "every experiment is different," implying no single "cookbook" recipe will suffice to assess experimental results in all cases and (b) "significance should depend on the deviations in measurements," pointing towards the importance of probability theory in modeling the deviations. Unfortunately (a) indicates that a universal "simple formula" is not possible. However, some things can be said in general. These include Deviations in measurements can be attributed partly to predictable phenomena as determined by properties of the subjects or the experiments. For example, weights of people depend (on average) partly on their gender. Deviations that are not predictable or determinate are usually modeled as random variables. How you analyze the deviations into these deterministic and random components is a probability model. Probability models can be as simple as textbook descriptions of dice and coins, but for realistic situations they can be quite complex. Statistical "significance" measures the chance, when (hypothetically) the treatment has no effect, that some measure of difference between treatment and control groups would cause us to infer the groups are indeed different. This description is lengthy because so much is involved in its preparation: measuring the results, expressing the differences between the groups in some way (the test statistic), and selecting an inference procedure based on that statistic. Each of these things is under the control of the experimenter or observer and each is important. A simple textbook example concerns a controlled experiment in which only two outcomes are possible for each subject, such as "dies" and "lives". With good experimental design--double-blinding, randomization of subjects, careful measurement, etc.--we can view the experimental outcomes behaving random draws of tickets from a box, where each ticket is labeled with one of the two outcomes. This is the probability model. The test statistic is usually the difference in proportions between the two groups (e.g., the difference between their mortality rates). Statistical theory, in the form of the Neyman-Pearson Lemma, tells us to base our determination of the experimental result on whether this difference exceeds some predetermined threshold. Probability theory allows us to analyze this tickets-in-a-box model to come up with an appropriate threshold (the test's critical region). The theory shows precisely how that threshold depends on the sizes of the control and treatment groups. To go further, you need to learn some basic probability theory and see applications in some exemplary cases. This will accustom you to the habit of "thinking statistically" about everyday things. Two great resources are Smith & Gonick's Cartoon Guide to Statistics and the classic Freedman et al. textbook Statistics, used at Berkeley for several generations. (The link goes to an older edition which you can inspect online and buy used for almost nothing.)
When is a deviation statistically significant?
This question gets to the heart of statistical thinking by recognizing that both (a) "every experiment is different," implying no single "cookbook" recipe will suffice to assess experimental results i
When is a deviation statistically significant? This question gets to the heart of statistical thinking by recognizing that both (a) "every experiment is different," implying no single "cookbook" recipe will suffice to assess experimental results in all cases and (b) "significance should depend on the deviations in measurements," pointing towards the importance of probability theory in modeling the deviations. Unfortunately (a) indicates that a universal "simple formula" is not possible. However, some things can be said in general. These include Deviations in measurements can be attributed partly to predictable phenomena as determined by properties of the subjects or the experiments. For example, weights of people depend (on average) partly on their gender. Deviations that are not predictable or determinate are usually modeled as random variables. How you analyze the deviations into these deterministic and random components is a probability model. Probability models can be as simple as textbook descriptions of dice and coins, but for realistic situations they can be quite complex. Statistical "significance" measures the chance, when (hypothetically) the treatment has no effect, that some measure of difference between treatment and control groups would cause us to infer the groups are indeed different. This description is lengthy because so much is involved in its preparation: measuring the results, expressing the differences between the groups in some way (the test statistic), and selecting an inference procedure based on that statistic. Each of these things is under the control of the experimenter or observer and each is important. A simple textbook example concerns a controlled experiment in which only two outcomes are possible for each subject, such as "dies" and "lives". With good experimental design--double-blinding, randomization of subjects, careful measurement, etc.--we can view the experimental outcomes behaving random draws of tickets from a box, where each ticket is labeled with one of the two outcomes. This is the probability model. The test statistic is usually the difference in proportions between the two groups (e.g., the difference between their mortality rates). Statistical theory, in the form of the Neyman-Pearson Lemma, tells us to base our determination of the experimental result on whether this difference exceeds some predetermined threshold. Probability theory allows us to analyze this tickets-in-a-box model to come up with an appropriate threshold (the test's critical region). The theory shows precisely how that threshold depends on the sizes of the control and treatment groups. To go further, you need to learn some basic probability theory and see applications in some exemplary cases. This will accustom you to the habit of "thinking statistically" about everyday things. Two great resources are Smith & Gonick's Cartoon Guide to Statistics and the classic Freedman et al. textbook Statistics, used at Berkeley for several generations. (The link goes to an older edition which you can inspect online and buy used for almost nothing.)
When is a deviation statistically significant? This question gets to the heart of statistical thinking by recognizing that both (a) "every experiment is different," implying no single "cookbook" recipe will suffice to assess experimental results i
41,321
Gradient descent oscillating a lot. Have I chosen my step direction incorrectly?
When you say 'a absolute loss function', do you mean you're using least absolute deviations (LAD) instead of the more usual ordinary least squares (OLS)? As that wikipedia article says, although LAD is more robust to outliers than OLS it can be unstable and even have multiple solutions, so it doesn't seem that surprising if it's harder to find the minimum of the objective function even when there's only one. If you're trying this because you're after some sort of robust regression, I think there are several more attractive alternatives than LAD.
Gradient descent oscillating a lot. Have I chosen my step direction incorrectly?
When you say 'a absolute loss function', do you mean you're using least absolute deviations (LAD) instead of the more usual ordinary least squares (OLS)? As that wikipedia article says, although LAD i
Gradient descent oscillating a lot. Have I chosen my step direction incorrectly? When you say 'a absolute loss function', do you mean you're using least absolute deviations (LAD) instead of the more usual ordinary least squares (OLS)? As that wikipedia article says, although LAD is more robust to outliers than OLS it can be unstable and even have multiple solutions, so it doesn't seem that surprising if it's harder to find the minimum of the objective function even when there's only one. If you're trying this because you're after some sort of robust regression, I think there are several more attractive alternatives than LAD.
Gradient descent oscillating a lot. Have I chosen my step direction incorrectly? When you say 'a absolute loss function', do you mean you're using least absolute deviations (LAD) instead of the more usual ordinary least squares (OLS)? As that wikipedia article says, although LAD i
41,322
Gradient descent oscillating a lot. Have I chosen my step direction incorrectly?
This is possibly a consequence of a known deficiency of steepest descent algorithms in general. Using a conjugate gradient algorithm may improve convergence.
Gradient descent oscillating a lot. Have I chosen my step direction incorrectly?
This is possibly a consequence of a known deficiency of steepest descent algorithms in general. Using a conjugate gradient algorithm may improve convergence.
Gradient descent oscillating a lot. Have I chosen my step direction incorrectly? This is possibly a consequence of a known deficiency of steepest descent algorithms in general. Using a conjugate gradient algorithm may improve convergence.
Gradient descent oscillating a lot. Have I chosen my step direction incorrectly? This is possibly a consequence of a known deficiency of steepest descent algorithms in general. Using a conjugate gradient algorithm may improve convergence.
41,323
Repositories and data analysis projects
Regarding your first question: What strategies do people use to map studies, publications, and analyses onto repositories? One year ago or so, I decided to have one repository for each publication, presentation or semester/class. My typical directory looks like this: .git .gitignore README.org ana dat doc org The underlying idea is (hopefully) obvious: Each publication, presentation, class is an "autarchic entity" which I could easily share with others. By the way, you are not the first to ask this question: One repository/multiple projects without getting mixed up? However, I also started using git for managing projects which might result in some publications (the directory structure follows roughly John Myles White's ProjectTemplate, without using it, though). .git .gitignore README.org ana data docs graphs lib org reports tests Regarding your second question: When should related entities (e.g., publications, studies, etc.) be split into multiple repositories? I cannot think of any reason to split a publication, conference etc. related repository into multiple repositories. But I would be interested in other opinions...
Repositories and data analysis projects
Regarding your first question: What strategies do people use to map studies, publications, and analyses onto repositories? One year ago or so, I decided to have one repository for each publication,
Repositories and data analysis projects Regarding your first question: What strategies do people use to map studies, publications, and analyses onto repositories? One year ago or so, I decided to have one repository for each publication, presentation or semester/class. My typical directory looks like this: .git .gitignore README.org ana dat doc org The underlying idea is (hopefully) obvious: Each publication, presentation, class is an "autarchic entity" which I could easily share with others. By the way, you are not the first to ask this question: One repository/multiple projects without getting mixed up? However, I also started using git for managing projects which might result in some publications (the directory structure follows roughly John Myles White's ProjectTemplate, without using it, though). .git .gitignore README.org ana data docs graphs lib org reports tests Regarding your second question: When should related entities (e.g., publications, studies, etc.) be split into multiple repositories? I cannot think of any reason to split a publication, conference etc. related repository into multiple repositories. But I would be interested in other opinions...
Repositories and data analysis projects Regarding your first question: What strategies do people use to map studies, publications, and analyses onto repositories? One year ago or so, I decided to have one repository for each publication,
41,324
Repositories and data analysis projects
I keep a separate repository for each project, with a project being centered around a particular data set or question being addressed. The repo contains the data, code, and Sweave documents/plots that explain and express the results. I maintain a separate repo for each discrete publication or presentation because A single project may result in multiple publications or presentations. Once a publication is out or you've given the presentation, you are essentially "done" with the contents of that repo so they don't need to be dragged around with the project. A output (publication/presentation/chapter) may contain data from more than one project. Not all of the results from a project will end up in a particular piece of output. Code that is reusable across projects gets its own repo, as well. If I come up with a new & discrete question using data that is already in one repo, I'll copy that data to a new repo. If you want to be really strict about it, many version control systems offer the idea of "subprojects", but I've found that to be overkill.
Repositories and data analysis projects
I keep a separate repository for each project, with a project being centered around a particular data set or question being addressed. The repo contains the data, code, and Sweave documents/plots that
Repositories and data analysis projects I keep a separate repository for each project, with a project being centered around a particular data set or question being addressed. The repo contains the data, code, and Sweave documents/plots that explain and express the results. I maintain a separate repo for each discrete publication or presentation because A single project may result in multiple publications or presentations. Once a publication is out or you've given the presentation, you are essentially "done" with the contents of that repo so they don't need to be dragged around with the project. A output (publication/presentation/chapter) may contain data from more than one project. Not all of the results from a project will end up in a particular piece of output. Code that is reusable across projects gets its own repo, as well. If I come up with a new & discrete question using data that is already in one repo, I'll copy that data to a new repo. If you want to be really strict about it, many version control systems offer the idea of "subprojects", but I've found that to be overkill.
Repositories and data analysis projects I keep a separate repository for each project, with a project being centered around a particular data set or question being addressed. The repo contains the data, code, and Sweave documents/plots that
41,325
Fractal alternative to correlation
I doubt you're going to find a single answer to this, given the space of fractal dimensions. Most papers (in physics, geology) looking at correlation simply stick to a Pearson correlation with fractal math reserved for identifying dimension/self-similarity, etc. But you might be interested in the following papers which use a "Correlation Fractal Dimension" as a similarity metric. The second paper mentions a fractal clustering algorithm which employs this metric. Estimating the Selectivity of Spatial Queries Using the `Correlation' Fractal Dimension (Belussi, Faloutsos, 1995) Characterizing Datasets Using Fractal Methods (Abrahao, Barbosa, 2003)
Fractal alternative to correlation
I doubt you're going to find a single answer to this, given the space of fractal dimensions. Most papers (in physics, geology) looking at correlation simply stick to a Pearson correlation with fracta
Fractal alternative to correlation I doubt you're going to find a single answer to this, given the space of fractal dimensions. Most papers (in physics, geology) looking at correlation simply stick to a Pearson correlation with fractal math reserved for identifying dimension/self-similarity, etc. But you might be interested in the following papers which use a "Correlation Fractal Dimension" as a similarity metric. The second paper mentions a fractal clustering algorithm which employs this metric. Estimating the Selectivity of Spatial Queries Using the `Correlation' Fractal Dimension (Belussi, Faloutsos, 1995) Characterizing Datasets Using Fractal Methods (Abrahao, Barbosa, 2003)
Fractal alternative to correlation I doubt you're going to find a single answer to this, given the space of fractal dimensions. Most papers (in physics, geology) looking at correlation simply stick to a Pearson correlation with fracta
41,326
Fractal alternative to correlation
I agree with @ars that you are unlikely to get one answer for this (you may also have more success on http://mathoverflow.net, since our community tends to be more applied, while this technique would have very little real-world usage). The Abrahao/Barbosa paper is a good reference. Just to provide some additional sources: This paper looks at the correlation between fractal dimensions, which seems like a reasonable approach to the problem. "The correlation of fractal structures in the photospheric and the coronal magnetic field" (Dimitropoulou, Georgoulis, Isliker, Vlahos, Anastasiadis, Strintzi, Moussas 2009) This paper uses the multi-fractal spectra to estimate correlation: "Continuous wavelet transform based time-scale and multi-fractal analysis of the nonlinear oscillations in a hollow cathode glow discharge plasma" (Nurujjaman, Narayanan, Iyengar 2009) Regarding the "Correlation Fractal Dimension", this paper provides a fast algorithm: "Faster estimation of the correlation fractal dimension using box-counting" (Attikos, Doumpos 2009)
Fractal alternative to correlation
I agree with @ars that you are unlikely to get one answer for this (you may also have more success on http://mathoverflow.net, since our community tends to be more applied, while this technique would
Fractal alternative to correlation I agree with @ars that you are unlikely to get one answer for this (you may also have more success on http://mathoverflow.net, since our community tends to be more applied, while this technique would have very little real-world usage). The Abrahao/Barbosa paper is a good reference. Just to provide some additional sources: This paper looks at the correlation between fractal dimensions, which seems like a reasonable approach to the problem. "The correlation of fractal structures in the photospheric and the coronal magnetic field" (Dimitropoulou, Georgoulis, Isliker, Vlahos, Anastasiadis, Strintzi, Moussas 2009) This paper uses the multi-fractal spectra to estimate correlation: "Continuous wavelet transform based time-scale and multi-fractal analysis of the nonlinear oscillations in a hollow cathode glow discharge plasma" (Nurujjaman, Narayanan, Iyengar 2009) Regarding the "Correlation Fractal Dimension", this paper provides a fast algorithm: "Faster estimation of the correlation fractal dimension using box-counting" (Attikos, Doumpos 2009)
Fractal alternative to correlation I agree with @ars that you are unlikely to get one answer for this (you may also have more success on http://mathoverflow.net, since our community tends to be more applied, while this technique would
41,327
Dealing with missing data due to variable not being measured over initial period of a study
I like the partial identification approach to missing data of Manski. The basic idea is to ask: given all possible values the missing data could have, what is the set of values that the estimated parameters could take? This set might be very large, in which case you could consider restricting the distribution of the missing data. Manski has a bunch of papers and a book on this topic. This short paper is a good overview. Inference in partially identified models can be complicated and is an active area of research. This review (ungated pdf) is a good place to get started.
Dealing with missing data due to variable not being measured over initial period of a study
I like the partial identification approach to missing data of Manski. The basic idea is to ask: given all possible values the missing data could have, what is the set of values that the estimated para
Dealing with missing data due to variable not being measured over initial period of a study I like the partial identification approach to missing data of Manski. The basic idea is to ask: given all possible values the missing data could have, what is the set of values that the estimated parameters could take? This set might be very large, in which case you could consider restricting the distribution of the missing data. Manski has a bunch of papers and a book on this topic. This short paper is a good overview. Inference in partially identified models can be complicated and is an active area of research. This review (ungated pdf) is a good place to get started.
Dealing with missing data due to variable not being measured over initial period of a study I like the partial identification approach to missing data of Manski. The basic idea is to ask: given all possible values the missing data could have, what is the set of values that the estimated para
41,328
Analytical solutions to limits of correlation stress testing
This is not a complete answer but it was too long to fit in as a comment and hopefully gives you some ideas. What I am about to say is not really a proof but more of an intuitive sketch as to why the minimum eigenvalue may matter as far as the upper stress boundary is concerned. Every correlation matrix can be decomposed into a set of eigenvectors and a corresponding set of eigenvalues. The eigenvectors correspond to the axis of the ellipsoid associated with the correlation matrix and the eigenvalues give us a 'sense' of the length of the axis associated with the corresponding eigenvector. Now, when you stress a correlation matrix you are essentially performing one or more of the following two operations simultaneously: 1. You are rotating the eigenvectors and 2. You are changing the eigenvalues. Notice that rotating eigenvectors simply changes the orientation of the ellipsoid but if the eigenvalues remain positive then we have a psd correlation matrix. However, as eigenvalues drop the ellipsoid shrinks in the direction of the corresponding eigenvector and eventually as the eigenvalue reaches zero the ellipsoid collapses completely in that direction resulting in a matrix that is not psd. As you stress the correlation matrix there is less room along the axis that is shortest (i.e., the axis which has the lowest eigenvalue) to shrink and thus the minimum eigenvalue has a special role to play in stress testing.
Analytical solutions to limits of correlation stress testing
This is not a complete answer but it was too long to fit in as a comment and hopefully gives you some ideas. What I am about to say is not really a proof but more of an intuitive sketch as to why the
Analytical solutions to limits of correlation stress testing This is not a complete answer but it was too long to fit in as a comment and hopefully gives you some ideas. What I am about to say is not really a proof but more of an intuitive sketch as to why the minimum eigenvalue may matter as far as the upper stress boundary is concerned. Every correlation matrix can be decomposed into a set of eigenvectors and a corresponding set of eigenvalues. The eigenvectors correspond to the axis of the ellipsoid associated with the correlation matrix and the eigenvalues give us a 'sense' of the length of the axis associated with the corresponding eigenvector. Now, when you stress a correlation matrix you are essentially performing one or more of the following two operations simultaneously: 1. You are rotating the eigenvectors and 2. You are changing the eigenvalues. Notice that rotating eigenvectors simply changes the orientation of the ellipsoid but if the eigenvalues remain positive then we have a psd correlation matrix. However, as eigenvalues drop the ellipsoid shrinks in the direction of the corresponding eigenvector and eventually as the eigenvalue reaches zero the ellipsoid collapses completely in that direction resulting in a matrix that is not psd. As you stress the correlation matrix there is less room along the axis that is shortest (i.e., the axis which has the lowest eigenvalue) to shrink and thus the minimum eigenvalue has a special role to play in stress testing.
Analytical solutions to limits of correlation stress testing This is not a complete answer but it was too long to fit in as a comment and hopefully gives you some ideas. What I am about to say is not really a proof but more of an intuitive sketch as to why the
41,329
Analytical solutions to limits of correlation stress testing
As kwak has pointed out, my question was answered on another forum: http://www.or-exchange.com/questions/695/analytical-solutions-to-limits-of-correlation-stress-testing I did several quick calculations and the suggested analytical solution is consistent with the numerical ones. I still need to check the proof.
Analytical solutions to limits of correlation stress testing
As kwak has pointed out, my question was answered on another forum: http://www.or-exchange.com/questions/695/analytical-solutions-to-limits-of-correlation-stress-testing I did several quick calculatio
Analytical solutions to limits of correlation stress testing As kwak has pointed out, my question was answered on another forum: http://www.or-exchange.com/questions/695/analytical-solutions-to-limits-of-correlation-stress-testing I did several quick calculations and the suggested analytical solution is consistent with the numerical ones. I still need to check the proof.
Analytical solutions to limits of correlation stress testing As kwak has pointed out, my question was answered on another forum: http://www.or-exchange.com/questions/695/analytical-solutions-to-limits-of-correlation-stress-testing I did several quick calculatio
41,330
Analytical solutions to limits of correlation stress testing
The proof should be rather simple. Let $C$ be your correlation matrix (it has all ones on the diagonal). You multiply each element on the off diagonal by $(1+k)$. This is equivalent to computing the matrix $\hat{C} = (1+k) C - k \operatorname{diag}(C) = (1+k)C - k I,$ where $\operatorname{diag}$ is the diagonal part of a matrix, which in the case of $C$ is $I$, the identity matrix. It is well known that the eigenvalues of a matrix commute with a polynomial applied to the matrix, and we are computing a polynomial function of $C$, with polynomial function $f(x) = (1+k)x - k$. Thus if $\lambda$ is an eigenvalue of $C$, then $f(\lambda) = (1+k)\lambda - k$ is an eigenvalue of $\hat{C} = f(C)$. Setting $f(\lambda) \le 0$ for $\lambda$ an eigenvalue of $C$ gives the desired condition on $k$. Note that depending on whether $k$ is positive or negative, you will want to check either $f(\lambda_1)$ or $f(\lambda_n)$, where $\lambda_1, \lambda_n$ are the smallest and largest eigenvalue of $C$. Unless $C$ is the identity matrix, you will have $\lambda_1 \lt 1 \lt \lambda_n$. This is the case because the sum of the eigenvalues equals $n$, the size of the matrix $C$. The commutivity of eigenvalues and polynomials is easy to check, actually. First if $x, \lambda$ are eigenvector, eigenvalue of matrix $A$, show that $x, c\lambda^j$ are eigenvector, eigenvalue of $c A^j$. This holds for integer $j$, even negative integers or zero. Then show that if $x, \lambda_1$ are eigenvector, -value of $A$ and $x, \lambda_2$ are eigenvector, -value of $B$, then $x, \lambda_1 + \lambda_2$ are eigenvector, -value of $A + B$. From there, one can easily show that $x, c_0 + c_1 \lambda + c_2 \lambda^2 + \ldots c_n \lambda^n$ are eigenvector, -value of the matrix $c_0 I + c_1 A + c_2 A^2 + \ldots c_n A^n$.
Analytical solutions to limits of correlation stress testing
The proof should be rather simple. Let $C$ be your correlation matrix (it has all ones on the diagonal). You multiply each element on the off diagonal by $(1+k)$. This is equivalent to computing the m
Analytical solutions to limits of correlation stress testing The proof should be rather simple. Let $C$ be your correlation matrix (it has all ones on the diagonal). You multiply each element on the off diagonal by $(1+k)$. This is equivalent to computing the matrix $\hat{C} = (1+k) C - k \operatorname{diag}(C) = (1+k)C - k I,$ where $\operatorname{diag}$ is the diagonal part of a matrix, which in the case of $C$ is $I$, the identity matrix. It is well known that the eigenvalues of a matrix commute with a polynomial applied to the matrix, and we are computing a polynomial function of $C$, with polynomial function $f(x) = (1+k)x - k$. Thus if $\lambda$ is an eigenvalue of $C$, then $f(\lambda) = (1+k)\lambda - k$ is an eigenvalue of $\hat{C} = f(C)$. Setting $f(\lambda) \le 0$ for $\lambda$ an eigenvalue of $C$ gives the desired condition on $k$. Note that depending on whether $k$ is positive or negative, you will want to check either $f(\lambda_1)$ or $f(\lambda_n)$, where $\lambda_1, \lambda_n$ are the smallest and largest eigenvalue of $C$. Unless $C$ is the identity matrix, you will have $\lambda_1 \lt 1 \lt \lambda_n$. This is the case because the sum of the eigenvalues equals $n$, the size of the matrix $C$. The commutivity of eigenvalues and polynomials is easy to check, actually. First if $x, \lambda$ are eigenvector, eigenvalue of matrix $A$, show that $x, c\lambda^j$ are eigenvector, eigenvalue of $c A^j$. This holds for integer $j$, even negative integers or zero. Then show that if $x, \lambda_1$ are eigenvector, -value of $A$ and $x, \lambda_2$ are eigenvector, -value of $B$, then $x, \lambda_1 + \lambda_2$ are eigenvector, -value of $A + B$. From there, one can easily show that $x, c_0 + c_1 \lambda + c_2 \lambda^2 + \ldots c_n \lambda^n$ are eigenvector, -value of the matrix $c_0 I + c_1 A + c_2 A^2 + \ldots c_n A^n$.
Analytical solutions to limits of correlation stress testing The proof should be rather simple. Let $C$ be your correlation matrix (it has all ones on the diagonal). You multiply each element on the off diagonal by $(1+k)$. This is equivalent to computing the m
41,331
Analytical solutions to limits of correlation stress testing
I am not sure what the real question is, but suppose instead of changing every non-diagonal element, you changed just 2 (to keep the resulting matrix symmetric). That is let $\hat{C}$ be $C$ with $\hat{C_{i,j}} = C_{i,j} + \Delta C / 2= \hat{C_{j,i}},$ for some choice of $i,j$ with $i \ne j$. (alternatively, imagine $\Delta C$ is added to $C_{i,j}$ only, and so $\hat{C}$ is no longer symmetric.) I will consider the question "how small can $\Delta C$ be before $\hat{C}$ is no longer PSD?" This question is easily solved as well, but the answer is not enlightening in my view. Let $\lambda_k, x^{(k)}$ be eigenvalue and eigenvector of $C$, where the eigenvector has unit norm. $\hat{C}$ is no longer PSD if there is index $k$ such that $\lambda_k + \Delta C x^{(k)}_i x^{(k)}_j < 0$. This can only hold if $x^{(k)}_i x^{(k)}_j < 0$, in which case we have $\Delta C > -\lambda_k / x^{(k)}_i x^{(k)}_j$. Compute the RHS for each $k$ for which the negativity condition holds and take the minimum, and that gives you the sufficient condition on $\Delta C.$
Analytical solutions to limits of correlation stress testing
I am not sure what the real question is, but suppose instead of changing every non-diagonal element, you changed just 2 (to keep the resulting matrix symmetric). That is let $\hat{C}$ be $C$ with $\ha
Analytical solutions to limits of correlation stress testing I am not sure what the real question is, but suppose instead of changing every non-diagonal element, you changed just 2 (to keep the resulting matrix symmetric). That is let $\hat{C}$ be $C$ with $\hat{C_{i,j}} = C_{i,j} + \Delta C / 2= \hat{C_{j,i}},$ for some choice of $i,j$ with $i \ne j$. (alternatively, imagine $\Delta C$ is added to $C_{i,j}$ only, and so $\hat{C}$ is no longer symmetric.) I will consider the question "how small can $\Delta C$ be before $\hat{C}$ is no longer PSD?" This question is easily solved as well, but the answer is not enlightening in my view. Let $\lambda_k, x^{(k)}$ be eigenvalue and eigenvector of $C$, where the eigenvector has unit norm. $\hat{C}$ is no longer PSD if there is index $k$ such that $\lambda_k + \Delta C x^{(k)}_i x^{(k)}_j < 0$. This can only hold if $x^{(k)}_i x^{(k)}_j < 0$, in which case we have $\Delta C > -\lambda_k / x^{(k)}_i x^{(k)}_j$. Compute the RHS for each $k$ for which the negativity condition holds and take the minimum, and that gives you the sufficient condition on $\Delta C.$
Analytical solutions to limits of correlation stress testing I am not sure what the real question is, but suppose instead of changing every non-diagonal element, you changed just 2 (to keep the resulting matrix symmetric). That is let $\hat{C}$ be $C$ with $\ha
41,332
Preferred method for identifying curvilinear effect in multi-variable regression framework
It sounds as though you are interested in formal inference and for that method 4 is best. Add X^2 to a model containing terms you wish to control for and conduct a test to assess the streght of evidence for the quadratic term given the terms in the model. Note however that "absence of evidence is not evidence of absence" and statistical power will come into play (this is of interest if you fail to reject or the CI contains zero). You willof course also want to perform diagnostics of model assumptions prior to drawing conclusions. Methods 1 and 2 are excellent exploratory tools and I would encourage exploring the relationship in as many meaningful ways as you wish (since you know a priori what formal test you will conduct -- a test of the quadratic term -- this will not lead to data-driven hypothesis testing). Other methods of exploration include plotting a fitted LOESS smoother or spline to the (possibly partial) relationships, fitting smoothers or parametric fits within subsets of the data (eg using conditioning plots), a 3d scatterplot with a fitted surface (particularly if you include continuous interactions), etc. These plots will not only help you understand the data better but can also be used as part of a less formal case for/against the quadratic (keeping in mind that humans are excellent at spotting trends in noise). I'm not sure what model selection methods you refer to in 3, but generally automated model selection and testing do not mix. If you are referring to using information criteria (AICc, BIC, ...) note that the theory behind these is based on prediction rather than testing. So, number 4 is the most rigorous way to test the quadratic. Finally, 2 comments on terminology: 'multivariate' models are those whose response is a matrix, and 'multivariable' models are those with a vector response and multiple terms on the RHS. Partial residual plots differ from partial regression plots..
Preferred method for identifying curvilinear effect in multi-variable regression framework
It sounds as though you are interested in formal inference and for that method 4 is best. Add X^2 to a model containing terms you wish to control for and conduct a test to assess the streght of evide
Preferred method for identifying curvilinear effect in multi-variable regression framework It sounds as though you are interested in formal inference and for that method 4 is best. Add X^2 to a model containing terms you wish to control for and conduct a test to assess the streght of evidence for the quadratic term given the terms in the model. Note however that "absence of evidence is not evidence of absence" and statistical power will come into play (this is of interest if you fail to reject or the CI contains zero). You willof course also want to perform diagnostics of model assumptions prior to drawing conclusions. Methods 1 and 2 are excellent exploratory tools and I would encourage exploring the relationship in as many meaningful ways as you wish (since you know a priori what formal test you will conduct -- a test of the quadratic term -- this will not lead to data-driven hypothesis testing). Other methods of exploration include plotting a fitted LOESS smoother or spline to the (possibly partial) relationships, fitting smoothers or parametric fits within subsets of the data (eg using conditioning plots), a 3d scatterplot with a fitted surface (particularly if you include continuous interactions), etc. These plots will not only help you understand the data better but can also be used as part of a less formal case for/against the quadratic (keeping in mind that humans are excellent at spotting trends in noise). I'm not sure what model selection methods you refer to in 3, but generally automated model selection and testing do not mix. If you are referring to using information criteria (AICc, BIC, ...) note that the theory behind these is based on prediction rather than testing. So, number 4 is the most rigorous way to test the quadratic. Finally, 2 comments on terminology: 'multivariate' models are those whose response is a matrix, and 'multivariable' models are those with a vector response and multiple terms on the RHS. Partial residual plots differ from partial regression plots..
Preferred method for identifying curvilinear effect in multi-variable regression framework It sounds as though you are interested in formal inference and for that method 4 is best. Add X^2 to a model containing terms you wish to control for and conduct a test to assess the streght of evide
41,333
Preferred method for identifying curvilinear effect in multi-variable regression framework
Thanks again for the response, and any other responses in the future will be much appreciated. I think I personally prefer using exploratory tools to identify the relationships, especially since the original researcher did not give any real reason why a curvilinear relationship would exist theoretically. Although exploration would identify if the relationship was not properly identified (e.g. if it should have been a cubed polynomial term instead of squared), this seems unlikely given theres no reason why it would have a curve in it to begin with. The attached image is a plot of several of their finals models, and I have plotted the expected value of Y given their X and X^2 coefficients reported, holding everything else in the models constant. If their results are representative, I should observe similar findings in my sample controlling for other confounders. It also is enlightening just to plot their findings, as I see the squared term dominates in several of the models, and so for all practical purposes it has a negative relationship that reaches the bottom of realistic Y values fairly quickly.
Preferred method for identifying curvilinear effect in multi-variable regression framework
Thanks again for the response, and any other responses in the future will be much appreciated. I think I personally prefer using exploratory tools to identify the relationships, especially since the o
Preferred method for identifying curvilinear effect in multi-variable regression framework Thanks again for the response, and any other responses in the future will be much appreciated. I think I personally prefer using exploratory tools to identify the relationships, especially since the original researcher did not give any real reason why a curvilinear relationship would exist theoretically. Although exploration would identify if the relationship was not properly identified (e.g. if it should have been a cubed polynomial term instead of squared), this seems unlikely given theres no reason why it would have a curve in it to begin with. The attached image is a plot of several of their finals models, and I have plotted the expected value of Y given their X and X^2 coefficients reported, holding everything else in the models constant. If their results are representative, I should observe similar findings in my sample controlling for other confounders. It also is enlightening just to plot their findings, as I see the squared term dominates in several of the models, and so for all practical purposes it has a negative relationship that reaches the bottom of realistic Y values fairly quickly.
Preferred method for identifying curvilinear effect in multi-variable regression framework Thanks again for the response, and any other responses in the future will be much appreciated. I think I personally prefer using exploratory tools to identify the relationships, especially since the o
41,334
Mixed regression models and custom link functions in R?
Douglas Bates addressed this on the sig-ME list a while back: using glmer with user-defined link function I'm not aware of significant changes since, but his recommendation (using a quasi family with specified link and variance) might be of use. Hopefully this addresses your first and third questions. I'm not aware of other packages - sorry.
Mixed regression models and custom link functions in R?
Douglas Bates addressed this on the sig-ME list a while back: using glmer with user-defined link function I'm not aware of significant changes since, but his recommendation (using a quasi family wit
Mixed regression models and custom link functions in R? Douglas Bates addressed this on the sig-ME list a while back: using glmer with user-defined link function I'm not aware of significant changes since, but his recommendation (using a quasi family with specified link and variance) might be of use. Hopefully this addresses your first and third questions. I'm not aware of other packages - sorry.
Mixed regression models and custom link functions in R? Douglas Bates addressed this on the sig-ME list a while back: using glmer with user-defined link function I'm not aware of significant changes since, but his recommendation (using a quasi family wit
41,335
Mixed regression models and custom link functions in R?
repeated::gnlmix() PROC NLMIXED -- If the link or its inverse can be represented with the functions available in SAS. I need to dig more into the code. Some repeated::gnlmix() examples: library(repeated) set.seed(99) dat <- data.frame(id = c(1,1,1, 2,2,2, 3,3,3, 4,4,4), y = c(1,0,1, 0,1,1, 0,0,0, 1,1,1), x = rnorm(12) ) attach(dat) y_cbind <- cbind(y, 1-y) # probit regression gnlmix(y=y_cbind, distribution = "binomial", nest = id, mixture = "normal", random = "b_id", mu = ~ pnorm(beta0 + beta1*x + b_id), pmu = list(beta0=0, beta1=0), pmix = log(4) ) # Location parameters: # estimate se # beta0 0.2825 0.7878 # beta1 -0.7628 1.1498 # # Mixing dispersion parameter: # estimate se # 0.4249 2.072 # cauchy link gnlmix(y=y_cbind, distribution = "binomial", nest = id, mixture = "normal", random = "b_id", mu = ~ pcauchy(beta0 + beta1*x + b_id), pmu = list(beta0=0, beta1=0), pmix = log(4) ) # Location parameters: # estimate se # beta0 0.6973 1.791 # beta1 -1.2328 2.812 # # Mixing dispersion parameter: # estimate se # 1.805 3.038 # logistic regression gnlmix(y=y_cbind, distribution = "binomial", nest = id, mixture = "normal", random = "b_id", mu = ~ plogis(beta0 + beta1*x + b_id), pmu = list(beta0=0, beta1=0), pmix = log(4) ) # Location parameters: # estimate se # beta0 0.4981 1.356 # beta1 -1.2740 2.036 # # Mixing dispersion parameter: # estimate se # 1.496 2.177 # custom link / inverse (logistic regression) custom_inv <- function(eta) exp(eta) / (exp(eta) + 1) gnlmix(y=y_cbind, distribution = "binomial", nest = id, mixture = "normal", random = "b_id", mu = ~ custom_inv(beta0 + beta1*x + b_id), pmu = list(beta0=0, beta1=0), pmix = log(4) ) # Location parameters: # estimate se # beta0 0.4981 1.356 # beta1 -1.2740 2.036 # # Mixing dispersion parameter: # estimate se # 1.496 2.177 # custom link / inverse custom_inv <- function(eta) log(exp(eta)+1) / (log(exp(eta)+1) + pi/2) gnlmix(y=y_cbind, distribution = "binomial", nest = id, mixture = "normal", random = "b_id", mu = ~ custom_inv(beta0 + beta1*x + b_id), pmu = list(beta0=0, beta1=0), pmix = log(4) ) # Location parameters: # estimate se # beta0 4.333 5.477 # beta1 -2.291 5.571 # # Mixing dispersion parameter: # estimate se # 3.879 2.386 For GLMs, see gnlm::gnlr() as shown here.
Mixed regression models and custom link functions in R?
repeated::gnlmix() PROC NLMIXED -- If the link or its inverse can be represented with the functions available in SAS. I need to dig more into the code. Some repeated::gnlmix() examples: library(repea
Mixed regression models and custom link functions in R? repeated::gnlmix() PROC NLMIXED -- If the link or its inverse can be represented with the functions available in SAS. I need to dig more into the code. Some repeated::gnlmix() examples: library(repeated) set.seed(99) dat <- data.frame(id = c(1,1,1, 2,2,2, 3,3,3, 4,4,4), y = c(1,0,1, 0,1,1, 0,0,0, 1,1,1), x = rnorm(12) ) attach(dat) y_cbind <- cbind(y, 1-y) # probit regression gnlmix(y=y_cbind, distribution = "binomial", nest = id, mixture = "normal", random = "b_id", mu = ~ pnorm(beta0 + beta1*x + b_id), pmu = list(beta0=0, beta1=0), pmix = log(4) ) # Location parameters: # estimate se # beta0 0.2825 0.7878 # beta1 -0.7628 1.1498 # # Mixing dispersion parameter: # estimate se # 0.4249 2.072 # cauchy link gnlmix(y=y_cbind, distribution = "binomial", nest = id, mixture = "normal", random = "b_id", mu = ~ pcauchy(beta0 + beta1*x + b_id), pmu = list(beta0=0, beta1=0), pmix = log(4) ) # Location parameters: # estimate se # beta0 0.6973 1.791 # beta1 -1.2328 2.812 # # Mixing dispersion parameter: # estimate se # 1.805 3.038 # logistic regression gnlmix(y=y_cbind, distribution = "binomial", nest = id, mixture = "normal", random = "b_id", mu = ~ plogis(beta0 + beta1*x + b_id), pmu = list(beta0=0, beta1=0), pmix = log(4) ) # Location parameters: # estimate se # beta0 0.4981 1.356 # beta1 -1.2740 2.036 # # Mixing dispersion parameter: # estimate se # 1.496 2.177 # custom link / inverse (logistic regression) custom_inv <- function(eta) exp(eta) / (exp(eta) + 1) gnlmix(y=y_cbind, distribution = "binomial", nest = id, mixture = "normal", random = "b_id", mu = ~ custom_inv(beta0 + beta1*x + b_id), pmu = list(beta0=0, beta1=0), pmix = log(4) ) # Location parameters: # estimate se # beta0 0.4981 1.356 # beta1 -1.2740 2.036 # # Mixing dispersion parameter: # estimate se # 1.496 2.177 # custom link / inverse custom_inv <- function(eta) log(exp(eta)+1) / (log(exp(eta)+1) + pi/2) gnlmix(y=y_cbind, distribution = "binomial", nest = id, mixture = "normal", random = "b_id", mu = ~ custom_inv(beta0 + beta1*x + b_id), pmu = list(beta0=0, beta1=0), pmix = log(4) ) # Location parameters: # estimate se # beta0 4.333 5.477 # beta1 -2.291 5.571 # # Mixing dispersion parameter: # estimate se # 3.879 2.386 For GLMs, see gnlm::gnlr() as shown here.
Mixed regression models and custom link functions in R? repeated::gnlmix() PROC NLMIXED -- If the link or its inverse can be represented with the functions available in SAS. I need to dig more into the code. Some repeated::gnlmix() examples: library(repea
41,336
Mixed regression models and custom link functions in R?
As pointed out by @Ben Bolker, this isn't a problem for versions of lme4 >= 1.0-4 (circa 09-2013). Link functions can now be specified in R code - which seems to answer 1) and 3) from above with the answer being that the constraints for link functions were due to how lme4 pre 1.0 was programmed as opposed to conceptual.
Mixed regression models and custom link functions in R?
As pointed out by @Ben Bolker, this isn't a problem for versions of lme4 >= 1.0-4 (circa 09-2013). Link functions can now be specified in R code - which seems to answer 1) and 3) from above with the
Mixed regression models and custom link functions in R? As pointed out by @Ben Bolker, this isn't a problem for versions of lme4 >= 1.0-4 (circa 09-2013). Link functions can now be specified in R code - which seems to answer 1) and 3) from above with the answer being that the constraints for link functions were due to how lme4 pre 1.0 was programmed as opposed to conceptual.
Mixed regression models and custom link functions in R? As pointed out by @Ben Bolker, this isn't a problem for versions of lme4 >= 1.0-4 (circa 09-2013). Link functions can now be specified in R code - which seems to answer 1) and 3) from above with the
41,337
Modeling of real-time streaming data?
This area roughly falls into two categories. The first concerns stream processing and querying issues and associated models and algorithms. The second is efficient algorithms and models for learning from data streams (or data stream mining). It's my impression that the CEP industry is connected to the first area. For example, StreamBase originated from the Aurora project at Brown/Brandeis/MIT. A similar project was Widom's STREAM at Stanford. Reviewing the publications at either of those projects' sites should help exploring the area. A nice paper summarizing the research issues (in 2002) from the first area is Models and issues in data stream systems by Babcock et al. In stream mining, I'd recommend starting with Mining Data Streams: A Review by Gaber et al. BTW, I'm not sure exactly what you're interested in as far as specific models. If it's stream mining and classification in particular, the VFDT is a popular choice. The two review papers (linked above) point to many other models and it's very contextual.
Modeling of real-time streaming data?
This area roughly falls into two categories. The first concerns stream processing and querying issues and associated models and algorithms. The second is efficient algorithms and models for learning
Modeling of real-time streaming data? This area roughly falls into two categories. The first concerns stream processing and querying issues and associated models and algorithms. The second is efficient algorithms and models for learning from data streams (or data stream mining). It's my impression that the CEP industry is connected to the first area. For example, StreamBase originated from the Aurora project at Brown/Brandeis/MIT. A similar project was Widom's STREAM at Stanford. Reviewing the publications at either of those projects' sites should help exploring the area. A nice paper summarizing the research issues (in 2002) from the first area is Models and issues in data stream systems by Babcock et al. In stream mining, I'd recommend starting with Mining Data Streams: A Review by Gaber et al. BTW, I'm not sure exactly what you're interested in as far as specific models. If it's stream mining and classification in particular, the VFDT is a popular choice. The two review papers (linked above) point to many other models and it's very contextual.
Modeling of real-time streaming data? This area roughly falls into two categories. The first concerns stream processing and querying issues and associated models and algorithms. The second is efficient algorithms and models for learning
41,338
Modeling of real-time streaming data?
It is going to depend a lot on what exactly you are looking for, but start at Data Streams: Algorithms and Application by Muthukrishnan . There are many others that can be found by googling "data stream algorithms", or following the references in the paper.
Modeling of real-time streaming data?
It is going to depend a lot on what exactly you are looking for, but start at Data Streams: Algorithms and Application by Muthukrishnan . There are many others that can be found by googling "data stre
Modeling of real-time streaming data? It is going to depend a lot on what exactly you are looking for, but start at Data Streams: Algorithms and Application by Muthukrishnan . There are many others that can be found by googling "data stream algorithms", or following the references in the paper.
Modeling of real-time streaming data? It is going to depend a lot on what exactly you are looking for, but start at Data Streams: Algorithms and Application by Muthukrishnan . There are many others that can be found by googling "data stre
41,339
Modeling of real-time streaming data?
I am not sure how far this would be relevant to what you want to do but see the paper on adaptive question design called FASTPACE. The goal of the algorithm is to ask the next question from a survey respondent based on his/her previous questions and answers. The data does not arrive as fast as stock prices but nevertheless latency is an issue as most survey respondents expect the next question to appear within a few seconds.
Modeling of real-time streaming data?
I am not sure how far this would be relevant to what you want to do but see the paper on adaptive question design called FASTPACE. The goal of the algorithm is to ask the next question from a survey r
Modeling of real-time streaming data? I am not sure how far this would be relevant to what you want to do but see the paper on adaptive question design called FASTPACE. The goal of the algorithm is to ask the next question from a survey respondent based on his/her previous questions and answers. The data does not arrive as fast as stock prices but nevertheless latency is an issue as most survey respondents expect the next question to appear within a few seconds.
Modeling of real-time streaming data? I am not sure how far this would be relevant to what you want to do but see the paper on adaptive question design called FASTPACE. The goal of the algorithm is to ask the next question from a survey r
41,340
Modeling of real-time streaming data?
Bayesian networks are perfect for online estimation, and offer a great diversity of models.
Modeling of real-time streaming data?
Bayesian networks are perfect for online estimation, and offer a great diversity of models.
Modeling of real-time streaming data? Bayesian networks are perfect for online estimation, and offer a great diversity of models.
Modeling of real-time streaming data? Bayesian networks are perfect for online estimation, and offer a great diversity of models.
41,341
Modeling of real-time streaming data?
I'm not sure what sort of data you need to process, but statistical algorithms are used quite frequently in robotics, media art, digital signal processing etc. It may be worthwhile to borrow from these domains.
Modeling of real-time streaming data?
I'm not sure what sort of data you need to process, but statistical algorithms are used quite frequently in robotics, media art, digital signal processing etc. It may be worthwhile to borrow from thes
Modeling of real-time streaming data? I'm not sure what sort of data you need to process, but statistical algorithms are used quite frequently in robotics, media art, digital signal processing etc. It may be worthwhile to borrow from these domains.
Modeling of real-time streaming data? I'm not sure what sort of data you need to process, but statistical algorithms are used quite frequently in robotics, media art, digital signal processing etc. It may be worthwhile to borrow from thes
41,342
Modeling of real-time streaming data?
you have postrank http://data.postrank.com/content How do you sort what content is current and meaningful? We do it for you. PostRank gathers original content, as well as information at the feed and story level. This includes title, author, language, tags, and related links. We analyze that data to deliver timely, socially relevant information from millions of online sources. Then we deliver it how you want it. Real-time, custom, filtered access to every piece of content we index, along with its rich metadata
Modeling of real-time streaming data?
you have postrank http://data.postrank.com/content How do you sort what content is current and meaningful? We do it for you. PostRank gathers original content, as well as information at the feed and s
Modeling of real-time streaming data? you have postrank http://data.postrank.com/content How do you sort what content is current and meaningful? We do it for you. PostRank gathers original content, as well as information at the feed and story level. This includes title, author, language, tags, and related links. We analyze that data to deliver timely, socially relevant information from millions of online sources. Then we deliver it how you want it. Real-time, custom, filtered access to every piece of content we index, along with its rich metadata
Modeling of real-time streaming data? you have postrank http://data.postrank.com/content How do you sort what content is current and meaningful? We do it for you. PostRank gathers original content, as well as information at the feed and s
41,343
What's the purpose of window function in spectral analysis?
It depends on where you apply the window function. If you do it in the time domain, it's because you only want to analyze the periodic behavior of the function in a short duration. You do this when you don't believe that your data is from a stationary process. If you do it in the frequency domain, then you do it to isolate a specific set of frequencies for further analysis; you do this when you believe that (for instance) high-frequency components are spurious. The first three chapters of "A Wavelet Tour of Signal Processing" by Stephane Mallat have an excellent introduction to signal processing in general, and chapter 4 goes into a very good discussion of windowing and time-frequency representations in both continuous and discrete time, along with a few worked-out examples.
What's the purpose of window function in spectral analysis?
It depends on where you apply the window function. If you do it in the time domain, it's because you only want to analyze the periodic behavior of the function in a short duration. You do this when
What's the purpose of window function in spectral analysis? It depends on where you apply the window function. If you do it in the time domain, it's because you only want to analyze the periodic behavior of the function in a short duration. You do this when you don't believe that your data is from a stationary process. If you do it in the frequency domain, then you do it to isolate a specific set of frequencies for further analysis; you do this when you believe that (for instance) high-frequency components are spurious. The first three chapters of "A Wavelet Tour of Signal Processing" by Stephane Mallat have an excellent introduction to signal processing in general, and chapter 4 goes into a very good discussion of windowing and time-frequency representations in both continuous and discrete time, along with a few worked-out examples.
What's the purpose of window function in spectral analysis? It depends on where you apply the window function. If you do it in the time domain, it's because you only want to analyze the periodic behavior of the function in a short duration. You do this when
41,344
What's the purpose of window function in spectral analysis?
The main aim of windowing in spectral analysis is the ability of zooming into the finer details of the signal rather than looking the whole signal as such. Short Time Fourier Transforms(STFT) are of prime importance in case of speech signal processing where the information like pitch or the formant frequencies are extracted by analyzing the signals through a window of specific duration. The width of the windowing function relates to how the signal is represented that is it determines whether there is good frequency resolution (frequency components close together can be separated) or good time resolution (the time at which frequencies change).A wide window gives better frequency resolution but poor time resolution. A narrower window gives good time resolution but poor frequency resolution. These are called narrowband and wideband transforms, respectively. This is the exact reason as why a wavelet transform was developed where a wavelet transform is capable of giving good time resolution for high frequency events and good frequency resolution for low frequency events. This type of analysis is well suited for real signals.
What's the purpose of window function in spectral analysis?
The main aim of windowing in spectral analysis is the ability of zooming into the finer details of the signal rather than looking the whole signal as such. Short Time Fourier Transforms(STFT) are of p
What's the purpose of window function in spectral analysis? The main aim of windowing in spectral analysis is the ability of zooming into the finer details of the signal rather than looking the whole signal as such. Short Time Fourier Transforms(STFT) are of prime importance in case of speech signal processing where the information like pitch or the formant frequencies are extracted by analyzing the signals through a window of specific duration. The width of the windowing function relates to how the signal is represented that is it determines whether there is good frequency resolution (frequency components close together can be separated) or good time resolution (the time at which frequencies change).A wide window gives better frequency resolution but poor time resolution. A narrower window gives good time resolution but poor frequency resolution. These are called narrowband and wideband transforms, respectively. This is the exact reason as why a wavelet transform was developed where a wavelet transform is capable of giving good time resolution for high frequency events and good frequency resolution for low frequency events. This type of analysis is well suited for real signals.
What's the purpose of window function in spectral analysis? The main aim of windowing in spectral analysis is the ability of zooming into the finer details of the signal rather than looking the whole signal as such. Short Time Fourier Transforms(STFT) are of p
41,345
Kullback–Leibler divergence between two multivariate t distributions with different degrees of freedom?
Check the following post: Kullback Leibler divergence between two multivariate t distributions The authors reduce the dimension of the integral from $p$ (in your notation) to 1, which seems to be easier to handle. The post contains numerical examples in R. Edit. As mentioned by @utobi in a comment, it is not a closed-form solution since it still involves univariate numerical integration. However, it's better than a vanilla multivariate integration. Indeed, this solution is a more "numerically tractable" alternative to multivariate integration, but not a closed-form one.
Kullback–Leibler divergence between two multivariate t distributions with different degrees of freed
Check the following post: Kullback Leibler divergence between two multivariate t distributions The authors reduce the dimension of the integral from $p$ (in your notation) to 1, which seems to be easi
Kullback–Leibler divergence between two multivariate t distributions with different degrees of freedom? Check the following post: Kullback Leibler divergence between two multivariate t distributions The authors reduce the dimension of the integral from $p$ (in your notation) to 1, which seems to be easier to handle. The post contains numerical examples in R. Edit. As mentioned by @utobi in a comment, it is not a closed-form solution since it still involves univariate numerical integration. However, it's better than a vanilla multivariate integration. Indeed, this solution is a more "numerically tractable" alternative to multivariate integration, but not a closed-form one.
Kullback–Leibler divergence between two multivariate t distributions with different degrees of freed Check the following post: Kullback Leibler divergence between two multivariate t distributions The authors reduce the dimension of the integral from $p$ (in your notation) to 1, which seems to be easi
41,346
EM algorithm for Bivariate Normal
Denoting the Normal parameters by $\theta$, the observed likelihood is $$\pi_0^{n_0}\pi_1^{n_1}\pi_2^{n_2}\prod_{i:\,c_i=0}f_X(u_i,v_i;\theta) \prod_{i:\,c_i=1}f_U(u_i;\theta)\prod_{i:\,c_i=2}f_V(v_i;\theta)$$ with each term being in closed (Normal) form. Hence this likelihood can be optimised in $(\theta,\pi)$ and does not require an EM algorithm. If EM is implemented as a toy problem, the completed likelihood is $$\pi_0^{n_0}\pi_1^{n_1}\pi_2^{n_2}\prod_{i:\,c_i=0}f_X(u_i,v_i;\theta) \prod_{i:\,c_i=1}f_X(u_i,V_i;\theta) \prod_{i:\,c_i=2}f_X(U_i,v_i;\theta)$$ where the missing / latent variables are upper cases. Removing the $\pi_j$'s in front which do not require at all EM to be optimised as $$\hat\pi_i=n_i/n,$$ the E function (on $\theta$) is $$\begin{align}\text{E}[\theta'|\theta,\mathcal D]&= \sum_{i:\,c_i=0}\log f_X(u_i,v_i;\theta')+ \sum_{i:\,c_i=1}\mathbb E_\theta[\log f_X(u_i,V_i;\theta')|U_i=u_i]\\ &\qquad+ \sum_{i:\,c_i=2}\mathbb E_\theta[\log f_X(U_i,v_i;\theta')|V_i=v_i]\\ &=\sum_{i:\,c_i=0}\log f_X(u_i,v_i;\theta')\\ &\qquad+\sum_{i:\,c_i=1}\mathbb \log f_U(u_i;\theta')+ \sum_{i:\,c_i=1}\mathbb E_\theta[\log f_{V|U}(V_i;\theta',U_i=u_i])|U_i=u_i]\\ &\qquad+\sum_{i:\,c_i=2}\log f_V(v_i;\theta')+ \sum_{i:\,c_i=2}\mathbb E_\theta[\log f_{U|V}(U_i;\theta',V_i=v_i)|V_i=v_i]\end{align}$$ [where all density terms are normal] to be optimised in $\theta'$ (M-step). Interestingly, albeit generically, this E-function also writes as $$\overbrace{\sum_{i:\,c_i=0}\log f_X(u_i,v_i;\theta')+\sum_{i:\,c_i=1}\mathbb \log f_U(u_i;\theta')+\sum_{i:\,c_i=2}\log f_V(v_i;\theta')}^\text{observed log-likelihood}\\ \left. \begin{align}&+\sum_{i:\,c_i=1}\mathbb E_\theta[\log f_{V|U}(V_i;\theta',U_i=u_i])|U_i=u_i]\\ &+\sum_{i:\,c_i=2}\mathbb E_\theta[\log f_{U|V}(U_i;\theta',V_i=v_i)|V_i=v_i] \end{align}\right.$$ which means that close to (EM) convergence the expected part should not contribute significantly. When reaching a fixed point, i.e., when $\theta=\theta'$, $$\mathbb E_\theta[\log f_{V|U}(V;\theta',U=u_i])|U=u_i]=-\frac{1}{2}$$
EM algorithm for Bivariate Normal
Denoting the Normal parameters by $\theta$, the observed likelihood is $$\pi_0^{n_0}\pi_1^{n_1}\pi_2^{n_2}\prod_{i:\,c_i=0}f_X(u_i,v_i;\theta) \prod_{i:\,c_i=1}f_U(u_i;\theta)\prod_{i:\,c_i=2}f_V(v_i;
EM algorithm for Bivariate Normal Denoting the Normal parameters by $\theta$, the observed likelihood is $$\pi_0^{n_0}\pi_1^{n_1}\pi_2^{n_2}\prod_{i:\,c_i=0}f_X(u_i,v_i;\theta) \prod_{i:\,c_i=1}f_U(u_i;\theta)\prod_{i:\,c_i=2}f_V(v_i;\theta)$$ with each term being in closed (Normal) form. Hence this likelihood can be optimised in $(\theta,\pi)$ and does not require an EM algorithm. If EM is implemented as a toy problem, the completed likelihood is $$\pi_0^{n_0}\pi_1^{n_1}\pi_2^{n_2}\prod_{i:\,c_i=0}f_X(u_i,v_i;\theta) \prod_{i:\,c_i=1}f_X(u_i,V_i;\theta) \prod_{i:\,c_i=2}f_X(U_i,v_i;\theta)$$ where the missing / latent variables are upper cases. Removing the $\pi_j$'s in front which do not require at all EM to be optimised as $$\hat\pi_i=n_i/n,$$ the E function (on $\theta$) is $$\begin{align}\text{E}[\theta'|\theta,\mathcal D]&= \sum_{i:\,c_i=0}\log f_X(u_i,v_i;\theta')+ \sum_{i:\,c_i=1}\mathbb E_\theta[\log f_X(u_i,V_i;\theta')|U_i=u_i]\\ &\qquad+ \sum_{i:\,c_i=2}\mathbb E_\theta[\log f_X(U_i,v_i;\theta')|V_i=v_i]\\ &=\sum_{i:\,c_i=0}\log f_X(u_i,v_i;\theta')\\ &\qquad+\sum_{i:\,c_i=1}\mathbb \log f_U(u_i;\theta')+ \sum_{i:\,c_i=1}\mathbb E_\theta[\log f_{V|U}(V_i;\theta',U_i=u_i])|U_i=u_i]\\ &\qquad+\sum_{i:\,c_i=2}\log f_V(v_i;\theta')+ \sum_{i:\,c_i=2}\mathbb E_\theta[\log f_{U|V}(U_i;\theta',V_i=v_i)|V_i=v_i]\end{align}$$ [where all density terms are normal] to be optimised in $\theta'$ (M-step). Interestingly, albeit generically, this E-function also writes as $$\overbrace{\sum_{i:\,c_i=0}\log f_X(u_i,v_i;\theta')+\sum_{i:\,c_i=1}\mathbb \log f_U(u_i;\theta')+\sum_{i:\,c_i=2}\log f_V(v_i;\theta')}^\text{observed log-likelihood}\\ \left. \begin{align}&+\sum_{i:\,c_i=1}\mathbb E_\theta[\log f_{V|U}(V_i;\theta',U_i=u_i])|U_i=u_i]\\ &+\sum_{i:\,c_i=2}\mathbb E_\theta[\log f_{U|V}(U_i;\theta',V_i=v_i)|V_i=v_i] \end{align}\right.$$ which means that close to (EM) convergence the expected part should not contribute significantly. When reaching a fixed point, i.e., when $\theta=\theta'$, $$\mathbb E_\theta[\log f_{V|U}(V;\theta',U=u_i])|U=u_i]=-\frac{1}{2}$$
EM algorithm for Bivariate Normal Denoting the Normal parameters by $\theta$, the observed likelihood is $$\pi_0^{n_0}\pi_1^{n_1}\pi_2^{n_2}\prod_{i:\,c_i=0}f_X(u_i,v_i;\theta) \prod_{i:\,c_i=1}f_U(u_i;\theta)\prod_{i:\,c_i=2}f_V(v_i;
41,347
Can robust standard errors be less than those from normal OLS?
OLS gives every point equal weight in estimating the error of the estimates. The variance/error is estimated as $$\widehat{\text{Var}(\beta) }= \hat{\sigma} (X^TX)^{-1} $$ A weighted least squares estimator might use an estimate like $$\widehat{\text{Var}(\beta) }= \hat{\sigma} (X^TWX)^{-1} $$ The weights might make some points more and others less important. As a result the estimates of the standard error can improve for some coefficients. In the example figure below an OLS estimator would assume that the variance is constant. As a result it would give the points near the origin the same weight as the points far from the origin. However, a robust regressor might give the points near the origin more weight because of the smaller variance. As a result that robust estimator will estimate a lower error for the intercept term. (And as we can see with our naked eye, the intercept is clearly around 0, but OLS will not see this because it assumes equal variance)
Can robust standard errors be less than those from normal OLS?
OLS gives every point equal weight in estimating the error of the estimates. The variance/error is estimated as $$\widehat{\text{Var}(\beta) }= \hat{\sigma} (X^TX)^{-1} $$ A weighted least squares est
Can robust standard errors be less than those from normal OLS? OLS gives every point equal weight in estimating the error of the estimates. The variance/error is estimated as $$\widehat{\text{Var}(\beta) }= \hat{\sigma} (X^TX)^{-1} $$ A weighted least squares estimator might use an estimate like $$\widehat{\text{Var}(\beta) }= \hat{\sigma} (X^TWX)^{-1} $$ The weights might make some points more and others less important. As a result the estimates of the standard error can improve for some coefficients. In the example figure below an OLS estimator would assume that the variance is constant. As a result it would give the points near the origin the same weight as the points far from the origin. However, a robust regressor might give the points near the origin more weight because of the smaller variance. As a result that robust estimator will estimate a lower error for the intercept term. (And as we can see with our naked eye, the intercept is clearly around 0, but OLS will not see this because it assumes equal variance)
Can robust standard errors be less than those from normal OLS? OLS gives every point equal weight in estimating the error of the estimates. The variance/error is estimated as $$\widehat{\text{Var}(\beta) }= \hat{\sigma} (X^TX)^{-1} $$ A weighted least squares est
41,348
Can robust standard errors be less than those from normal OLS?
Yes they can be smaller than the standard variance estimates. The reason is that even in the case of linear models, robust standard errors are biased but consistent. Their variance estimates might be (severely) biased downwards due to this small-sample bias, see Imbens & Kolesar (2016, The Review of Economics and Statistics; ungated working paper version here): Second, and this has been pointed out in the theoretical literature before [e.g. Chesher and Jewitt, 1987], without having been appreciated in the empirical literature, problems with the standard robust EHW and LZ variances and confidence intervals can be substantial even with moderately large samples (such as 50 units / clusters) if the distribution of the regressors is skewed. Imbens, G. W., & Kolesar, M. (2016). Robust standard errors in small samples: Some practical advice. Review of Economics and Statistics, 98(4), 701-712.
Can robust standard errors be less than those from normal OLS?
Yes they can be smaller than the standard variance estimates. The reason is that even in the case of linear models, robust standard errors are biased but consistent. Their variance estimates might be
Can robust standard errors be less than those from normal OLS? Yes they can be smaller than the standard variance estimates. The reason is that even in the case of linear models, robust standard errors are biased but consistent. Their variance estimates might be (severely) biased downwards due to this small-sample bias, see Imbens & Kolesar (2016, The Review of Economics and Statistics; ungated working paper version here): Second, and this has been pointed out in the theoretical literature before [e.g. Chesher and Jewitt, 1987], without having been appreciated in the empirical literature, problems with the standard robust EHW and LZ variances and confidence intervals can be substantial even with moderately large samples (such as 50 units / clusters) if the distribution of the regressors is skewed. Imbens, G. W., & Kolesar, M. (2016). Robust standard errors in small samples: Some practical advice. Review of Economics and Statistics, 98(4), 701-712.
Can robust standard errors be less than those from normal OLS? Yes they can be smaller than the standard variance estimates. The reason is that even in the case of linear models, robust standard errors are biased but consistent. Their variance estimates might be
41,349
Can robust standard errors be less than those from normal OLS?
If the response is, conditionally on the covariates, Gaussian, then we know that OLS are best linear unbiased estimators by Gauss-Markov theorem; no other estimator can have lower variance than OLS. If the Gaussian assumption is not met we have no such guarantee anymore. Indeed, since the influence function (IF) of the OLS estimator is unbounded and the variance of the OLS estimator is proportional to the IF, then the variance of the estimator is unbounded as well. In practice, this means that even a single aberrant observation can drive away the OLS estimate along with its variance. On the other hand, robust estimators (e.g. Huber (1964) DOI: 10.1214/aoms/1177703732, Hampel et al. (1984) DOI:10.1002/9781118186435, etc.) typically have a bounded IF, thus they deliver bounded estimates with bounded variance. The point of this is that a "bad" observation will have only a limited impact on the robust estimate and its variance, whereas it can have a large effect on an estimate obtained from an estimator with unbounded IF such as OLS.
Can robust standard errors be less than those from normal OLS?
If the response is, conditionally on the covariates, Gaussian, then we know that OLS are best linear unbiased estimators by Gauss-Markov theorem; no other estimator can have lower variance than OLS. I
Can robust standard errors be less than those from normal OLS? If the response is, conditionally on the covariates, Gaussian, then we know that OLS are best linear unbiased estimators by Gauss-Markov theorem; no other estimator can have lower variance than OLS. If the Gaussian assumption is not met we have no such guarantee anymore. Indeed, since the influence function (IF) of the OLS estimator is unbounded and the variance of the OLS estimator is proportional to the IF, then the variance of the estimator is unbounded as well. In practice, this means that even a single aberrant observation can drive away the OLS estimate along with its variance. On the other hand, robust estimators (e.g. Huber (1964) DOI: 10.1214/aoms/1177703732, Hampel et al. (1984) DOI:10.1002/9781118186435, etc.) typically have a bounded IF, thus they deliver bounded estimates with bounded variance. The point of this is that a "bad" observation will have only a limited impact on the robust estimate and its variance, whereas it can have a large effect on an estimate obtained from an estimator with unbounded IF such as OLS.
Can robust standard errors be less than those from normal OLS? If the response is, conditionally on the covariates, Gaussian, then we know that OLS are best linear unbiased estimators by Gauss-Markov theorem; no other estimator can have lower variance than OLS. I
41,350
Why Do Residuals Need To Be Homoscedastic (Equal Variance)?
The bounty asks for citations. Some relevant citations appear in comments to Literature on robustness of regression assumptions. I reproduce them here: Whuber: Draper & Smith (Applied Regression Analysis, 2nd Ed.) develop the regression equations at the beginning of section 2.6, then discuss what can be done in a subsection "Without Distributional Assumptions," and only then discuss what can further be done (mainly with the F tests) in a subsection "With Distributional Assumptions." Ultimately, "robustness" is going to be relative to the conclusions you are trying to draw: some of them will be largely insensitive to homoscedasticity but others might be more sensitive. Ben Bolker: Coombs, William T., James Algina, and Debra Olson Oltman. "Univariate and multivariate omnibus hypothesis tests selected to control type I error rates when population variances are not necessarily equal." Review of Educational Research 66.2 (1996): 137-179 ; Tomarken, Andrew J., and Ronald C. Serlin. "Comparison of ANOVA alternatives under variance heterogeneity and specific noncentrality structures." Psychological Bulletin 99.1 (1986): 90. Incidentally, I found this thread by using the Search feature. This is exact string that I used homoscedastic [references] answers:1 and it was the first result. More information about how to effectively search the site is here: FAQ: Best Practices for Searching CV.
Why Do Residuals Need To Be Homoscedastic (Equal Variance)?
The bounty asks for citations. Some relevant citations appear in comments to Literature on robustness of regression assumptions. I reproduce them here: Whuber: Draper & Smith (Applied Regression Anal
Why Do Residuals Need To Be Homoscedastic (Equal Variance)? The bounty asks for citations. Some relevant citations appear in comments to Literature on robustness of regression assumptions. I reproduce them here: Whuber: Draper & Smith (Applied Regression Analysis, 2nd Ed.) develop the regression equations at the beginning of section 2.6, then discuss what can be done in a subsection "Without Distributional Assumptions," and only then discuss what can further be done (mainly with the F tests) in a subsection "With Distributional Assumptions." Ultimately, "robustness" is going to be relative to the conclusions you are trying to draw: some of them will be largely insensitive to homoscedasticity but others might be more sensitive. Ben Bolker: Coombs, William T., James Algina, and Debra Olson Oltman. "Univariate and multivariate omnibus hypothesis tests selected to control type I error rates when population variances are not necessarily equal." Review of Educational Research 66.2 (1996): 137-179 ; Tomarken, Andrew J., and Ronald C. Serlin. "Comparison of ANOVA alternatives under variance heterogeneity and specific noncentrality structures." Psychological Bulletin 99.1 (1986): 90. Incidentally, I found this thread by using the Search feature. This is exact string that I used homoscedastic [references] answers:1 and it was the first result. More information about how to effectively search the site is here: FAQ: Best Practices for Searching CV.
Why Do Residuals Need To Be Homoscedastic (Equal Variance)? The bounty asks for citations. Some relevant citations appear in comments to Literature on robustness of regression assumptions. I reproduce them here: Whuber: Draper & Smith (Applied Regression Anal
41,351
Why Do Residuals Need To Be Homoscedastic (Equal Variance)?
The assumptions of residual normality and homoscedaticity are used in the theoretical derivation of the Mean Squared Error. This loss is actually a scaled negative logarithmic likelihood for the following regression model: $$y = f(\theta, x) + \epsilon$$ where $\epsilon$ is a zero mean normal random variable, independent of $x$. If we use Mean Squared Error in our optimization task and the residuals turn out to be heteroscedatic, that means that our model was incorrect from the beginning. If we want to retain residual normality, but capture heteroscedaticity, we can consider a more complex parametric model: $$y = f(\theta, x) + g(\theta, x)\epsilon$$ where $\epsilon \sim N(0, 1)$ is independent of $x$. The loss function to be optimized here will be different: $$\sum_{i = 1}^N \ln(g(\theta, x_i)) + (\frac{y_i - f(\theta, x_i)}{g(\theta, x_i)})^2$$
Why Do Residuals Need To Be Homoscedastic (Equal Variance)?
The assumptions of residual normality and homoscedaticity are used in the theoretical derivation of the Mean Squared Error. This loss is actually a scaled negative logarithmic likelihood for the follo
Why Do Residuals Need To Be Homoscedastic (Equal Variance)? The assumptions of residual normality and homoscedaticity are used in the theoretical derivation of the Mean Squared Error. This loss is actually a scaled negative logarithmic likelihood for the following regression model: $$y = f(\theta, x) + \epsilon$$ where $\epsilon$ is a zero mean normal random variable, independent of $x$. If we use Mean Squared Error in our optimization task and the residuals turn out to be heteroscedatic, that means that our model was incorrect from the beginning. If we want to retain residual normality, but capture heteroscedaticity, we can consider a more complex parametric model: $$y = f(\theta, x) + g(\theta, x)\epsilon$$ where $\epsilon \sim N(0, 1)$ is independent of $x$. The loss function to be optimized here will be different: $$\sum_{i = 1}^N \ln(g(\theta, x_i)) + (\frac{y_i - f(\theta, x_i)}{g(\theta, x_i)})^2$$
Why Do Residuals Need To Be Homoscedastic (Equal Variance)? The assumptions of residual normality and homoscedaticity are used in the theoretical derivation of the Mean Squared Error. This loss is actually a scaled negative logarithmic likelihood for the follo
41,352
Why Do Residuals Need To Be Homoscedastic (Equal Variance)?
I have written quite a bit on model assumptions here and here. Just to add a general remark to the discussion: Statistical model assumptions are required for proving mathematical theorems regarding the quality of a method. In case model assumptions are violated, the theoretical "guarantees" of the theorems cannot be taken for granted (this includes straightforward things as the correctness of p-values). Now we have to keep in mind that the mathematical model and its formal assumptions live in the mathematical formal world and not in the real world, in which, as George Box famously wrote, "all models are wrong but some are useful". The same holds for the theorems concerning the methods. If model assumptions do not hold, theory does not guarantee good behaviour (although there are a few exceptions where theory also exists that characterises behaviour outside the nominal model, the Central Limit Theorem arguably being an example in case of violation of normality). This does not necessarily mean that the behaviour is bad! One idea that is often involved is that if model violations are very mild, they may well be harmless. This is often true but unfortunately not always, and investigating which violations of assumptions cause what kind of trouble and when it is harmless and when rather not is a box of Pandora, things depend strongly on what exactly goes on (for example to what extent heteroscedasticity in a two-sample situation is harmful depends on whether the larger variance occurs in the larger or in the smaller sample). On the positive side, some quite substantial violations of model assumptions do not cause much harm (some very obviously non-normal distributions play very nicely with inference based on the normal assumption). Regarding heteroscedasticity, this means that we observe different amounts of variation in different places in $x$-space, which means that observations in different places give us differently strong information about where the regression line should be. As the LS-regression estimator treats all observations in the same way, it should be clear that better estimators could be defined weighting more informative observations up (but one would need to know some detail about the exact shape of heteroscedasticity to choose them). This means in the first place that the LS-estimator loses optimality, however it may still be OK; to some extent this depends on how much precision is required, and how strong the heteroscedasticity is. Also the LS-estimator will assume for prediction that precision is everywhere the same, whereas you may want to be warned that in some places much less precision for prediction can be achieved. Regarding p-values of associated tests, I'd suspect that some power will be lost, but I don't expect the effect to be strong as long as heteroscedasticity is mild. Often heteroscedasticity is a hint that the linear model works better with transformed variables; switching for example from $y$ to $\log y$ or $\sqrt y$ (maybe of $y+c$) has often more visible effect on heteroscedasticity than on linearity, but may improve the model a lot.
Why Do Residuals Need To Be Homoscedastic (Equal Variance)?
I have written quite a bit on model assumptions here and here. Just to add a general remark to the discussion: Statistical model assumptions are required for proving mathematical theorems regarding th
Why Do Residuals Need To Be Homoscedastic (Equal Variance)? I have written quite a bit on model assumptions here and here. Just to add a general remark to the discussion: Statistical model assumptions are required for proving mathematical theorems regarding the quality of a method. In case model assumptions are violated, the theoretical "guarantees" of the theorems cannot be taken for granted (this includes straightforward things as the correctness of p-values). Now we have to keep in mind that the mathematical model and its formal assumptions live in the mathematical formal world and not in the real world, in which, as George Box famously wrote, "all models are wrong but some are useful". The same holds for the theorems concerning the methods. If model assumptions do not hold, theory does not guarantee good behaviour (although there are a few exceptions where theory also exists that characterises behaviour outside the nominal model, the Central Limit Theorem arguably being an example in case of violation of normality). This does not necessarily mean that the behaviour is bad! One idea that is often involved is that if model violations are very mild, they may well be harmless. This is often true but unfortunately not always, and investigating which violations of assumptions cause what kind of trouble and when it is harmless and when rather not is a box of Pandora, things depend strongly on what exactly goes on (for example to what extent heteroscedasticity in a two-sample situation is harmful depends on whether the larger variance occurs in the larger or in the smaller sample). On the positive side, some quite substantial violations of model assumptions do not cause much harm (some very obviously non-normal distributions play very nicely with inference based on the normal assumption). Regarding heteroscedasticity, this means that we observe different amounts of variation in different places in $x$-space, which means that observations in different places give us differently strong information about where the regression line should be. As the LS-regression estimator treats all observations in the same way, it should be clear that better estimators could be defined weighting more informative observations up (but one would need to know some detail about the exact shape of heteroscedasticity to choose them). This means in the first place that the LS-estimator loses optimality, however it may still be OK; to some extent this depends on how much precision is required, and how strong the heteroscedasticity is. Also the LS-estimator will assume for prediction that precision is everywhere the same, whereas you may want to be warned that in some places much less precision for prediction can be achieved. Regarding p-values of associated tests, I'd suspect that some power will be lost, but I don't expect the effect to be strong as long as heteroscedasticity is mild. Often heteroscedasticity is a hint that the linear model works better with transformed variables; switching for example from $y$ to $\log y$ or $\sqrt y$ (maybe of $y+c$) has often more visible effect on heteroscedasticity than on linearity, but may improve the model a lot.
Why Do Residuals Need To Be Homoscedastic (Equal Variance)? I have written quite a bit on model assumptions here and here. Just to add a general remark to the discussion: Statistical model assumptions are required for proving mathematical theorems regarding th
41,353
How to extract coefficients corresponding to data from each time in a mixed effect model in R?
Context: Since it is known that vaccine A induces higher antibody levels than vaccine B, I interpret the question to mean: How do we use visit 1 and visit 2 data to test that A has the same efficacy on the second visit no matter which vaccine a subject receives on the first visit? I describe two ways to do it, with and without random subject effects. It's preferable to fit one model to all the data, rather than separate models to subsets of the data. This way information is appropriately pooled across multiple subsets/visits. Your mixed models treat Visit as a continuous variable because it's of type "numeric". You get a coefficient estimate for the linear effect of number of visits (and it's number, not order). This is not what you intend. So make Visit a categorical variable by casting it to type "factor". data_raw$Visit <- factor(data_raw$Visit) Let's specify a model for the full data by interacting Visit and Vaccine. m1 <- lmer(Antibody ~ Vaccine * Visit + (1 | ID), data_raw) #> fixed-effect model matrix is rank deficient so dropping 1 column / coefficient We get a warning message. Since all subjects receive the same vaccine on their second visit, lmer drops the interaction. We can compare the two vaccines on the first visit or receiving A on both visits. But we cannot compare the follow-up efficacy of A between those who receive A first and those who receive B first. Analysis I: mixed model for repeated measurements Instead let's introduce a new variable FirstVaccine which indicates the vaccine received on the first visit. (Acknowledgement: The OP mentioned this approach in a comment.) data_raw$FirstVaccine <- rep(data_raw$Vaccine[data_raw$Visit == 1], 2) m2 <- lmer(Antibody ~ FirstVaccine * Visit + (1 | ID), data_raw) Now we can estimate the main effects as well as the interaction. We can evaluate the follow-up efficacy of A as the second-visit contrast between those who receive A and those who receive B on their first visit. This is easy to do with the emmeans package. pairs(emmeans(m2, ~ FirstVaccine | Visit)) #> Visit = 1: #> contrast estimate SE df t.ratio p.value #> A - B 25.000 4.59 7.99 5.448 0.0006 #> #> Visit = 2: #> contrast estimate SE df t.ratio p.value #> A - B -0.333 4.59 7.99 -0.073 0.9439 Analysis II: pre-post treatment comparison The mixed model accounts for the correlation between observations from the same subject by introducing random subject effects. Alternatively, we can consider the two visits as paired (before and after) observations and analyze this study as a pre-post treatment design; the first vaccine is the "treatment". First we rearrange the data so that two observations of the same subject are on the same row. In the "wide" table the rows are independent, so there is no need for random effects. visit1 <- subset(data_raw, Visit == 1, c("ID", "Antibody", "Vaccine")) visit2 <- subset(data_raw, Visit == 2, c("ID", "Antibody", "Vaccine")) data_wide <- merge(visit1, visit2, by = "ID", suffixes = c("_1", "_2")) data_wide #> ID Antibody_1 Vaccine_1 Antibody_2 Vaccine_2 #> 1 1 50 A 101 A #> 2 2 60 A 102 A #> 3 3 70 A 102 A #> 4 4 30 B 102 A #> 5 5 40 B 101 A #> 6 6 35 B 103 A m3 <- lm(Antibody_2 ~ Antibody_1 + Vaccine_1, data = data_wide) The estimate of the second-visit difference in antibodies between the two groups is bigger (in absolute value), with a smaller standard error, as there is less variability in antibody levels on the second visit than on the first. pairs(emmeans(m3, ~ Vaccine_1)) #> contrast estimate SE df t.ratio p.value #> A - B -0.833 1.65 3 -0.506 0.6475 Keep in mind this distinction between the two analyses: the mixed model assumes the error variance is the same on both visits; the pre-post comparison doesn't and it estimates only the second-visit error variance.
How to extract coefficients corresponding to data from each time in a mixed effect model in R?
Context: Since it is known that vaccine A induces higher antibody levels than vaccine B, I interpret the question to mean: How do we use visit 1 and visit 2 data to test that A has the same efficacy o
How to extract coefficients corresponding to data from each time in a mixed effect model in R? Context: Since it is known that vaccine A induces higher antibody levels than vaccine B, I interpret the question to mean: How do we use visit 1 and visit 2 data to test that A has the same efficacy on the second visit no matter which vaccine a subject receives on the first visit? I describe two ways to do it, with and without random subject effects. It's preferable to fit one model to all the data, rather than separate models to subsets of the data. This way information is appropriately pooled across multiple subsets/visits. Your mixed models treat Visit as a continuous variable because it's of type "numeric". You get a coefficient estimate for the linear effect of number of visits (and it's number, not order). This is not what you intend. So make Visit a categorical variable by casting it to type "factor". data_raw$Visit <- factor(data_raw$Visit) Let's specify a model for the full data by interacting Visit and Vaccine. m1 <- lmer(Antibody ~ Vaccine * Visit + (1 | ID), data_raw) #> fixed-effect model matrix is rank deficient so dropping 1 column / coefficient We get a warning message. Since all subjects receive the same vaccine on their second visit, lmer drops the interaction. We can compare the two vaccines on the first visit or receiving A on both visits. But we cannot compare the follow-up efficacy of A between those who receive A first and those who receive B first. Analysis I: mixed model for repeated measurements Instead let's introduce a new variable FirstVaccine which indicates the vaccine received on the first visit. (Acknowledgement: The OP mentioned this approach in a comment.) data_raw$FirstVaccine <- rep(data_raw$Vaccine[data_raw$Visit == 1], 2) m2 <- lmer(Antibody ~ FirstVaccine * Visit + (1 | ID), data_raw) Now we can estimate the main effects as well as the interaction. We can evaluate the follow-up efficacy of A as the second-visit contrast between those who receive A and those who receive B on their first visit. This is easy to do with the emmeans package. pairs(emmeans(m2, ~ FirstVaccine | Visit)) #> Visit = 1: #> contrast estimate SE df t.ratio p.value #> A - B 25.000 4.59 7.99 5.448 0.0006 #> #> Visit = 2: #> contrast estimate SE df t.ratio p.value #> A - B -0.333 4.59 7.99 -0.073 0.9439 Analysis II: pre-post treatment comparison The mixed model accounts for the correlation between observations from the same subject by introducing random subject effects. Alternatively, we can consider the two visits as paired (before and after) observations and analyze this study as a pre-post treatment design; the first vaccine is the "treatment". First we rearrange the data so that two observations of the same subject are on the same row. In the "wide" table the rows are independent, so there is no need for random effects. visit1 <- subset(data_raw, Visit == 1, c("ID", "Antibody", "Vaccine")) visit2 <- subset(data_raw, Visit == 2, c("ID", "Antibody", "Vaccine")) data_wide <- merge(visit1, visit2, by = "ID", suffixes = c("_1", "_2")) data_wide #> ID Antibody_1 Vaccine_1 Antibody_2 Vaccine_2 #> 1 1 50 A 101 A #> 2 2 60 A 102 A #> 3 3 70 A 102 A #> 4 4 30 B 102 A #> 5 5 40 B 101 A #> 6 6 35 B 103 A m3 <- lm(Antibody_2 ~ Antibody_1 + Vaccine_1, data = data_wide) The estimate of the second-visit difference in antibodies between the two groups is bigger (in absolute value), with a smaller standard error, as there is less variability in antibody levels on the second visit than on the first. pairs(emmeans(m3, ~ Vaccine_1)) #> contrast estimate SE df t.ratio p.value #> A - B -0.833 1.65 3 -0.506 0.6475 Keep in mind this distinction between the two analyses: the mixed model assumes the error variance is the same on both visits; the pre-post comparison doesn't and it estimates only the second-visit error variance.
How to extract coefficients corresponding to data from each time in a mixed effect model in R? Context: Since it is known that vaccine A induces higher antibody levels than vaccine B, I interpret the question to mean: How do we use visit 1 and visit 2 data to test that A has the same efficacy o
41,354
What is Galton's paradox?
The "paradox" here arises from sneaking in an implicit insinuation of independence that does not actually hold, which allows the argument to lead you to a wrong answer with a series of plausible-sounding steps. As you can see from your enumeration of the possible outcomes, every possible outcome is one where "at least two are alike" so conditioning on this event has no effect on the probabilities (it is equivalent to conditioning on the sample space). However, by then looking at an event pertaining to "the third" coin we are implicitly referencing an event that depends on which two of the previous values are alike. Consequently, it turns out that the outcome of "the third" coin is not independent of the shared outcome of the other two coins. While it is (marginally) true that "it is an even chance that the third is a head or a tail", this no longer holds once we condition on the outcome of the other two coins. To see this, let's proceed through the enumeration and look at the outcome of "the third" coin compared to the other two. For each row $k$ let $R_k$ denote the coin that is designated as "the third" coin in the outcome (which can take on multiple values in some cases), let $S_k$ denote the outcome of "the two" coins, and let $T_k$ denote the outcome of "the third" coin. Going through the enumerated rows we get: $$\begin{matrix} R_1 = 1,2,3 & & & S_1 = 0 & & & T_1 = 0 & & & S_1 = T_1, \\ R_2 = 3 \quad \quad & & & S_2 = 0 & & & T_2 = 1 & & & S_2 \neq T_2, \\ R_3 = 2 \quad \quad & & & S_3 = 0 & & & T_3 = 1 & & & S_3 \neq T_3, \\ R_4 = 1 \quad \quad & & & S_4 = 1 & & & T_4 = 0 & & & S_4 \neq T_4, \\ R_5 = 1 \quad \quad & & & S_5 = 0 & & & T_5 = 1 & & & S_5 \neq T_5, \\ R_6 = 2 \quad \quad & & & S_6 = 1 & & & T_6 = 0 & & & S_6 \neq T_6, \\ R_7 = 3 \quad \quad & & & S_7 = 1 & & & T_7 = 0 & & & S_7 \neq T_7, \\ R_8 = 1,2,3 & & & S_8 = 1 & & & T_8 = 1 & & & S_8 = T_8. \\ \end{matrix}$$ As you can see, if we take the rows to be equiprobable (which occurs with flipping of independent fair coins) then it is true that $\mathbb{P}(T=0) = \mathbb{P}(T=1) = \tfrac{1}{2}$ (i.e., the third coin is equally likely to be a head or tail). However, the random variables $S$ and $T$ are not independent. In fact, we have: $$\begin{matrix} \mathbb{P}(T=0|S=0) = \tfrac{1}{4} & & & \mathbb{P}(T=0|S=1) = \tfrac{3}{4}, \\[6pt] \mathbb{P}(T=1|S=0) = \tfrac{3}{4} & & & \mathbb{P}(T=1|S=1) = \tfrac{1}{4}. \\[6pt] \end{matrix}$$ Consequently, the probability that all the coins have the same outcome is: $$\begin{align} \mathbb{P}(S=T) &= \mathbb{P}(S=T|S=0) \cdot \mathbb{P}(S=0) + \mathbb{P}(S=T|S=1) \cdot \mathbb{P}(S=1) \\[6pt] &= \mathbb{P}(T=0|S=0) \cdot \mathbb{P}(S=0) + \mathbb{P}(T=1|S=1) \cdot \mathbb{P}(S=1) \\[6pt] &= \tfrac{1}{4} \cdot \tfrac{1}{2} + \tfrac{1}{4} \cdot \tfrac{1}{2} \\[6pt] &= \tfrac{1}{4}. \\[6pt] \end{align}$$ We can see from this working that the marginal probability $\mathbb{P}(T=0) = \mathbb{P}(T=1) = \tfrac{1}{2}$ does not mean that $\mathbb{P}(S=T) = \tfrac{1}{2}$ (which is what the paradox is trying to convince you of). The reason for this is that $S$ and $T$ are not independent. As has been pointed out in the comments on the question, there is some ambiguity in the identity of "the third" coin in this problem. However, that is not really affecting anything --- we can see that the probabilities in question are invariant to the way we select "the third" coin in the two ambiguous cases. The real reason for the "paradox" is the fact that the outcome of "the third" coin is not independent of the outcome of "the two" coins with shared outcomes (irrespective of how the third coin is chosen in cases of ambiguity). The argument in the paradox works by appealing to the intuitive plausibility of independence, when in fact it does not hold.
What is Galton's paradox?
The "paradox" here arises from sneaking in an implicit insinuation of independence that does not actually hold, which allows the argument to lead you to a wrong answer with a series of plausible-sound
What is Galton's paradox? The "paradox" here arises from sneaking in an implicit insinuation of independence that does not actually hold, which allows the argument to lead you to a wrong answer with a series of plausible-sounding steps. As you can see from your enumeration of the possible outcomes, every possible outcome is one where "at least two are alike" so conditioning on this event has no effect on the probabilities (it is equivalent to conditioning on the sample space). However, by then looking at an event pertaining to "the third" coin we are implicitly referencing an event that depends on which two of the previous values are alike. Consequently, it turns out that the outcome of "the third" coin is not independent of the shared outcome of the other two coins. While it is (marginally) true that "it is an even chance that the third is a head or a tail", this no longer holds once we condition on the outcome of the other two coins. To see this, let's proceed through the enumeration and look at the outcome of "the third" coin compared to the other two. For each row $k$ let $R_k$ denote the coin that is designated as "the third" coin in the outcome (which can take on multiple values in some cases), let $S_k$ denote the outcome of "the two" coins, and let $T_k$ denote the outcome of "the third" coin. Going through the enumerated rows we get: $$\begin{matrix} R_1 = 1,2,3 & & & S_1 = 0 & & & T_1 = 0 & & & S_1 = T_1, \\ R_2 = 3 \quad \quad & & & S_2 = 0 & & & T_2 = 1 & & & S_2 \neq T_2, \\ R_3 = 2 \quad \quad & & & S_3 = 0 & & & T_3 = 1 & & & S_3 \neq T_3, \\ R_4 = 1 \quad \quad & & & S_4 = 1 & & & T_4 = 0 & & & S_4 \neq T_4, \\ R_5 = 1 \quad \quad & & & S_5 = 0 & & & T_5 = 1 & & & S_5 \neq T_5, \\ R_6 = 2 \quad \quad & & & S_6 = 1 & & & T_6 = 0 & & & S_6 \neq T_6, \\ R_7 = 3 \quad \quad & & & S_7 = 1 & & & T_7 = 0 & & & S_7 \neq T_7, \\ R_8 = 1,2,3 & & & S_8 = 1 & & & T_8 = 1 & & & S_8 = T_8. \\ \end{matrix}$$ As you can see, if we take the rows to be equiprobable (which occurs with flipping of independent fair coins) then it is true that $\mathbb{P}(T=0) = \mathbb{P}(T=1) = \tfrac{1}{2}$ (i.e., the third coin is equally likely to be a head or tail). However, the random variables $S$ and $T$ are not independent. In fact, we have: $$\begin{matrix} \mathbb{P}(T=0|S=0) = \tfrac{1}{4} & & & \mathbb{P}(T=0|S=1) = \tfrac{3}{4}, \\[6pt] \mathbb{P}(T=1|S=0) = \tfrac{3}{4} & & & \mathbb{P}(T=1|S=1) = \tfrac{1}{4}. \\[6pt] \end{matrix}$$ Consequently, the probability that all the coins have the same outcome is: $$\begin{align} \mathbb{P}(S=T) &= \mathbb{P}(S=T|S=0) \cdot \mathbb{P}(S=0) + \mathbb{P}(S=T|S=1) \cdot \mathbb{P}(S=1) \\[6pt] &= \mathbb{P}(T=0|S=0) \cdot \mathbb{P}(S=0) + \mathbb{P}(T=1|S=1) \cdot \mathbb{P}(S=1) \\[6pt] &= \tfrac{1}{4} \cdot \tfrac{1}{2} + \tfrac{1}{4} \cdot \tfrac{1}{2} \\[6pt] &= \tfrac{1}{4}. \\[6pt] \end{align}$$ We can see from this working that the marginal probability $\mathbb{P}(T=0) = \mathbb{P}(T=1) = \tfrac{1}{2}$ does not mean that $\mathbb{P}(S=T) = \tfrac{1}{2}$ (which is what the paradox is trying to convince you of). The reason for this is that $S$ and $T$ are not independent. As has been pointed out in the comments on the question, there is some ambiguity in the identity of "the third" coin in this problem. However, that is not really affecting anything --- we can see that the probabilities in question are invariant to the way we select "the third" coin in the two ambiguous cases. The real reason for the "paradox" is the fact that the outcome of "the third" coin is not independent of the outcome of "the two" coins with shared outcomes (irrespective of how the third coin is chosen in cases of ambiguity). The argument in the paradox works by appealing to the intuitive plausibility of independence, when in fact it does not hold.
What is Galton's paradox? The "paradox" here arises from sneaking in an implicit insinuation of independence that does not actually hold, which allows the argument to lead you to a wrong answer with a series of plausible-sound
41,355
How to choose $\gamma$ parameter in Focal Loss?
The parameter $\gamma$ smoothly adjusts the rate at which easy examples are down-weighted and that is quite dataset and application dependent. In the paper, the focal loss is actually given as: $βˆ’\alpha (1 βˆ’ p_t)^\gamma \log(p_t)$ which is a reformulated view of the standard cross-entropy loss and the class imbalance itself is "controlled" by $\alpha$ rather than $\gamma$. People often treat the focal loss as a tool to primarily address class imbalance whether it is actually a tool to primarily address information asymmetry during learning; i.e. focal loss can very relevant when training with a balanced set where one of the two classes is easy to distinguish. But to bring us back: there is no good rule of thumb aside setting $\gamma=2$ (as the paper suggests) and then adjusting it based on our evaluation criteria. This point highlights the difference between a loss function and an evaluation metric; CV.SE has thread on Loss function and evaluation metric if you want to explore this distinction further but the main point to carry here is that $\gamma$ (i.e. a hyper-parameter of our loss) needs to be adjust in relation to our evaluation criteria and "on it's own" is often meaningless.
How to choose $\gamma$ parameter in Focal Loss?
The parameter $\gamma$ smoothly adjusts the rate at which easy examples are down-weighted and that is quite dataset and application dependent. In the paper, the focal loss is actually given as: $βˆ’\alp
How to choose $\gamma$ parameter in Focal Loss? The parameter $\gamma$ smoothly adjusts the rate at which easy examples are down-weighted and that is quite dataset and application dependent. In the paper, the focal loss is actually given as: $βˆ’\alpha (1 βˆ’ p_t)^\gamma \log(p_t)$ which is a reformulated view of the standard cross-entropy loss and the class imbalance itself is "controlled" by $\alpha$ rather than $\gamma$. People often treat the focal loss as a tool to primarily address class imbalance whether it is actually a tool to primarily address information asymmetry during learning; i.e. focal loss can very relevant when training with a balanced set where one of the two classes is easy to distinguish. But to bring us back: there is no good rule of thumb aside setting $\gamma=2$ (as the paper suggests) and then adjusting it based on our evaluation criteria. This point highlights the difference between a loss function and an evaluation metric; CV.SE has thread on Loss function and evaluation metric if you want to explore this distinction further but the main point to carry here is that $\gamma$ (i.e. a hyper-parameter of our loss) needs to be adjust in relation to our evaluation criteria and "on it's own" is often meaningless.
How to choose $\gamma$ parameter in Focal Loss? The parameter $\gamma$ smoothly adjusts the rate at which easy examples are down-weighted and that is quite dataset and application dependent. In the paper, the focal loss is actually given as: $βˆ’\alp
41,356
How to choose $\gamma$ parameter in Focal Loss?
On page 3, the authors write "we found $\gamma = 2$ to work best in our experiments." This tells us that they chose $\gamma$ experimentally by training models with different values and then choosing the $\gamma$ from the best model. Because this value was chosen experimentally, it may not be the best choice across all modeling tasks or datasets. You might use $\gamma =2$, with the reasoning that the paper authors found that to be the best value. Alternatively, you can tune $\gamma$ experimentally (assuming you have the resources to do so).
How to choose $\gamma$ parameter in Focal Loss?
On page 3, the authors write "we found $\gamma = 2$ to work best in our experiments." This tells us that they chose $\gamma$ experimentally by training models with different values and then choosing t
How to choose $\gamma$ parameter in Focal Loss? On page 3, the authors write "we found $\gamma = 2$ to work best in our experiments." This tells us that they chose $\gamma$ experimentally by training models with different values and then choosing the $\gamma$ from the best model. Because this value was chosen experimentally, it may not be the best choice across all modeling tasks or datasets. You might use $\gamma =2$, with the reasoning that the paper authors found that to be the best value. Alternatively, you can tune $\gamma$ experimentally (assuming you have the resources to do so).
How to choose $\gamma$ parameter in Focal Loss? On page 3, the authors write "we found $\gamma = 2$ to work best in our experiments." This tells us that they chose $\gamma$ experimentally by training models with different values and then choosing t
41,357
Fast likelihood evaluation for Gaussian distribution with diagonal plus low rank covariance
$\newcommand{\L}{\Lambda}$We need to be able to efficiently evaluate $y^T(\Sigma + \L\L^T)^{-1} y$ and $\det (\Sigma + \L\L^T)$. The standard approach here is to use the Woodbury matrix identity and matrix determinant lemma to change our hard operations from being on $p\times p$ matrices to being on $d\times d$ matrices. The Woodbury matrix identity gives us $$ (\Sigma + \L\L^T)^{-1} = \Sigma^{-1} - \Sigma^{-1}\L(I + \L^T \Sigma^{-1} \L)^{-1}\L^T\Sigma^{-1}. $$ $\Sigma$ is diagonal so $\Sigma^{-1}$ takes $O(p)$ operations. $\Sigma^{-1} \L$ then is scaling each row of $\Lambda$ by the corresponding element of $\Sigma^{-1}$ so this takes $O(dp)$ time. $\L^T (\Sigma^{-1} \L)$ then naively takes $O(d^2 p)$, so the time taken to get to $I + \L^T \Sigma^{-1} \L$ is $O(d^2p)$. This is a $d\times d$ matrix now so inversion is naively $O(d^3)$ so we're at $O(d^3 + d^2p)$. $\Sigma^{-1}\L(I + \L^T \Sigma^{-1} \L)^{-1}$ is $O(d^2p)$ as well, but then we end up with a $(p\times d) (d\times p)$ matrix multiplication which is $O(p^2d)$, so in all we're at $O(d^3 + d^2p + dp^2)$ and $d \ll p$ means this is effectively $O(dp^2)$ which is better than the $O(p^3)$ we'd have with a direct naive inversion. For the determinant, the matrix determinant lemma gives us $$ \det(\Sigma + \L\L^T) = \det(I + \L^T \Sigma^{-1} \L)\det \Sigma. $$ $\det \Sigma$ is just $O(p)$, and we can do $I + \L^T \Sigma^{-1} \L$ in $O(d^2p)$ as we saw above. We now need the determinant of this matrix which is $d\times d$ so we're at $O(d^3 + d^2 p)$ which is effectively $O(d^2 p)$ given $d \ll p$. All together we can do this in $O(dp^2)$ operations (and it would be a little faster if we did this for real since matrix multiplication and inversion can be done a little faster than the naive way).
Fast likelihood evaluation for Gaussian distribution with diagonal plus low rank covariance
$\newcommand{\L}{\Lambda}$We need to be able to efficiently evaluate $y^T(\Sigma + \L\L^T)^{-1} y$ and $\det (\Sigma + \L\L^T)$. The standard approach here is to use the Woodbury matrix identity and m
Fast likelihood evaluation for Gaussian distribution with diagonal plus low rank covariance $\newcommand{\L}{\Lambda}$We need to be able to efficiently evaluate $y^T(\Sigma + \L\L^T)^{-1} y$ and $\det (\Sigma + \L\L^T)$. The standard approach here is to use the Woodbury matrix identity and matrix determinant lemma to change our hard operations from being on $p\times p$ matrices to being on $d\times d$ matrices. The Woodbury matrix identity gives us $$ (\Sigma + \L\L^T)^{-1} = \Sigma^{-1} - \Sigma^{-1}\L(I + \L^T \Sigma^{-1} \L)^{-1}\L^T\Sigma^{-1}. $$ $\Sigma$ is diagonal so $\Sigma^{-1}$ takes $O(p)$ operations. $\Sigma^{-1} \L$ then is scaling each row of $\Lambda$ by the corresponding element of $\Sigma^{-1}$ so this takes $O(dp)$ time. $\L^T (\Sigma^{-1} \L)$ then naively takes $O(d^2 p)$, so the time taken to get to $I + \L^T \Sigma^{-1} \L$ is $O(d^2p)$. This is a $d\times d$ matrix now so inversion is naively $O(d^3)$ so we're at $O(d^3 + d^2p)$. $\Sigma^{-1}\L(I + \L^T \Sigma^{-1} \L)^{-1}$ is $O(d^2p)$ as well, but then we end up with a $(p\times d) (d\times p)$ matrix multiplication which is $O(p^2d)$, so in all we're at $O(d^3 + d^2p + dp^2)$ and $d \ll p$ means this is effectively $O(dp^2)$ which is better than the $O(p^3)$ we'd have with a direct naive inversion. For the determinant, the matrix determinant lemma gives us $$ \det(\Sigma + \L\L^T) = \det(I + \L^T \Sigma^{-1} \L)\det \Sigma. $$ $\det \Sigma$ is just $O(p)$, and we can do $I + \L^T \Sigma^{-1} \L$ in $O(d^2p)$ as we saw above. We now need the determinant of this matrix which is $d\times d$ so we're at $O(d^3 + d^2 p)$ which is effectively $O(d^2 p)$ given $d \ll p$. All together we can do this in $O(dp^2)$ operations (and it would be a little faster if we did this for real since matrix multiplication and inversion can be done a little faster than the naive way).
Fast likelihood evaluation for Gaussian distribution with diagonal plus low rank covariance $\newcommand{\L}{\Lambda}$We need to be able to efficiently evaluate $y^T(\Sigma + \L\L^T)^{-1} y$ and $\det (\Sigma + \L\L^T)$. The standard approach here is to use the Woodbury matrix identity and m
41,358
Difference between splines from different packages (mgcv, rms etc.)
The main difference is the choice of knots and penalization. To start, let's focus on cubic splines for x, y data.* I find it useful to start from the extreme situation, an interpolating spline that connects all data points with a smooth curve. Then each x-axis value is a knot at which two cubic functions interpolating on either side of the knot agree in their values (and with the corresponding y value) and in their first and second derivatives. That can fit the data at hand perfectly but at the cost of a very "wiggly" curve and probable overfitting that won't generalize well to new data. The different approaches can be thought of as different ways to avoid that overfitting. A cubic smoothing spline might keep the original knot locations along the x-axis while penalizing the roughness of the curve in terms of its integrated squared second derivative. An optimal penalty can be chosen by (restricted) marginal likelihood or generalized cross-validation. That Wikipedia entry outlines other methods, including regression splines and penalized splines: Regression splines. In this method, the data is fitted to a set of spline basis functions with a reduced set of knots, typically by least squares. No roughness penalty is used... Penalized splines. This combines the reduced knots of regression splines, with the roughness penalty of smoothing splines. Thin plate splines and Elastic maps method for manifold learning. This method combines the least squares penalty for approximation error with the bending and stretching penalty of the approximating manifold and uses the coarse discretization of the optimization problem. In this terminology, the mgcv package has a major focus on smoothing/penalization methods, with thin-plate splines as a default, although it can accommodate unpenalized regression splines. (The help pages for that package don't restrict the term "regression splines" to unpenalized methods.) A simple implementation of penalized splines is seen in the pspline() function in the survival package, which sets up a small set of evenly spaced symmetric basis functions that span the x-axis data range. The corresponding coefficients are then penalized automatically when fitting coxph or survreg survival models. The ns() and rcs() functions implement "natural" cubic regression splines, restricted to be linear beyond the outermost knots. By your choice of the number of knots, you thus specify the number of degrees of freedom to be used in the fit. There is no inherent penalization beyond the choice of numbers of knots. Therneau and Grambsch, in Modeling Survival Data: Extending the Cox Model discuss regression splines in Section 5.4 and smoothing splines in Section 5.5, without massive mathematical detail about spline basis functions that can become confusing. They put one difference between them this way: One issue with regression splines is the arbitrary choice of control point (knot) locations. Are the default quantiles good values, would the curve change significantly if other knot locations were selected, or can knot position be optimized? For a data set that contains a sudden feature, such as a changepoint, the choice of particular knot locations may either enhance or mask the feature. An alternative to the regression spline is a smoothing spline. That said, their pspline() function spaces a limited number of basis functions evenly across the x-axis value range, without regard to the distribution of x values. See Section 5.8.3 of their book. One might consider that a different "arbitrary choice." Furthermore, regression splines allow you to pre-specify how many degrees of freedom to devote to the modeled predictor. That's an advantage with Harrell's approach to Regression Modeling Strategies, in which such explicit choices early in modeling are key. With penalization methods, one typically lets the data determine how many degrees of freedom to use up. Regression splines work well in practice with typical data, when you don't need the highly specialized types of fits provided by mgcv for things like geospatial data. Here's a particular comparison of rcs() and gam() fitting of data generated from the Runge function; code is below. The gam() fit devoted 8.95 degrees of freedom (df) to the penalized fit, plus the intercept for 9.95 df total. The corresponding df used by the ols() fit with an rcs(x,7) term were 6 for x and 7 df total. Whichever choice you make, don't just accept default parameter settings blindly; not to choose is to choose, and you should understand the choices you are (even implicitly) making about your spline approximation. For example, the gam() fit above used the default bs=tp (thin-plate spline) setting for the smoothing basis, which "do not have β€˜knots’ (at least not in any conventional sense): a truncated eigen-decomposition is used to achieve the rank reduction." With this size data set, the rcs(x,7) term led to outer knots at the 0.05 and 0.95 quantiles of x values, with 5 interior knots "equally spaced between these on the quantile scale." (Emphasis added.) Read the help pages carefully. This site has many posts on these types of splines. Frank Harrell, author of the rms package, often discusses regression splines. Gavin Simpson, author of the gratia package that helps to visualize mgcv models, often discusses GAM. Searches here for posts by those reputable sources will provide much for further study. Code for the figure: runge <- function(x) {1/(1+25*x^2)} set.seed(1) xvals <- runif(200,min=-1,max=1) yvals <- exp(log(runge(xvals))+log(rlnorm(200,sdlog=0.075))) ## add some multiplicative error dfspl <- data.frame(x=xvals,y=yvals) library(rms) library(mgcv) ddspl <- datadist(dfspl) options(datadist="ddspl") olsFit7 <- ols(y~rcs(x,7),data=dfspl) ## default is 5 knots, used 7 gamFit <- gam(y~s(x),data=dfspl) ## use defaults plot(y~x,data=dfspl,bty="n") curve(runge(x),from=-1,to=1,add=TRUE) lines(seq(-1,1,length.out=100),predict(gamFit,newdata=data.frame(x=seq(-1,1,length.out=100))),col="red",lwd=3) lines(Predict(olsFit7),col="blue",lwd=3) legend("topleft",legend="black, actual\nred, gam\nblue, rcs",bty="n") ## to see an interpolating spline for these data, run ## isplFit <- splines::interpSpline(y~x,dfspl); plot(predict(isplFit,seq(-1,1,length.out=500)),type="l") *There can be different choices of the basis functions used to construct the cubic splines, but as comments note those choices are somewhat arbitrary and should give similar results in practice. Also, a default spline in the mgcv package doesn't involve knots in the usual sense at all, as the answer eventually notes.
Difference between splines from different packages (mgcv, rms etc.)
The main difference is the choice of knots and penalization. To start, let's focus on cubic splines for x, y data.* I find it useful to start from the extreme situation, an interpolating spline that c
Difference between splines from different packages (mgcv, rms etc.) The main difference is the choice of knots and penalization. To start, let's focus on cubic splines for x, y data.* I find it useful to start from the extreme situation, an interpolating spline that connects all data points with a smooth curve. Then each x-axis value is a knot at which two cubic functions interpolating on either side of the knot agree in their values (and with the corresponding y value) and in their first and second derivatives. That can fit the data at hand perfectly but at the cost of a very "wiggly" curve and probable overfitting that won't generalize well to new data. The different approaches can be thought of as different ways to avoid that overfitting. A cubic smoothing spline might keep the original knot locations along the x-axis while penalizing the roughness of the curve in terms of its integrated squared second derivative. An optimal penalty can be chosen by (restricted) marginal likelihood or generalized cross-validation. That Wikipedia entry outlines other methods, including regression splines and penalized splines: Regression splines. In this method, the data is fitted to a set of spline basis functions with a reduced set of knots, typically by least squares. No roughness penalty is used... Penalized splines. This combines the reduced knots of regression splines, with the roughness penalty of smoothing splines. Thin plate splines and Elastic maps method for manifold learning. This method combines the least squares penalty for approximation error with the bending and stretching penalty of the approximating manifold and uses the coarse discretization of the optimization problem. In this terminology, the mgcv package has a major focus on smoothing/penalization methods, with thin-plate splines as a default, although it can accommodate unpenalized regression splines. (The help pages for that package don't restrict the term "regression splines" to unpenalized methods.) A simple implementation of penalized splines is seen in the pspline() function in the survival package, which sets up a small set of evenly spaced symmetric basis functions that span the x-axis data range. The corresponding coefficients are then penalized automatically when fitting coxph or survreg survival models. The ns() and rcs() functions implement "natural" cubic regression splines, restricted to be linear beyond the outermost knots. By your choice of the number of knots, you thus specify the number of degrees of freedom to be used in the fit. There is no inherent penalization beyond the choice of numbers of knots. Therneau and Grambsch, in Modeling Survival Data: Extending the Cox Model discuss regression splines in Section 5.4 and smoothing splines in Section 5.5, without massive mathematical detail about spline basis functions that can become confusing. They put one difference between them this way: One issue with regression splines is the arbitrary choice of control point (knot) locations. Are the default quantiles good values, would the curve change significantly if other knot locations were selected, or can knot position be optimized? For a data set that contains a sudden feature, such as a changepoint, the choice of particular knot locations may either enhance or mask the feature. An alternative to the regression spline is a smoothing spline. That said, their pspline() function spaces a limited number of basis functions evenly across the x-axis value range, without regard to the distribution of x values. See Section 5.8.3 of their book. One might consider that a different "arbitrary choice." Furthermore, regression splines allow you to pre-specify how many degrees of freedom to devote to the modeled predictor. That's an advantage with Harrell's approach to Regression Modeling Strategies, in which such explicit choices early in modeling are key. With penalization methods, one typically lets the data determine how many degrees of freedom to use up. Regression splines work well in practice with typical data, when you don't need the highly specialized types of fits provided by mgcv for things like geospatial data. Here's a particular comparison of rcs() and gam() fitting of data generated from the Runge function; code is below. The gam() fit devoted 8.95 degrees of freedom (df) to the penalized fit, plus the intercept for 9.95 df total. The corresponding df used by the ols() fit with an rcs(x,7) term were 6 for x and 7 df total. Whichever choice you make, don't just accept default parameter settings blindly; not to choose is to choose, and you should understand the choices you are (even implicitly) making about your spline approximation. For example, the gam() fit above used the default bs=tp (thin-plate spline) setting for the smoothing basis, which "do not have β€˜knots’ (at least not in any conventional sense): a truncated eigen-decomposition is used to achieve the rank reduction." With this size data set, the rcs(x,7) term led to outer knots at the 0.05 and 0.95 quantiles of x values, with 5 interior knots "equally spaced between these on the quantile scale." (Emphasis added.) Read the help pages carefully. This site has many posts on these types of splines. Frank Harrell, author of the rms package, often discusses regression splines. Gavin Simpson, author of the gratia package that helps to visualize mgcv models, often discusses GAM. Searches here for posts by those reputable sources will provide much for further study. Code for the figure: runge <- function(x) {1/(1+25*x^2)} set.seed(1) xvals <- runif(200,min=-1,max=1) yvals <- exp(log(runge(xvals))+log(rlnorm(200,sdlog=0.075))) ## add some multiplicative error dfspl <- data.frame(x=xvals,y=yvals) library(rms) library(mgcv) ddspl <- datadist(dfspl) options(datadist="ddspl") olsFit7 <- ols(y~rcs(x,7),data=dfspl) ## default is 5 knots, used 7 gamFit <- gam(y~s(x),data=dfspl) ## use defaults plot(y~x,data=dfspl,bty="n") curve(runge(x),from=-1,to=1,add=TRUE) lines(seq(-1,1,length.out=100),predict(gamFit,newdata=data.frame(x=seq(-1,1,length.out=100))),col="red",lwd=3) lines(Predict(olsFit7),col="blue",lwd=3) legend("topleft",legend="black, actual\nred, gam\nblue, rcs",bty="n") ## to see an interpolating spline for these data, run ## isplFit <- splines::interpSpline(y~x,dfspl); plot(predict(isplFit,seq(-1,1,length.out=500)),type="l") *There can be different choices of the basis functions used to construct the cubic splines, but as comments note those choices are somewhat arbitrary and should give similar results in practice. Also, a default spline in the mgcv package doesn't involve knots in the usual sense at all, as the answer eventually notes.
Difference between splines from different packages (mgcv, rms etc.) The main difference is the choice of knots and penalization. To start, let's focus on cubic splines for x, y data.* I find it useful to start from the extreme situation, an interpolating spline that c
41,359
Please clarify Bayesian calibration of the posterior mean
It may be confusing that the $\hat \theta = E[\theta \mid y]$ seems to use the chosen prior and the posterior distribution then implied by the observation, while the $E\left[\theta \mid \hat \theta\right]-\hat \theta$ in the miscalibration calculation seems to use the actual (though presumably unknown) distribution for $\theta$. It is probably easier with an example. Suppose we have $\theta \in [0,1]$ as the parameter of a Bernoulli random variable $Y$ which is $1$ with probability $\theta$ and $0$ otherwise If we use a prior $p(\theta)=2\theta$, then observing $Y=1$ will suggest to us a posterior distribution $p(\theta \mid Y=1)=3\theta^2$ with mean $\hat \theta =\frac34$, observing $Y=0$ will suggest to us a posterior distribution $p(\theta \mid Y=0)=6\theta(1-\theta)$ with mean $\hat \theta =\frac12$, and there is a $1-1$ relationship here between the value of $Y$ and $\hat \theta$. If the prior is the correct distribution of $\theta$ then when $\hat \theta =\frac34$, we have $E\left[\theta \mid \hat \theta=\frac34\right] - \hat\theta =\frac34-\frac34=0$ when $\hat \theta =\frac12$, we have $E\left[\theta \mid \hat \theta=\frac12\right] - \hat\theta =\frac12-\frac12=0$ automatically as asserted, and also the probability of observing $Y=1$ and estimating $\hat \theta=\frac34$ is $\frac23$ the probability of observing $Y=0$ and estimating $\hat \theta=\frac12$ is $\frac13$ so $E\left[\hat\theta\right]=\frac23 \times \frac34 +\frac13\times \frac12 =\frac23 = E[\theta]$ and all is well with the world. But if the prior were wrong and in fact $\theta$ in reality had a density of $2(1-\theta)$ i.e. with $\theta$ and $Y$ more likely to be smaller than the assumed prior suggested, then the actual conditional expectations for $\theta$ would be smaller when $\hat \theta =\frac34$, we would have $E\left[\theta \mid \hat \theta=\frac34\right] - \hat\theta =\frac12-\frac34=-\frac14$ when $\hat \theta =\frac12$, we would have $E\left[\theta \mid \hat \theta=\frac12\right] - \hat\theta =\frac14-\frac12=-\frac14$ so a miscalibration of $- \frac14$ (in more complicated cases it does not have to be constant) and the probability of observing $Y=1$ and estimating $\hat \theta=\frac34$ would have been $\frac13$ the probability of observing $Y=0$ and estimating $\hat \theta=\frac12$ would have been $\frac23$ making $E[\hat\theta]=\frac13 \times \frac34 +\frac23\times \frac12 =\frac7{12} \not = \frac13 = E[\theta]$, which may be undesirable.
Please clarify Bayesian calibration of the posterior mean
It may be confusing that the $\hat \theta = E[\theta \mid y]$ seems to use the chosen prior and the posterior distribution then implied by the observation, while the $E\left[\theta \mid \hat \theta\ri
Please clarify Bayesian calibration of the posterior mean It may be confusing that the $\hat \theta = E[\theta \mid y]$ seems to use the chosen prior and the posterior distribution then implied by the observation, while the $E\left[\theta \mid \hat \theta\right]-\hat \theta$ in the miscalibration calculation seems to use the actual (though presumably unknown) distribution for $\theta$. It is probably easier with an example. Suppose we have $\theta \in [0,1]$ as the parameter of a Bernoulli random variable $Y$ which is $1$ with probability $\theta$ and $0$ otherwise If we use a prior $p(\theta)=2\theta$, then observing $Y=1$ will suggest to us a posterior distribution $p(\theta \mid Y=1)=3\theta^2$ with mean $\hat \theta =\frac34$, observing $Y=0$ will suggest to us a posterior distribution $p(\theta \mid Y=0)=6\theta(1-\theta)$ with mean $\hat \theta =\frac12$, and there is a $1-1$ relationship here between the value of $Y$ and $\hat \theta$. If the prior is the correct distribution of $\theta$ then when $\hat \theta =\frac34$, we have $E\left[\theta \mid \hat \theta=\frac34\right] - \hat\theta =\frac34-\frac34=0$ when $\hat \theta =\frac12$, we have $E\left[\theta \mid \hat \theta=\frac12\right] - \hat\theta =\frac12-\frac12=0$ automatically as asserted, and also the probability of observing $Y=1$ and estimating $\hat \theta=\frac34$ is $\frac23$ the probability of observing $Y=0$ and estimating $\hat \theta=\frac12$ is $\frac13$ so $E\left[\hat\theta\right]=\frac23 \times \frac34 +\frac13\times \frac12 =\frac23 = E[\theta]$ and all is well with the world. But if the prior were wrong and in fact $\theta$ in reality had a density of $2(1-\theta)$ i.e. with $\theta$ and $Y$ more likely to be smaller than the assumed prior suggested, then the actual conditional expectations for $\theta$ would be smaller when $\hat \theta =\frac34$, we would have $E\left[\theta \mid \hat \theta=\frac34\right] - \hat\theta =\frac12-\frac34=-\frac14$ when $\hat \theta =\frac12$, we would have $E\left[\theta \mid \hat \theta=\frac12\right] - \hat\theta =\frac14-\frac12=-\frac14$ so a miscalibration of $- \frac14$ (in more complicated cases it does not have to be constant) and the probability of observing $Y=1$ and estimating $\hat \theta=\frac34$ would have been $\frac13$ the probability of observing $Y=0$ and estimating $\hat \theta=\frac12$ would have been $\frac23$ making $E[\hat\theta]=\frac13 \times \frac34 +\frac23\times \frac12 =\frac7{12} \not = \frac13 = E[\theta]$, which may be undesirable.
Please clarify Bayesian calibration of the posterior mean It may be confusing that the $\hat \theta = E[\theta \mid y]$ seems to use the chosen prior and the posterior distribution then implied by the observation, while the $E\left[\theta \mid \hat \theta\ri
41,360
Understand the idea of margin in contrastive loss for siamese networks
The best explanation is given in A Tutorial on Energy-Based Learning by LeCun et al, concretely in section 5. Also, Learning a Similarity Metric Discriminatively, with Application to Face Verification by Chopra et al. provides a detailed analysis for the case of face verification. The motivation for introducing the margin is to avoid a collapsed solution (where the resulting energy landscape is constant or zero, that is, the model is not able to distinguish between good and bad solutions). Training will be successful when the model associates lower energy values to correct answers, and higher energy values to incorrect answers. The paper describes in detail, what properties the loss function must fulfill. If you write the above expression in a slightly more abstract manner: $YL_G + (1-Y)L_I$ where $L_G$ is the loss for the similar pair of samples, and $L_I$ for the dissimilar one, how should these loss functions behave?. You want $L_G$ to be monotonically increasing, so that the network learns to pull down the energy values for similar samples, and $L_I$ monotonically decreasing to do the opposite for dissimilar samples. The contrastive loss is just one such loss function that fulfills that condition. Now, why the margin? If $m=0$ notice that both terms would then match, and after training you would be giving all samples the same energy value. This effect is shown in the following figures, After introducing the margin, you have a well-behaved loss function Both figures are taken from the first reference.
Understand the idea of margin in contrastive loss for siamese networks
The best explanation is given in A Tutorial on Energy-Based Learning by LeCun et al, concretely in section 5. Also, Learning a Similarity Metric Discriminatively, with Application to Face Verification
Understand the idea of margin in contrastive loss for siamese networks The best explanation is given in A Tutorial on Energy-Based Learning by LeCun et al, concretely in section 5. Also, Learning a Similarity Metric Discriminatively, with Application to Face Verification by Chopra et al. provides a detailed analysis for the case of face verification. The motivation for introducing the margin is to avoid a collapsed solution (where the resulting energy landscape is constant or zero, that is, the model is not able to distinguish between good and bad solutions). Training will be successful when the model associates lower energy values to correct answers, and higher energy values to incorrect answers. The paper describes in detail, what properties the loss function must fulfill. If you write the above expression in a slightly more abstract manner: $YL_G + (1-Y)L_I$ where $L_G$ is the loss for the similar pair of samples, and $L_I$ for the dissimilar one, how should these loss functions behave?. You want $L_G$ to be monotonically increasing, so that the network learns to pull down the energy values for similar samples, and $L_I$ monotonically decreasing to do the opposite for dissimilar samples. The contrastive loss is just one such loss function that fulfills that condition. Now, why the margin? If $m=0$ notice that both terms would then match, and after training you would be giving all samples the same energy value. This effect is shown in the following figures, After introducing the margin, you have a well-behaved loss function Both figures are taken from the first reference.
Understand the idea of margin in contrastive loss for siamese networks The best explanation is given in A Tutorial on Energy-Based Learning by LeCun et al, concretely in section 5. Also, Learning a Similarity Metric Discriminatively, with Application to Face Verification
41,361
Understand the idea of margin in contrastive loss for siamese networks
If you look at the Loss it is composed of two parts, 1st the loss when they are similar and second the loss when they are dissimilar. If model works very well, observation which are similar should have very small distance. Using Sqaure distance in first ensure that model is penalized if its gives high distance for similar observation (classes) For Dissimilar observation, if two class are seprated well enough defined by Margin then the error contirbution is zero. Lets look at the example below : Suppose we choose margin to be 10, and we have two observation where distance between them is 19,1 lets see how loss looks like Error Observation 1 = max(0,10-19)^2 = 0 - No Contribution to error Error Observation 2 = max(0,10-1)^2 = 81 - High Contribution to error As objective is to minimize loss, Observation 2 which is difficult to embed would be contibuting to loss so model can optimise for that So margin ensure observation which have was well separated i.e. Distance Greater than Margin their contribution to error is zero. So optimisation algorithm can concentrate on seprating difficult Data Point in above example Observation 2. Thus Margin Helps on optimisation to embed difficult to seprate points
Understand the idea of margin in contrastive loss for siamese networks
If you look at the Loss it is composed of two parts, 1st the loss when they are similar and second the loss when they are dissimilar. If model works very well, observation which are similar should ha
Understand the idea of margin in contrastive loss for siamese networks If you look at the Loss it is composed of two parts, 1st the loss when they are similar and second the loss when they are dissimilar. If model works very well, observation which are similar should have very small distance. Using Sqaure distance in first ensure that model is penalized if its gives high distance for similar observation (classes) For Dissimilar observation, if two class are seprated well enough defined by Margin then the error contirbution is zero. Lets look at the example below : Suppose we choose margin to be 10, and we have two observation where distance between them is 19,1 lets see how loss looks like Error Observation 1 = max(0,10-19)^2 = 0 - No Contribution to error Error Observation 2 = max(0,10-1)^2 = 81 - High Contribution to error As objective is to minimize loss, Observation 2 which is difficult to embed would be contibuting to loss so model can optimise for that So margin ensure observation which have was well separated i.e. Distance Greater than Margin their contribution to error is zero. So optimisation algorithm can concentrate on seprating difficult Data Point in above example Observation 2. Thus Margin Helps on optimisation to embed difficult to seprate points
Understand the idea of margin in contrastive loss for siamese networks If you look at the Loss it is composed of two parts, 1st the loss when they are similar and second the loss when they are dissimilar. If model works very well, observation which are similar should ha
41,362
How can I learn statistical a/b testing?
Two books come to mind: Trustworthy Online Controlled Experiments by Kohavi, Tang, and Xu Statistical Methods in Online A/B Testing by Georgi Georgiev The first book collects a great deal of wisdom distilled from years of experience that was scattered in obscure field journals and touched only briefly in textbooks on statistics and field experimentation. There is also a treasure trove of practical examples and institutional details about online experimentation that is missing from those sources. It covers a great deal of terrain but includes references for those who want to go a bit deeper. The second book covers some esoteric, but relevant topics like one-sided hypothesis tests and confidence intervals, holdouts, and percentage changes standard errors, that are ignored or touched on briefly in the conventional treatments. It has an exhaustive list of common misunderstandings of these and many other concepts. The presentation is thoughtful and deep, though not in an excessively mathematical way. I think this has become my go-to book for these topics and a very good complement to textbooks on statistics and field experiments and as well as the Kohavi, Tang, and Xu book. These are both applied books, but they are not exactly cookbooks for how to analyze experimental data. If you lack a background in applied statistics, you may need to supplement with that to implement their advice.
How can I learn statistical a/b testing?
Two books come to mind: Trustworthy Online Controlled Experiments by Kohavi, Tang, and Xu Statistical Methods in Online A/B Testing by Georgi Georgiev The first book collects a great deal of wisdom
How can I learn statistical a/b testing? Two books come to mind: Trustworthy Online Controlled Experiments by Kohavi, Tang, and Xu Statistical Methods in Online A/B Testing by Georgi Georgiev The first book collects a great deal of wisdom distilled from years of experience that was scattered in obscure field journals and touched only briefly in textbooks on statistics and field experimentation. There is also a treasure trove of practical examples and institutional details about online experimentation that is missing from those sources. It covers a great deal of terrain but includes references for those who want to go a bit deeper. The second book covers some esoteric, but relevant topics like one-sided hypothesis tests and confidence intervals, holdouts, and percentage changes standard errors, that are ignored or touched on briefly in the conventional treatments. It has an exhaustive list of common misunderstandings of these and many other concepts. The presentation is thoughtful and deep, though not in an excessively mathematical way. I think this has become my go-to book for these topics and a very good complement to textbooks on statistics and field experiments and as well as the Kohavi, Tang, and Xu book. These are both applied books, but they are not exactly cookbooks for how to analyze experimental data. If you lack a background in applied statistics, you may need to supplement with that to implement their advice.
How can I learn statistical a/b testing? Two books come to mind: Trustworthy Online Controlled Experiments by Kohavi, Tang, and Xu Statistical Methods in Online A/B Testing by Georgi Georgiev The first book collects a great deal of wisdom
41,363
Interpretation of regression coefficients with multiple categorical predictors
I think your question fundamentally goes back to the difference between the interpretation of main-effects in main-effect-only (y ~ cat1 + cat2) vs. interactive (y ~ cat1 * cat2) regression models. When your model is of the form: y ~ sex + schoolgend. Then, YES, .175 has no choice but to represent both the: diff. bet. girls in girl-only vs. mixed schools as well as: diff. bet. boys in girl-only vs. mixed schools (we'll see why this substantively doesn't make sense in your case) In main-effect-only models, this interpretation arises from the fact that you can keep any one predictor constant at any of its levels (doesn't matter which one) while varying the other predictor's levels. So, for schgendgirl-only coef., you're saying holding sex constant at any of its levels (either boys, OR girls) which equivalently means regardless of students' sex; boys or girls, how much y will change if we change schgend from mixed (its reference level) to schgendgirl-only (the level of the tabled coef.)? In interactive models, however, the main effect of one predictor is measurable ONLY when we keep the other predictors at their reference values/levels. So, your problem was that you applied the logic of interpretation for the main effects in interactive models to that in main-effect-only models. Indeed, it makes good sense in your case to let students' sex and schoolgend to interact. Because, as researchers, we may reasonably want to know how y changes for different genders situated in same vs. different school gender systems (a contextual effect). Now let's see why some of the comparisons based on your model are substantively meaningless. By the way your two categorical predictors are set-up, you're telling your model that sex has two levels, and schgend has three levels. But in reality because boys can't be in girl-only, and girls can't be in boys-only schools (data for such combinations don't exist), you get several irrelevant extrapolations as shown in your post-hoc analysis for boys in girl-only and girls in boy-only schools as you don't let sex and schgend to interact. So, what to do? First, recode your schgend to have its real two levels (same_sex [all girls or all boys] vs. mixed schools): tutorial2<-transform(tutorial,schgend2=ifelse(schgend!="mixedsch","same_sex","mixedsch")) Second, change your model to be interactive: Form2 <- normexam ~ 1 + standlrt + schgend2 * sex + (standlrt | school) model2 <- lmer(Form2, data = tutorial2, REML = FALSE) round(coef(summary(model2)),4) Estimate Std. Error t value (Intercept) -0.1888 0.0514 -3.6767 standlrt 0.5544 0.0199 27.8071 schgend2same_sex 0.1799 0.0991 1.8141 sexgirl 0.1683 0.0338 4.9750 schgend2same_sex:sexgirl -0.0050 0.1110 -0.0454 Notice that the meaning of schgend2same_sex ($0.1799$) now matches your interactive-model interpretation logic i.e., it ONLY represents: diff. bet. boys in boy-only vs. mixed schools. The corresponding difference for girls is a tiny bit (~$-.005$) smaller. That is, diff. bet. girls in girl-only vs. mixed schools is ~$0.1749$ (you'll see this in the post-hoc table below shown as $.1748$ due to rounding). Third, perform your desired post-hocs: emmeans(model, pairwise~schgend2*sex)$contrast # contrast estimate SE df z.ratio p.value # mixedsch boy - same_sex boy -0.1799 0.0991 Inf -1.814 0.2666 # mixedsch boy - mixedsch girl -0.1683 0.0338 Inf -4.975 <.0001 # mixedsch boy - same_sex girl -0.3431 0.0780 Inf -4.396 0.0001 # same_sex boy - mixedsch girl 0.0116 0.0997 Inf 0.116 0.9994 # same_sex boy - same_sex girl -0.1632 0.1058 Inf -1.543 0.4115 # mixedsch girl - same_sex girl -0.1748 0.0788 Inf -2.219 0.1180 Now, you get all six possible caparisons between your categorical predictors.
Interpretation of regression coefficients with multiple categorical predictors
I think your question fundamentally goes back to the difference between the interpretation of main-effects in main-effect-only (y ~ cat1 + cat2) vs. interactive (y ~ cat1 * cat2) regression models. Wh
Interpretation of regression coefficients with multiple categorical predictors I think your question fundamentally goes back to the difference between the interpretation of main-effects in main-effect-only (y ~ cat1 + cat2) vs. interactive (y ~ cat1 * cat2) regression models. When your model is of the form: y ~ sex + schoolgend. Then, YES, .175 has no choice but to represent both the: diff. bet. girls in girl-only vs. mixed schools as well as: diff. bet. boys in girl-only vs. mixed schools (we'll see why this substantively doesn't make sense in your case) In main-effect-only models, this interpretation arises from the fact that you can keep any one predictor constant at any of its levels (doesn't matter which one) while varying the other predictor's levels. So, for schgendgirl-only coef., you're saying holding sex constant at any of its levels (either boys, OR girls) which equivalently means regardless of students' sex; boys or girls, how much y will change if we change schgend from mixed (its reference level) to schgendgirl-only (the level of the tabled coef.)? In interactive models, however, the main effect of one predictor is measurable ONLY when we keep the other predictors at their reference values/levels. So, your problem was that you applied the logic of interpretation for the main effects in interactive models to that in main-effect-only models. Indeed, it makes good sense in your case to let students' sex and schoolgend to interact. Because, as researchers, we may reasonably want to know how y changes for different genders situated in same vs. different school gender systems (a contextual effect). Now let's see why some of the comparisons based on your model are substantively meaningless. By the way your two categorical predictors are set-up, you're telling your model that sex has two levels, and schgend has three levels. But in reality because boys can't be in girl-only, and girls can't be in boys-only schools (data for such combinations don't exist), you get several irrelevant extrapolations as shown in your post-hoc analysis for boys in girl-only and girls in boy-only schools as you don't let sex and schgend to interact. So, what to do? First, recode your schgend to have its real two levels (same_sex [all girls or all boys] vs. mixed schools): tutorial2<-transform(tutorial,schgend2=ifelse(schgend!="mixedsch","same_sex","mixedsch")) Second, change your model to be interactive: Form2 <- normexam ~ 1 + standlrt + schgend2 * sex + (standlrt | school) model2 <- lmer(Form2, data = tutorial2, REML = FALSE) round(coef(summary(model2)),4) Estimate Std. Error t value (Intercept) -0.1888 0.0514 -3.6767 standlrt 0.5544 0.0199 27.8071 schgend2same_sex 0.1799 0.0991 1.8141 sexgirl 0.1683 0.0338 4.9750 schgend2same_sex:sexgirl -0.0050 0.1110 -0.0454 Notice that the meaning of schgend2same_sex ($0.1799$) now matches your interactive-model interpretation logic i.e., it ONLY represents: diff. bet. boys in boy-only vs. mixed schools. The corresponding difference for girls is a tiny bit (~$-.005$) smaller. That is, diff. bet. girls in girl-only vs. mixed schools is ~$0.1749$ (you'll see this in the post-hoc table below shown as $.1748$ due to rounding). Third, perform your desired post-hocs: emmeans(model, pairwise~schgend2*sex)$contrast # contrast estimate SE df z.ratio p.value # mixedsch boy - same_sex boy -0.1799 0.0991 Inf -1.814 0.2666 # mixedsch boy - mixedsch girl -0.1683 0.0338 Inf -4.975 <.0001 # mixedsch boy - same_sex girl -0.3431 0.0780 Inf -4.396 0.0001 # same_sex boy - mixedsch girl 0.0116 0.0997 Inf 0.116 0.9994 # same_sex boy - same_sex girl -0.1632 0.1058 Inf -1.543 0.4115 # mixedsch girl - same_sex girl -0.1748 0.0788 Inf -2.219 0.1180 Now, you get all six possible caparisons between your categorical predictors.
Interpretation of regression coefficients with multiple categorical predictors I think your question fundamentally goes back to the difference between the interpretation of main-effects in main-effect-only (y ~ cat1 + cat2) vs. interactive (y ~ cat1 * cat2) regression models. Wh
41,364
Interpretation of regression coefficients with multiple categorical predictors
It's the difference between the (predicted) mean of girls in girls-only schools and the (predicted) mean of girls in mixed schools. You can see this by looking at the design matrix or solving for a predicted value using the fitted regression equation. Let's make some simple data and work through this. d = expand.grid(sex=c("boys","girls"), schoolgend=c("boy-only", "girl-only", "mixed")) d = d[-c(2,3),] d$y = c(-0.189+0.180, -0.189+0.168+0.175, -0.189, -0.189+0.168) d = as.data.frame(lapply(d, rep, 2)) d = d[with(d, order(schoolgend, sex)),] d$y = d$y + rep(c(-.001, .001), times=4) d$schoolgend = relevel(d$schoolgend, ref="mixed"); d aggregate(y~sex+schoolgend, d, mean) # sex schoolgend y # 1 boys mixed -0.189 # 2 girls mixed -0.021 # 3 boys boy-only -0.009 # 4 girls girl-only 0.154 model.matrix(lm(y~sex+schoolgend, d)) # this is the design matrix # (Intercept) sexgirls schoolgendboy-only schoolgendgirl-only # 1 1 0 1 0 # 5 1 0 1 0 # 2 1 1 0 1 # 6 1 1 0 1 # 3 1 0 0 0 # 7 1 0 0 0 # 4 1 1 0 0 # 8 1 1 0 0 m = lm(y~sex+schoolgend, d) t(t(coef(m))) # (Intercept) -0.189 # sexgirls 0.168 # schoolgendboy-only 0.180 # schoolgendgirl-only 0.175 Looking at the design matrix, it's easy to see that schoolgendgirls-only marks off the difference between girls in mixed schools and girls in girls-only schools. You can also see this by looking at the complete regression equation. \begin{align} \hat{y} &= -0.189 + 0.168 x{\rm(sex=girls)} + 0.180 x{\rm(sg=boyonly)} + 0.175x{\rm (sg=girlonly)} \\ \hat{y} &= -0.189 + 0.168 \cdot 1 + 0.180 \cdot 0 + 0.175 \cdot 1 \\ \hat{y} &= -0.189 + 0.168 + 0.175 \end{align} Update: The main question appears to be whether the interpretation below is correct. I have learned to interpret any main effect coef for a categorical predictor by thinking of that coef. as something that can differ from its reference category to affect "y" holding any other categorical predictor in the model at its reference category This is not quite correct, although it is a common (and intuitive) way to explain it (and which I have used myself). The truth is that is the difference with its reference level holding all other variables constant. The other variables can be held constant at their means / reference levels, or at any other value. It may help to read my answer here: What does "all else equal" mean in multiple regression?
Interpretation of regression coefficients with multiple categorical predictors
It's the difference between the (predicted) mean of girls in girls-only schools and the (predicted) mean of girls in mixed schools. You can see this by looking at the design matrix or solving for a p
Interpretation of regression coefficients with multiple categorical predictors It's the difference between the (predicted) mean of girls in girls-only schools and the (predicted) mean of girls in mixed schools. You can see this by looking at the design matrix or solving for a predicted value using the fitted regression equation. Let's make some simple data and work through this. d = expand.grid(sex=c("boys","girls"), schoolgend=c("boy-only", "girl-only", "mixed")) d = d[-c(2,3),] d$y = c(-0.189+0.180, -0.189+0.168+0.175, -0.189, -0.189+0.168) d = as.data.frame(lapply(d, rep, 2)) d = d[with(d, order(schoolgend, sex)),] d$y = d$y + rep(c(-.001, .001), times=4) d$schoolgend = relevel(d$schoolgend, ref="mixed"); d aggregate(y~sex+schoolgend, d, mean) # sex schoolgend y # 1 boys mixed -0.189 # 2 girls mixed -0.021 # 3 boys boy-only -0.009 # 4 girls girl-only 0.154 model.matrix(lm(y~sex+schoolgend, d)) # this is the design matrix # (Intercept) sexgirls schoolgendboy-only schoolgendgirl-only # 1 1 0 1 0 # 5 1 0 1 0 # 2 1 1 0 1 # 6 1 1 0 1 # 3 1 0 0 0 # 7 1 0 0 0 # 4 1 1 0 0 # 8 1 1 0 0 m = lm(y~sex+schoolgend, d) t(t(coef(m))) # (Intercept) -0.189 # sexgirls 0.168 # schoolgendboy-only 0.180 # schoolgendgirl-only 0.175 Looking at the design matrix, it's easy to see that schoolgendgirls-only marks off the difference between girls in mixed schools and girls in girls-only schools. You can also see this by looking at the complete regression equation. \begin{align} \hat{y} &= -0.189 + 0.168 x{\rm(sex=girls)} + 0.180 x{\rm(sg=boyonly)} + 0.175x{\rm (sg=girlonly)} \\ \hat{y} &= -0.189 + 0.168 \cdot 1 + 0.180 \cdot 0 + 0.175 \cdot 1 \\ \hat{y} &= -0.189 + 0.168 + 0.175 \end{align} Update: The main question appears to be whether the interpretation below is correct. I have learned to interpret any main effect coef for a categorical predictor by thinking of that coef. as something that can differ from its reference category to affect "y" holding any other categorical predictor in the model at its reference category This is not quite correct, although it is a common (and intuitive) way to explain it (and which I have used myself). The truth is that is the difference with its reference level holding all other variables constant. The other variables can be held constant at their means / reference levels, or at any other value. It may help to read my answer here: What does "all else equal" mean in multiple regression?
Interpretation of regression coefficients with multiple categorical predictors It's the difference between the (predicted) mean of girls in girls-only schools and the (predicted) mean of girls in mixed schools. You can see this by looking at the design matrix or solving for a p
41,365
Interpretation of regression coefficients with multiple categorical predictors
The answers so far address interpretations that implicitly ignore the multilevel nature of the model. They are all correct though, that you don't have interactions, so the interpretations hinge on the tricky issue of boys-only or girls-only schools not having the other sex. The R code is helpful but let's put this in terms of the coefficients and see where we're at: normexam ~ 1 + standlrt + schgend + sex + (standlrt | school) Level 1 (student): $$exam_{ij} = \beta_{0j} + \beta_{1j}standlrt_{ij} + \beta_{2j}sex_{ij} + r_{ij}$$ Level 2 (school): $$\beta_{0j} = \gamma_{00} + \gamma_{01}schgendboys_{j} + \gamma_{02}schgendgirls_{j} + u_{0j}$$ $$\beta_{1j} = \gamma_{10} + u_{1j}$$ $$\beta_{2j} = \gamma_{20}$$ Combined: $$exam_{ij} = \gamma_{00} + \gamma_{01}schgendboys_{j} + \gamma_{02}schgendgirls{j} + \gamma_{10}standlrt{ij} + \gamma_{20}sex_{ij} + u_{0j} + u_{1j}standlrt_{ij} + r_{ij}$$ Let's hold sex constant at male. In this model (with dummy coding), $\gamma_{00}$ (the intercept) is the grand mean exam score in mixed schools. $\gamma_{01}$ is the difference in school average between mixed and boys-only, $\gamma_{02}$, difference in school average between mixed and girls only, $\gamma_{10}$ is the pooled estimate (average) standlrt slope across all schools, $\gamma_{20}$ is the overall difference between male and female students (non-random). It's easier to think about it in the following way: within each school we're supposedly estimating the standlrt slopes controlling for the sex of the student, and then between schools, we're examining the effect of school type (mixed, boys-only, girls-only) on the school's average exam scores, while controlling for the level-1 variables within a school. Within the single sex schools, obviously the effect of sex cannot be estimated, but we still get a coefficient $\gamma_{20}$ because we're actually estimating it using the entire sample, and not letting it vary across schools. This works because in arriving at MLM estimates, the individual school regressions are actually not performed. Instead, estimates of variance components (the r's and the u's) enable the fitting of the combined model. One can then obtain the school-level intercepts and slopes (you should try that to see if some are NA's). Hope this helps!
Interpretation of regression coefficients with multiple categorical predictors
The answers so far address interpretations that implicitly ignore the multilevel nature of the model. They are all correct though, that you don't have interactions, so the interpretations hinge on the
Interpretation of regression coefficients with multiple categorical predictors The answers so far address interpretations that implicitly ignore the multilevel nature of the model. They are all correct though, that you don't have interactions, so the interpretations hinge on the tricky issue of boys-only or girls-only schools not having the other sex. The R code is helpful but let's put this in terms of the coefficients and see where we're at: normexam ~ 1 + standlrt + schgend + sex + (standlrt | school) Level 1 (student): $$exam_{ij} = \beta_{0j} + \beta_{1j}standlrt_{ij} + \beta_{2j}sex_{ij} + r_{ij}$$ Level 2 (school): $$\beta_{0j} = \gamma_{00} + \gamma_{01}schgendboys_{j} + \gamma_{02}schgendgirls_{j} + u_{0j}$$ $$\beta_{1j} = \gamma_{10} + u_{1j}$$ $$\beta_{2j} = \gamma_{20}$$ Combined: $$exam_{ij} = \gamma_{00} + \gamma_{01}schgendboys_{j} + \gamma_{02}schgendgirls{j} + \gamma_{10}standlrt{ij} + \gamma_{20}sex_{ij} + u_{0j} + u_{1j}standlrt_{ij} + r_{ij}$$ Let's hold sex constant at male. In this model (with dummy coding), $\gamma_{00}$ (the intercept) is the grand mean exam score in mixed schools. $\gamma_{01}$ is the difference in school average between mixed and boys-only, $\gamma_{02}$, difference in school average between mixed and girls only, $\gamma_{10}$ is the pooled estimate (average) standlrt slope across all schools, $\gamma_{20}$ is the overall difference between male and female students (non-random). It's easier to think about it in the following way: within each school we're supposedly estimating the standlrt slopes controlling for the sex of the student, and then between schools, we're examining the effect of school type (mixed, boys-only, girls-only) on the school's average exam scores, while controlling for the level-1 variables within a school. Within the single sex schools, obviously the effect of sex cannot be estimated, but we still get a coefficient $\gamma_{20}$ because we're actually estimating it using the entire sample, and not letting it vary across schools. This works because in arriving at MLM estimates, the individual school regressions are actually not performed. Instead, estimates of variance components (the r's and the u's) enable the fitting of the combined model. One can then obtain the school-level intercepts and slopes (you should try that to see if some are NA's). Hope this helps!
Interpretation of regression coefficients with multiple categorical predictors The answers so far address interpretations that implicitly ignore the multilevel nature of the model. They are all correct though, that you don't have interactions, so the interpretations hinge on the
41,366
causal graph - counting the number of backdoor paths in a DAG
For Example 1, you are correct. $A\leftarrow Z\to W\to M\to Y$ is a valid backdoor path with no colliders in it (which would stop the backdoor path from being a problem). In Example 2, you are incorrect. The definition of a backdoor path implies that the first arrow has to go into $G$ (in this case), or it's not a backdoor path. Only $G\leftarrow E\leftarrow D\to A\to B$ satisfies that criterion.
causal graph - counting the number of backdoor paths in a DAG
For Example 1, you are correct. $A\leftarrow Z\to W\to M\to Y$ is a valid backdoor path with no colliders in it (which would stop the backdoor path from being a problem). In Example 2, you are incorre
causal graph - counting the number of backdoor paths in a DAG For Example 1, you are correct. $A\leftarrow Z\to W\to M\to Y$ is a valid backdoor path with no colliders in it (which would stop the backdoor path from being a problem). In Example 2, you are incorrect. The definition of a backdoor path implies that the first arrow has to go into $G$ (in this case), or it's not a backdoor path. Only $G\leftarrow E\leftarrow D\to A\to B$ satisfies that criterion.
causal graph - counting the number of backdoor paths in a DAG For Example 1, you are correct. $A\leftarrow Z\to W\to M\to Y$ is a valid backdoor path with no colliders in it (which would stop the backdoor path from being a problem). In Example 2, you are incorre
41,367
Understanding the pdf of a truncated normal distribution
Perhaps a more general notation will uncover the basic concepts and help you answer your question. There's little more to the following analysis than using mathematical notation carefully. Because that makes it abstract, I rephrase the key results in English: look for the quoted passages. When there are $m$ random variables $X=(X_1, \ldots, X_m)$ they have a distribution. This distribution gives the chance that $X$ lies in any Borel measurable set $\mathcal{R},$ written $$F_X(\mathcal{R}) = \Pr(X\in\mathcal{R}).$$ The distribution is (absolutely) continuous when there is a density function $f_X$ defined on all of $\mathbb{R}^m$ whose integral gives the probability. That is, for all $\mathcal R,$ $$\Pr(X\in\mathcal{R}) = F_X(\mathcal{R})= \iint_\mathcal{R} f_X(x)\mathrm{d}x = \iint_{\mathbb{R}^m} \mathcal{I}_{\mathcal{R}}(x)f_X(x)\,\mathrm{d}x.\tag{*}$$ The latter expression involves the indicator function $\mathcal{I}_{\mathcal{R}}$ (which by definition takes the value $1$ at all points in $\mathbb{R}$ and otherwise is zero). It enables us to express the integral over any region in terms of an integral over the entire space $\mathbb{R}^m.$ Suppose $\mathcal{E} \subset \mathbb{R}^m$ is a measurable set. Then the truncation of $F_X$ to $\mathcal{E}$ is a distribution function that arises when we "throw out all outcomes where $X$ is not in $\mathcal{E}.$" It is obtained in the simplest possible manner: just "limit the probability to the part of $\mathcal{R}$ lying in $\mathcal{E}:$" $$F_X^{\mathcal{E}}(\mathcal{R})\, \propto\, F_X(\mathcal{E}\cap\mathcal{R}).$$ The implicit multiple $\lambda$ in this proportion has to be such to make the total probability $1,$ leading to the equation $$1 =F^{\mathcal{E}}_X(\mathbb{R}^m) = \lambda F_X(\mathcal{E}\cap\mathbb{R}^m)= \lambda F_X(\mathcal{E})$$ yielding a unique (and obvious) value for $\lambda$ which we may plug into the foregoing to yield $$F^{\mathcal{E}}_X(\mathcal{R}) = \frac{F_X(\mathcal{E}\cap\mathcal{R})}{F_X(\mathcal{E})}.$$ This reads as "the chance $X$ is in the part of $\mathcal{R}$ lying in $\mathcal{E}$ relative to the chance $X$ is in $\mathcal{E}.$" When $F_X$ is absolutely continuous the identity $\mathcal{I}_{\mathcal{E}\cap\mathcal{R}} = \mathcal{I}_{\mathcal{E}}\,\mathcal{I}_{\mathcal{R}}$ (a consequence of the arithmetic facts $1\times1=1$ and $1\times 0 = 0\times 0 = 0$) produces $$F^{\mathcal{E}}_X(\mathcal{R})\, \propto\, \iint_{\mathcal{E} \cap \mathcal{R}} f_X(x)\,\mathrm{d}x = \iint_{\mathbb{R}^m} \mathcal{I}_{\mathcal{E}}(x)\mathcal{I}_{\mathcal{R}}(x)f_X(x)\,\mathrm{d}x = \iint_{\mathcal{R}} \mathcal{I}_{\mathcal{E}}(x)f_X(x)\,\mathrm{d}x$$ and therefore $$F^{\mathcal{E}}_X(\mathcal{R}) = \frac{\iint_{\mathcal{R}} \mathcal{I}_{\mathcal{E}}(x)f_X(x)\,\mathrm{d}x}{\iint_{\mathcal{E}} f_X(x)\,\mathrm{d}x} = \iint_{\mathcal{R}}\frac{ \mathcal{I}_{\mathcal{E}}(x)f_X(x)}{\iint_{\mathcal{E}} f_X(x)\,\mathrm{d}x}\,\mathrm{d}x = \iint f_X^{\mathcal{E}}(x)\,\mathrm{d}x.$$ This exhibits the density of the truncated variable as $$f_X^{\mathcal{E}}(x) = \frac{ \mathcal{I}_{\mathcal{E}}(x)f_X(x)}{\iint_{\mathcal{E}} f_X(x)\,\mathrm{d}x}.$$ It is "the density $f_X,$ zeroed beyond $\mathcal{E},$ as renormalized to integrate to unity." Here is an application. Let $m=2$ and suppose $\mathcal{E}$ is the region defined by $$\mathcal{E} = \{(x_1,x_2)\mid a_1\le x_1\le b_1,\, a_2 \le x_2 \le 2x_1\}.$$ It is either empty, a point, a triangle, or (generically) a trapezoid. Applying the preceding analysis shows that for any density $f_{X_1,X_2},$ the truncated density is given by Fubini's Theorem as $$\begin{aligned} f_{X_1,X_2}^\mathcal{E}(x_1,x_2) &= \frac{ \mathcal{I}_{\mathcal{E}}(x)f_X(x)}{\iint_{\mathcal{E}} f_X(x)\,\mathrm{d}x} \\ &= \frac{ \mathcal{I}_{\mathcal{E}}(x_1,x_2) f_{X_1,X_2}(x_1,x_2)}{\int_{a_1}^{b_1}\int_{a_2}^{2x_1} f_{X_1,X_2}(x_1,x_2)\,\mathrm{d}x_2\mathrm{d}x_1} \\ &= \frac{ f_{X_1,X_2}(x_1,x_2)}{\int_{a_1}^{b_1}\int_{a_2}^{2x_1} f_{X_1,X_2}(x_1,x_2)\,\mathrm{d}x_2\mathrm{d}x_1} \end{aligned}$$ for $(x_1,x_2)\in\mathcal{E}$ (and zero otherwise). When you use the binormal density for $f_X$ you have the answer to the question.
Understanding the pdf of a truncated normal distribution
Perhaps a more general notation will uncover the basic concepts and help you answer your question. There's little more to the following analysis than using mathematical notation carefully. Because t
Understanding the pdf of a truncated normal distribution Perhaps a more general notation will uncover the basic concepts and help you answer your question. There's little more to the following analysis than using mathematical notation carefully. Because that makes it abstract, I rephrase the key results in English: look for the quoted passages. When there are $m$ random variables $X=(X_1, \ldots, X_m)$ they have a distribution. This distribution gives the chance that $X$ lies in any Borel measurable set $\mathcal{R},$ written $$F_X(\mathcal{R}) = \Pr(X\in\mathcal{R}).$$ The distribution is (absolutely) continuous when there is a density function $f_X$ defined on all of $\mathbb{R}^m$ whose integral gives the probability. That is, for all $\mathcal R,$ $$\Pr(X\in\mathcal{R}) = F_X(\mathcal{R})= \iint_\mathcal{R} f_X(x)\mathrm{d}x = \iint_{\mathbb{R}^m} \mathcal{I}_{\mathcal{R}}(x)f_X(x)\,\mathrm{d}x.\tag{*}$$ The latter expression involves the indicator function $\mathcal{I}_{\mathcal{R}}$ (which by definition takes the value $1$ at all points in $\mathbb{R}$ and otherwise is zero). It enables us to express the integral over any region in terms of an integral over the entire space $\mathbb{R}^m.$ Suppose $\mathcal{E} \subset \mathbb{R}^m$ is a measurable set. Then the truncation of $F_X$ to $\mathcal{E}$ is a distribution function that arises when we "throw out all outcomes where $X$ is not in $\mathcal{E}.$" It is obtained in the simplest possible manner: just "limit the probability to the part of $\mathcal{R}$ lying in $\mathcal{E}:$" $$F_X^{\mathcal{E}}(\mathcal{R})\, \propto\, F_X(\mathcal{E}\cap\mathcal{R}).$$ The implicit multiple $\lambda$ in this proportion has to be such to make the total probability $1,$ leading to the equation $$1 =F^{\mathcal{E}}_X(\mathbb{R}^m) = \lambda F_X(\mathcal{E}\cap\mathbb{R}^m)= \lambda F_X(\mathcal{E})$$ yielding a unique (and obvious) value for $\lambda$ which we may plug into the foregoing to yield $$F^{\mathcal{E}}_X(\mathcal{R}) = \frac{F_X(\mathcal{E}\cap\mathcal{R})}{F_X(\mathcal{E})}.$$ This reads as "the chance $X$ is in the part of $\mathcal{R}$ lying in $\mathcal{E}$ relative to the chance $X$ is in $\mathcal{E}.$" When $F_X$ is absolutely continuous the identity $\mathcal{I}_{\mathcal{E}\cap\mathcal{R}} = \mathcal{I}_{\mathcal{E}}\,\mathcal{I}_{\mathcal{R}}$ (a consequence of the arithmetic facts $1\times1=1$ and $1\times 0 = 0\times 0 = 0$) produces $$F^{\mathcal{E}}_X(\mathcal{R})\, \propto\, \iint_{\mathcal{E} \cap \mathcal{R}} f_X(x)\,\mathrm{d}x = \iint_{\mathbb{R}^m} \mathcal{I}_{\mathcal{E}}(x)\mathcal{I}_{\mathcal{R}}(x)f_X(x)\,\mathrm{d}x = \iint_{\mathcal{R}} \mathcal{I}_{\mathcal{E}}(x)f_X(x)\,\mathrm{d}x$$ and therefore $$F^{\mathcal{E}}_X(\mathcal{R}) = \frac{\iint_{\mathcal{R}} \mathcal{I}_{\mathcal{E}}(x)f_X(x)\,\mathrm{d}x}{\iint_{\mathcal{E}} f_X(x)\,\mathrm{d}x} = \iint_{\mathcal{R}}\frac{ \mathcal{I}_{\mathcal{E}}(x)f_X(x)}{\iint_{\mathcal{E}} f_X(x)\,\mathrm{d}x}\,\mathrm{d}x = \iint f_X^{\mathcal{E}}(x)\,\mathrm{d}x.$$ This exhibits the density of the truncated variable as $$f_X^{\mathcal{E}}(x) = \frac{ \mathcal{I}_{\mathcal{E}}(x)f_X(x)}{\iint_{\mathcal{E}} f_X(x)\,\mathrm{d}x}.$$ It is "the density $f_X,$ zeroed beyond $\mathcal{E},$ as renormalized to integrate to unity." Here is an application. Let $m=2$ and suppose $\mathcal{E}$ is the region defined by $$\mathcal{E} = \{(x_1,x_2)\mid a_1\le x_1\le b_1,\, a_2 \le x_2 \le 2x_1\}.$$ It is either empty, a point, a triangle, or (generically) a trapezoid. Applying the preceding analysis shows that for any density $f_{X_1,X_2},$ the truncated density is given by Fubini's Theorem as $$\begin{aligned} f_{X_1,X_2}^\mathcal{E}(x_1,x_2) &= \frac{ \mathcal{I}_{\mathcal{E}}(x)f_X(x)}{\iint_{\mathcal{E}} f_X(x)\,\mathrm{d}x} \\ &= \frac{ \mathcal{I}_{\mathcal{E}}(x_1,x_2) f_{X_1,X_2}(x_1,x_2)}{\int_{a_1}^{b_1}\int_{a_2}^{2x_1} f_{X_1,X_2}(x_1,x_2)\,\mathrm{d}x_2\mathrm{d}x_1} \\ &= \frac{ f_{X_1,X_2}(x_1,x_2)}{\int_{a_1}^{b_1}\int_{a_2}^{2x_1} f_{X_1,X_2}(x_1,x_2)\,\mathrm{d}x_2\mathrm{d}x_1} \end{aligned}$$ for $(x_1,x_2)\in\mathcal{E}$ (and zero otherwise). When you use the binormal density for $f_X$ you have the answer to the question.
Understanding the pdf of a truncated normal distribution Perhaps a more general notation will uncover the basic concepts and help you answer your question. There's little more to the following analysis than using mathematical notation carefully. Because t
41,368
Distribution of $\frac{X}{X+Y}$ if $X,Y$ are independent Beta random variables
This situation is described by T. Pham-Gia in 'Distributions of the ratios of independent beta variables and applications' in Communications in Statistics - Theory and Methods Volume 29, 2000 - Issue 12 https://doi.org/10.1080/03610920008832632 For the variable $T = \frac{X_1}{X_1+X_2}$ you get $$f(t) = \begin{cases} t^{\alpha_1-1}(1-t)^{\alpha_1+1}\cdot B(\alpha_1+\alpha_2,\beta_2)\cdot {_2F_1}(\alpha_1+\alpha_2,1-\beta_1;\alpha_1+\alpha_2+\beta_2;\frac{t}{1-t})/A & \text{for $0 \leq t < 1/2$} \\ t^{-(\alpha_2+1)}(1-t)^{\alpha_2-1}\cdot B(\alpha_1+\alpha_2,\beta_1)\cdot {_2F_1}(\alpha_1+\alpha_2,1-\beta_2;\alpha_1+\alpha_2+\beta_1;\frac{1-t}{t})/A & \text{for $1/2 \leq t \leq 1$ } \end{cases}$$ with $A = B(\alpha_1,\beta_1)\cdot B(\alpha_2,\beta_2)$ and ${_2F_1}$ a hypergeometric function.
Distribution of $\frac{X}{X+Y}$ if $X,Y$ are independent Beta random variables
This situation is described by T. Pham-Gia in 'Distributions of the ratios of independent beta variables and applications' in Communications in Statistics - Theory and Methods Volume 29, 2000 - Issue
Distribution of $\frac{X}{X+Y}$ if $X,Y$ are independent Beta random variables This situation is described by T. Pham-Gia in 'Distributions of the ratios of independent beta variables and applications' in Communications in Statistics - Theory and Methods Volume 29, 2000 - Issue 12 https://doi.org/10.1080/03610920008832632 For the variable $T = \frac{X_1}{X_1+X_2}$ you get $$f(t) = \begin{cases} t^{\alpha_1-1}(1-t)^{\alpha_1+1}\cdot B(\alpha_1+\alpha_2,\beta_2)\cdot {_2F_1}(\alpha_1+\alpha_2,1-\beta_1;\alpha_1+\alpha_2+\beta_2;\frac{t}{1-t})/A & \text{for $0 \leq t < 1/2$} \\ t^{-(\alpha_2+1)}(1-t)^{\alpha_2-1}\cdot B(\alpha_1+\alpha_2,\beta_1)\cdot {_2F_1}(\alpha_1+\alpha_2,1-\beta_2;\alpha_1+\alpha_2+\beta_1;\frac{1-t}{t})/A & \text{for $1/2 \leq t \leq 1$ } \end{cases}$$ with $A = B(\alpha_1,\beta_1)\cdot B(\alpha_2,\beta_2)$ and ${_2F_1}$ a hypergeometric function.
Distribution of $\frac{X}{X+Y}$ if $X,Y$ are independent Beta random variables This situation is described by T. Pham-Gia in 'Distributions of the ratios of independent beta variables and applications' in Communications in Statistics - Theory and Methods Volume 29, 2000 - Issue
41,369
Subgroups in meta-analysis
For simplicity let us assume there are two groups although the issues are the same for multiple groups. The choices are (a) to run an analysis on each group separately (b) to run an analysis on the whole data-set with a two-level factor as a moderator. The advantage of option (b) is that you have more data and hence your estimate of $\tau^2$ will be more precise. With 20 studies it was probably not very precise anyway (suggest they give confidence intervals for $\tau^2$ or $I^2$). A slight disadvantage of (b) is that it assumes that $\tau^2$ has the same value in each group but there are options in software to relax that assumption. There is detail on how to do this in R using the metafor package here. If the split was based on theory then there is no real multiplicity issue here but if it is data-driven then caution is obviously needed.
Subgroups in meta-analysis
For simplicity let us assume there are two groups although the issues are the same for multiple groups. The choices are (a) to run an analysis on each group separately (b) to run an analysis on the wh
Subgroups in meta-analysis For simplicity let us assume there are two groups although the issues are the same for multiple groups. The choices are (a) to run an analysis on each group separately (b) to run an analysis on the whole data-set with a two-level factor as a moderator. The advantage of option (b) is that you have more data and hence your estimate of $\tau^2$ will be more precise. With 20 studies it was probably not very precise anyway (suggest they give confidence intervals for $\tau^2$ or $I^2$). A slight disadvantage of (b) is that it assumes that $\tau^2$ has the same value in each group but there are options in software to relax that assumption. There is detail on how to do this in R using the metafor package here. If the split was based on theory then there is no real multiplicity issue here but if it is data-driven then caution is obviously needed.
Subgroups in meta-analysis For simplicity let us assume there are two groups although the issues are the same for multiple groups. The choices are (a) to run an analysis on each group separately (b) to run an analysis on the wh
41,370
Subgroups in meta-analysis
There definitely should be a multiple comparison correction. Meta-analyses are...generally not of the highest quality, with regards to statistical soundness.
Subgroups in meta-analysis
There definitely should be a multiple comparison correction. Meta-analyses are...generally not of the highest quality, with regards to statistical soundness.
Subgroups in meta-analysis There definitely should be a multiple comparison correction. Meta-analyses are...generally not of the highest quality, with regards to statistical soundness.
Subgroups in meta-analysis There definitely should be a multiple comparison correction. Meta-analyses are...generally not of the highest quality, with regards to statistical soundness.
41,371
Subgroups in meta-analysis
It depends whether the data obtained using different methodologies can be statistically compared. Normally in a MA you first show the results overall and then you run a sensitivity analysis e.g. stratified analysis.
Subgroups in meta-analysis
It depends whether the data obtained using different methodologies can be statistically compared. Normally in a MA you first show the results overall and then you run a sensitivity analysis e.g. strat
Subgroups in meta-analysis It depends whether the data obtained using different methodologies can be statistically compared. Normally in a MA you first show the results overall and then you run a sensitivity analysis e.g. stratified analysis.
Subgroups in meta-analysis It depends whether the data obtained using different methodologies can be statistically compared. Normally in a MA you first show the results overall and then you run a sensitivity analysis e.g. strat
41,372
Why are Transformers "suboptimal" for language modeling but not for translation?
I think I acquired some insights into this question after posting it 1.5 months ago, and since there are no other answers, I'll share them: Plain RNNs are, in practice, incapable of learning long-term dependencies, and while LSTMs can do it, they are still focused on recent inputs. This suits LMs just fine, because LMs are evaluated via PPL and similar scores, under which the recent past is extremely informative. Why are some people using Transformers for LMs then, despite this? Two reasons: Memory consumption and efficiency (Transformers are still efficient with small batch sizes, while large batch sizes use a lot of memory in both LSTMs and Transformers) Human perception of the quality of generated text is different from PPL. Researchers are actually trying to get their models to pay more attention to the less recent past, which is where Transformers are better. So why did Transformers beat LSTMs on the translation tasks then? Two more reasons: The BLEU score, used to evaluate translations, is different from PPL Translation needs non-local attention more than plain LMs do (Texts get re-ordered significantly, when translated)
Why are Transformers "suboptimal" for language modeling but not for translation?
I think I acquired some insights into this question after posting it 1.5 months ago, and since there are no other answers, I'll share them: Plain RNNs are, in practice, incapable of learning long-term
Why are Transformers "suboptimal" for language modeling but not for translation? I think I acquired some insights into this question after posting it 1.5 months ago, and since there are no other answers, I'll share them: Plain RNNs are, in practice, incapable of learning long-term dependencies, and while LSTMs can do it, they are still focused on recent inputs. This suits LMs just fine, because LMs are evaluated via PPL and similar scores, under which the recent past is extremely informative. Why are some people using Transformers for LMs then, despite this? Two reasons: Memory consumption and efficiency (Transformers are still efficient with small batch sizes, while large batch sizes use a lot of memory in both LSTMs and Transformers) Human perception of the quality of generated text is different from PPL. Researchers are actually trying to get their models to pay more attention to the less recent past, which is where Transformers are better. So why did Transformers beat LSTMs on the translation tasks then? Two more reasons: The BLEU score, used to evaluate translations, is different from PPL Translation needs non-local attention more than plain LMs do (Texts get re-ordered significantly, when translated)
Why are Transformers "suboptimal" for language modeling but not for translation? I think I acquired some insights into this question after posting it 1.5 months ago, and since there are no other answers, I'll share them: Plain RNNs are, in practice, incapable of learning long-term
41,373
Estimate Ratio of Normalizing Constants from two datasets
[Warning: the following proposals, except one, assume $f$ can be evaluated at arbitrary values. If the only inputs are the sets $A$ and $B$, and the samples $\mathbf x$ and $\mathbf y$, the problem has no solution since any combination $\alpha f_A(x)+(1-\alpha) f_B(x)$ could produce exactly the same samples $\mathbf x$ and $\mathbf y$.] If an expectation under $f$ [assumed to be a density, i.e. normalised] is known, as in control variate settings, $$\int h(x) f(x)\,\text dx=\mathfrak h>0$$ solving$$\alpha\int_A h(x) \frac{\tilde p(x)}{Z_p} \,\text dx+(1-\alpha) \int_B h(x) \frac{\tilde q(x)}{Z_q} \,\text dx=\mathfrak h\tag{1}$$returns $$\alpha=Z_p$$unless both integrals are identical. Replacing (1) with its Monte Carlo version $$\sum_{i=1}^N\{\hat\alpha h(x_i)+(1-\hat\alpha)h(y_i)\}=n\mathfrak h$$ returns an estimator of $Z_p$. In the case $f$ is not normalised, two such functions $h$ would be required. An illustration in the Normal $\mathcal N(0,1)$ case when $A=(-\infty,1)$, $p_A=0.841$, $h(x)=x$, and $\mathfrak h=0$: for(t in al<-1:1e2){ x=(x<-rnorm(4e5/p))[x<1][1:1e5] y=(y<-rnorm(4e5/(1-p)))[y>1][1:1e5] al[t]=1/(1-mean(x)/mean(y))} resulting in a concentrated approximation of $p_A$: Another (crude) approach would be to estimate (by a kernel density estimator) the densities on both samples and, assuming continuity of the density $f$ at the boundary, make them meet at this boundary (between $A$ and $B$). As in this example p=pnorm(1) #A is (-oo,1) and B (1,+oo) and f is dnorm wh=N<-1:1e5 x=(x<-rnorm(4*N/p))[x<1][1:N] #sample from p over A y=(y<-rnorm(4*N/(1-p)))[y>1][1:N] #sample from q over B a=density(x,ker="gaussian",to=1) #KDE of p hatfa=approxfun(a$x,a$y) b=density(y,ker="gaussian",from=1) #KDE of q hatfa=approxfun(a$x,a$y) leading to > hatfb(1)/hatfa(1) [1] 4.917869 as the estimate of $p_A/p_B$. Repeated simulations show however that the estimator is biased downwards. As an alternative, once one is using a kernel approximation, one can implement a full (reversible jump) MCMC version for simulating moves between $A$ and $B$, based on the non-parametric density estimator as a proposal: mm=wh=1:N;wh[1]=x[1] #mm model indicator, 1 stands for A for (t in 2:N){#Metropolis-Hastings steps mm[t]=mm[t-1];wh[t]=wh[t-1] if(mm[t]){#propose to move to B prop=rnorm(1,sample(y,1),b$bw) while(prop<1)prop=rnorm(1,sample(y,1),b$bw)#constrained to B if(dnorm(wh[t])*hatfb(prop)*runif(1)<dnorm(prop)*hatfa(wh[t])){ wh[t]=prop;mm[t]=0} }else{#propose to move to A prop=rnorm(1,sample(x,1),a$bw) while(prop>1)prop=rnorm(1,sample(x,1),a$bw)#constrained to A if(dnorm(wh[t])*hatfa(prop)*runif(1)<dnorm(prop)*hatfb(wh[t])){ wh[t]=prop;mm[t]=1}} } resulting in an estimate of the ratio > mean(mm)/mean(!mm) [1] 5.127451
Estimate Ratio of Normalizing Constants from two datasets
[Warning: the following proposals, except one, assume $f$ can be evaluated at arbitrary values. If the only inputs are the sets $A$ and $B$, and the samples $\mathbf x$ and $\mathbf y$, the problem ha
Estimate Ratio of Normalizing Constants from two datasets [Warning: the following proposals, except one, assume $f$ can be evaluated at arbitrary values. If the only inputs are the sets $A$ and $B$, and the samples $\mathbf x$ and $\mathbf y$, the problem has no solution since any combination $\alpha f_A(x)+(1-\alpha) f_B(x)$ could produce exactly the same samples $\mathbf x$ and $\mathbf y$.] If an expectation under $f$ [assumed to be a density, i.e. normalised] is known, as in control variate settings, $$\int h(x) f(x)\,\text dx=\mathfrak h>0$$ solving$$\alpha\int_A h(x) \frac{\tilde p(x)}{Z_p} \,\text dx+(1-\alpha) \int_B h(x) \frac{\tilde q(x)}{Z_q} \,\text dx=\mathfrak h\tag{1}$$returns $$\alpha=Z_p$$unless both integrals are identical. Replacing (1) with its Monte Carlo version $$\sum_{i=1}^N\{\hat\alpha h(x_i)+(1-\hat\alpha)h(y_i)\}=n\mathfrak h$$ returns an estimator of $Z_p$. In the case $f$ is not normalised, two such functions $h$ would be required. An illustration in the Normal $\mathcal N(0,1)$ case when $A=(-\infty,1)$, $p_A=0.841$, $h(x)=x$, and $\mathfrak h=0$: for(t in al<-1:1e2){ x=(x<-rnorm(4e5/p))[x<1][1:1e5] y=(y<-rnorm(4e5/(1-p)))[y>1][1:1e5] al[t]=1/(1-mean(x)/mean(y))} resulting in a concentrated approximation of $p_A$: Another (crude) approach would be to estimate (by a kernel density estimator) the densities on both samples and, assuming continuity of the density $f$ at the boundary, make them meet at this boundary (between $A$ and $B$). As in this example p=pnorm(1) #A is (-oo,1) and B (1,+oo) and f is dnorm wh=N<-1:1e5 x=(x<-rnorm(4*N/p))[x<1][1:N] #sample from p over A y=(y<-rnorm(4*N/(1-p)))[y>1][1:N] #sample from q over B a=density(x,ker="gaussian",to=1) #KDE of p hatfa=approxfun(a$x,a$y) b=density(y,ker="gaussian",from=1) #KDE of q hatfa=approxfun(a$x,a$y) leading to > hatfb(1)/hatfa(1) [1] 4.917869 as the estimate of $p_A/p_B$. Repeated simulations show however that the estimator is biased downwards. As an alternative, once one is using a kernel approximation, one can implement a full (reversible jump) MCMC version for simulating moves between $A$ and $B$, based on the non-parametric density estimator as a proposal: mm=wh=1:N;wh[1]=x[1] #mm model indicator, 1 stands for A for (t in 2:N){#Metropolis-Hastings steps mm[t]=mm[t-1];wh[t]=wh[t-1] if(mm[t]){#propose to move to B prop=rnorm(1,sample(y,1),b$bw) while(prop<1)prop=rnorm(1,sample(y,1),b$bw)#constrained to B if(dnorm(wh[t])*hatfb(prop)*runif(1)<dnorm(prop)*hatfa(wh[t])){ wh[t]=prop;mm[t]=0} }else{#propose to move to A prop=rnorm(1,sample(x,1),a$bw) while(prop>1)prop=rnorm(1,sample(x,1),a$bw)#constrained to A if(dnorm(wh[t])*hatfa(prop)*runif(1)<dnorm(prop)*hatfb(wh[t])){ wh[t]=prop;mm[t]=1}} } resulting in an estimate of the ratio > mean(mm)/mean(!mm) [1] 5.127451
Estimate Ratio of Normalizing Constants from two datasets [Warning: the following proposals, except one, assume $f$ can be evaluated at arbitrary values. If the only inputs are the sets $A$ and $B$, and the samples $\mathbf x$ and $\mathbf y$, the problem ha
41,374
LightGBM model improvement when the focus is on probability prediction
Using the binary log-loss classification as an objective is a good move in this situation (and in most situations). We might want to point Optuna (or our general hyper-parameter search framework) to minimise the Brier score of the predictions if we care about how much the probabilities might be off; the AUC-ROC is a ranking score, it is better than F1-score for this task but not our best bet necessarily. Regarding the particular questions in the main post: Yes, but we can potentially do better (as discussed above). Using metrics based on discontinuous rules like Precision, Recall, F1, etc. can be misleading. This post on Is accuracy an improper scoring rule in a binary classification setting? focuses on Accuracy but the same applies for metrics like Precision, etc. Try different hyper-parameters as well as learners; LightGBM is awesome but not a panacea. Even simply trying XGBoost and Catboost might be enough to explore some obvious easy pickings. Regarding the sub-question in the comments: Using isotonic regression can be beneficial but it has to be setup carefully (hold-out sets, etc.). I do it irrespective of "resampling" if I have time but usually it give me little gains in terms of ROC-/PR-AUC. It might worth considering other calibration options too like Platt scaling and beta calibration; I have not found one to dominate over the others in my work though. Please see my answer in the CV.SE thread: Biased prediction (overestimation) for xgboost I think it is pertinent to your question. As mentioned there, (early) gradient boosting implementation are (were?) not very well calibrated. With larger datasets and more well-designed loss-functions this might have been ameliorated nowadays to some extent but I have not seen any recent papers.
LightGBM model improvement when the focus is on probability prediction
Using the binary log-loss classification as an objective is a good move in this situation (and in most situations). We might want to point Optuna (or our general hyper-parameter search framework) to m
LightGBM model improvement when the focus is on probability prediction Using the binary log-loss classification as an objective is a good move in this situation (and in most situations). We might want to point Optuna (or our general hyper-parameter search framework) to minimise the Brier score of the predictions if we care about how much the probabilities might be off; the AUC-ROC is a ranking score, it is better than F1-score for this task but not our best bet necessarily. Regarding the particular questions in the main post: Yes, but we can potentially do better (as discussed above). Using metrics based on discontinuous rules like Precision, Recall, F1, etc. can be misleading. This post on Is accuracy an improper scoring rule in a binary classification setting? focuses on Accuracy but the same applies for metrics like Precision, etc. Try different hyper-parameters as well as learners; LightGBM is awesome but not a panacea. Even simply trying XGBoost and Catboost might be enough to explore some obvious easy pickings. Regarding the sub-question in the comments: Using isotonic regression can be beneficial but it has to be setup carefully (hold-out sets, etc.). I do it irrespective of "resampling" if I have time but usually it give me little gains in terms of ROC-/PR-AUC. It might worth considering other calibration options too like Platt scaling and beta calibration; I have not found one to dominate over the others in my work though. Please see my answer in the CV.SE thread: Biased prediction (overestimation) for xgboost I think it is pertinent to your question. As mentioned there, (early) gradient boosting implementation are (were?) not very well calibrated. With larger datasets and more well-designed loss-functions this might have been ameliorated nowadays to some extent but I have not seen any recent papers.
LightGBM model improvement when the focus is on probability prediction Using the binary log-loss classification as an objective is a good move in this situation (and in most situations). We might want to point Optuna (or our general hyper-parameter search framework) to m
41,375
Best way to combine MCMC inference with multiple imputation? [duplicate]
One well-known approach is exactly what you describe (if I understood correctly): i.e. combine the inferences from the analyses of a large number of imputed datasets (each analyzed separately) by just using the equally weighted mixture distribution of the posterior distributions as the combined posterior distribution. In practice, this means that we just throw together all the (or a random subset) of the MCMC samples that we generated by analyzing each of the multiply imputed datasets on their own. We use this combined set of MCMC samples from all the models, as if they were a giant single set of MCMC samples. This is described in Bayesian Data Analysis (3rd edition by Gelman et al. 2014 on page 452). It's also investigated and reported to perform well with a sufficiently large number of imputations (e.g. 100) by Zhou and Reiter 2010 (Zhou, X. and Reiter, J.P. 2010. A note on Bayesian inference after multiple imputation. The American Statistician, 64(2), pp. 159-163.). Note: checks for non-convergence need to be done within each imputed datasets. E.g. if you treat chains from separate imputations as if they were separate chains run on the same datasets, checks like Rhat etc. will tell you that you have a problem, because - unsurprisingly - differently imputed datasets do result in (slightly) different posterior distributions. With that caveat, I've essentially treated them like separate chains (e.g. if I had 4 chains per imputation and 100 imputation, I thereafter proceeded as if I had 400 chains). There's alternatives to this. E.g. it is also clear that you could also run a single MCMC sampler across all imputations and at each MCMC iteration use the "mixture-likelihood" for all the imputations, but I'm not aware that any software does this easily (you can of course hand-code this in something like Stan). The alternative to have a single model that imputes and analyzes at the same time is of course also a serious option, but again harder to implement. Keeping imputation and analysis as separate steps also has advantages in terms of addressing different questions/estimands (e.g. jump-to-reference-group imputation becomes easier to implement).
Best way to combine MCMC inference with multiple imputation? [duplicate]
One well-known approach is exactly what you describe (if I understood correctly): i.e. combine the inferences from the analyses of a large number of imputed datasets (each analyzed separately) by just
Best way to combine MCMC inference with multiple imputation? [duplicate] One well-known approach is exactly what you describe (if I understood correctly): i.e. combine the inferences from the analyses of a large number of imputed datasets (each analyzed separately) by just using the equally weighted mixture distribution of the posterior distributions as the combined posterior distribution. In practice, this means that we just throw together all the (or a random subset) of the MCMC samples that we generated by analyzing each of the multiply imputed datasets on their own. We use this combined set of MCMC samples from all the models, as if they were a giant single set of MCMC samples. This is described in Bayesian Data Analysis (3rd edition by Gelman et al. 2014 on page 452). It's also investigated and reported to perform well with a sufficiently large number of imputations (e.g. 100) by Zhou and Reiter 2010 (Zhou, X. and Reiter, J.P. 2010. A note on Bayesian inference after multiple imputation. The American Statistician, 64(2), pp. 159-163.). Note: checks for non-convergence need to be done within each imputed datasets. E.g. if you treat chains from separate imputations as if they were separate chains run on the same datasets, checks like Rhat etc. will tell you that you have a problem, because - unsurprisingly - differently imputed datasets do result in (slightly) different posterior distributions. With that caveat, I've essentially treated them like separate chains (e.g. if I had 4 chains per imputation and 100 imputation, I thereafter proceeded as if I had 400 chains). There's alternatives to this. E.g. it is also clear that you could also run a single MCMC sampler across all imputations and at each MCMC iteration use the "mixture-likelihood" for all the imputations, but I'm not aware that any software does this easily (you can of course hand-code this in something like Stan). The alternative to have a single model that imputes and analyzes at the same time is of course also a serious option, but again harder to implement. Keeping imputation and analysis as separate steps also has advantages in terms of addressing different questions/estimands (e.g. jump-to-reference-group imputation becomes easier to implement).
Best way to combine MCMC inference with multiple imputation? [duplicate] One well-known approach is exactly what you describe (if I understood correctly): i.e. combine the inferences from the analyses of a large number of imputed datasets (each analyzed separately) by just
41,376
Best way to combine MCMC inference with multiple imputation? [duplicate]
(Thanks for the reminder! The answer has been revised to focus more on the originally posted question) I think the paper by Zhou, as recommended above by @BjΓΆrn, specifically discussed about Bayesian inference after multiple imputation. Recently, I am also applying Bayesian conditional logistic regression after multiple imputation (m = 100) in my PhD project. I mixed the MCMC draws from each imputed dataset, and used them to approximate posterior distribution and calculate point estimate and credible interval. I also combined the MCMC draws within each imputed dataset and plotted the posterior distribution across all the datasets in the same graph, as a way to present the variation in posterior approximation across imputed datasets. @BjΓΆrn suggested above that treating chains from imputed datasets as separate chains and combine them across datasets. It seems reasonable but also I am a bit unsure. I am wondering if there is any reference supporting this. With this in doubt, as for checking MCMC sampling quality, I checked only for the first imputed dataset (or you could check any other one or multiple datasets) – calculating Rhat and effective sample size, and plotting a trace plot (and there are many other useful metrics and plots). Sorry I am new to the forum so I couldn't reply directly above to @BjΓΆrn's response.
Best way to combine MCMC inference with multiple imputation? [duplicate]
(Thanks for the reminder! The answer has been revised to focus more on the originally posted question) I think the paper by Zhou, as recommended above by @BjΓΆrn, specifically discussed about Bayesian
Best way to combine MCMC inference with multiple imputation? [duplicate] (Thanks for the reminder! The answer has been revised to focus more on the originally posted question) I think the paper by Zhou, as recommended above by @BjΓΆrn, specifically discussed about Bayesian inference after multiple imputation. Recently, I am also applying Bayesian conditional logistic regression after multiple imputation (m = 100) in my PhD project. I mixed the MCMC draws from each imputed dataset, and used them to approximate posterior distribution and calculate point estimate and credible interval. I also combined the MCMC draws within each imputed dataset and plotted the posterior distribution across all the datasets in the same graph, as a way to present the variation in posterior approximation across imputed datasets. @BjΓΆrn suggested above that treating chains from imputed datasets as separate chains and combine them across datasets. It seems reasonable but also I am a bit unsure. I am wondering if there is any reference supporting this. With this in doubt, as for checking MCMC sampling quality, I checked only for the first imputed dataset (or you could check any other one or multiple datasets) – calculating Rhat and effective sample size, and plotting a trace plot (and there are many other useful metrics and plots). Sorry I am new to the forum so I couldn't reply directly above to @BjΓΆrn's response.
Best way to combine MCMC inference with multiple imputation? [duplicate] (Thanks for the reminder! The answer has been revised to focus more on the originally posted question) I think the paper by Zhou, as recommended above by @BjΓΆrn, specifically discussed about Bayesian
41,377
Best way to combine MCMC inference with multiple imputation? [duplicate]
Are you familiar with censorship in survival analysis modeling? Censorship means that a patient was removed from the study without explicitly dying (at least in the context of survival analysis.) There are appropriate architectures to handle censorship; however, it's more a question of model architecture than the underlying MCMC sampling algorithm. For exploration of survival analysis via PyMC3 (uses HMC), see here. In your write-up, it's not clear whether you have a survival analysis problem or something different. Nonetheless, I'd recommend approaching your problem from a model architecture perspective not an MCMC-variant-specific perspective. If you could provide some more details, we (the community) could provide some recommendations on how to handle observed and latent values (censoring.) You didn't explicitly say that you're approaching this from a Bayesian perspective, however, MCMC is very common in the Bayesian paradigm, so I'll assume you prefer to be as Bayesian as possible. With that said, imputing values is not very Bayesian at all, as you'd be adding biases to your dataset without properly defining them via prior distributions. Censorship is the way to go so you have a "fork" so to speak that distinguishes the observed from the latent, and this will be captured nicely by your posterior distribution.
Best way to combine MCMC inference with multiple imputation? [duplicate]
Are you familiar with censorship in survival analysis modeling? Censorship means that a patient was removed from the study without explicitly dying (at least in the context of survival analysis.) Ther
Best way to combine MCMC inference with multiple imputation? [duplicate] Are you familiar with censorship in survival analysis modeling? Censorship means that a patient was removed from the study without explicitly dying (at least in the context of survival analysis.) There are appropriate architectures to handle censorship; however, it's more a question of model architecture than the underlying MCMC sampling algorithm. For exploration of survival analysis via PyMC3 (uses HMC), see here. In your write-up, it's not clear whether you have a survival analysis problem or something different. Nonetheless, I'd recommend approaching your problem from a model architecture perspective not an MCMC-variant-specific perspective. If you could provide some more details, we (the community) could provide some recommendations on how to handle observed and latent values (censoring.) You didn't explicitly say that you're approaching this from a Bayesian perspective, however, MCMC is very common in the Bayesian paradigm, so I'll assume you prefer to be as Bayesian as possible. With that said, imputing values is not very Bayesian at all, as you'd be adding biases to your dataset without properly defining them via prior distributions. Censorship is the way to go so you have a "fork" so to speak that distinguishes the observed from the latent, and this will be captured nicely by your posterior distribution.
Best way to combine MCMC inference with multiple imputation? [duplicate] Are you familiar with censorship in survival analysis modeling? Censorship means that a patient was removed from the study without explicitly dying (at least in the context of survival analysis.) Ther
41,378
Best way to combine MCMC inference with multiple imputation? [duplicate]
I wrote a paper arxiv.org/abs/1907.09090 that describes how the pseudo-marginal approach can impute missing data. 400 covariates sounds tough, though, to be completely honest. Depends on what kind of distributions you want to put on the columns, the number of rows, how you program everything. Intractable in your case? Probably, yes. In section 3.3, we describe the approach (not ours) that sounds like what you want. Maybe some references in there will give you some formulas. Here’s a quote: Multiple Imputation (MI) generates multiple complete data sets by sampling several sets of plausible values for each missing data point by sampling from the posterior predictive distribution [19], [20], [7]. The same analysis is performed separately on each data set, and the results are then combined. For example, in the context of regression analysis, the model parameters derived from each imputed dataset [sic] are combined by a simple average. The parameter variances are calculated by averaging the individual variances from each imputation, and the formula includes an additional term to capture the between-imputation variance.
Best way to combine MCMC inference with multiple imputation? [duplicate]
I wrote a paper arxiv.org/abs/1907.09090 that describes how the pseudo-marginal approach can impute missing data. 400 covariates sounds tough, though, to be completely honest. Depends on what kind of
Best way to combine MCMC inference with multiple imputation? [duplicate] I wrote a paper arxiv.org/abs/1907.09090 that describes how the pseudo-marginal approach can impute missing data. 400 covariates sounds tough, though, to be completely honest. Depends on what kind of distributions you want to put on the columns, the number of rows, how you program everything. Intractable in your case? Probably, yes. In section 3.3, we describe the approach (not ours) that sounds like what you want. Maybe some references in there will give you some formulas. Here’s a quote: Multiple Imputation (MI) generates multiple complete data sets by sampling several sets of plausible values for each missing data point by sampling from the posterior predictive distribution [19], [20], [7]. The same analysis is performed separately on each data set, and the results are then combined. For example, in the context of regression analysis, the model parameters derived from each imputed dataset [sic] are combined by a simple average. The parameter variances are calculated by averaging the individual variances from each imputation, and the formula includes an additional term to capture the between-imputation variance.
Best way to combine MCMC inference with multiple imputation? [duplicate] I wrote a paper arxiv.org/abs/1907.09090 that describes how the pseudo-marginal approach can impute missing data. 400 covariates sounds tough, though, to be completely honest. Depends on what kind of
41,379
Feature Interaction and its applications?
Quoted from the OP's link: 5.4 Feature Interaction When features interact with each other in a prediction model, the prediction cannot be expressed as the sum of the feature effects, because the effect of one feature depends on the value of the other feature. Aristotle's predicate "The whole is greater than the sum of its parts" applies in the presence of interactions. 5.4.1 Feature Interaction? If a machine learning model makes a prediction based on two features, we can decompose the prediction into four terms: a constant term, a term for the first feature, a term for the second feature and a term for the interaction between the two features. The interaction between two features is the change in the prediction that occurs by varying the features after considering the individual feature effects. I would like to be a little pedantic and alter the last sentence above: The interaction between two features is the change in the prediction that occurs by varying the features while considering the individual feature effects. Another way to think about an interaction is that it occurs when the effect of one feature depends on the value of another feature. Note that interaction are a natural result of considering the general model: $$ Y = f(x,Z)$$ where $x$ is a matrix of continuous explanatory variables (features) and $Z$ is a random variable which we can think of as normally distributed around zero, but it does not have to be. If we expand this around $x_0$, with a 2nd order taylor series we obtain: $$Y \approx \beta_0 + \sum_{i = 1}^{p} \beta_{i}(x_i-x_{i0}) + \sum_{i = 1}^{p}\sum_{j = 1}^{p} \beta_{ij}(x_i-x_{i0})(x_j-x_{j0}) + \left( \sigma + \sum_{i = 1}^{p} \gamma_i(x_i-x_{i0}) \right) Z + \sigma Z^2 $$ where the 3rd term contains cross products of two linear terms - which are the interactions. Are Feature Interactions used for Feature Selection or Feature Generation? I would consider interactions as Feature Generation, and they are a very useful way of modelling a natural form of nonlinearity. Edit: Of course, once you have generated the interaction feature, there is then the question of whether to include it in your model, and that is where feature selection comes into play.
Feature Interaction and its applications?
Quoted from the OP's link: 5.4 Feature Interaction When features interact with each other in a prediction model, the prediction cannot be expressed as the sum of the feature effects, because the effe
Feature Interaction and its applications? Quoted from the OP's link: 5.4 Feature Interaction When features interact with each other in a prediction model, the prediction cannot be expressed as the sum of the feature effects, because the effect of one feature depends on the value of the other feature. Aristotle's predicate "The whole is greater than the sum of its parts" applies in the presence of interactions. 5.4.1 Feature Interaction? If a machine learning model makes a prediction based on two features, we can decompose the prediction into four terms: a constant term, a term for the first feature, a term for the second feature and a term for the interaction between the two features. The interaction between two features is the change in the prediction that occurs by varying the features after considering the individual feature effects. I would like to be a little pedantic and alter the last sentence above: The interaction between two features is the change in the prediction that occurs by varying the features while considering the individual feature effects. Another way to think about an interaction is that it occurs when the effect of one feature depends on the value of another feature. Note that interaction are a natural result of considering the general model: $$ Y = f(x,Z)$$ where $x$ is a matrix of continuous explanatory variables (features) and $Z$ is a random variable which we can think of as normally distributed around zero, but it does not have to be. If we expand this around $x_0$, with a 2nd order taylor series we obtain: $$Y \approx \beta_0 + \sum_{i = 1}^{p} \beta_{i}(x_i-x_{i0}) + \sum_{i = 1}^{p}\sum_{j = 1}^{p} \beta_{ij}(x_i-x_{i0})(x_j-x_{j0}) + \left( \sigma + \sum_{i = 1}^{p} \gamma_i(x_i-x_{i0}) \right) Z + \sigma Z^2 $$ where the 3rd term contains cross products of two linear terms - which are the interactions. Are Feature Interactions used for Feature Selection or Feature Generation? I would consider interactions as Feature Generation, and they are a very useful way of modelling a natural form of nonlinearity. Edit: Of course, once you have generated the interaction feature, there is then the question of whether to include it in your model, and that is where feature selection comes into play.
Feature Interaction and its applications? Quoted from the OP's link: 5.4 Feature Interaction When features interact with each other in a prediction model, the prediction cannot be expressed as the sum of the feature effects, because the effe
41,380
Feature Interaction and its applications?
Feature interaction seems to be just new (machine learning?) terminology for plain old interaction. As such there is already many posts at this site, see this list.
Feature Interaction and its applications?
Feature interaction seems to be just new (machine learning?) terminology for plain old interaction. As such there is already many posts at this site, see this list.
Feature Interaction and its applications? Feature interaction seems to be just new (machine learning?) terminology for plain old interaction. As such there is already many posts at this site, see this list.
Feature Interaction and its applications? Feature interaction seems to be just new (machine learning?) terminology for plain old interaction. As such there is already many posts at this site, see this list.
41,381
If $X_n - \mu = O_p(a_n)$ does that imply that $X_n^{-1} - \mu^{-1} = O_p(a_n)$?
You mention convergence in probability, but note that $X_n - \mu = O_p(a_n)$ does not imply that $\frac{X_n - \mu}{a_n}$ converges in probability to $0$. Wikipedia has the relevant definition. The implication does not hold. As a counterexample, suppose $\mu = 1$, every $a_n = 1$, and $P(X_n = \frac{1}{n}) = 1$. Then $P(|\frac{X_n - \mu}{a_n}| > 10) = 0$ for all $n$, so $X_n - \mu = O_p(a_n)$. But for any $M > 0$ and any $n > M+1$, we have $P(|\frac{X_n^{-1} - \mu^{-1}}{a_n}| > M) = 1$. So it is not the case that $X_n^{-1} - \mu^{-1} = O_p(a_n)$. Edit: proof for the case $a_n = n^{-0.5}$. Suppose that $X_n - \mu = O_p(a_n)$, where $a_n \to 0$ and every $a_n > 0$. And suppose that $f$ is a function for which there exists an open interval $I$ and a positive constant $K$ such that $\mu \in I$ and for all $x \in I$, $|f(x) - f(\mu)| < K|x-\mu|$. (The reciprocal function meets this condition if $\mu \ne 0$.) We seek to show that for any $\epsilon > 0$, there exist $M, N$ such that for all $n > N$, $P(|f(X_n) - f(\mu)| > a_n M) < \epsilon$. First pick $U, W$ large enough that for all $n > W$, $P(|X_n - \mu| > a_n U) < \frac \epsilon 2$. Since $a_n \to 0$, we can pick $V > W$ such that for all $n > V$, for all $x \notin I$, we have $|x - \mu| > a_n U$. This means that $P(X_n \notin I) < \frac \epsilon 2$ for $n > V$. In symbols, if $n > V$, $P(|f(X_n) - f(\mu)| > a_n K U) \le P(|X_n - \mu| > a_n U) + P(X_n \notin I) < \frac \epsilon 2 + \frac \epsilon 2 = \epsilon$. (The intuition for this is that if $n > V$ then it's unlikely that $X_n \notin I$; but if $X_n \in I$ it's unlikely that $|f(X_n) - f(\mu)| > a_n K U$. In other words, $X_n$ is probably not far enough from $\mu$ for $f$ to behave badly (as the reciprocal function does near 0), and if $f$ doesn't behave badly then it preserves the relevant big-O behaviour.) Let $M = KU, N = V$ and we're done.
If $X_n - \mu = O_p(a_n)$ does that imply that $X_n^{-1} - \mu^{-1} = O_p(a_n)$?
You mention convergence in probability, but note that $X_n - \mu = O_p(a_n)$ does not imply that $\frac{X_n - \mu}{a_n}$ converges in probability to $0$. Wikipedia has the relevant definition. The imp
If $X_n - \mu = O_p(a_n)$ does that imply that $X_n^{-1} - \mu^{-1} = O_p(a_n)$? You mention convergence in probability, but note that $X_n - \mu = O_p(a_n)$ does not imply that $\frac{X_n - \mu}{a_n}$ converges in probability to $0$. Wikipedia has the relevant definition. The implication does not hold. As a counterexample, suppose $\mu = 1$, every $a_n = 1$, and $P(X_n = \frac{1}{n}) = 1$. Then $P(|\frac{X_n - \mu}{a_n}| > 10) = 0$ for all $n$, so $X_n - \mu = O_p(a_n)$. But for any $M > 0$ and any $n > M+1$, we have $P(|\frac{X_n^{-1} - \mu^{-1}}{a_n}| > M) = 1$. So it is not the case that $X_n^{-1} - \mu^{-1} = O_p(a_n)$. Edit: proof for the case $a_n = n^{-0.5}$. Suppose that $X_n - \mu = O_p(a_n)$, where $a_n \to 0$ and every $a_n > 0$. And suppose that $f$ is a function for which there exists an open interval $I$ and a positive constant $K$ such that $\mu \in I$ and for all $x \in I$, $|f(x) - f(\mu)| < K|x-\mu|$. (The reciprocal function meets this condition if $\mu \ne 0$.) We seek to show that for any $\epsilon > 0$, there exist $M, N$ such that for all $n > N$, $P(|f(X_n) - f(\mu)| > a_n M) < \epsilon$. First pick $U, W$ large enough that for all $n > W$, $P(|X_n - \mu| > a_n U) < \frac \epsilon 2$. Since $a_n \to 0$, we can pick $V > W$ such that for all $n > V$, for all $x \notin I$, we have $|x - \mu| > a_n U$. This means that $P(X_n \notin I) < \frac \epsilon 2$ for $n > V$. In symbols, if $n > V$, $P(|f(X_n) - f(\mu)| > a_n K U) \le P(|X_n - \mu| > a_n U) + P(X_n \notin I) < \frac \epsilon 2 + \frac \epsilon 2 = \epsilon$. (The intuition for this is that if $n > V$ then it's unlikely that $X_n \notin I$; but if $X_n \in I$ it's unlikely that $|f(X_n) - f(\mu)| > a_n K U$. In other words, $X_n$ is probably not far enough from $\mu$ for $f$ to behave badly (as the reciprocal function does near 0), and if $f$ doesn't behave badly then it preserves the relevant big-O behaviour.) Let $M = KU, N = V$ and we're done.
If $X_n - \mu = O_p(a_n)$ does that imply that $X_n^{-1} - \mu^{-1} = O_p(a_n)$? You mention convergence in probability, but note that $X_n - \mu = O_p(a_n)$ does not imply that $\frac{X_n - \mu}{a_n}$ converges in probability to $0$. Wikipedia has the relevant definition. The imp
41,382
If $X_n - \mu = O_p(a_n)$ does that imply that $X_n^{-1} - \mu^{-1} = O_p(a_n)$?
Your question relates to the continuous mapping theorem which states $$X_n \xrightarrow[]{p} a \implies g(X_n) \xrightarrow[]{p} g(a)$$ But this convergence in probability relates to small $o$ notation and not big $O$.
If $X_n - \mu = O_p(a_n)$ does that imply that $X_n^{-1} - \mu^{-1} = O_p(a_n)$?
Your question relates to the continuous mapping theorem which states $$X_n \xrightarrow[]{p} a \implies g(X_n) \xrightarrow[]{p} g(a)$$ But this convergence in probability relates to small $o$ notatio
If $X_n - \mu = O_p(a_n)$ does that imply that $X_n^{-1} - \mu^{-1} = O_p(a_n)$? Your question relates to the continuous mapping theorem which states $$X_n \xrightarrow[]{p} a \implies g(X_n) \xrightarrow[]{p} g(a)$$ But this convergence in probability relates to small $o$ notation and not big $O$.
If $X_n - \mu = O_p(a_n)$ does that imply that $X_n^{-1} - \mu^{-1} = O_p(a_n)$? Your question relates to the continuous mapping theorem which states $$X_n \xrightarrow[]{p} a \implies g(X_n) \xrightarrow[]{p} g(a)$$ But this convergence in probability relates to small $o$ notatio
41,383
Normalized Cross Entropy
First note that the denominator does not depend on the model, so it is only a linear transform of the LLH. Unless your model is worse than predicting a constant, the denominator should be higher than the numerator, so it is usually between 0 and 1 Typically, when the label is difficult to predict accurately, the LLH is not very far from the denominator. The proposed normalization may allow to get a metric a bit more comparable between datasets with different ratio of positives. Personally I like using 1 - LLH / Entropy ( So 1 minus their metric), which can be interpreted as the "proportion of entropy explained by the model".
Normalized Cross Entropy
First note that the denominator does not depend on the model, so it is only a linear transform of the LLH. Unless your model is worse than predicting a constant, the denominator should be higher than
Normalized Cross Entropy First note that the denominator does not depend on the model, so it is only a linear transform of the LLH. Unless your model is worse than predicting a constant, the denominator should be higher than the numerator, so it is usually between 0 and 1 Typically, when the label is difficult to predict accurately, the LLH is not very far from the denominator. The proposed normalization may allow to get a metric a bit more comparable between datasets with different ratio of positives. Personally I like using 1 - LLH / Entropy ( So 1 minus their metric), which can be interpreted as the "proportion of entropy explained by the model".
Normalized Cross Entropy First note that the denominator does not depend on the model, so it is only a linear transform of the LLH. Unless your model is worse than predicting a constant, the denominator should be higher than
41,384
Normalized Cross Entropy
I think what the author meant was that the denominator (log loss from the background CTR) will be close to 0 when the background CTR p is close to either 0 or 1. This can be easily verified by plotting a graph. It does not look like the sentence was referring to the numerator.
Normalized Cross Entropy
I think what the author meant was that the denominator (log loss from the background CTR) will be close to 0 when the background CTR p is close to either 0 or 1. This can be easily verified by plottin
Normalized Cross Entropy I think what the author meant was that the denominator (log loss from the background CTR) will be close to 0 when the background CTR p is close to either 0 or 1. This can be easily verified by plotting a graph. It does not look like the sentence was referring to the numerator.
Normalized Cross Entropy I think what the author meant was that the denominator (log loss from the background CTR) will be close to 0 when the background CTR p is close to either 0 or 1. This can be easily verified by plottin
41,385
Normalized Cross Entropy
Simply speaking, one wants to compare his model accuracy versus a 'free' vanilla model (that outputs always the majority class). How? create a ratio and put the entropy of the free model into denominator. Why? for extremely unbalanced data with 99% majority class, even 'free' vanilla model claims high accuracy, which in real life often a useless prediction. I further would suggest the following modification: E(of my model)/E(of baseline 'free' model) - 1 to capture the actual improvement in entropy.
Normalized Cross Entropy
Simply speaking, one wants to compare his model accuracy versus a 'free' vanilla model (that outputs always the majority class). How? create a ratio and put the entropy of the free model into denomina
Normalized Cross Entropy Simply speaking, one wants to compare his model accuracy versus a 'free' vanilla model (that outputs always the majority class). How? create a ratio and put the entropy of the free model into denominator. Why? for extremely unbalanced data with 99% majority class, even 'free' vanilla model claims high accuracy, which in real life often a useless prediction. I further would suggest the following modification: E(of my model)/E(of baseline 'free' model) - 1 to capture the actual improvement in entropy.
Normalized Cross Entropy Simply speaking, one wants to compare his model accuracy versus a 'free' vanilla model (that outputs always the majority class). How? create a ratio and put the entropy of the free model into denomina
41,386
Normalized Cross Entropy
the closer p is to 0 or 1, the easier it is to achieve a better log loss (i.e. cross entropy, i.e. numerator). If almost all of the cases are of one category, then we can always predict a high probability of that category and get a fairly small log loss, since extreme probabilities will be close to almost all of the cases, and then there are just a couple of mistakes. Contrast this with perfect balance of the classes. If we predict extreme probabilities in favor of class $0$, then we have bad predictions half of the time. If we predict extreme probabilities in favor of class $1$, then we have bad predictions half of the time. There are ways to break this. For instance, an extremely extreme probability prediction of the wrong class can wreck the entire log loss calculation (in the sense of making the log loss very large). Because of this, I am not so sure that I agree with the claim the authors make. Nonetheless, their approach seems to be similar to (if not the same as) McFadden's $R^2$, and they do exactly what I argue is correct for an out-of-sample $R^2$-style metric. That McFadden $R^2$ metric, and many more, are discussed on a UCLA page about pseudo $R^2$ values in classification problems.
Normalized Cross Entropy
the closer p is to 0 or 1, the easier it is to achieve a better log loss (i.e. cross entropy, i.e. numerator). If almost all of the cases are of one category, then we can always predict a high probab
Normalized Cross Entropy the closer p is to 0 or 1, the easier it is to achieve a better log loss (i.e. cross entropy, i.e. numerator). If almost all of the cases are of one category, then we can always predict a high probability of that category and get a fairly small log loss, since extreme probabilities will be close to almost all of the cases, and then there are just a couple of mistakes. Contrast this with perfect balance of the classes. If we predict extreme probabilities in favor of class $0$, then we have bad predictions half of the time. If we predict extreme probabilities in favor of class $1$, then we have bad predictions half of the time. There are ways to break this. For instance, an extremely extreme probability prediction of the wrong class can wreck the entire log loss calculation (in the sense of making the log loss very large). Because of this, I am not so sure that I agree with the claim the authors make. Nonetheless, their approach seems to be similar to (if not the same as) McFadden's $R^2$, and they do exactly what I argue is correct for an out-of-sample $R^2$-style metric. That McFadden $R^2$ metric, and many more, are discussed on a UCLA page about pseudo $R^2$ values in classification problems.
Normalized Cross Entropy the closer p is to 0 or 1, the easier it is to achieve a better log loss (i.e. cross entropy, i.e. numerator). If almost all of the cases are of one category, then we can always predict a high probab
41,387
Terminology: unconditional heteroskedasticity
You can treat it as a shorthand for "heteroskedasticity that does not depend on variables explicitly recognized by the model". In a more practical sense, it is "heteroskedasticity that does not depend on variables on which we have data". So "conditional heteroskedasticity" would be "heteroskedasticity that does depend on..." It is always a good thing to enquire about the philosophical meaning of a term, but sometimes, utilitarian considerations as regards the use of labels to communicate take over. RESPONSE TO COMMENTS Suppose that we are examining the output of a specific industry at a specific period of time and geographical area, having available a cross-sectional sample that contains data related to production (output, inputs). We are pretty sure that we have data on all inputs $\mathbf x$ and we consider the model $$Q_i = F(\mathbf x_i) + \varepsilon_i$$ What does $\varepsilon_i$ represents? Many things, but (structural reasoning) based on our knowledge of the industry and the specific market, we are certain of this: customer preferences and demand for the product of this industry depends on whether the customer lives in cities or in the country. In particular, city dwellers have much more volatile preferences, chasing the latest fashion etc, while country folks have much more stable preferences. Each firm has a mixed customer base, both city and country. This means that we expect (structural reasoning) the error term to differ depending on the customer mix of each firm (observation). A way to model this knowledge is to postulate a classical zero-mean, independent, homoskedastic etc, disturbance $u_i$ that represents the error term when the customer base is city-only, then consider a variable $m_i \in [0,1]$ that reflects the proportion of city-customers for each firm, and set $$\varepsilon_i = m_iu_i.$$ The variable $m_i$ is at least party deterministic, in the sense that it is directly influenced by the marketing/management decisions of each firm. Assume also that whatever part of $m_i$ is stochastic, is not statistically associated with the inputs. SITUATION A : Unconditional Heteroskedasticity (effectively) Suppose that your sample does not contain data on $m_i$. In this case, the regression error is conditionally heteroskedastic given $m_i$, but you cannot do anything about it. Moreover, because $m_i$ is deterministic, you end up with an unconditionally heteroskedastic error term. SITUATION B : Conditional heteroskedasticity (implementable) Suppose now that you have a data series on the $m_i$ variable. Then you can effectively condition on $m_i$. For example, in an OLS estimation with a linear regression function setting we will get $${\rm Var}(\hat \beta \mid X, m) = \sigma^2_u(X'X)^{-1}[X'{\rm diag}\{m_i^2\}X](X'X)^{-1}$$ SITUATION C: Clustered Standard Errors (heir of "group-wise heteroskedasticity") Suppose now that you do not have data on $m_i$, but instead you have a classification variable that meta-classifies the observations in three groups according to customer mix: "more country-oriented", "more city-oriented", "balanced". Then you can do something with this variable and implement a "clustered standard errors" estimation based on it, to at least capture to a degree the variability that comes from the customer mix.
Terminology: unconditional heteroskedasticity
You can treat it as a shorthand for "heteroskedasticity that does not depend on variables explicitly recognized by the model". In a more practical sense, it is "heteroskedasticity that does not depen
Terminology: unconditional heteroskedasticity You can treat it as a shorthand for "heteroskedasticity that does not depend on variables explicitly recognized by the model". In a more practical sense, it is "heteroskedasticity that does not depend on variables on which we have data". So "conditional heteroskedasticity" would be "heteroskedasticity that does depend on..." It is always a good thing to enquire about the philosophical meaning of a term, but sometimes, utilitarian considerations as regards the use of labels to communicate take over. RESPONSE TO COMMENTS Suppose that we are examining the output of a specific industry at a specific period of time and geographical area, having available a cross-sectional sample that contains data related to production (output, inputs). We are pretty sure that we have data on all inputs $\mathbf x$ and we consider the model $$Q_i = F(\mathbf x_i) + \varepsilon_i$$ What does $\varepsilon_i$ represents? Many things, but (structural reasoning) based on our knowledge of the industry and the specific market, we are certain of this: customer preferences and demand for the product of this industry depends on whether the customer lives in cities or in the country. In particular, city dwellers have much more volatile preferences, chasing the latest fashion etc, while country folks have much more stable preferences. Each firm has a mixed customer base, both city and country. This means that we expect (structural reasoning) the error term to differ depending on the customer mix of each firm (observation). A way to model this knowledge is to postulate a classical zero-mean, independent, homoskedastic etc, disturbance $u_i$ that represents the error term when the customer base is city-only, then consider a variable $m_i \in [0,1]$ that reflects the proportion of city-customers for each firm, and set $$\varepsilon_i = m_iu_i.$$ The variable $m_i$ is at least party deterministic, in the sense that it is directly influenced by the marketing/management decisions of each firm. Assume also that whatever part of $m_i$ is stochastic, is not statistically associated with the inputs. SITUATION A : Unconditional Heteroskedasticity (effectively) Suppose that your sample does not contain data on $m_i$. In this case, the regression error is conditionally heteroskedastic given $m_i$, but you cannot do anything about it. Moreover, because $m_i$ is deterministic, you end up with an unconditionally heteroskedastic error term. SITUATION B : Conditional heteroskedasticity (implementable) Suppose now that you have a data series on the $m_i$ variable. Then you can effectively condition on $m_i$. For example, in an OLS estimation with a linear regression function setting we will get $${\rm Var}(\hat \beta \mid X, m) = \sigma^2_u(X'X)^{-1}[X'{\rm diag}\{m_i^2\}X](X'X)^{-1}$$ SITUATION C: Clustered Standard Errors (heir of "group-wise heteroskedasticity") Suppose now that you do not have data on $m_i$, but instead you have a classification variable that meta-classifies the observations in three groups according to customer mix: "more country-oriented", "more city-oriented", "balanced". Then you can do something with this variable and implement a "clustered standard errors" estimation based on it, to at least capture to a degree the variability that comes from the customer mix.
Terminology: unconditional heteroskedasticity You can treat it as a shorthand for "heteroskedasticity that does not depend on variables explicitly recognized by the model". In a more practical sense, it is "heteroskedasticity that does not depen
41,388
What is the specific issue with using count data for ANOVA tests
Count data cannot really have a normal distribution, except as an approximation in the case of large counts. But that is not the main reason: Count data do not have constant variance. For the most used model, the Poisson distribution, the variance equals the mean, for many other reasonable models (cluster processes, like people arriving at some place in groups), variance is proportional to the mean. A classical solution which is sometimes useful even today is the square root transformation, stabilizing variances. See Why is the square root transformation recommended for count data?. Counts are extensive variables, not intensive. See Goodness of fit and which model to choose linear regression or Poisson As mentioned in a comment, ordinal regression models is a possibility. See GLM with continuous data piled up at zero for details, especially the answer by F. Harrell. Today, with count data mostly think poisson-regression (or a variant), which is a glm (generalized linear model), at least as a starting point. But you can still use anova thinking, as all experimental design ideas used in anova can also be used with generalized linear models! So you can still use a split-plot model with poisson regression. There are many similar posts.
What is the specific issue with using count data for ANOVA tests
Count data cannot really have a normal distribution, except as an approximation in the case of large counts. But that is not the main reason: Count data do not have constant variance. For the most us
What is the specific issue with using count data for ANOVA tests Count data cannot really have a normal distribution, except as an approximation in the case of large counts. But that is not the main reason: Count data do not have constant variance. For the most used model, the Poisson distribution, the variance equals the mean, for many other reasonable models (cluster processes, like people arriving at some place in groups), variance is proportional to the mean. A classical solution which is sometimes useful even today is the square root transformation, stabilizing variances. See Why is the square root transformation recommended for count data?. Counts are extensive variables, not intensive. See Goodness of fit and which model to choose linear regression or Poisson As mentioned in a comment, ordinal regression models is a possibility. See GLM with continuous data piled up at zero for details, especially the answer by F. Harrell. Today, with count data mostly think poisson-regression (or a variant), which is a glm (generalized linear model), at least as a starting point. But you can still use anova thinking, as all experimental design ideas used in anova can also be used with generalized linear models! So you can still use a split-plot model with poisson regression. There are many similar posts.
What is the specific issue with using count data for ANOVA tests Count data cannot really have a normal distribution, except as an approximation in the case of large counts. But that is not the main reason: Count data do not have constant variance. For the most us
41,389
Multiplying vectors by the covariance matrix?
They're not exactly on a line, but yes, they generally follow the main eigenvector because the projected point has the following coordinates (assuming $x$ with dimensions $2\times 1$):$$\Sigma x=\sigma_1u_1u_1^Tx+\sigma_2u_2u_2^Tx=(\sigma_1<u_1,x>)u_1+(\sigma_2<u_2,x>)u_2$$ Here, $u_i$ are eigenvectors, and $\sigma_i$ are eigenvalues. Since $\sigma_1>\sigma_2$ and for the most of the data component in the direction of $x_1$ is larger than the one in $x_2$, the coefficient before $u_1^T$ is typically much larger than the one before $u_2^T$. This causes the points align with the first eigenvector mostly. If there were some outliers, especially nearly perpendicular to the first eigenvector, they would not be aligned so much with $u_1$'s direction. import matplotlib.pyplot as plt import numpy as np mean = [0, 0] cov = [[1, 0.9], [0.9, 1]] x, y = np.random.multivariate_normal(mean, cov, 1000).transpose() x = np.hstack([x, -10]) y = np.hstack([y, 10]) plt.scatter(x, y) plt.show() new_x = [] new_y = [] for i in range(len(x)): vec = np.array([x[i],y[i]]) trsf = np.matmul(vec.transpose(),cov) new_x.append(trsf[0]) new_y.append(trsf[1]) plt.scatter(new_x,new_y)
Multiplying vectors by the covariance matrix?
They're not exactly on a line, but yes, they generally follow the main eigenvector because the projected point has the following coordinates (assuming $x$ with dimensions $2\times 1$):$$\Sigma x=\sigm
Multiplying vectors by the covariance matrix? They're not exactly on a line, but yes, they generally follow the main eigenvector because the projected point has the following coordinates (assuming $x$ with dimensions $2\times 1$):$$\Sigma x=\sigma_1u_1u_1^Tx+\sigma_2u_2u_2^Tx=(\sigma_1<u_1,x>)u_1+(\sigma_2<u_2,x>)u_2$$ Here, $u_i$ are eigenvectors, and $\sigma_i$ are eigenvalues. Since $\sigma_1>\sigma_2$ and for the most of the data component in the direction of $x_1$ is larger than the one in $x_2$, the coefficient before $u_1^T$ is typically much larger than the one before $u_2^T$. This causes the points align with the first eigenvector mostly. If there were some outliers, especially nearly perpendicular to the first eigenvector, they would not be aligned so much with $u_1$'s direction. import matplotlib.pyplot as plt import numpy as np mean = [0, 0] cov = [[1, 0.9], [0.9, 1]] x, y = np.random.multivariate_normal(mean, cov, 1000).transpose() x = np.hstack([x, -10]) y = np.hstack([y, 10]) plt.scatter(x, y) plt.show() new_x = [] new_y = [] for i in range(len(x)): vec = np.array([x[i],y[i]]) trsf = np.matmul(vec.transpose(),cov) new_x.append(trsf[0]) new_y.append(trsf[1]) plt.scatter(new_x,new_y)
Multiplying vectors by the covariance matrix? They're not exactly on a line, but yes, they generally follow the main eigenvector because the projected point has the following coordinates (assuming $x$ with dimensions $2\times 1$):$$\Sigma x=\sigm
41,390
Should we center original data if we want to get principal component?
While it is true that your original data can be reconstructed from the principal components, even if you didn't center the data when calculating them, part of what one is usually trying to do in principal components analysis is dimensionality reduction. That is you want to find a subset of the principal components that captures most of the variation in the data. This happens when the variance of the coefficients of the principal components is small for all of the components after the first few. For that to happen, the centroid of the cloud of data points has to be at the origin, which is equivalent to centering the data. Here's a 2D example to illustrate. Consider the following dataset: This data is nearly one-dimensional, and would be well-represented by a single linear component. However, because the data does not pass through the origin, you can't describe it with a scalar multiplied by a single principal component vector (because a linear combination of a single vector always passes through the origin). Centering the data translates this cloud of points so that its centroid is at the origin, making it possible to represent the line running down the middle of the cloud with a single principal component. You can see the difference if you try running the PCA with and without the centering. With centering: > prcomp(m, centering=TRUE) Standard deviations (1, .., p=2): [1] 2.46321136 0.04164508 Rotation (n x k) = (2 x 2): PC1 PC2 x -0.4484345 -0.8938157 y -0.8938157 0.4484345 The singular value for the second component (0.04) is much smaller than that of the first (2.46), indicating that most of the variation in the data is accounted for by the first component. We could reduce the dimensionality of the dataset from 2 to 1 by dropping the second component. If, on the other hand, we don't center the data, we get a less useful result: > prcomp(m, center=FALSE) Standard deviations (1, .., p=2): [1] 6.240952 1.065940 Rotation (n x k) = (2 x 2): PC1 PC2 x -0.04988157 0.99875514 y -0.99875514 -0.04988157 In this case, the singular value for the second component is smaller than that of the first component, but not nearly as much so as when we centered the data. In this case, we probably wouldn't get an adequate reconstruction of the data using just the first component and dropping the second. Thus, the uncentered version of the calculation is not useful for dimensionality reduction.
Should we center original data if we want to get principal component?
While it is true that your original data can be reconstructed from the principal components, even if you didn't center the data when calculating them, part of what one is usually trying to do in princ
Should we center original data if we want to get principal component? While it is true that your original data can be reconstructed from the principal components, even if you didn't center the data when calculating them, part of what one is usually trying to do in principal components analysis is dimensionality reduction. That is you want to find a subset of the principal components that captures most of the variation in the data. This happens when the variance of the coefficients of the principal components is small for all of the components after the first few. For that to happen, the centroid of the cloud of data points has to be at the origin, which is equivalent to centering the data. Here's a 2D example to illustrate. Consider the following dataset: This data is nearly one-dimensional, and would be well-represented by a single linear component. However, because the data does not pass through the origin, you can't describe it with a scalar multiplied by a single principal component vector (because a linear combination of a single vector always passes through the origin). Centering the data translates this cloud of points so that its centroid is at the origin, making it possible to represent the line running down the middle of the cloud with a single principal component. You can see the difference if you try running the PCA with and without the centering. With centering: > prcomp(m, centering=TRUE) Standard deviations (1, .., p=2): [1] 2.46321136 0.04164508 Rotation (n x k) = (2 x 2): PC1 PC2 x -0.4484345 -0.8938157 y -0.8938157 0.4484345 The singular value for the second component (0.04) is much smaller than that of the first (2.46), indicating that most of the variation in the data is accounted for by the first component. We could reduce the dimensionality of the dataset from 2 to 1 by dropping the second component. If, on the other hand, we don't center the data, we get a less useful result: > prcomp(m, center=FALSE) Standard deviations (1, .., p=2): [1] 6.240952 1.065940 Rotation (n x k) = (2 x 2): PC1 PC2 x -0.04988157 0.99875514 y -0.99875514 -0.04988157 In this case, the singular value for the second component is smaller than that of the first component, but not nearly as much so as when we centered the data. In this case, we probably wouldn't get an adequate reconstruction of the data using just the first component and dropping the second. Thus, the uncentered version of the calculation is not useful for dimensionality reduction.
Should we center original data if we want to get principal component? While it is true that your original data can be reconstructed from the principal components, even if you didn't center the data when calculating them, part of what one is usually trying to do in princ
41,391
Should we center original data if we want to get principal component?
PCA is done on the centered data matrix in the first place (because $X^TX$ is the (scaled) covariance estimate if $X$ is centered). So, while fitting, $X$ is centered internally. The same mathematical operation takes place while transforming new data points.
Should we center original data if we want to get principal component?
PCA is done on the centered data matrix in the first place (because $X^TX$ is the (scaled) covariance estimate if $X$ is centered). So, while fitting, $X$ is centered internally. The same mathematical
Should we center original data if we want to get principal component? PCA is done on the centered data matrix in the first place (because $X^TX$ is the (scaled) covariance estimate if $X$ is centered). So, while fitting, $X$ is centered internally. The same mathematical operation takes place while transforming new data points.
Should we center original data if we want to get principal component? PCA is done on the centered data matrix in the first place (because $X^TX$ is the (scaled) covariance estimate if $X$ is centered). So, while fitting, $X$ is centered internally. The same mathematical
41,392
When should I do train test split?
Your procedure is correct generally. In a more complex loop, additional operations may include validation, hyper-parameter optimisation, feature selection etc. Typically, feature extraction follows exploratory data analysis (EDA), where you get to know your data, analyse/summarise it, draw intuitive conclusions. In EDA, you don't necessarily do a train/test split. Note that, if you repeat steps 2-3 in a feedback loop so that you test whether newly extracted features (e.g. interaction variables) are useful for the model or not, you'll need a validation step.
When should I do train test split?
Your procedure is correct generally. In a more complex loop, additional operations may include validation, hyper-parameter optimisation, feature selection etc. Typically, feature extraction follows ex
When should I do train test split? Your procedure is correct generally. In a more complex loop, additional operations may include validation, hyper-parameter optimisation, feature selection etc. Typically, feature extraction follows exploratory data analysis (EDA), where you get to know your data, analyse/summarise it, draw intuitive conclusions. In EDA, you don't necessarily do a train/test split. Note that, if you repeat steps 2-3 in a feedback loop so that you test whether newly extracted features (e.g. interaction variables) are useful for the model or not, you'll need a validation step.
When should I do train test split? Your procedure is correct generally. In a more complex loop, additional operations may include validation, hyper-parameter optimisation, feature selection etc. Typically, feature extraction follows ex
41,393
Likelihood ratio test for mixed effects model
My first hint is to use lmer from the lme4 package, not lme. When the variance components approach zero it will be more likely to converge without errors, although it may (and should) give a singular fit warning. My second hint is to simulate $b_i$ with $\sigma_b^2$ not as identically zero, but just very small.
Likelihood ratio test for mixed effects model
My first hint is to use lmer from the lme4 package, not lme. When the variance components approach zero it will be more likely to converge without errors, although it may (and should) give a singular
Likelihood ratio test for mixed effects model My first hint is to use lmer from the lme4 package, not lme. When the variance components approach zero it will be more likely to converge without errors, although it may (and should) give a singular fit warning. My second hint is to simulate $b_i$ with $\sigma_b^2$ not as identically zero, but just very small.
Likelihood ratio test for mixed effects model My first hint is to use lmer from the lme4 package, not lme. When the variance components approach zero it will be more likely to converge without errors, although it may (and should) give a singular
41,394
Batch normalization and the need for bias in neural networks
Check your software, but broadly the answer to your question is: yes, using batch normalization obviates the need for a bias in the preceding linear layer. Your question does a good job of laying out where you are confused, so let me speak to it: the shift term in batch normalization is also a vector, for instance the documentation for BatchNorm2d in Pytorch reads: "The mean and standard-deviation are calculated per-dimension over the mini-batches and $\gamma$ and $\beta$ are learnable parameter vectors of size $C$ (where $C$ is the input size). "
Batch normalization and the need for bias in neural networks
Check your software, but broadly the answer to your question is: yes, using batch normalization obviates the need for a bias in the preceding linear layer. Your question does a good job of laying out
Batch normalization and the need for bias in neural networks Check your software, but broadly the answer to your question is: yes, using batch normalization obviates the need for a bias in the preceding linear layer. Your question does a good job of laying out where you are confused, so let me speak to it: the shift term in batch normalization is also a vector, for instance the documentation for BatchNorm2d in Pytorch reads: "The mean and standard-deviation are calculated per-dimension over the mini-batches and $\gamma$ and $\beta$ are learnable parameter vectors of size $C$ (where $C$ is the input size). "
Batch normalization and the need for bias in neural networks Check your software, but broadly the answer to your question is: yes, using batch normalization obviates the need for a bias in the preceding linear layer. Your question does a good job of laying out
41,395
Batch normalization and the need for bias in neural networks
Here's a quote from the original BN paper that should answer your question: i.e. each activation is shifted by its own shift parameter (beta). So yes, the batch normalization eliminates the need for a bias vector. Just a side note: in Pytorch the BN's betas are all initialized to zero by default, whereas the biases in linear and convolutional layers are initialized to random values.
Batch normalization and the need for bias in neural networks
Here's a quote from the original BN paper that should answer your question: i.e. each activation is shifted by its own shift parameter (beta). So yes, the batch normalization eliminates the need for
Batch normalization and the need for bias in neural networks Here's a quote from the original BN paper that should answer your question: i.e. each activation is shifted by its own shift parameter (beta). So yes, the batch normalization eliminates the need for a bias vector. Just a side note: in Pytorch the BN's betas are all initialized to zero by default, whereas the biases in linear and convolutional layers are initialized to random values.
Batch normalization and the need for bias in neural networks Here's a quote from the original BN paper that should answer your question: i.e. each activation is shifted by its own shift parameter (beta). So yes, the batch normalization eliminates the need for
41,396
Is it better to compute Average Precision using the trapezoidal rule or the rectangle method?
UPDATE This journal article explains why linear interpolation is both "too optimist" and is also "incorrect," due to the non-linear properties of the Precision-Recall curve: https://www.biostat.wisc.edu/~page/rocpr.pdf Due to the non-linear nature of the precision-response curve, linear interpolation results in erroneous overestimations. With an averaging rule, missed changes in slope average out. With interpolation, they do not. Thus if points don't cover all the slope changes in the real curve, interpolation errors add up. This is why interpolation is "too optimistic," and why the midpoint rule generally has half the error that the trapezoidal rule has. https://math.libretexts.org/Courses/Mount_Royal_University/MATH_2200%3A_Calculus_for_Scientists_II/2%3A_Techniques_of_Integration/2.5%3A_Numerical_Integration_-_Midpoint%2C_Trapezoid%2C_Simpson%27s_rule http://math.cmu.edu/~mittal/Recitation_notes.pdf https://activecalculus.org/single/sec-5-6-num-int.html This article is referenced as "[Davis2006]" in the scikit-learn documentation as the explanation as to why linear interpolation is inappropriate and "too optimistic" here. See: https://scikit-learn.org/stable/modules/model_evaluation.html#precision-recall-f-measure-metrics Also, The function sklearn.metrics.average_precision_score does not use the rectangle rule, or any Riemann sum, right or otherwise. It uses "average precision." The formulas are very different. Note that f(x) is very, very different than Pi. Due to the formulas for precision and recall, the Average Precision is actually computing an average, with discrete values between 0 and 1. Regarding Riemann, f(x) = y. This gives you the height to multiply the delta with. There is no averaging there. Average precision is most analogous to the midpoint rule, as they are both doing averages. Note that R uses the same formula for Average Precision: https://www.rdocumentation.org/packages/yardstick/versions/0.0.4/topics/average_precision
Is it better to compute Average Precision using the trapezoidal rule or the rectangle method?
UPDATE This journal article explains why linear interpolation is both "too optimist" and is also "incorrect," due to the non-linear properties of the Precision-Recall curve: https://www.biostat.wisc.e
Is it better to compute Average Precision using the trapezoidal rule or the rectangle method? UPDATE This journal article explains why linear interpolation is both "too optimist" and is also "incorrect," due to the non-linear properties of the Precision-Recall curve: https://www.biostat.wisc.edu/~page/rocpr.pdf Due to the non-linear nature of the precision-response curve, linear interpolation results in erroneous overestimations. With an averaging rule, missed changes in slope average out. With interpolation, they do not. Thus if points don't cover all the slope changes in the real curve, interpolation errors add up. This is why interpolation is "too optimistic," and why the midpoint rule generally has half the error that the trapezoidal rule has. https://math.libretexts.org/Courses/Mount_Royal_University/MATH_2200%3A_Calculus_for_Scientists_II/2%3A_Techniques_of_Integration/2.5%3A_Numerical_Integration_-_Midpoint%2C_Trapezoid%2C_Simpson%27s_rule http://math.cmu.edu/~mittal/Recitation_notes.pdf https://activecalculus.org/single/sec-5-6-num-int.html This article is referenced as "[Davis2006]" in the scikit-learn documentation as the explanation as to why linear interpolation is inappropriate and "too optimistic" here. See: https://scikit-learn.org/stable/modules/model_evaluation.html#precision-recall-f-measure-metrics Also, The function sklearn.metrics.average_precision_score does not use the rectangle rule, or any Riemann sum, right or otherwise. It uses "average precision." The formulas are very different. Note that f(x) is very, very different than Pi. Due to the formulas for precision and recall, the Average Precision is actually computing an average, with discrete values between 0 and 1. Regarding Riemann, f(x) = y. This gives you the height to multiply the delta with. There is no averaging there. Average precision is most analogous to the midpoint rule, as they are both doing averages. Note that R uses the same formula for Average Precision: https://www.rdocumentation.org/packages/yardstick/versions/0.0.4/topics/average_precision
Is it better to compute Average Precision using the trapezoidal rule or the rectangle method? UPDATE This journal article explains why linear interpolation is both "too optimist" and is also "incorrect," due to the non-linear properties of the Precision-Recall curve: https://www.biostat.wisc.e
41,397
Is it better to compute Average Precision using the trapezoidal rule or the rectangle method?
For a piecewise linear function, using the trapezoidal rule with endpoints on each of the ends of the "pieces" will yield the exact area under the curve --- i.e., it is equivalent to integration under the curve. This occurs when the trapezoids correspond exactly with the lines in the piecewise linear function. (Of course, this does not hold if there are endpoints of the pieces in the function that are not endpoints of the trapezoids.) Contrarily, the rectangular method will not give an exact area under the curve, though it should be close if you use a large number of rectangles. As to which method is better, the exact method (trapezoidal) is better if it is computationally feasible. I am not aware of any particular reason why it should not be computationally more expensive than the rectangular method, since the only difference is that it uses the average height of each endpoint instead of the maximum height. If we partition the recall values using the endpoints $r_0 < r_1 < \cdots < r_n$ then we have: $$\begin{align} \text{Rectangular area} &= \sum_{k=1}^n (r_k - r_{k-1}) \times \max (P(r_k), P(r_{k-1})), \\[10pt] \text{Trapezoidal area} &= \sum_{k=1}^n (r_k - r_{k-1}) \times \frac{P(r_k) + P(r_{k-1})}{2}. \\[6pt] \end{align}$$ Assuming that these endpoints contain the endpoints of the piecewise linear function, it is simple to show that the trapezoidal area is the exact area under the curve.
Is it better to compute Average Precision using the trapezoidal rule or the rectangle method?
For a piecewise linear function, using the trapezoidal rule with endpoints on each of the ends of the "pieces" will yield the exact area under the curve --- i.e., it is equivalent to integration under
Is it better to compute Average Precision using the trapezoidal rule or the rectangle method? For a piecewise linear function, using the trapezoidal rule with endpoints on each of the ends of the "pieces" will yield the exact area under the curve --- i.e., it is equivalent to integration under the curve. This occurs when the trapezoids correspond exactly with the lines in the piecewise linear function. (Of course, this does not hold if there are endpoints of the pieces in the function that are not endpoints of the trapezoids.) Contrarily, the rectangular method will not give an exact area under the curve, though it should be close if you use a large number of rectangles. As to which method is better, the exact method (trapezoidal) is better if it is computationally feasible. I am not aware of any particular reason why it should not be computationally more expensive than the rectangular method, since the only difference is that it uses the average height of each endpoint instead of the maximum height. If we partition the recall values using the endpoints $r_0 < r_1 < \cdots < r_n$ then we have: $$\begin{align} \text{Rectangular area} &= \sum_{k=1}^n (r_k - r_{k-1}) \times \max (P(r_k), P(r_{k-1})), \\[10pt] \text{Trapezoidal area} &= \sum_{k=1}^n (r_k - r_{k-1}) \times \frac{P(r_k) + P(r_{k-1})}{2}. \\[6pt] \end{align}$$ Assuming that these endpoints contain the endpoints of the piecewise linear function, it is simple to show that the trapezoidal area is the exact area under the curve.
Is it better to compute Average Precision using the trapezoidal rule or the rectangle method? For a piecewise linear function, using the trapezoidal rule with endpoints on each of the ends of the "pieces" will yield the exact area under the curve --- i.e., it is equivalent to integration under
41,398
Does sample size affect choice between fixed and random effect
Some care is needed when talking about samples size in the context of mixed models. First, there is the overall (total) sample size, let's call it $N$ Then there is the number of subjects (cities in the case of your example), let's call it $n$ Then there is the number of observations within each subject (city). In observational studies this will often be different between each subject, so we need to index it. Let's index it by $i$ and call it $m_{i} \quad \forall i \in [1..n]$ Obviously we have that $$ \sum_{i=1}^{n} m_i = N$$ Note that apart from this condition, $N$ and $n$ are unrelated. $N$ could be very large, while $n$ can be small. For example in your case of cities you might samples thousands of participants from only 4 cities. $n$ is still 4, and exactly the same considerations apply as in your other question On the other hand we could have that $N$ is small and $n$ is large (subject to the condition noted above) which means we can have small clusters. In general, the question around the minimum sample size for the $m_i$ is a little tricky. Basically the minimum is 1, but if there are too many singleton clusters, there are going to be issues with statistical power and possibly model convergence. This question and it's answers should provide more background and detail on that. Then there is also another quantity known as the "effective sample size". This is related to the extent of correlation within the clusters. If there is no correlation, then random intercepts are not needed and the effective sample size is $N$, however when there are correlations then this is reduced by what is known as the design effect, $DE$: $$ DE = 1 +(m-1)\rho$$ where $m$ is the average cluster size and $\rho$ is the intraclass correlation coefficient (variance partition coefficient), and this applies when calculating sample sizes needed for overall linear statistics (means and totals). For regression coefficients it is a little more complicated.
Does sample size affect choice between fixed and random effect
Some care is needed when talking about samples size in the context of mixed models. First, there is the overall (total) sample size, let's call it $N$ Then there is the number of subjects (cities in t
Does sample size affect choice between fixed and random effect Some care is needed when talking about samples size in the context of mixed models. First, there is the overall (total) sample size, let's call it $N$ Then there is the number of subjects (cities in the case of your example), let's call it $n$ Then there is the number of observations within each subject (city). In observational studies this will often be different between each subject, so we need to index it. Let's index it by $i$ and call it $m_{i} \quad \forall i \in [1..n]$ Obviously we have that $$ \sum_{i=1}^{n} m_i = N$$ Note that apart from this condition, $N$ and $n$ are unrelated. $N$ could be very large, while $n$ can be small. For example in your case of cities you might samples thousands of participants from only 4 cities. $n$ is still 4, and exactly the same considerations apply as in your other question On the other hand we could have that $N$ is small and $n$ is large (subject to the condition noted above) which means we can have small clusters. In general, the question around the minimum sample size for the $m_i$ is a little tricky. Basically the minimum is 1, but if there are too many singleton clusters, there are going to be issues with statistical power and possibly model convergence. This question and it's answers should provide more background and detail on that. Then there is also another quantity known as the "effective sample size". This is related to the extent of correlation within the clusters. If there is no correlation, then random intercepts are not needed and the effective sample size is $N$, however when there are correlations then this is reduced by what is known as the design effect, $DE$: $$ DE = 1 +(m-1)\rho$$ where $m$ is the average cluster size and $\rho$ is the intraclass correlation coefficient (variance partition coefficient), and this applies when calculating sample sizes needed for overall linear statistics (means and totals). For regression coefficients it is a little more complicated.
Does sample size affect choice between fixed and random effect Some care is needed when talking about samples size in the context of mixed models. First, there is the overall (total) sample size, let's call it $N$ Then there is the number of subjects (cities in t
41,399
Demonstrating complete-pooling, no-pooling, and partial-pooling regression in R
So I went ahead and generated some data to demonstrate that these work as expected. library(tidyverse) library(lme4) if(!require(modelr)){ install.packages('modelr') } library(modelr) pop_mean<-10 n_groups<-4 groups<-gl(n_groups, 20) Z<-model.matrix(~groups-1) group_means<-rnorm(n_groups, 0, 2.5) y<- pop_mean + Z%*%group_means + rnorm(length(groups), 0, 0.5) d<-tibble(y, groups) The data generating mechanism from the top down is as follows... $$ \theta_i \sim \mathcal{N}(10, 2.5) $$ $$y_{i,j} \sim \mathcal{N}(\theta_i, 0.5) $$ Let's take a look at complete, no, and partial pooling. Complete Pooling This should return the same as the sample mean of y. This assumes that all the data are generated from a single normal distribution, with some mean and variance. The complete pooling uses all the data to estimate that one mean. complete_pooling<-lm(y~1, data = d) summary(complete_pooling) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 9.264 0.214 43.29 <2e-16 *** --- Signif. codes: 0 β€˜***’ 0.001 β€˜**’ 0.01 β€˜*’ 0.05 β€˜.’ 0.1 β€˜ ’ 1 Residual standard error: 1.914 on 79 degrees of freedom No Pooling In this scenario, we agree that the groups are distinct, but we estimate their means using the data from those groups. no_pooling<-lm(y~groups-1, data = d) #remove the intercept from the model summary(no_pooling) Coefficients: Estimate Std. Error t value Pr(>|t|) groups1 6.2116 0.1045 59.44 <2e-16 *** groups2 10.9183 0.1045 104.48 <2e-16 *** groups3 10.5156 0.1045 100.63 <2e-16 *** groups4 9.4088 0.1045 90.04 <2e-16 *** --- group_means + pop_means # pretty close >>> 6.311974 10.878787 10.354225 9.634138 So we estimate the group means fairly well. Partial Pooling partial_pooling<-lmer(y~ 1 + 1|groups, data = d) summary(partial_pooling) Random effects: Groups Name Variance Std.Dev. groups (Intercept) 4.5362 2.1298 Residual 0.2184 0.4673 Number of obs: 80, groups: groups, 4 Fixed effects: Estimate Std. Error t value (Intercept) 9.264 1.066 8.688 modelr::data_grid(d, groups) %>% modelr::add_predictions(partial_pooling) # A tibble: 4 x 2 groups pred <fct> <dbl> 1 1 6.22 2 2 10.9 3 3 10.5 4 4 9.41 As you can see, the estimates for the groups are partially pooled towards the population mean (they are slightly less extreme than the complete pooling model). Here is some code to reproduce these results. The results are not exactly the same because I didn't set the random seed when I wrote this. library(tidyverse) library(lme4) if(!require(modelr)){ install.packages('modelr') } library(modelr) #Generate data set.seed(123) pop_mean<-10 n_groups<-4 groups<-gl(n_groups, 20) Z<-model.matrix(~groups-1) group_means<-rnorm(n_groups, 0, 2.5) y<- pop_mean + Z%*%group_means + rnorm(length(groups), 0, 0.5) d = tibble(y, groups) complete_pooling<-lm(y~1, data = d) no_pooling<-lm(y~groups-1, data = d) partial_pooling<-lmer(y~ 1 + 1|groups, data = d) modelr::data_grid(d, groups) %>% modelr::add_predictions(partial_pooling) EDIT: Here is an example with a fixed effect. library(tidyverse) library(lme4) if(!require(modelr)){ install.packages('modelr') } library(modelr) #Generate data set.seed(123) pop_mean<-10 n_groups<-4 groups<-gl(n_groups, 20) x<-rnorm(length(groups)) Z<-model.matrix(~groups-1) group_means<-rnorm(n_groups, 0, 2.5) y<- pop_mean + 2*x + Z%*%group_means + rnorm(length(groups), 0, 0.5) d = tibble(y, groups,x) complete_pooling<-lm(y~x, data = d) no_pooling<-lm(y~groups + x -1, data = d) partial_pooling<-lmer(y~ x + 1 + 1|groups, data = d) modelr::data_grid(d, groups,x=0) %>% modelr::add_predictions(partial_pooling) You will note that the effect estimates in the partial pooling model are pooled towards the complete pooling estimates. They are ever so slightly closer.
Demonstrating complete-pooling, no-pooling, and partial-pooling regression in R
So I went ahead and generated some data to demonstrate that these work as expected. library(tidyverse) library(lme4) if(!require(modelr)){ install.packages('modelr') } library(modelr) pop_mean<-10
Demonstrating complete-pooling, no-pooling, and partial-pooling regression in R So I went ahead and generated some data to demonstrate that these work as expected. library(tidyverse) library(lme4) if(!require(modelr)){ install.packages('modelr') } library(modelr) pop_mean<-10 n_groups<-4 groups<-gl(n_groups, 20) Z<-model.matrix(~groups-1) group_means<-rnorm(n_groups, 0, 2.5) y<- pop_mean + Z%*%group_means + rnorm(length(groups), 0, 0.5) d<-tibble(y, groups) The data generating mechanism from the top down is as follows... $$ \theta_i \sim \mathcal{N}(10, 2.5) $$ $$y_{i,j} \sim \mathcal{N}(\theta_i, 0.5) $$ Let's take a look at complete, no, and partial pooling. Complete Pooling This should return the same as the sample mean of y. This assumes that all the data are generated from a single normal distribution, with some mean and variance. The complete pooling uses all the data to estimate that one mean. complete_pooling<-lm(y~1, data = d) summary(complete_pooling) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 9.264 0.214 43.29 <2e-16 *** --- Signif. codes: 0 β€˜***’ 0.001 β€˜**’ 0.01 β€˜*’ 0.05 β€˜.’ 0.1 β€˜ ’ 1 Residual standard error: 1.914 on 79 degrees of freedom No Pooling In this scenario, we agree that the groups are distinct, but we estimate their means using the data from those groups. no_pooling<-lm(y~groups-1, data = d) #remove the intercept from the model summary(no_pooling) Coefficients: Estimate Std. Error t value Pr(>|t|) groups1 6.2116 0.1045 59.44 <2e-16 *** groups2 10.9183 0.1045 104.48 <2e-16 *** groups3 10.5156 0.1045 100.63 <2e-16 *** groups4 9.4088 0.1045 90.04 <2e-16 *** --- group_means + pop_means # pretty close >>> 6.311974 10.878787 10.354225 9.634138 So we estimate the group means fairly well. Partial Pooling partial_pooling<-lmer(y~ 1 + 1|groups, data = d) summary(partial_pooling) Random effects: Groups Name Variance Std.Dev. groups (Intercept) 4.5362 2.1298 Residual 0.2184 0.4673 Number of obs: 80, groups: groups, 4 Fixed effects: Estimate Std. Error t value (Intercept) 9.264 1.066 8.688 modelr::data_grid(d, groups) %>% modelr::add_predictions(partial_pooling) # A tibble: 4 x 2 groups pred <fct> <dbl> 1 1 6.22 2 2 10.9 3 3 10.5 4 4 9.41 As you can see, the estimates for the groups are partially pooled towards the population mean (they are slightly less extreme than the complete pooling model). Here is some code to reproduce these results. The results are not exactly the same because I didn't set the random seed when I wrote this. library(tidyverse) library(lme4) if(!require(modelr)){ install.packages('modelr') } library(modelr) #Generate data set.seed(123) pop_mean<-10 n_groups<-4 groups<-gl(n_groups, 20) Z<-model.matrix(~groups-1) group_means<-rnorm(n_groups, 0, 2.5) y<- pop_mean + Z%*%group_means + rnorm(length(groups), 0, 0.5) d = tibble(y, groups) complete_pooling<-lm(y~1, data = d) no_pooling<-lm(y~groups-1, data = d) partial_pooling<-lmer(y~ 1 + 1|groups, data = d) modelr::data_grid(d, groups) %>% modelr::add_predictions(partial_pooling) EDIT: Here is an example with a fixed effect. library(tidyverse) library(lme4) if(!require(modelr)){ install.packages('modelr') } library(modelr) #Generate data set.seed(123) pop_mean<-10 n_groups<-4 groups<-gl(n_groups, 20) x<-rnorm(length(groups)) Z<-model.matrix(~groups-1) group_means<-rnorm(n_groups, 0, 2.5) y<- pop_mean + 2*x + Z%*%group_means + rnorm(length(groups), 0, 0.5) d = tibble(y, groups,x) complete_pooling<-lm(y~x, data = d) no_pooling<-lm(y~groups + x -1, data = d) partial_pooling<-lmer(y~ x + 1 + 1|groups, data = d) modelr::data_grid(d, groups,x=0) %>% modelr::add_predictions(partial_pooling) You will note that the effect estimates in the partial pooling model are pooled towards the complete pooling estimates. They are ever so slightly closer.
Demonstrating complete-pooling, no-pooling, and partial-pooling regression in R So I went ahead and generated some data to demonstrate that these work as expected. library(tidyverse) library(lme4) if(!require(modelr)){ install.packages('modelr') } library(modelr) pop_mean<-10
41,400
Why does the posterior predictive distribution involve an integral?
You don't exactly know $\omega$ but you have some idea, a distribution based on the previous data you've seen, which is described by $p(\omega|X,Y)$. If you had a constant $\omega_0$, the posterior predictive distribution would be $p(y^*|x^*,\omega_0)$, but the integral is basically an expected value (i.e. a weighted average) over all possible $\omega$. By the way, the integral is at the same time comes from total probability law: $$p(y^*|x^*,X,Y)=\int \underbrace{p(y^*|x^*,\omega,X,Y)p(\omega|X,Y)}_{p(y,\omega|x^*,X,Y)}d\omega=\int p(y^*|x^*,\omega)p(\omega|X,Y)d\omega$$ The first term inside the integral is simplified as $p(y^*|x^*,\omega,X,Y)=p(y^*|x^*,\omega)$, because when you actually know the model parameters, you don't need the training data to learn them. So, given the input $x^*$, the output $y^*$ is assumed to be dependent on only the model parameters, $\omega$.
Why does the posterior predictive distribution involve an integral?
You don't exactly know $\omega$ but you have some idea, a distribution based on the previous data you've seen, which is described by $p(\omega|X,Y)$. If you had a constant $\omega_0$, the posterior pr
Why does the posterior predictive distribution involve an integral? You don't exactly know $\omega$ but you have some idea, a distribution based on the previous data you've seen, which is described by $p(\omega|X,Y)$. If you had a constant $\omega_0$, the posterior predictive distribution would be $p(y^*|x^*,\omega_0)$, but the integral is basically an expected value (i.e. a weighted average) over all possible $\omega$. By the way, the integral is at the same time comes from total probability law: $$p(y^*|x^*,X,Y)=\int \underbrace{p(y^*|x^*,\omega,X,Y)p(\omega|X,Y)}_{p(y,\omega|x^*,X,Y)}d\omega=\int p(y^*|x^*,\omega)p(\omega|X,Y)d\omega$$ The first term inside the integral is simplified as $p(y^*|x^*,\omega,X,Y)=p(y^*|x^*,\omega)$, because when you actually know the model parameters, you don't need the training data to learn them. So, given the input $x^*$, the output $y^*$ is assumed to be dependent on only the model parameters, $\omega$.
Why does the posterior predictive distribution involve an integral? You don't exactly know $\omega$ but you have some idea, a distribution based on the previous data you've seen, which is described by $p(\omega|X,Y)$. If you had a constant $\omega_0$, the posterior pr