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 |
|---|---|---|---|---|---|---|
17,701 | When data has a gaussian distribution, how many samples will characterise it? | Some brief numerics gives the following error distributions for the fit of 30 samples created from a standard normal distribution then fit to a univariate Gaussian.
The quartiles are indicated. It is assumed that this level of variation is desired in the multi-dimensional case.
I don't have the time to beat up MatLab to get the total result, so I will share my "rule of thumb". The 30 is provided as a rule of thumb, or heuristic so it is assumed that heuristics are not unacceptable.
My heuristic is to use Pascal's triangle multiplied by the univariate case.
If I am using 2d data then I go to the 2nd row and sum it to get 2x the number of samples, or 60 samples.
For 3d data I go to the 3rd row and sum it to get 4x the number of samples or 120 samples. For 5d data I go to the 5th row and sum it to get 16x the number of samples, or 480 samples.
Best of luck.
EDIT:
It was intuitive, but everything has to be defended in math. I can't just take leaps from formulation of polynomial forms from Finite Elements with experience to get a ballpark.
The equation for the sum of the $ k^{th}$ row of Pascal's triangle is $ 2^k$.
My idea for the approach here is to equate the AIC of a higher-dimensional distribution with more samples to a reduced dimensional distribution with fewer samples.
The Akaike Information Criterion (AIC) is defined as $ AIC = n \log( \frac {RSS}{n}) + 2*k$ where $ RSS$ is residual sum of squares, $ n$ is sample count, and $ k$ is parameter count for the model.
$ AIC_1 = AIC_2$
$ n_1 \log(\frac {RSS_1}{n_1}) +2k_1 = n_2 \log(\frac {RSS_2}{n_2}) +2k_2$
For each dimension that we eliminate this means that the mean loses a row and the covariance loses both a row and a column. We can state this as
$ k \left( d\right)= d^2+d$.
of
$k \left( d+1 \right) - k \left( d\right) = 2 d + 2$
Assuming the error per sample point is constant relates the residual sum of squares to the sample count, and the term in the logarithm stays constant. The difference in sample count becomes a scaling constant.
so we have:
$ n_1 A +2(k_2+2d+2) = n_2 A +2k_2 $
solving for the increase in samples with dimension gives:
$ n_2- n_1 = (2(k_2+2d+2) - 2k_2) A^{-1} = (4 d+4 ) \cdot A^{-1} $
So what is the scaling function? Lets assume that for a 2-dimensional multivariate Gaussian the number of samples required is 15 per parameter. There are 2 means and 4 elements of the covariance therefore 6 parameters or 90 samples. The difference is 60 samples, the value of $ A^{-1} = 5$.
At this point I would say that the heuristic starts a little low but ends up being about 2x the number of samples required. Its range of best utility, in my personal opinion, is around 4 dimensions or so.
EDIT:
So I have read the answer of @whuber and I like it. It is empirical, and in this case that is authoritative. I voted for his answer.
In the following I am attempting to discuss and hoping to be able to use more than ~300 characters, and I am hoping to be able to embed pictures. I am therefore discussing within the bounds of the answer. I hope this is okay.
I am at this point not convinced that use of AIC for this, or how sample size and parameter sizes were used was incorrect.
Next steps:
replicate @whuber's results, confirm them empirically
Test the AIC, at least in some ensemble sense, to confirm whether it is appropriate
If AIC is appropriate, then try to use empirical methods to chase down flaw in reasoning.
Comments and suggestions welcome. | When data has a gaussian distribution, how many samples will characterise it? | Some brief numerics gives the following error distributions for the fit of 30 samples created from a standard normal distribution then fit to a univariate Gaussian.
The quartiles are indicated. It i | When data has a gaussian distribution, how many samples will characterise it?
Some brief numerics gives the following error distributions for the fit of 30 samples created from a standard normal distribution then fit to a univariate Gaussian.
The quartiles are indicated. It is assumed that this level of variation is desired in the multi-dimensional case.
I don't have the time to beat up MatLab to get the total result, so I will share my "rule of thumb". The 30 is provided as a rule of thumb, or heuristic so it is assumed that heuristics are not unacceptable.
My heuristic is to use Pascal's triangle multiplied by the univariate case.
If I am using 2d data then I go to the 2nd row and sum it to get 2x the number of samples, or 60 samples.
For 3d data I go to the 3rd row and sum it to get 4x the number of samples or 120 samples. For 5d data I go to the 5th row and sum it to get 16x the number of samples, or 480 samples.
Best of luck.
EDIT:
It was intuitive, but everything has to be defended in math. I can't just take leaps from formulation of polynomial forms from Finite Elements with experience to get a ballpark.
The equation for the sum of the $ k^{th}$ row of Pascal's triangle is $ 2^k$.
My idea for the approach here is to equate the AIC of a higher-dimensional distribution with more samples to a reduced dimensional distribution with fewer samples.
The Akaike Information Criterion (AIC) is defined as $ AIC = n \log( \frac {RSS}{n}) + 2*k$ where $ RSS$ is residual sum of squares, $ n$ is sample count, and $ k$ is parameter count for the model.
$ AIC_1 = AIC_2$
$ n_1 \log(\frac {RSS_1}{n_1}) +2k_1 = n_2 \log(\frac {RSS_2}{n_2}) +2k_2$
For each dimension that we eliminate this means that the mean loses a row and the covariance loses both a row and a column. We can state this as
$ k \left( d\right)= d^2+d$.
of
$k \left( d+1 \right) - k \left( d\right) = 2 d + 2$
Assuming the error per sample point is constant relates the residual sum of squares to the sample count, and the term in the logarithm stays constant. The difference in sample count becomes a scaling constant.
so we have:
$ n_1 A +2(k_2+2d+2) = n_2 A +2k_2 $
solving for the increase in samples with dimension gives:
$ n_2- n_1 = (2(k_2+2d+2) - 2k_2) A^{-1} = (4 d+4 ) \cdot A^{-1} $
So what is the scaling function? Lets assume that for a 2-dimensional multivariate Gaussian the number of samples required is 15 per parameter. There are 2 means and 4 elements of the covariance therefore 6 parameters or 90 samples. The difference is 60 samples, the value of $ A^{-1} = 5$.
At this point I would say that the heuristic starts a little low but ends up being about 2x the number of samples required. Its range of best utility, in my personal opinion, is around 4 dimensions or so.
EDIT:
So I have read the answer of @whuber and I like it. It is empirical, and in this case that is authoritative. I voted for his answer.
In the following I am attempting to discuss and hoping to be able to use more than ~300 characters, and I am hoping to be able to embed pictures. I am therefore discussing within the bounds of the answer. I hope this is okay.
I am at this point not convinced that use of AIC for this, or how sample size and parameter sizes were used was incorrect.
Next steps:
replicate @whuber's results, confirm them empirically
Test the AIC, at least in some ensemble sense, to confirm whether it is appropriate
If AIC is appropriate, then try to use empirical methods to chase down flaw in reasoning.
Comments and suggestions welcome. | When data has a gaussian distribution, how many samples will characterise it?
Some brief numerics gives the following error distributions for the fit of 30 samples created from a standard normal distribution then fit to a univariate Gaussian.
The quartiles are indicated. It i |
17,702 | When data has a gaussian distribution, how many samples will characterise it? | Theorem 9.2.4 from Vershynin's "High Dimensional Probability" book gives a dimension-free sample complexity of estimating covariance matrix | When data has a gaussian distribution, how many samples will characterise it? | Theorem 9.2.4 from Vershynin's "High Dimensional Probability" book gives a dimension-free sample complexity of estimating covariance matrix | When data has a gaussian distribution, how many samples will characterise it?
Theorem 9.2.4 from Vershynin's "High Dimensional Probability" book gives a dimension-free sample complexity of estimating covariance matrix | When data has a gaussian distribution, how many samples will characterise it?
Theorem 9.2.4 from Vershynin's "High Dimensional Probability" book gives a dimension-free sample complexity of estimating covariance matrix |
17,703 | Partitioning trees in R: party vs. rpart | I agree with @Iterator that the methodology is easier to explain for rpart. However, if you are looking for easily explainable rules, party (without bagged trees) doesn't lose anything in regard to explaining the prediction - you still have a single tree. If you are also interested in looking at drivers of the outcome variable (not just pure predictive power) I would still think that party is the way to go - explaining that a decision tree (like rpart) can be quite biased in how it selects which variables are important and how it creates splits. Party uses permutation tests and statistically determine which variables are most important and how the splits are made. So, instead of biased leaning towards categorical variables with many levels, like rpart for example, party uses statistical tests to find the best structure. | Partitioning trees in R: party vs. rpart | I agree with @Iterator that the methodology is easier to explain for rpart. However, if you are looking for easily explainable rules, party (without bagged trees) doesn't lose anything in regard to ex | Partitioning trees in R: party vs. rpart
I agree with @Iterator that the methodology is easier to explain for rpart. However, if you are looking for easily explainable rules, party (without bagged trees) doesn't lose anything in regard to explaining the prediction - you still have a single tree. If you are also interested in looking at drivers of the outcome variable (not just pure predictive power) I would still think that party is the way to go - explaining that a decision tree (like rpart) can be quite biased in how it selects which variables are important and how it creates splits. Party uses permutation tests and statistically determine which variables are most important and how the splits are made. So, instead of biased leaning towards categorical variables with many levels, like rpart for example, party uses statistical tests to find the best structure. | Partitioning trees in R: party vs. rpart
I agree with @Iterator that the methodology is easier to explain for rpart. However, if you are looking for easily explainable rules, party (without bagged trees) doesn't lose anything in regard to ex |
17,704 | Partitioning trees in R: party vs. rpart | [NB: See update 1 below.]
I find that the methodology for rpart is far easier to explain than party. The latter, however, is much more sophisticated and likely to give better models. The way I sometimes explain party is to speak of it as basis for producing local linear (or GLM) models. I build up to this by pointing out that the results for rpart are constant across all elements that fall into the leaf node, i.e. the box/region bounded by the splits. Even if there might be improvements via local models, you don't get anything but a constant prediction.
In contrast, party develops the splits to potentially optimize the models for the regions. It is actually using a different criteria than model optimality, but you need to gauge your own capacity for explaining the difference to determine whether you can explain it well. The papers for it are pretty accessible for a researcher, but may be quite challenging for someone not willing to consider simpler methods like random forests, boosting, etc. Mathematically, I think that party is more sophisticated... Nonetheless, CART models are easier to explain, both in terms of methodology and results, and these provide a decent stepping stone for introducing more sophisticated tree-based models.
In short, I would say that you have to do rpart for clarity, and you can use party for accuracy / peformance, but I wouldn't introduce party without introducing rpart.
Update 1. I based my answer on my understanding of party as it was a year or two ago. It has grown up quite a bit, but I would modify my answer to say that I'd still recommend rpart for its brevity and legacy, should "non-fancy" be an important criterion for your client/collaborator. Yet, I would try to migrate to using more functionality from party, after having introduced someone to rpart. It's better to start small, with loss functions, splitting criteria, etc., in a simple context, before introducing a package and methodology that involve far more involved concepts. | Partitioning trees in R: party vs. rpart | [NB: See update 1 below.]
I find that the methodology for rpart is far easier to explain than party. The latter, however, is much more sophisticated and likely to give better models. The way I somet | Partitioning trees in R: party vs. rpart
[NB: See update 1 below.]
I find that the methodology for rpart is far easier to explain than party. The latter, however, is much more sophisticated and likely to give better models. The way I sometimes explain party is to speak of it as basis for producing local linear (or GLM) models. I build up to this by pointing out that the results for rpart are constant across all elements that fall into the leaf node, i.e. the box/region bounded by the splits. Even if there might be improvements via local models, you don't get anything but a constant prediction.
In contrast, party develops the splits to potentially optimize the models for the regions. It is actually using a different criteria than model optimality, but you need to gauge your own capacity for explaining the difference to determine whether you can explain it well. The papers for it are pretty accessible for a researcher, but may be quite challenging for someone not willing to consider simpler methods like random forests, boosting, etc. Mathematically, I think that party is more sophisticated... Nonetheless, CART models are easier to explain, both in terms of methodology and results, and these provide a decent stepping stone for introducing more sophisticated tree-based models.
In short, I would say that you have to do rpart for clarity, and you can use party for accuracy / peformance, but I wouldn't introduce party without introducing rpart.
Update 1. I based my answer on my understanding of party as it was a year or two ago. It has grown up quite a bit, but I would modify my answer to say that I'd still recommend rpart for its brevity and legacy, should "non-fancy" be an important criterion for your client/collaborator. Yet, I would try to migrate to using more functionality from party, after having introduced someone to rpart. It's better to start small, with loss functions, splitting criteria, etc., in a simple context, before introducing a package and methodology that involve far more involved concepts. | Partitioning trees in R: party vs. rpart
[NB: See update 1 below.]
I find that the methodology for rpart is far easier to explain than party. The latter, however, is much more sophisticated and likely to give better models. The way I somet |
17,705 | Computing the mode of data sampled from a continuous distribution | In R, applying the method that isn't based on parametric modelling of the underlying distribution and uses the default kernel estimator of density to 10000 gamma distributed variables:
x <- rgamma(10000, 2, 5)
z <- density(x)
plot(z) # always good to check visually
z$x[z$y==max(z$y)]
returns 0.199 which is the value of x estimated to have the highest density (the density estimates are stored as "z$y"). | Computing the mode of data sampled from a continuous distribution | In R, applying the method that isn't based on parametric modelling of the underlying distribution and uses the default kernel estimator of density to 10000 gamma distributed variables:
x <- rgamma(100 | Computing the mode of data sampled from a continuous distribution
In R, applying the method that isn't based on parametric modelling of the underlying distribution and uses the default kernel estimator of density to 10000 gamma distributed variables:
x <- rgamma(10000, 2, 5)
z <- density(x)
plot(z) # always good to check visually
z$x[z$y==max(z$y)]
returns 0.199 which is the value of x estimated to have the highest density (the density estimates are stored as "z$y"). | Computing the mode of data sampled from a continuous distribution
In R, applying the method that isn't based on parametric modelling of the underlying distribution and uses the default kernel estimator of density to 10000 gamma distributed variables:
x <- rgamma(100 |
17,706 | Computing the mode of data sampled from a continuous distribution | Suppose you make a histogram, of bin size b, and the largest bin has k entries, from your total sample of size n. Then the average PDF within that bin can be estimated as b*k/n.
The problem is that another bin, which has fewer total members, could have a high spot density. You can only know about this if you have a reasonable assumption about the rate of change of the PDF. If you do, then you can estimate the probability that the second largest bin actually contains the mode.
The underlying problem is this. A sample provides good knowledge of the CDF, by the Kolmogorov-Smirnov theorem, and so a good estimate of median and other quantiles. But knowing an approximation to a function in L1 does not provide approximate knowledge of its derivative. So no sample provides good knowledge of the PDF, without additional assumptions. | Computing the mode of data sampled from a continuous distribution | Suppose you make a histogram, of bin size b, and the largest bin has k entries, from your total sample of size n. Then the average PDF within that bin can be estimated as b*k/n.
The problem is that a | Computing the mode of data sampled from a continuous distribution
Suppose you make a histogram, of bin size b, and the largest bin has k entries, from your total sample of size n. Then the average PDF within that bin can be estimated as b*k/n.
The problem is that another bin, which has fewer total members, could have a high spot density. You can only know about this if you have a reasonable assumption about the rate of change of the PDF. If you do, then you can estimate the probability that the second largest bin actually contains the mode.
The underlying problem is this. A sample provides good knowledge of the CDF, by the Kolmogorov-Smirnov theorem, and so a good estimate of median and other quantiles. But knowing an approximation to a function in L1 does not provide approximate knowledge of its derivative. So no sample provides good knowledge of the PDF, without additional assumptions. | Computing the mode of data sampled from a continuous distribution
Suppose you make a histogram, of bin size b, and the largest bin has k entries, from your total sample of size n. Then the average PDF within that bin can be estimated as b*k/n.
The problem is that a |
17,707 | Computing the mode of data sampled from a continuous distribution | Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
In order to calculate the mode of a continious distribution in python I suggest three options. Scipy have scipy.stats.mode(data)[0] but it's not exact. For the three options after we need to get an approximation of de PDF function of the data. An excellent method is Gaussian Kernel
Density Estimation(WIKIPEDIA). With scipy we can use distribution = scipy.stats.gaussian_kde(data) and get pdf value of the dataset with distribution.pdf(x)[0]. The three methods search the max value of the distribution and get the preimage of the value in the the domian. The first use scipy minimize method, the second use max() native function, and the third SHGO scipy method. Here and imgage of comparison:
And the complete code:
import numpy as np
import scipy.stats
import scipy.optimize
import matplotlib as mpl
import matplotlib.pyplot as plt
import random
mpl.style.use("ggplot")
def plot_histogram(data, distribution, modes):
plt.figure(figsize=(8, 4))
plt.hist(data, density=True, ec='white')
plt.title('HISTOGRAM')
plt.xlabel('Values')
plt.ylabel('Frequencies')
x_plot = np.linspace(min(data), max(data), 1000)
y_plot = distribution.pdf(x_plot)
plt.plot(x_plot, y_plot, linewidth=4, label="PDF KDE")
for name, mode in modes.items():
plt.axvline(mode, linewidth=2, label=name+": "+str(mode)[:7], color=(random.uniform(0, 1), random.uniform(0, 1), random.uniform(0, 1)))
plt.legend(title='DISTRIBUTIONS', bbox_to_anchor=(1.05, 1), loc='upper left')
plt.show()
## SCIPY MODE
def calc_scipy_mode(data):
return scipy.stats.mode(data)[0]
## METHOD 1: MAXIMIZE PDF SCIPY MINIMIZE
def calc_minimize_mode(data, distribution):
def objective(x):
return 1/distribution.pdf(x)[0]
bnds = [(min(data), max(data))]
solution = scipy.optimize.minimize(objective, [1], bounds = bnds)
return solution.x[0]
## METHOD 2: MAXIMIZE PDF AND GET PREIMAGE
def calc_max_pdf_mode(data, distribution):
x_domain = np.linspace(min(data), max(data), 1000)
y_pdf = distribution.pdf(x_domain)
i = np.argmax(y_pdf)
return x_domain[i]
## METHOD 3: ## METHOD 3: MAXIMIZE PDF SCIPY SHGO
def calc_shgo_mode(data, distribution):
def objective(x):
return 1/distribution.pdf(x)[0]
bnds = [[min(data), max(data)]]
solution = scipy.optimize.shgo(objective, bounds= bnds, n=100*len(data))
return solution.x[0]
def calculate_mode(data):
## KDE
distribution = scipy.stats.gaussian_kde(data)
scipy_mode = calc_scipy_mode(data)[0]
minimize_mode = calc_minimize_mode(data, distribution)
max_pdf_mode = calc_max_pdf_mode(data, distribution)
shgo_mode = calc_shgo_mode(data, distribution)
modes = {
"scipy_mode": scipy_mode,
"minimize_mode": minimize_mode,
"max_pdf_mode": max_pdf_mode,
"shgo_mode": shgo_mode
}
plot_histogram(data, distribution, modes)
if __name__ == "__main__":
data = [d1, d2, d3, ..........]
calculate_mode(data) | Computing the mode of data sampled from a continuous distribution | Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
| Computing the mode of data sampled from a continuous distribution
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
In order to calculate the mode of a continious distribution in python I suggest three options. Scipy have scipy.stats.mode(data)[0] but it's not exact. For the three options after we need to get an approximation of de PDF function of the data. An excellent method is Gaussian Kernel
Density Estimation(WIKIPEDIA). With scipy we can use distribution = scipy.stats.gaussian_kde(data) and get pdf value of the dataset with distribution.pdf(x)[0]. The three methods search the max value of the distribution and get the preimage of the value in the the domian. The first use scipy minimize method, the second use max() native function, and the third SHGO scipy method. Here and imgage of comparison:
And the complete code:
import numpy as np
import scipy.stats
import scipy.optimize
import matplotlib as mpl
import matplotlib.pyplot as plt
import random
mpl.style.use("ggplot")
def plot_histogram(data, distribution, modes):
plt.figure(figsize=(8, 4))
plt.hist(data, density=True, ec='white')
plt.title('HISTOGRAM')
plt.xlabel('Values')
plt.ylabel('Frequencies')
x_plot = np.linspace(min(data), max(data), 1000)
y_plot = distribution.pdf(x_plot)
plt.plot(x_plot, y_plot, linewidth=4, label="PDF KDE")
for name, mode in modes.items():
plt.axvline(mode, linewidth=2, label=name+": "+str(mode)[:7], color=(random.uniform(0, 1), random.uniform(0, 1), random.uniform(0, 1)))
plt.legend(title='DISTRIBUTIONS', bbox_to_anchor=(1.05, 1), loc='upper left')
plt.show()
## SCIPY MODE
def calc_scipy_mode(data):
return scipy.stats.mode(data)[0]
## METHOD 1: MAXIMIZE PDF SCIPY MINIMIZE
def calc_minimize_mode(data, distribution):
def objective(x):
return 1/distribution.pdf(x)[0]
bnds = [(min(data), max(data))]
solution = scipy.optimize.minimize(objective, [1], bounds = bnds)
return solution.x[0]
## METHOD 2: MAXIMIZE PDF AND GET PREIMAGE
def calc_max_pdf_mode(data, distribution):
x_domain = np.linspace(min(data), max(data), 1000)
y_pdf = distribution.pdf(x_domain)
i = np.argmax(y_pdf)
return x_domain[i]
## METHOD 3: ## METHOD 3: MAXIMIZE PDF SCIPY SHGO
def calc_shgo_mode(data, distribution):
def objective(x):
return 1/distribution.pdf(x)[0]
bnds = [[min(data), max(data)]]
solution = scipy.optimize.shgo(objective, bounds= bnds, n=100*len(data))
return solution.x[0]
def calculate_mode(data):
## KDE
distribution = scipy.stats.gaussian_kde(data)
scipy_mode = calc_scipy_mode(data)[0]
minimize_mode = calc_minimize_mode(data, distribution)
max_pdf_mode = calc_max_pdf_mode(data, distribution)
shgo_mode = calc_shgo_mode(data, distribution)
modes = {
"scipy_mode": scipy_mode,
"minimize_mode": minimize_mode,
"max_pdf_mode": max_pdf_mode,
"shgo_mode": shgo_mode
}
plot_histogram(data, distribution, modes)
if __name__ == "__main__":
data = [d1, d2, d3, ..........]
calculate_mode(data) | Computing the mode of data sampled from a continuous distribution
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
|
17,708 | Computing the mode of data sampled from a continuous distribution | Recently I faced a similar problem, and came up with this code in Wolfram Mathematica:
ModeEstimate[data_?VectorQ] :=
MaximalBy[data, PDF[SmoothKernelDistribution[data]], 1][[1]];
But keep in mind it is a rough estimate, and can even be totally wrong if the actual continuous distribution has narrow peaks that are not adequately represented in the sample, or the sample happens to contain sporadic clusters of values. I believe there is no way to quantify uncertainty in the computed estimate without additional information about the actual distribution.
SmoothKernelDistribution function has various options that you can try to adjust to get better results for your specific use cases. | Computing the mode of data sampled from a continuous distribution | Recently I faced a similar problem, and came up with this code in Wolfram Mathematica:
ModeEstimate[data_?VectorQ] :=
MaximalBy[data, PDF[SmoothKernelDistribution[data]], 1][[1]];
But keep in mind | Computing the mode of data sampled from a continuous distribution
Recently I faced a similar problem, and came up with this code in Wolfram Mathematica:
ModeEstimate[data_?VectorQ] :=
MaximalBy[data, PDF[SmoothKernelDistribution[data]], 1][[1]];
But keep in mind it is a rough estimate, and can even be totally wrong if the actual continuous distribution has narrow peaks that are not adequately represented in the sample, or the sample happens to contain sporadic clusters of values. I believe there is no way to quantify uncertainty in the computed estimate without additional information about the actual distribution.
SmoothKernelDistribution function has various options that you can try to adjust to get better results for your specific use cases. | Computing the mode of data sampled from a continuous distribution
Recently I faced a similar problem, and came up with this code in Wolfram Mathematica:
ModeEstimate[data_?VectorQ] :=
MaximalBy[data, PDF[SmoothKernelDistribution[data]], 1][[1]];
But keep in mind |
17,709 | Computing the mode of data sampled from a continuous distribution | Here are some general solution sketches that also work for high-dimensional distributions:
Train an f-GAN with reverse KL divergence, without giving any random input to the generator (i.e. force it to be deterministic).
Train an f-GAN with reverse KL divergence, move the input distribution to the generator towards a Dirac delta function as training progresses, and add a gradient penalty to the generator loss function.
Train a (differentiable) generative model that can tractably evaluate an approximation of the pdf at any point (I believe that e.g. a VAE, a flow-based model, or an autoregressive model would do). Then use some type of optimization (some flavor of gradient ascent can be used if model inference is differentiable) to find a maximum of that approximation. | Computing the mode of data sampled from a continuous distribution | Here are some general solution sketches that also work for high-dimensional distributions:
Train an f-GAN with reverse KL divergence, without giving any random input to the generator (i.e. force it t | Computing the mode of data sampled from a continuous distribution
Here are some general solution sketches that also work for high-dimensional distributions:
Train an f-GAN with reverse KL divergence, without giving any random input to the generator (i.e. force it to be deterministic).
Train an f-GAN with reverse KL divergence, move the input distribution to the generator towards a Dirac delta function as training progresses, and add a gradient penalty to the generator loss function.
Train a (differentiable) generative model that can tractably evaluate an approximation of the pdf at any point (I believe that e.g. a VAE, a flow-based model, or an autoregressive model would do). Then use some type of optimization (some flavor of gradient ascent can be used if model inference is differentiable) to find a maximum of that approximation. | Computing the mode of data sampled from a continuous distribution
Here are some general solution sketches that also work for high-dimensional distributions:
Train an f-GAN with reverse KL divergence, without giving any random input to the generator (i.e. force it t |
17,710 | What is a 'message passing method'? | Since you ask for references, I can recommend chapter 16 of David MacKay's Information Theory, Inference, and Learning Algorithms. (you don't need to read the previous 15 chapters to understand ch. 16) The book is free for downloading from the author's website (with permission from the publisher).
For an interesting example, check out the thesis of John Winn. Uses a message passing algorithm for generic Variational Ensemble Learning - enabling simple construction of inference problems such as ICA and PCA. | What is a 'message passing method'? | Since you ask for references, I can recommend chapter 16 of David MacKay's Information Theory, Inference, and Learning Algorithms. (you don't need to read the previous 15 chapters to understand ch. 1 | What is a 'message passing method'?
Since you ask for references, I can recommend chapter 16 of David MacKay's Information Theory, Inference, and Learning Algorithms. (you don't need to read the previous 15 chapters to understand ch. 16) The book is free for downloading from the author's website (with permission from the publisher).
For an interesting example, check out the thesis of John Winn. Uses a message passing algorithm for generic Variational Ensemble Learning - enabling simple construction of inference problems such as ICA and PCA. | What is a 'message passing method'?
Since you ask for references, I can recommend chapter 16 of David MacKay's Information Theory, Inference, and Learning Algorithms. (you don't need to read the previous 15 chapters to understand ch. 1 |
17,711 | What is a 'message passing method'? | Maybe the article on belief propagation will be helpful.
The article gives a two bullet point description of how "messages" are passed along edges in a factor graph. This "message passing" can be done for any graph. For trees the algorithm is exact in the sense that it gives the computation of desired marginal and joint distributions of the nodes in the tree. Iterations of the algorithm for general graphs are attempts to produce approximations of the desired marginal or joint distributions. | What is a 'message passing method'? | Maybe the article on belief propagation will be helpful.
The article gives a two bullet point description of how "messages" are passed along edges in a factor graph. This "message passing" can be don | What is a 'message passing method'?
Maybe the article on belief propagation will be helpful.
The article gives a two bullet point description of how "messages" are passed along edges in a factor graph. This "message passing" can be done for any graph. For trees the algorithm is exact in the sense that it gives the computation of desired marginal and joint distributions of the nodes in the tree. Iterations of the algorithm for general graphs are attempts to produce approximations of the desired marginal or joint distributions. | What is a 'message passing method'?
Maybe the article on belief propagation will be helpful.
The article gives a two bullet point description of how "messages" are passed along edges in a factor graph. This "message passing" can be don |
17,712 | Hamiltonian Monte Carlo: how to make sense of the Metropolis-Hasting proposal? | The deterministic Hamiltonian trajectories are useful only because they are consistent with the target distribution. In particular, trajectories with a typical energy project onto regions of high probability of the target distribution. If we could integrate Hamilton's equations exactly and construct explicit Hamiltonian trajectories then we would have a complete algorithm already and not need any acceptance step.
Unfortunately outside of a few very simple examples we can't integrate Hamilton's equations exactly. That's why we have to bring in symplectic integrators. Symplectic integrators are used to construct high accuracy numerical approximations to the exact Hamiltonian trajectories that we can't solve analytically. The small error inherent in symplectic integrators causes these numerical trajectories to deviate away from the true trajectories, and hence the projections of the numerical trajectories will deviate away from the typical set of the target distribution. We need to introduce a way to correct for this deviation.
The original implementation of Hamiltonian Monte Carlo considered the final point in a trajectory of fixed length as a proposal, and then applied a Metropolis acceptance procedure to that proposal. If the numerical trajectory had accumulated too much error, and hence deviated too far from the initial energy, then that proposed would be rejected. In other words, the acceptance procedure throws away proposals that end up projecting too far away from the typical set of the target distribution so that the only samples we keep are those that fall into the typical set.
Note that the more modern implementations that I advocate for in the Conceptual paper are not in fact Metropolis-Hastings algorithms. Sampling a random trajectory and then a random point from that random trajectory is a more general way to correct for the numerical error introduced by symplectic integrators. Metropolis-Hastings is just one way to implement this more general algorithm, but slice sampling (as done in NUTS) and multinomial sampling (as currently done in Stan) work just as well if not better. But ultimately the intuition is the same -- we're probabilistically selecting points with small numerical error to ensure exact samples from the target distribution. | Hamiltonian Monte Carlo: how to make sense of the Metropolis-Hasting proposal? | The deterministic Hamiltonian trajectories are useful only because they are consistent with the target distribution. In particular, trajectories with a typical energy project onto regions of high pro | Hamiltonian Monte Carlo: how to make sense of the Metropolis-Hasting proposal?
The deterministic Hamiltonian trajectories are useful only because they are consistent with the target distribution. In particular, trajectories with a typical energy project onto regions of high probability of the target distribution. If we could integrate Hamilton's equations exactly and construct explicit Hamiltonian trajectories then we would have a complete algorithm already and not need any acceptance step.
Unfortunately outside of a few very simple examples we can't integrate Hamilton's equations exactly. That's why we have to bring in symplectic integrators. Symplectic integrators are used to construct high accuracy numerical approximations to the exact Hamiltonian trajectories that we can't solve analytically. The small error inherent in symplectic integrators causes these numerical trajectories to deviate away from the true trajectories, and hence the projections of the numerical trajectories will deviate away from the typical set of the target distribution. We need to introduce a way to correct for this deviation.
The original implementation of Hamiltonian Monte Carlo considered the final point in a trajectory of fixed length as a proposal, and then applied a Metropolis acceptance procedure to that proposal. If the numerical trajectory had accumulated too much error, and hence deviated too far from the initial energy, then that proposed would be rejected. In other words, the acceptance procedure throws away proposals that end up projecting too far away from the typical set of the target distribution so that the only samples we keep are those that fall into the typical set.
Note that the more modern implementations that I advocate for in the Conceptual paper are not in fact Metropolis-Hastings algorithms. Sampling a random trajectory and then a random point from that random trajectory is a more general way to correct for the numerical error introduced by symplectic integrators. Metropolis-Hastings is just one way to implement this more general algorithm, but slice sampling (as done in NUTS) and multinomial sampling (as currently done in Stan) work just as well if not better. But ultimately the intuition is the same -- we're probabilistically selecting points with small numerical error to ensure exact samples from the target distribution. | Hamiltonian Monte Carlo: how to make sense of the Metropolis-Hasting proposal?
The deterministic Hamiltonian trajectories are useful only because they are consistent with the target distribution. In particular, trajectories with a typical energy project onto regions of high pro |
17,713 | Undergraduate-level proofs of the Pitman–Koopman–Darmois theorem | The reason the Lemma is called Pitman-Koopman-Darmois is, unsurprisingly, that the three authors established similar versions of the lemma, independently at about the same time:
Darmois, G. (1935) Sur les lois de probabilité à estimation
exhaustive, Comptes Rendus de l'Académie des Sciences, 200,
1265-1266.
Koopman, B.O. (1936) On Distributions Admitting a Sufficient
Statistic, Transactions of the American Mathematical Society, Vol.
39, No. 3. [link]
Pitman, E.J.G. (1936) Sufficient statistics and
intrinsic accuracy, Proceedings of the Cambridge Philosophical Society, 32, 567-579.
following a one-dimensional result in
Fisher, R.A. (1934) Two new properties of mathematical likelihood, Proceedings of the Royal Society, Series A, 144, 285-307.
I do not know of a non-technical proof of this result. One proof that does not involve complex arguments is Don Fraser's (p.13-16), based on the argument that the likelihood function is a sufficient statistic,with functional value. But I find the argument disputable because statistics are real vectors that are functions of the sample $x$, not functionals (function valued transforms). With all due respect, by changing the nature of the statistic, Don Fraser changes the definition of sufficiency and hence the meaning of the Darmois-Koopman-Pitman lemma. | Undergraduate-level proofs of the Pitman–Koopman–Darmois theorem | The reason the Lemma is called Pitman-Koopman-Darmois is, unsurprisingly, that the three authors established similar versions of the lemma, independently at about the same time:
Darmois, G. (1935) Su | Undergraduate-level proofs of the Pitman–Koopman–Darmois theorem
The reason the Lemma is called Pitman-Koopman-Darmois is, unsurprisingly, that the three authors established similar versions of the lemma, independently at about the same time:
Darmois, G. (1935) Sur les lois de probabilité à estimation
exhaustive, Comptes Rendus de l'Académie des Sciences, 200,
1265-1266.
Koopman, B.O. (1936) On Distributions Admitting a Sufficient
Statistic, Transactions of the American Mathematical Society, Vol.
39, No. 3. [link]
Pitman, E.J.G. (1936) Sufficient statistics and
intrinsic accuracy, Proceedings of the Cambridge Philosophical Society, 32, 567-579.
following a one-dimensional result in
Fisher, R.A. (1934) Two new properties of mathematical likelihood, Proceedings of the Royal Society, Series A, 144, 285-307.
I do not know of a non-technical proof of this result. One proof that does not involve complex arguments is Don Fraser's (p.13-16), based on the argument that the likelihood function is a sufficient statistic,with functional value. But I find the argument disputable because statistics are real vectors that are functions of the sample $x$, not functionals (function valued transforms). With all due respect, by changing the nature of the statistic, Don Fraser changes the definition of sufficiency and hence the meaning of the Darmois-Koopman-Pitman lemma. | Undergraduate-level proofs of the Pitman–Koopman–Darmois theorem
The reason the Lemma is called Pitman-Koopman-Darmois is, unsurprisingly, that the three authors established similar versions of the lemma, independently at about the same time:
Darmois, G. (1935) Su |
17,714 | Why is deep reinforcement learning unstable? | The main problem is that, as in many other fields, DNN can be hard to train. Here, one problem is the correlation of input data: if you think about a video game (they actually use those to test their algorithms), you can imagine that screenshots taken one step after another are highly correlated: the game evolves "continuously". That, for NNs, can be a problem: doing many iterations of gradient descent on similar and correlated inputs may lead to overfit them and/or fall into a local minimum. This why they use experience replay: they store a series of "snapshots" of the game, then shuffle them, and pick them some steps later to do training. In this way, the data is not correlated anymore.
Then, they notice how during the training the Q values (predicted by the NN) can change the on going policy, so making the agent prefer only a set of actions and causing it to store data that is correlated for the same reasons as before: this is why they delay training and update Q periodically, to ensure that the agent can explore the game, and train on shuffled and uncorrelated data. | Why is deep reinforcement learning unstable? | The main problem is that, as in many other fields, DNN can be hard to train. Here, one problem is the correlation of input data: if you think about a video game (they actually use those to test their | Why is deep reinforcement learning unstable?
The main problem is that, as in many other fields, DNN can be hard to train. Here, one problem is the correlation of input data: if you think about a video game (they actually use those to test their algorithms), you can imagine that screenshots taken one step after another are highly correlated: the game evolves "continuously". That, for NNs, can be a problem: doing many iterations of gradient descent on similar and correlated inputs may lead to overfit them and/or fall into a local minimum. This why they use experience replay: they store a series of "snapshots" of the game, then shuffle them, and pick them some steps later to do training. In this way, the data is not correlated anymore.
Then, they notice how during the training the Q values (predicted by the NN) can change the on going policy, so making the agent prefer only a set of actions and causing it to store data that is correlated for the same reasons as before: this is why they delay training and update Q periodically, to ensure that the agent can explore the game, and train on shuffled and uncorrelated data. | Why is deep reinforcement learning unstable?
The main problem is that, as in many other fields, DNN can be hard to train. Here, one problem is the correlation of input data: if you think about a video game (they actually use those to test their |
17,715 | Sensitivity Analysis in Deep Neural Networks | The sensitivity analysis you suggest corresponds to examining the partial derivatives of the outputs with respect to the inputs. Say the output vector $y \in \mathbb{R}^m$ is given by $y= f(x)$ , where $x \in \mathbb{R}^d$ is the input vector and $f$ is the function the network implements. The Jacobian of the outputs w.r.t. the inputs is:
$$J_{ij}(x) = \frac{\partial}{\partial x_j} f_i(x)$$
The Jacobian gives the local rate of change of each output w.r.t. each input, so it tells us how $f$ will behave in response to infinitesimal perturbations. If we start with input $x$ and add an infinitesimal value $\Delta$ to the $j$th input, we expect the $i$th output to increase by $\Delta J_{ij}(x)$.
If $J_{ij}(x)$ has large magnitude, it means that output $i$ is sensitive to input $j$ in the vicinity of $x$. Because $f$ is, in general, nonlinear, this notion of sensitivity depends on the input; it may be large in some regions and near zero in others. If you want some kind of summary measure of how strongly the outputs depend on the inputs, you'd have to aggregate over multiple input values. For example, you could take the absolute value of the Jacobian, averaged over all inputs in the training set (which acts as a surrogate for the expected value w.r.t. the underlying distribution of inputs). Of course, this kind of summary will end up discarding information, so could be misleading in some circumstances.
You can use the chain rule to derive an expression for the Jacobian, similarly to how you'd derive the gradient of the loss function w.r.t. the parameters for use with backprop. You can also compute it using automatic differentiation, using a library like Theano, TensorFlow, etc. There's not much reason to perform finite differencing (i.e. actually simulate the perturbation and measure the change in output), unless the function your network implements is nondifferentiable (in which case the Jacobian doesn't exist).
A couple caveats: If the inputs have different units/scales than each other, the sensitivities will also have different units/scales, and can't be directly compared. Standardizing/scaling the inputs is one possible solution. It's also important to keep in mind is that this type of analysis tells us about the model itself, but not necessarily the underlying distribution that generated the data. For example, if two inputs are correlated, the model might end up using the first but not the second. In this case, we'd find that the sensitivity is high for the first input and low for the second, but should not conclude that the first input is inherently more important for predicting the output in general.
This article should be of interest. | Sensitivity Analysis in Deep Neural Networks | The sensitivity analysis you suggest corresponds to examining the partial derivatives of the outputs with respect to the inputs. Say the output vector $y \in \mathbb{R}^m$ is given by $y= f(x)$ , wher | Sensitivity Analysis in Deep Neural Networks
The sensitivity analysis you suggest corresponds to examining the partial derivatives of the outputs with respect to the inputs. Say the output vector $y \in \mathbb{R}^m$ is given by $y= f(x)$ , where $x \in \mathbb{R}^d$ is the input vector and $f$ is the function the network implements. The Jacobian of the outputs w.r.t. the inputs is:
$$J_{ij}(x) = \frac{\partial}{\partial x_j} f_i(x)$$
The Jacobian gives the local rate of change of each output w.r.t. each input, so it tells us how $f$ will behave in response to infinitesimal perturbations. If we start with input $x$ and add an infinitesimal value $\Delta$ to the $j$th input, we expect the $i$th output to increase by $\Delta J_{ij}(x)$.
If $J_{ij}(x)$ has large magnitude, it means that output $i$ is sensitive to input $j$ in the vicinity of $x$. Because $f$ is, in general, nonlinear, this notion of sensitivity depends on the input; it may be large in some regions and near zero in others. If you want some kind of summary measure of how strongly the outputs depend on the inputs, you'd have to aggregate over multiple input values. For example, you could take the absolute value of the Jacobian, averaged over all inputs in the training set (which acts as a surrogate for the expected value w.r.t. the underlying distribution of inputs). Of course, this kind of summary will end up discarding information, so could be misleading in some circumstances.
You can use the chain rule to derive an expression for the Jacobian, similarly to how you'd derive the gradient of the loss function w.r.t. the parameters for use with backprop. You can also compute it using automatic differentiation, using a library like Theano, TensorFlow, etc. There's not much reason to perform finite differencing (i.e. actually simulate the perturbation and measure the change in output), unless the function your network implements is nondifferentiable (in which case the Jacobian doesn't exist).
A couple caveats: If the inputs have different units/scales than each other, the sensitivities will also have different units/scales, and can't be directly compared. Standardizing/scaling the inputs is one possible solution. It's also important to keep in mind is that this type of analysis tells us about the model itself, but not necessarily the underlying distribution that generated the data. For example, if two inputs are correlated, the model might end up using the first but not the second. In this case, we'd find that the sensitivity is high for the first input and low for the second, but should not conclude that the first input is inherently more important for predicting the output in general.
This article should be of interest. | Sensitivity Analysis in Deep Neural Networks
The sensitivity analysis you suggest corresponds to examining the partial derivatives of the outputs with respect to the inputs. Say the output vector $y \in \mathbb{R}^m$ is given by $y= f(x)$ , wher |
17,716 | Sensitivity Analysis in Deep Neural Networks | Although from a different community, the sensitivity of output of DNN to input is also of high interest of earth science or other applied physics field. Because it's more-or-less a representation of the interpretation of the neural network. It told us how the output can be influenced by the input. Please find my publication about it in data assimilation over here: https://www.sciencedirect.com/science/article/pii/S0034425722002309. We tries to make the DNN "physically plausible" by calculating the sensitivity (or Jacobian), and tried to see whether the sensitivity makes physical sense. We also find some problems about that and are addressing them. Just follow our work. | Sensitivity Analysis in Deep Neural Networks | Although from a different community, the sensitivity of output of DNN to input is also of high interest of earth science or other applied physics field. Because it's more-or-less a representation of t | Sensitivity Analysis in Deep Neural Networks
Although from a different community, the sensitivity of output of DNN to input is also of high interest of earth science or other applied physics field. Because it's more-or-less a representation of the interpretation of the neural network. It told us how the output can be influenced by the input. Please find my publication about it in data assimilation over here: https://www.sciencedirect.com/science/article/pii/S0034425722002309. We tries to make the DNN "physically plausible" by calculating the sensitivity (or Jacobian), and tried to see whether the sensitivity makes physical sense. We also find some problems about that and are addressing them. Just follow our work. | Sensitivity Analysis in Deep Neural Networks
Although from a different community, the sensitivity of output of DNN to input is also of high interest of earth science or other applied physics field. Because it's more-or-less a representation of t |
17,717 | Distribution of the square of a non-standard normal random variable | It is a scaled non-central chi-square distribution with one degree of freedom. More specifically, if $Z$ is a normal random variable with mean $\mu$ and variance $\sigma^2$, then $\frac{Z^2}{\sigma^2}$ is a non-central chi-square random variable with one degree of freedom and non-centrality parameter $\lambda=\left(\frac{\mu}{\sigma}\right)^2$. | Distribution of the square of a non-standard normal random variable | It is a scaled non-central chi-square distribution with one degree of freedom. More specifically, if $Z$ is a normal random variable with mean $\mu$ and variance $\sigma^2$, then $\frac{Z^2}{\sigma^2} | Distribution of the square of a non-standard normal random variable
It is a scaled non-central chi-square distribution with one degree of freedom. More specifically, if $Z$ is a normal random variable with mean $\mu$ and variance $\sigma^2$, then $\frac{Z^2}{\sigma^2}$ is a non-central chi-square random variable with one degree of freedom and non-centrality parameter $\lambda=\left(\frac{\mu}{\sigma}\right)^2$. | Distribution of the square of a non-standard normal random variable
It is a scaled non-central chi-square distribution with one degree of freedom. More specifically, if $Z$ is a normal random variable with mean $\mu$ and variance $\sigma^2$, then $\frac{Z^2}{\sigma^2} |
17,718 | What exactly is a distribution? | The following is for $\mathbb R-$valued random-variables. The extension to other spaces is straight forward if you are interested. I would argue that the following slightly more general definition is more intuitive than separately considering density, mass and cumulative distribution functions.
I include some mathematical / probabilistic terms in the text to make it correct. If one is not familiar with those terms, the intuition is equally well grasped by just thinking of "Borel sets" as "any subset of $\mathbb R$ that I can think of", and of the random variable a the numerical outcome of some experiment with an associated probability.
Let $\left( \Omega, \mathcal F, P \right)$ be a probability space and $X(\omega)$ an $\mathbb R-$valued random variable on this space.
The set function $Q(A):=P\left(\omega \in \Omega : X(\omega) \in A\right)$, where $A$ is a Borel set, is called the distribution of $X$.
In words, the distribution tells you (loosely speaking), for any subset of $\mathbb R $, the probability that $X$ takes on a value in that set. One can prove that $Q$ is completely determined by the function $F(x):=P(X\leq x)$ and vice versa. To do that -- and I skip the details here -- construct a measure on the Borel sets that assign the probability $F(x)$ to all sets $(-\infty, x)$ and argue that this finite measure agrees with $Q$ on a $\pi-$system generating the Borel $\sigma-$algebra.
If it so happens that $Q(A)$ can be written as $Q(A) =\int_Af(x)dx$ then $f$ is a density function for $Q$ and you can see, although this density is not uniquely determined (consider changes on sets of Lebesgue measure zero), it makes sense to also speak of $f$ as the distribution of $X$. Usually, however, we call it the probability density function of $X$.
Similarly, if it so happens that $Q(A)$ can be written as $Q(A)=\sum_{i\in A\cap\{\dots,-1,0,1,\dots\}}f(i)$, then it makes sense to speak of $f$ as the distribution of $X$ although we usually call it the probability mass function.
Thus, whenever you read something like "$X$ follows a uniform distribution on $[0,1]$", it simply means that the function $Q(A)$, which tells you the probability that $X$ takes on values in certain sets, is characterized by the probability density function $f(x)=I_{[0,1]}$ or the cumulative distribution function $F(x)=\int_{-\infty}^x f(t)dt$.
A final note on the case where there is no mention of a random variable, but only a distribution. One may prove that given a distribution function (or a mass, density or cumulative distribution function), there exists a probability space with a random variable that has this distribution. Thus, there is essentially no difference in speaking about a distribution, or about a random variable having that distribution. It's just a matter of one's focus. | What exactly is a distribution? | The following is for $\mathbb R-$valued random-variables. The extension to other spaces is straight forward if you are interested. I would argue that the following slightly more general definition is | What exactly is a distribution?
The following is for $\mathbb R-$valued random-variables. The extension to other spaces is straight forward if you are interested. I would argue that the following slightly more general definition is more intuitive than separately considering density, mass and cumulative distribution functions.
I include some mathematical / probabilistic terms in the text to make it correct. If one is not familiar with those terms, the intuition is equally well grasped by just thinking of "Borel sets" as "any subset of $\mathbb R$ that I can think of", and of the random variable a the numerical outcome of some experiment with an associated probability.
Let $\left( \Omega, \mathcal F, P \right)$ be a probability space and $X(\omega)$ an $\mathbb R-$valued random variable on this space.
The set function $Q(A):=P\left(\omega \in \Omega : X(\omega) \in A\right)$, where $A$ is a Borel set, is called the distribution of $X$.
In words, the distribution tells you (loosely speaking), for any subset of $\mathbb R $, the probability that $X$ takes on a value in that set. One can prove that $Q$ is completely determined by the function $F(x):=P(X\leq x)$ and vice versa. To do that -- and I skip the details here -- construct a measure on the Borel sets that assign the probability $F(x)$ to all sets $(-\infty, x)$ and argue that this finite measure agrees with $Q$ on a $\pi-$system generating the Borel $\sigma-$algebra.
If it so happens that $Q(A)$ can be written as $Q(A) =\int_Af(x)dx$ then $f$ is a density function for $Q$ and you can see, although this density is not uniquely determined (consider changes on sets of Lebesgue measure zero), it makes sense to also speak of $f$ as the distribution of $X$. Usually, however, we call it the probability density function of $X$.
Similarly, if it so happens that $Q(A)$ can be written as $Q(A)=\sum_{i\in A\cap\{\dots,-1,0,1,\dots\}}f(i)$, then it makes sense to speak of $f$ as the distribution of $X$ although we usually call it the probability mass function.
Thus, whenever you read something like "$X$ follows a uniform distribution on $[0,1]$", it simply means that the function $Q(A)$, which tells you the probability that $X$ takes on values in certain sets, is characterized by the probability density function $f(x)=I_{[0,1]}$ or the cumulative distribution function $F(x)=\int_{-\infty}^x f(t)dt$.
A final note on the case where there is no mention of a random variable, but only a distribution. One may prove that given a distribution function (or a mass, density or cumulative distribution function), there exists a probability space with a random variable that has this distribution. Thus, there is essentially no difference in speaking about a distribution, or about a random variable having that distribution. It's just a matter of one's focus. | What exactly is a distribution?
The following is for $\mathbb R-$valued random-variables. The extension to other spaces is straight forward if you are interested. I would argue that the following slightly more general definition is |
17,719 | What exactly is a distribution? | Let $(\Omega,\mathscr{F},P)$ be a probability space, let $(\mathscr{X},\mathscr{B})$ be a measurable space, and let $X:\Omega\to\mathscr{X}$ be a measurable function, which means that $X^{-1}(B)=\{\omega:X(\omega)\in B\}\in\mathscr{F}$ for every $B\in\mathscr{B}$. The distribution of $X$ is the probability measure $\mu_X$ over $(\mathscr{X},\mathscr{B})$ defined by $\mu_X(B)=P(X\in B)$. When $\mathscr{X}=\mathbb{R}$ and $\mathscr{B}$ is the Borel sigma-field, we refer to the function $X$ as a random "variable". | What exactly is a distribution? | Let $(\Omega,\mathscr{F},P)$ be a probability space, let $(\mathscr{X},\mathscr{B})$ be a measurable space, and let $X:\Omega\to\mathscr{X}$ be a measurable function, which means that $X^{-1}(B)=\{\om | What exactly is a distribution?
Let $(\Omega,\mathscr{F},P)$ be a probability space, let $(\mathscr{X},\mathscr{B})$ be a measurable space, and let $X:\Omega\to\mathscr{X}$ be a measurable function, which means that $X^{-1}(B)=\{\omega:X(\omega)\in B\}\in\mathscr{F}$ for every $B\in\mathscr{B}$. The distribution of $X$ is the probability measure $\mu_X$ over $(\mathscr{X},\mathscr{B})$ defined by $\mu_X(B)=P(X\in B)$. When $\mathscr{X}=\mathbb{R}$ and $\mathscr{B}$ is the Borel sigma-field, we refer to the function $X$ as a random "variable". | What exactly is a distribution?
Let $(\Omega,\mathscr{F},P)$ be a probability space, let $(\mathscr{X},\mathscr{B})$ be a measurable space, and let $X:\Omega\to\mathscr{X}$ be a measurable function, which means that $X^{-1}(B)=\{\om |
17,720 | What exactly is a distribution? | The question and answers so far seem to have focused on theoretical distributions. Empirical distributions provide a more intuitive understanding of distributions.
Example
During a class tournament in skipping rope we observe all the kids in
a class skipping rope. The first kid is able to jump twice, the
second four times, the next one fifteen times, etc. We record the
number of jumps. Five of the kids jumped eight times each, but only
one of the kids jumped twice. We say that jumping eight times is
differently distributed than jumping twice.
An ostensive definition for an observed distribution is the frequency of occurrences for each observed value of a variable.
In inferential statistics we then try to fit theoretical distributions to the observed distributions, because we would like to work with the assumptions of the theoretical distributions. You can reach a similar definition for theoretical distributions by replacing "observed" with "observerable" or to be more precise: "expected". | What exactly is a distribution? | The question and answers so far seem to have focused on theoretical distributions. Empirical distributions provide a more intuitive understanding of distributions.
Example
During a class tournament i | What exactly is a distribution?
The question and answers so far seem to have focused on theoretical distributions. Empirical distributions provide a more intuitive understanding of distributions.
Example
During a class tournament in skipping rope we observe all the kids in
a class skipping rope. The first kid is able to jump twice, the
second four times, the next one fifteen times, etc. We record the
number of jumps. Five of the kids jumped eight times each, but only
one of the kids jumped twice. We say that jumping eight times is
differently distributed than jumping twice.
An ostensive definition for an observed distribution is the frequency of occurrences for each observed value of a variable.
In inferential statistics we then try to fit theoretical distributions to the observed distributions, because we would like to work with the assumptions of the theoretical distributions. You can reach a similar definition for theoretical distributions by replacing "observed" with "observerable" or to be more precise: "expected". | What exactly is a distribution?
The question and answers so far seem to have focused on theoretical distributions. Empirical distributions provide a more intuitive understanding of distributions.
Example
During a class tournament i |
17,721 | Noncentrality Parameter - what is it, what does it do, what would be a suggested value? | In power calculations, we calibrate tests using knowledge of what the sampling distribution of the test statistic would be under the null hypothesis. Usually, it follows a $\chi^2$ or normal distribution. This allows you to calculate "critical values" for which, values exceeding this are deemed to be too highly inconsistent with what would be expected if the null were true.
The power of a statistical test is calculated by specifying the probability model for the data generating process under an alternative hypothesis, and calculating the sampling distribution for the same test statistic. This now takes on a different distribution.
For test statistics having a $\chi^2$ distribution under the null, they take a non-central $\chi^2$ distribution under the alternative that you create. These are very complicated distributions, but standard software can calculate density, distribution, and quantiles for them easily. The trick is that they are a convolution of standard $\chi^2$ densities and Poisson densities. In R, the dchisq, pchisq, and rchisq functions all have an optional ncp argument which is, by default, 0.
If the test statistic has a standard normal distribution under the null hypothesis, it will have a nonzero mean normal distribution under the alternative. Here that mean is the noncentrality parameter. For a t-test under an equal variance assumption, the mean is given by:
$$\delta = \frac{\mu_1 -\mu_2}{\sigma_{pooled}/\sqrt{n}}$$
In either case, data generated according to an alternative hypothesis will have test statistics following some noncentral distribution with noncentrality parameter ($\delta$). The $\delta$ is a sometimes unknown, often complicated function of the other data generating parameters. | Noncentrality Parameter - what is it, what does it do, what would be a suggested value? | In power calculations, we calibrate tests using knowledge of what the sampling distribution of the test statistic would be under the null hypothesis. Usually, it follows a $\chi^2$ or normal distribut | Noncentrality Parameter - what is it, what does it do, what would be a suggested value?
In power calculations, we calibrate tests using knowledge of what the sampling distribution of the test statistic would be under the null hypothesis. Usually, it follows a $\chi^2$ or normal distribution. This allows you to calculate "critical values" for which, values exceeding this are deemed to be too highly inconsistent with what would be expected if the null were true.
The power of a statistical test is calculated by specifying the probability model for the data generating process under an alternative hypothesis, and calculating the sampling distribution for the same test statistic. This now takes on a different distribution.
For test statistics having a $\chi^2$ distribution under the null, they take a non-central $\chi^2$ distribution under the alternative that you create. These are very complicated distributions, but standard software can calculate density, distribution, and quantiles for them easily. The trick is that they are a convolution of standard $\chi^2$ densities and Poisson densities. In R, the dchisq, pchisq, and rchisq functions all have an optional ncp argument which is, by default, 0.
If the test statistic has a standard normal distribution under the null hypothesis, it will have a nonzero mean normal distribution under the alternative. Here that mean is the noncentrality parameter. For a t-test under an equal variance assumption, the mean is given by:
$$\delta = \frac{\mu_1 -\mu_2}{\sigma_{pooled}/\sqrt{n}}$$
In either case, data generated according to an alternative hypothesis will have test statistics following some noncentral distribution with noncentrality parameter ($\delta$). The $\delta$ is a sometimes unknown, often complicated function of the other data generating parameters. | Noncentrality Parameter - what is it, what does it do, what would be a suggested value?
In power calculations, we calibrate tests using knowledge of what the sampling distribution of the test statistic would be under the null hypothesis. Usually, it follows a $\chi^2$ or normal distribut |
17,722 | Why does nobody use the Bayesian multinomial Naive Bayes classifier? | Here is a nice paper that addresses some of the 'systemic' shortcomings of the Multinomial Naive Bayes (MNB) classifier. The idea is that you can boost the performance of MNB through some tweaks. And they do mention using (uniform) Dirichlet priors.
Overall if you're interested in MNB and you haven't read this paper yet, I would strongly recommend to do so.
I also found an accompanying MSc thesis by the same person / people but haven't read it myself yet. You can check it out. | Why does nobody use the Bayesian multinomial Naive Bayes classifier? | Here is a nice paper that addresses some of the 'systemic' shortcomings of the Multinomial Naive Bayes (MNB) classifier. The idea is that you can boost the performance of MNB through some tweaks. And | Why does nobody use the Bayesian multinomial Naive Bayes classifier?
Here is a nice paper that addresses some of the 'systemic' shortcomings of the Multinomial Naive Bayes (MNB) classifier. The idea is that you can boost the performance of MNB through some tweaks. And they do mention using (uniform) Dirichlet priors.
Overall if you're interested in MNB and you haven't read this paper yet, I would strongly recommend to do so.
I also found an accompanying MSc thesis by the same person / people but haven't read it myself yet. You can check it out. | Why does nobody use the Bayesian multinomial Naive Bayes classifier?
Here is a nice paper that addresses some of the 'systemic' shortcomings of the Multinomial Naive Bayes (MNB) classifier. The idea is that you can boost the performance of MNB through some tweaks. And |
17,723 | Why does nobody use the Bayesian multinomial Naive Bayes classifier? | I suspect most NB implementations allow for the estimation of the conditional probabilities with the Laplace correction, which gives a MAP solution to the Bayesian NB classifier (with a particular Dirichlet prior). As @Zhubarb (+1) points out, Bayesian treatments of NB classifiers have already been derived and implemented (Rennie's thesis/papers are well worth reading). However, the independence assumption of NB is almost always wrong, in which case making the model more strongly dependent on that assumption (via a full Bayesian treatment) might not be a good thing to do. | Why does nobody use the Bayesian multinomial Naive Bayes classifier? | I suspect most NB implementations allow for the estimation of the conditional probabilities with the Laplace correction, which gives a MAP solution to the Bayesian NB classifier (with a particular Dir | Why does nobody use the Bayesian multinomial Naive Bayes classifier?
I suspect most NB implementations allow for the estimation of the conditional probabilities with the Laplace correction, which gives a MAP solution to the Bayesian NB classifier (with a particular Dirichlet prior). As @Zhubarb (+1) points out, Bayesian treatments of NB classifiers have already been derived and implemented (Rennie's thesis/papers are well worth reading). However, the independence assumption of NB is almost always wrong, in which case making the model more strongly dependent on that assumption (via a full Bayesian treatment) might not be a good thing to do. | Why does nobody use the Bayesian multinomial Naive Bayes classifier?
I suspect most NB implementations allow for the estimation of the conditional probabilities with the Laplace correction, which gives a MAP solution to the Bayesian NB classifier (with a particular Dir |
17,724 | Why does nobody use the Bayesian multinomial Naive Bayes classifier? | I do not believe what you describe is true. The probabilistic models for LDA and MNB are different.
One main difference between the two is that in the generative model for LDA, when a word is drawn, first a topic for that word is chosen, and then a word from that topic distribution is chosen. I.o.w. each word in a document can be drawn from a different topic.
In the generative model for MNB, the document is assigned one class and all the words in that document are drawn from the (same) distribution for that class. | Why does nobody use the Bayesian multinomial Naive Bayes classifier? | I do not believe what you describe is true. The probabilistic models for LDA and MNB are different.
One main difference between the two is that in the generative model for LDA, when a word is drawn, f | Why does nobody use the Bayesian multinomial Naive Bayes classifier?
I do not believe what you describe is true. The probabilistic models for LDA and MNB are different.
One main difference between the two is that in the generative model for LDA, when a word is drawn, first a topic for that word is chosen, and then a word from that topic distribution is chosen. I.o.w. each word in a document can be drawn from a different topic.
In the generative model for MNB, the document is assigned one class and all the words in that document are drawn from the (same) distribution for that class. | Why does nobody use the Bayesian multinomial Naive Bayes classifier?
I do not believe what you describe is true. The probabilistic models for LDA and MNB are different.
One main difference between the two is that in the generative model for LDA, when a word is drawn, f |
17,725 | Sufficient statistic, specifics/intuition problems | You'd probably benefit from reading about sufficiency in any textbook on theoretical statistics, where most of these questions will be covered in detail. Briefly ...
Not necessarily. Those are special cases: of distributions where the support (the range of values the data can take) doesn't depend on the unknown parameter(s), only those in the exponential family have a sufficent statistic of the same dimensionality as the number of parameters. So for estimating the shape & scale of a Weibull distribution or the location & scale of a logistic distribution from independent observations, the order statistic (the whole set of observations disregarding their sequence) is minimal sufficient—you can't reduce it further without losing information about the parameters. Where the support does depend on the unknown parameter(s) it varies: for a uniform distribution on $(0,\theta)$, the sample maximum is sufficient for $\theta$; for a uniform distribution on $(\theta-1,\theta+1)$ the sample minimum and maximum are together sufficient.
I don't know what you mean by "direct correspondence"; the alternative you give seems a fair way to describe sufficient statistics.
Yes: trivially the data as a whole are sufficient. (If you hear someone say there's no sufficient statistic they mean there's no low-dimensional one.)
Yes, that's the idea. (What's left—the distribution of the data conditional on the sufficient statistic—can be used for checking the distributional assumption independently of the unknown parameter(s).)
Apparently not, though I gather the counter-examples are not distributions you're likely to want to use in practice. [It'd be nice if anyone could explain this without getting too heavily into measure theory.]
In response to the further questions ...
The first factor, $ \mathrm{e}^{-n\lambda}\cdot\lambda^{\sum{x_i}}$, depends on $\lambda$ only through $\sum x_i$. So any one-to-one function of $\sum x_i$ is sufficient: $\sum x_i$, $\sum x_i/n$, $(\sum x_i)^2$†, & so on.
The second factor, $\tfrac{1}{x_1! x_2! \ldots x_n!}$, doesn't depend on $\lambda$ & so won't affect the value of $\lambda$ at which $f(x;\lambda)$ is a maximum. Derive the MLE & see for yourself.
The sample size $n$ is a known constant rather than a realized value of a random variable‡, so isn't considered part of the sufficient statistic; the same goes for known parameters other than the ones you want to infer things about.
† In this case squaring is one-to-one because $\sum x_i$ is always positive.
‡ When $n$ is a realized value of the random variable $N$, then it will be part of the sufficient statistic, $(\sum x_i,n)$. Say you choose a sample size of 10 or 100 by tossing a coin: $n$ tells you nothing about the value of $\theta$ but does affect how precisely you can estimate it; in this case it's called an ancillary complement to $\sum x_i$ & inference can proceed by conditioning on its realized value—in effect ignoring that it might have come out different. | Sufficient statistic, specifics/intuition problems | You'd probably benefit from reading about sufficiency in any textbook on theoretical statistics, where most of these questions will be covered in detail. Briefly ...
Not necessarily. Those are specia | Sufficient statistic, specifics/intuition problems
You'd probably benefit from reading about sufficiency in any textbook on theoretical statistics, where most of these questions will be covered in detail. Briefly ...
Not necessarily. Those are special cases: of distributions where the support (the range of values the data can take) doesn't depend on the unknown parameter(s), only those in the exponential family have a sufficent statistic of the same dimensionality as the number of parameters. So for estimating the shape & scale of a Weibull distribution or the location & scale of a logistic distribution from independent observations, the order statistic (the whole set of observations disregarding their sequence) is minimal sufficient—you can't reduce it further without losing information about the parameters. Where the support does depend on the unknown parameter(s) it varies: for a uniform distribution on $(0,\theta)$, the sample maximum is sufficient for $\theta$; for a uniform distribution on $(\theta-1,\theta+1)$ the sample minimum and maximum are together sufficient.
I don't know what you mean by "direct correspondence"; the alternative you give seems a fair way to describe sufficient statistics.
Yes: trivially the data as a whole are sufficient. (If you hear someone say there's no sufficient statistic they mean there's no low-dimensional one.)
Yes, that's the idea. (What's left—the distribution of the data conditional on the sufficient statistic—can be used for checking the distributional assumption independently of the unknown parameter(s).)
Apparently not, though I gather the counter-examples are not distributions you're likely to want to use in practice. [It'd be nice if anyone could explain this without getting too heavily into measure theory.]
In response to the further questions ...
The first factor, $ \mathrm{e}^{-n\lambda}\cdot\lambda^{\sum{x_i}}$, depends on $\lambda$ only through $\sum x_i$. So any one-to-one function of $\sum x_i$ is sufficient: $\sum x_i$, $\sum x_i/n$, $(\sum x_i)^2$†, & so on.
The second factor, $\tfrac{1}{x_1! x_2! \ldots x_n!}$, doesn't depend on $\lambda$ & so won't affect the value of $\lambda$ at which $f(x;\lambda)$ is a maximum. Derive the MLE & see for yourself.
The sample size $n$ is a known constant rather than a realized value of a random variable‡, so isn't considered part of the sufficient statistic; the same goes for known parameters other than the ones you want to infer things about.
† In this case squaring is one-to-one because $\sum x_i$ is always positive.
‡ When $n$ is a realized value of the random variable $N$, then it will be part of the sufficient statistic, $(\sum x_i,n)$. Say you choose a sample size of 10 or 100 by tossing a coin: $n$ tells you nothing about the value of $\theta$ but does affect how precisely you can estimate it; in this case it's called an ancillary complement to $\sum x_i$ & inference can proceed by conditioning on its realized value—in effect ignoring that it might have come out different. | Sufficient statistic, specifics/intuition problems
You'd probably benefit from reading about sufficiency in any textbook on theoretical statistics, where most of these questions will be covered in detail. Briefly ...
Not necessarily. Those are specia |
17,726 | Best way to visually present relationships from a multiple linear model | In my opinion, the model that you've described doesn't really lend itself to plotting, as plots function best when they display complex information that is hard to understand otherwise (e.g., complex interactions). However, if you'd like to display a plot of the relationships in your model, you've got two main options:
Display a series of plots of the bivariate relationships between each of your predictors of interest and your outcome, with a scatterplot of the raw datapoints. Plot error envelopes around your lines.
Display the plot from option 1, but instead of showing the raw datapoints, show the datapoints with your other predictors marginalized out (i.e., after subtracting out the contributions of the other predictors)
The benefit of option 1 is that it allows the viewer to assess the scatter in the raw data. The benefit of option 2 is that it shows the observation-level error that actually resulted in the standard error of the focal coefficient that you're displaying.
I have included R code and a graph of each option below, using data from Prestige dataset in the car package in R.
## Raw data ##
mod <- lm(income ~ education + women, data = Prestige)
summary(mod)
# Create a scatterplot of education against income
plot(Prestige$education, Prestige$income, xlab = "Years of education",
ylab = "Occupational income", bty = "n", pch = 16, col = "grey")
# Create a dataframe representing the values on the predictors for which we
# want predictions
pX <- expand.grid(education = seq(min(Prestige$education), max(Prestige$education), by = .1),
women = mean(Prestige$women))
# Get predicted values
pY <- predict(mod, pX, se.fit = T)
lines(pX$education, pY$fit, lwd = 2) # Prediction line
lines(pX$education, pY$fit - pY$se.fit) # -1 SE
lines(pX$education, pY$fit + pY$se.fit) # +1 SE
## Adjusted (marginalized) data ##
mod <- lm(income ~ education + women, data = Prestige)
summary(mod)
# Calculate the values of income, marginalizing out the effect of percentage women
margin_income <- coef(mod)["(Intercept)"] + coef(mod)["education"] * Prestige$education +
coef(mod)["women"] * mean(Prestige$women) + residuals(mod)
# Create a scatterplot of education against income
plot(Prestige$education, margin_income, xlab = "Years of education",
ylab = "Adjusted income", bty = "n", pch = 16, col = "grey")
# Create a dataframe representing the values on the predictors for which we
# want predictions
pX <- expand.grid(education = seq(min(Prestige$education), max(Prestige$education), by = .1),
women = mean(Prestige$women))
# Get predicted values
pY <- predict(mod, pX, se.fit = T)
lines(pX$education, pY$fit, lwd = 2) # Prediction line
lines(pX$education, pY$fit - pY$se.fit) # -1 SE
lines(pX$education, pY$fit + pY$se.fit) # +1 SE | Best way to visually present relationships from a multiple linear model | In my opinion, the model that you've described doesn't really lend itself to plotting, as plots function best when they display complex information that is hard to understand otherwise (e.g., complex | Best way to visually present relationships from a multiple linear model
In my opinion, the model that you've described doesn't really lend itself to plotting, as plots function best when they display complex information that is hard to understand otherwise (e.g., complex interactions). However, if you'd like to display a plot of the relationships in your model, you've got two main options:
Display a series of plots of the bivariate relationships between each of your predictors of interest and your outcome, with a scatterplot of the raw datapoints. Plot error envelopes around your lines.
Display the plot from option 1, but instead of showing the raw datapoints, show the datapoints with your other predictors marginalized out (i.e., after subtracting out the contributions of the other predictors)
The benefit of option 1 is that it allows the viewer to assess the scatter in the raw data. The benefit of option 2 is that it shows the observation-level error that actually resulted in the standard error of the focal coefficient that you're displaying.
I have included R code and a graph of each option below, using data from Prestige dataset in the car package in R.
## Raw data ##
mod <- lm(income ~ education + women, data = Prestige)
summary(mod)
# Create a scatterplot of education against income
plot(Prestige$education, Prestige$income, xlab = "Years of education",
ylab = "Occupational income", bty = "n", pch = 16, col = "grey")
# Create a dataframe representing the values on the predictors for which we
# want predictions
pX <- expand.grid(education = seq(min(Prestige$education), max(Prestige$education), by = .1),
women = mean(Prestige$women))
# Get predicted values
pY <- predict(mod, pX, se.fit = T)
lines(pX$education, pY$fit, lwd = 2) # Prediction line
lines(pX$education, pY$fit - pY$se.fit) # -1 SE
lines(pX$education, pY$fit + pY$se.fit) # +1 SE
## Adjusted (marginalized) data ##
mod <- lm(income ~ education + women, data = Prestige)
summary(mod)
# Calculate the values of income, marginalizing out the effect of percentage women
margin_income <- coef(mod)["(Intercept)"] + coef(mod)["education"] * Prestige$education +
coef(mod)["women"] * mean(Prestige$women) + residuals(mod)
# Create a scatterplot of education against income
plot(Prestige$education, margin_income, xlab = "Years of education",
ylab = "Adjusted income", bty = "n", pch = 16, col = "grey")
# Create a dataframe representing the values on the predictors for which we
# want predictions
pX <- expand.grid(education = seq(min(Prestige$education), max(Prestige$education), by = .1),
women = mean(Prestige$women))
# Get predicted values
pY <- predict(mod, pX, se.fit = T)
lines(pX$education, pY$fit, lwd = 2) # Prediction line
lines(pX$education, pY$fit - pY$se.fit) # -1 SE
lines(pX$education, pY$fit + pY$se.fit) # +1 SE | Best way to visually present relationships from a multiple linear model
In my opinion, the model that you've described doesn't really lend itself to plotting, as plots function best when they display complex information that is hard to understand otherwise (e.g., complex |
17,727 | What's a good prior distribution for degrees of freedom in a t distribution? | On page 372 of ARM, Gelman and Hill mention using a uniform distribution on the inverse of DF between 1/DF = .5 and 1/DF = 0.
Specifically, in BUGS, they use:
nu.y <- 1/nu.inv.y
nu.inv.y ~ dunif(0,.5) | What's a good prior distribution for degrees of freedom in a t distribution? | On page 372 of ARM, Gelman and Hill mention using a uniform distribution on the inverse of DF between 1/DF = .5 and 1/DF = 0.
Specifically, in BUGS, they use:
nu.y <- 1/nu.inv.y
nu.inv.y ~ dunif(0, | What's a good prior distribution for degrees of freedom in a t distribution?
On page 372 of ARM, Gelman and Hill mention using a uniform distribution on the inverse of DF between 1/DF = .5 and 1/DF = 0.
Specifically, in BUGS, they use:
nu.y <- 1/nu.inv.y
nu.inv.y ~ dunif(0,.5) | What's a good prior distribution for degrees of freedom in a t distribution?
On page 372 of ARM, Gelman and Hill mention using a uniform distribution on the inverse of DF between 1/DF = .5 and 1/DF = 0.
Specifically, in BUGS, they use:
nu.y <- 1/nu.inv.y
nu.inv.y ~ dunif(0, |
17,728 | What's a good prior distribution for degrees of freedom in a t distribution? | ARM (as referenced by John Salvatier in his answer) was originally published in 2006. Since then, there has been advocation of using a $ \nu \sim \text{Gamma}(2, 0.1)$ prior. This prior was proposed by Juárez and Steel (2010) in their paper Model-based clustering of non-Gaussian panel data based on skew-t distributions.
Gelman made the following post in 2015: “Do we have any recommendations for priors for student_t’s degrees of freedom parameter?”, which discusses this topic in more detail (as well as the penalised complexity prior proposed by Simpson et al (2014)). | What's a good prior distribution for degrees of freedom in a t distribution? | ARM (as referenced by John Salvatier in his answer) was originally published in 2006. Since then, there has been advocation of using a $ \nu \sim \text{Gamma}(2, 0.1)$ prior. This prior was proposed b | What's a good prior distribution for degrees of freedom in a t distribution?
ARM (as referenced by John Salvatier in his answer) was originally published in 2006. Since then, there has been advocation of using a $ \nu \sim \text{Gamma}(2, 0.1)$ prior. This prior was proposed by Juárez and Steel (2010) in their paper Model-based clustering of non-Gaussian panel data based on skew-t distributions.
Gelman made the following post in 2015: “Do we have any recommendations for priors for student_t’s degrees of freedom parameter?”, which discusses this topic in more detail (as well as the penalised complexity prior proposed by Simpson et al (2014)). | What's a good prior distribution for degrees of freedom in a t distribution?
ARM (as referenced by John Salvatier in his answer) was originally published in 2006. Since then, there has been advocation of using a $ \nu \sim \text{Gamma}(2, 0.1)$ prior. This prior was proposed b |
17,729 | When does a confidence interval "make sense" but the corresponding credible interval does not? | In a sequential experimental design, the credible interval can be misleading.
(Disclaimer: I am not arguing it is not reasonable - it is perfectly reasonable in Bayesian reasoning and is not misleading in the perspective of Bayesian point of view.)
For a simple example, let say we have a machine giving us a random sample $X$ from $N(\theta,1)$ with unknown $\theta$. Instead of drawing $n$ i.i.d. samples, we draw samples until $\sqrt{n} \bar{X}_n > k$ for a fixed $k$. That is, the number of samples is a stopping time $N$ defined by
$$
N = \inf\left\{n \geq 1 : \sqrt{n}\bar{X}_n > k \right\}.
$$
From the law of iterated logarithm, we know $P_{\theta}(N < \infty) = 1$ for any $\theta \in \mathbb{R}$. This type of stopping rule is commonly used in sequential testing/estimations to reduce the number of samples to do inference.
Likelihood principle shows that posterior of $\theta$ is not affected by stopping rule and thus for any reasonable smooth prior $\pi(\theta)$ (e.g., $\theta \sim N(0, 10))$, if we set a large enough $k$, the posterior of $\theta$ is approximately $N(\bar{X}_N, 1/N)$ and thus the credible interval is approximately given as
$$
CI_{bayes} :=\left[\bar{X}_N - \frac{1.96}{\sqrt{N}}, \bar{X}_N + \frac{1.96}{\sqrt{N}}\right].
$$
However, from the definition of $N$, we know that this credible interval does not contain $0$ if $k$ is large since
$$
0 < \bar{X}_N - \frac{k}{\sqrt{N}} \ll \bar{X}_N - \frac{1.96}{\sqrt{N}}
$$
for $k \gg 0$. Therefore, the frequentist coverage of $CI_{bayes}$ is zero since
$$
\inf_{\theta} P_\theta( \theta \in CI_{bayes} ) = 0,
$$
and $0$ is attained when $\theta$ is $0$. In contrast, the Bayesian coverage is always approximately equal to $0.95$ since
$$
\mathbb{P}( \theta \in CI_{bayes} | X_1, \dots, X_N) \approx 0.95.
$$
Take home message: If you are interested in having a frequentist guarantee, you should be careful about using Bayesian inference tools which is always valid for Bayesian guarantees but not always for frequentist ones.
(I learned this example from Larry's awesome lecture. This note contains many interesting discussion about the subtle difference between frequentist and Bayesian frameworks. http://www.stat.cmu.edu/~larry/=stat705/Lecture14.pdf)
EDIT In Livid's ABC, the tolerance value is too large, so even for the standard setting where we sample a fixed number of observations, it does not gives a correct CR. I am not familiar with ABC but if I only changed the tol value to 0.05, we can have a very skewed CR as following
> X = like(theta = 0)
> m = mean(X)
> print(m)
[1] 0.02779672
> as.numeric(hdi(chain[, 1], credMass = 0.95))
[1] -0.01711265 0.14253673
Of course, the chain is not well-stabilized but even if we increase the chain length, we can get similar CR - skewed to positive part.
In fact, I think the rejection rule based on mean difference is not well-suited in this setting since with high probability $\sqrt{N}\bar{X}_N$ is close to $k$ if $0<\theta \ll k$ and close to $-k$ if $-k \ll \theta <0$. | When does a confidence interval "make sense" but the corresponding credible interval does not? | In a sequential experimental design, the credible interval can be misleading.
(Disclaimer: I am not arguing it is not reasonable - it is perfectly reasonable in Bayesian reasoning and is not misleadi | When does a confidence interval "make sense" but the corresponding credible interval does not?
In a sequential experimental design, the credible interval can be misleading.
(Disclaimer: I am not arguing it is not reasonable - it is perfectly reasonable in Bayesian reasoning and is not misleading in the perspective of Bayesian point of view.)
For a simple example, let say we have a machine giving us a random sample $X$ from $N(\theta,1)$ with unknown $\theta$. Instead of drawing $n$ i.i.d. samples, we draw samples until $\sqrt{n} \bar{X}_n > k$ for a fixed $k$. That is, the number of samples is a stopping time $N$ defined by
$$
N = \inf\left\{n \geq 1 : \sqrt{n}\bar{X}_n > k \right\}.
$$
From the law of iterated logarithm, we know $P_{\theta}(N < \infty) = 1$ for any $\theta \in \mathbb{R}$. This type of stopping rule is commonly used in sequential testing/estimations to reduce the number of samples to do inference.
Likelihood principle shows that posterior of $\theta$ is not affected by stopping rule and thus for any reasonable smooth prior $\pi(\theta)$ (e.g., $\theta \sim N(0, 10))$, if we set a large enough $k$, the posterior of $\theta$ is approximately $N(\bar{X}_N, 1/N)$ and thus the credible interval is approximately given as
$$
CI_{bayes} :=\left[\bar{X}_N - \frac{1.96}{\sqrt{N}}, \bar{X}_N + \frac{1.96}{\sqrt{N}}\right].
$$
However, from the definition of $N$, we know that this credible interval does not contain $0$ if $k$ is large since
$$
0 < \bar{X}_N - \frac{k}{\sqrt{N}} \ll \bar{X}_N - \frac{1.96}{\sqrt{N}}
$$
for $k \gg 0$. Therefore, the frequentist coverage of $CI_{bayes}$ is zero since
$$
\inf_{\theta} P_\theta( \theta \in CI_{bayes} ) = 0,
$$
and $0$ is attained when $\theta$ is $0$. In contrast, the Bayesian coverage is always approximately equal to $0.95$ since
$$
\mathbb{P}( \theta \in CI_{bayes} | X_1, \dots, X_N) \approx 0.95.
$$
Take home message: If you are interested in having a frequentist guarantee, you should be careful about using Bayesian inference tools which is always valid for Bayesian guarantees but not always for frequentist ones.
(I learned this example from Larry's awesome lecture. This note contains many interesting discussion about the subtle difference between frequentist and Bayesian frameworks. http://www.stat.cmu.edu/~larry/=stat705/Lecture14.pdf)
EDIT In Livid's ABC, the tolerance value is too large, so even for the standard setting where we sample a fixed number of observations, it does not gives a correct CR. I am not familiar with ABC but if I only changed the tol value to 0.05, we can have a very skewed CR as following
> X = like(theta = 0)
> m = mean(X)
> print(m)
[1] 0.02779672
> as.numeric(hdi(chain[, 1], credMass = 0.95))
[1] -0.01711265 0.14253673
Of course, the chain is not well-stabilized but even if we increase the chain length, we can get similar CR - skewed to positive part.
In fact, I think the rejection rule based on mean difference is not well-suited in this setting since with high probability $\sqrt{N}\bar{X}_N$ is close to $k$ if $0<\theta \ll k$ and close to $-k$ if $-k \ll \theta <0$. | When does a confidence interval "make sense" but the corresponding credible interval does not?
In a sequential experimental design, the credible interval can be misleading.
(Disclaimer: I am not arguing it is not reasonable - it is perfectly reasonable in Bayesian reasoning and is not misleadi |
17,730 | When does a confidence interval "make sense" but the corresponding credible interval does not? | Since the credible interval is formed from the posterior distribution, based on a stipulated prior distribution, you can easily construct a very bad credible interval by using a prior distribution that is heavily concentrated on highly implausible parameter values. You can make a credible interval that does not "make sense" by using a prior distribution that is entirely concentrated on impossible parameter values. | When does a confidence interval "make sense" but the corresponding credible interval does not? | Since the credible interval is formed from the posterior distribution, based on a stipulated prior distribution, you can easily construct a very bad credible interval by using a prior distribution tha | When does a confidence interval "make sense" but the corresponding credible interval does not?
Since the credible interval is formed from the posterior distribution, based on a stipulated prior distribution, you can easily construct a very bad credible interval by using a prior distribution that is heavily concentrated on highly implausible parameter values. You can make a credible interval that does not "make sense" by using a prior distribution that is entirely concentrated on impossible parameter values. | When does a confidence interval "make sense" but the corresponding credible interval does not?
Since the credible interval is formed from the posterior distribution, based on a stipulated prior distribution, you can easily construct a very bad credible interval by using a prior distribution tha |
17,731 | When does a confidence interval "make sense" but the corresponding credible interval does not? | If we are using a flat prior, this is simply a game where we try to come up with a flat prior in a reparameterization that doesn't make sense.
For example, suppose we want to make inference on a probability. If we put a flat prior on the log odds of the probability, our 95% credible interval for the actual probability is the two points $\{0,1\}$ before we even see the data! If we get a single positive data point and construct a 95% credible interval, it is now the single point $\{1\}$.
This is why many Bayesians object to flat priors. | When does a confidence interval "make sense" but the corresponding credible interval does not? | If we are using a flat prior, this is simply a game where we try to come up with a flat prior in a reparameterization that doesn't make sense.
For example, suppose we want to make inference on a prob | When does a confidence interval "make sense" but the corresponding credible interval does not?
If we are using a flat prior, this is simply a game where we try to come up with a flat prior in a reparameterization that doesn't make sense.
For example, suppose we want to make inference on a probability. If we put a flat prior on the log odds of the probability, our 95% credible interval for the actual probability is the two points $\{0,1\}$ before we even see the data! If we get a single positive data point and construct a 95% credible interval, it is now the single point $\{1\}$.
This is why many Bayesians object to flat priors. | When does a confidence interval "make sense" but the corresponding credible interval does not?
If we are using a flat prior, this is simply a game where we try to come up with a flat prior in a reparameterization that doesn't make sense.
For example, suppose we want to make inference on a prob |
17,732 | Is it a valid claim, that by differencing a time series, it loses its memory, and as a result its predictive power? | This tries to answer the original question and not get into Marcos's paper etc. If you think that the level of a variable ( say log price ) has information, then differencing the series ( to obtain returns ), throws out information. If you don't think that the level has information, then differencing is fine. Engle and Granger in their 1987 econometric paper showed how it is possible to consider both levels and changes in the relationship between two series ( X and Y) through the use of an ECM. But it does not mean that there can't be cases where one doesn't care about the levels and is only interested in changes ( or vice versa ).
On a different note, here's a piece of advice. Whenever you read anything about strategies and techniques and approaches in finance don't put too much weight in them because, if the author REALLY TRULY HAS SOMETHING THAT WORKS, he-she is not going to divulge it anyway. Most of the stuff you read will be purposely vague and general and unless you know the details of what the person actually does, not terribly useful. That's not to say that Marcos doesn't write interesting papers but he's not going to tell you what he actually does so it's best to read his or anyone's presentations with that in mind. | Is it a valid claim, that by differencing a time series, it loses its memory, and as a result its pr | This tries to answer the original question and not get into Marcos's paper etc. If you think that the level of a variable ( say log price ) has information, then differencing the series ( to obtain re | Is it a valid claim, that by differencing a time series, it loses its memory, and as a result its predictive power?
This tries to answer the original question and not get into Marcos's paper etc. If you think that the level of a variable ( say log price ) has information, then differencing the series ( to obtain returns ), throws out information. If you don't think that the level has information, then differencing is fine. Engle and Granger in their 1987 econometric paper showed how it is possible to consider both levels and changes in the relationship between two series ( X and Y) through the use of an ECM. But it does not mean that there can't be cases where one doesn't care about the levels and is only interested in changes ( or vice versa ).
On a different note, here's a piece of advice. Whenever you read anything about strategies and techniques and approaches in finance don't put too much weight in them because, if the author REALLY TRULY HAS SOMETHING THAT WORKS, he-she is not going to divulge it anyway. Most of the stuff you read will be purposely vague and general and unless you know the details of what the person actually does, not terribly useful. That's not to say that Marcos doesn't write interesting papers but he's not going to tell you what he actually does so it's best to read his or anyone's presentations with that in mind. | Is it a valid claim, that by differencing a time series, it loses its memory, and as a result its pr
This tries to answer the original question and not get into Marcos's paper etc. If you think that the level of a variable ( say log price ) has information, then differencing the series ( to obtain re |
17,733 | Is it a valid claim, that by differencing a time series, it loses its memory, and as a result its predictive power? | Since my similar question was flagged as duplicate (good debate in the comments!), I came across Simon Kuttruf's explanation on Medium:
for integer orders of differencing only a (small) finite set of past
values is reflected in the resulting differenced series: the preceding
value in first order differencing, two preceding values for second
order differencing etc. While for fractional orders of differencing,
all coefficients take on (asymptotically small) non-zero values and so
past values get mixed into the differenced series, up to some chosen
cutoff. This phenomenon is here referred to as ‘long memory’ (or
‘wipe-out of memory’ resp).
If the fraction $d = .5$, then the first four coefficients (check my calculations) according to the recursive formula (see Simon's article)
$$
w_k = -w_{k - 1} \left( \frac{d - k + 1}{k} \right),
$$
the first four values would be 1, -.5, -1/8, and -1/16, leading to the transformation
$$z_t = y_t - \frac{1}{2} y_{t - 1} - \frac{1}{8} y_{t - 2} - \frac{1}{16} y_{t - 3} + \ldots$$
According to the terminology, the "memory is preserved" because the coefficients are positive for infinitely many past values of $y_{t-k}$.
The one example I can think of where memory is clearly lost by a first difference but without any apparent consequences is a true random walk. Where $\epsilon_i$ are i.i.d. $N(0, 1)$ random variables, let
$$
\begin{align}
y_1 &= \epsilon_1, \\
y_2 &= \epsilon_1 +\epsilon_2, \\
y_3 &= \epsilon_1 + \epsilon_2 + \epsilon_3, \\
y_4 &= \epsilon_1 +\epsilon_2 + \epsilon_3 +\epsilon_4.
\end{align}
$$
Then the first difference $y_4 - y_3 = \epsilon_4$ losses all of $y_4$'s information about $\epsilon_1, \ldots, \epsilon_3$, whereas the fractional differencing transformation would contain a bit of all of the epsilons. Not that they'd help you to forecast.
Another maybe more profound example where "memory" matters is a conintegrated time series regression problem described in page 11 of these notes by Eric Sims. There, taking first differences of two cointegrated random walks results in bias in the estimation stage, because the error in the difference vs difference regression includes a correction term to bring things in line with the long run relationship. If you rid yourself of that long term cointegrating relationship by differencing, you'll suffer bias. | Is it a valid claim, that by differencing a time series, it loses its memory, and as a result its pr | Since my similar question was flagged as duplicate (good debate in the comments!), I came across Simon Kuttruf's explanation on Medium:
for integer orders of differencing only a (small) finite set of | Is it a valid claim, that by differencing a time series, it loses its memory, and as a result its predictive power?
Since my similar question was flagged as duplicate (good debate in the comments!), I came across Simon Kuttruf's explanation on Medium:
for integer orders of differencing only a (small) finite set of past
values is reflected in the resulting differenced series: the preceding
value in first order differencing, two preceding values for second
order differencing etc. While for fractional orders of differencing,
all coefficients take on (asymptotically small) non-zero values and so
past values get mixed into the differenced series, up to some chosen
cutoff. This phenomenon is here referred to as ‘long memory’ (or
‘wipe-out of memory’ resp).
If the fraction $d = .5$, then the first four coefficients (check my calculations) according to the recursive formula (see Simon's article)
$$
w_k = -w_{k - 1} \left( \frac{d - k + 1}{k} \right),
$$
the first four values would be 1, -.5, -1/8, and -1/16, leading to the transformation
$$z_t = y_t - \frac{1}{2} y_{t - 1} - \frac{1}{8} y_{t - 2} - \frac{1}{16} y_{t - 3} + \ldots$$
According to the terminology, the "memory is preserved" because the coefficients are positive for infinitely many past values of $y_{t-k}$.
The one example I can think of where memory is clearly lost by a first difference but without any apparent consequences is a true random walk. Where $\epsilon_i$ are i.i.d. $N(0, 1)$ random variables, let
$$
\begin{align}
y_1 &= \epsilon_1, \\
y_2 &= \epsilon_1 +\epsilon_2, \\
y_3 &= \epsilon_1 + \epsilon_2 + \epsilon_3, \\
y_4 &= \epsilon_1 +\epsilon_2 + \epsilon_3 +\epsilon_4.
\end{align}
$$
Then the first difference $y_4 - y_3 = \epsilon_4$ losses all of $y_4$'s information about $\epsilon_1, \ldots, \epsilon_3$, whereas the fractional differencing transformation would contain a bit of all of the epsilons. Not that they'd help you to forecast.
Another maybe more profound example where "memory" matters is a conintegrated time series regression problem described in page 11 of these notes by Eric Sims. There, taking first differences of two cointegrated random walks results in bias in the estimation stage, because the error in the difference vs difference regression includes a correction term to bring things in line with the long run relationship. If you rid yourself of that long term cointegrating relationship by differencing, you'll suffer bias. | Is it a valid claim, that by differencing a time series, it loses its memory, and as a result its pr
Since my similar question was flagged as duplicate (good debate in the comments!), I came across Simon Kuttruf's explanation on Medium:
for integer orders of differencing only a (small) finite set of |
17,734 | Is it a valid claim, that by differencing a time series, it loses its memory, and as a result its predictive power? | The signal processing approach to such problems may be easier to understand. Among other things, the signal to noise ratio (SNR) for stocks may be so high as to render signal detection difficult, there are none-the-less many off-the-shelf algorithms for improving SNR, and that is perhaps of more interest to you. Such algorithms may sacrifice some signal (lossy algorithms) to accomplish noise reduction. The simplest algorithm to understand is perhaps addition. For example, if the trends are low frequency (long term) then reduction of the higher frequency noise by averaging (read as addition of) adjacent temporal signals or averaging over a short time 'window' will tend to reduce high frequency noise more so than low frequency signal thereby improving SNR. In the frequency domain this is called a low pass filter.
With respect to the question, addition and subtraction reduce information in the sense that when an average or difference is created, one loses the information as to what the numbers were before combining them. For example, given a $5$ as a result that could have come from $6-1$, $10-5$ or an uncountably infinite number of other number pairs.
Regarding information content such things are context dependent. If we assume that the noise contains no information, and that only the signal has information content, the goal of signal processing would then be to isolate the signal with the least possible signal loss while reducing the memoryless noise to zero. On the other hand, if the context is that both signal and noise contain information, then obviously noise reduction would seriously reduce information content.
With respect to prediction, if the noise contains no information then one could establish bounds or an 'envelope' in which the noise is contained. That is not exactly a prediction in the same sense as $y=f(t)$, but when coupled with the low pass signal may none-the-less offer a prediction range.
In the real world (assuming money is real) the high frequency data contains less information (but still some) and the low frequency data relatively more information. Still, signal processing may be useful. For example, examining the data in the frequency domain may reveal repetitive occurrences that are not obvious in the data itself, and such a process (Fourier transform) is lossless. | Is it a valid claim, that by differencing a time series, it loses its memory, and as a result its pr | The signal processing approach to such problems may be easier to understand. Among other things, the signal to noise ratio (SNR) for stocks may be so high as to render signal detection difficult, ther | Is it a valid claim, that by differencing a time series, it loses its memory, and as a result its predictive power?
The signal processing approach to such problems may be easier to understand. Among other things, the signal to noise ratio (SNR) for stocks may be so high as to render signal detection difficult, there are none-the-less many off-the-shelf algorithms for improving SNR, and that is perhaps of more interest to you. Such algorithms may sacrifice some signal (lossy algorithms) to accomplish noise reduction. The simplest algorithm to understand is perhaps addition. For example, if the trends are low frequency (long term) then reduction of the higher frequency noise by averaging (read as addition of) adjacent temporal signals or averaging over a short time 'window' will tend to reduce high frequency noise more so than low frequency signal thereby improving SNR. In the frequency domain this is called a low pass filter.
With respect to the question, addition and subtraction reduce information in the sense that when an average or difference is created, one loses the information as to what the numbers were before combining them. For example, given a $5$ as a result that could have come from $6-1$, $10-5$ or an uncountably infinite number of other number pairs.
Regarding information content such things are context dependent. If we assume that the noise contains no information, and that only the signal has information content, the goal of signal processing would then be to isolate the signal with the least possible signal loss while reducing the memoryless noise to zero. On the other hand, if the context is that both signal and noise contain information, then obviously noise reduction would seriously reduce information content.
With respect to prediction, if the noise contains no information then one could establish bounds or an 'envelope' in which the noise is contained. That is not exactly a prediction in the same sense as $y=f(t)$, but when coupled with the low pass signal may none-the-less offer a prediction range.
In the real world (assuming money is real) the high frequency data contains less information (but still some) and the low frequency data relatively more information. Still, signal processing may be useful. For example, examining the data in the frequency domain may reveal repetitive occurrences that are not obvious in the data itself, and such a process (Fourier transform) is lossless. | Is it a valid claim, that by differencing a time series, it loses its memory, and as a result its pr
The signal processing approach to such problems may be easier to understand. Among other things, the signal to noise ratio (SNR) for stocks may be so high as to render signal detection difficult, ther |
17,735 | Is it a valid claim, that by differencing a time series, it loses its memory, and as a result its predictive power? | It's a well-know trade off between explanatory and predictive modeling.
We don't really do the difference nowadays but when you try to fit a model, the goal at the beginning is very important.
I can have the best predictive model of all time with non sense coefficient estimates or have a really good explanatory model that predicts poorly.
So basically when you do a differenciation of your series, you are more in a explanatory case than predictive so you sacrifice a little of the predictive power to have a better model in quality. Or at least you are ready to sacrifice but i don't think it can be proved that it will always make loose predictive power, maybe 95% of the cases base on personal experience. | Is it a valid claim, that by differencing a time series, it loses its memory, and as a result its pr | It's a well-know trade off between explanatory and predictive modeling.
We don't really do the difference nowadays but when you try to fit a model, the goal at the beginning is very important.
I can h | Is it a valid claim, that by differencing a time series, it loses its memory, and as a result its predictive power?
It's a well-know trade off between explanatory and predictive modeling.
We don't really do the difference nowadays but when you try to fit a model, the goal at the beginning is very important.
I can have the best predictive model of all time with non sense coefficient estimates or have a really good explanatory model that predicts poorly.
So basically when you do a differenciation of your series, you are more in a explanatory case than predictive so you sacrifice a little of the predictive power to have a better model in quality. Or at least you are ready to sacrifice but i don't think it can be proved that it will always make loose predictive power, maybe 95% of the cases base on personal experience. | Is it a valid claim, that by differencing a time series, it loses its memory, and as a result its pr
It's a well-know trade off between explanatory and predictive modeling.
We don't really do the difference nowadays but when you try to fit a model, the goal at the beginning is very important.
I can h |
17,736 | Deep Learning: How does beta_1 and beta_2 in the Adam Optimizer affect it's learning? | The hyper-parameters $\beta_1$ and $\beta_2$ of Adam are initial decay rates used when estimating the first and second moments of the gradient, which are multiplied by themselves (exponentially) at the end of each training step (batch). Based on my read of Algorithm 1 in the paper, decreasing $\beta_1$ and $\beta_2$ of Adam will make the learning slower, so if training is going too fast, that could help.
People using Adam might set $\beta_1$ and $\beta_2$ to high values (above 0.9) because they are multiplied by themselves (i.e., exponentially) during training. Setting $\beta_1$ and/or $\beta_2$ of Adam below 0.5 will result in drastic decreases as the number of training steps/batches increases.
My experience is that $\beta_1$ and $\beta_2$ of Adam are definitely tweakable and can be tuned via Bayesian optimization. For that, I use Optuna and have found both of them need to be set much lower than the defaults for optimal MNIST classification (based on maximizing test data classification accuracy) with a deep network trained on 3,833 samples (randomly chosen) from the training data set and validated on the remainder (I explain my reason for choosing that size of training set in this question).
My experiment using Adam to classify MNIST (without allowing amsgrad) revealed the following settings maximized categorical accuracy on the test data (10,000 images, never used for either training or validation) after 500 trials. For the study, I implemented median pruning after the first 100 trials, and allowed each trial a maximum 500 epochs to either converge (defined as patience of 50 epochs with no validation categorical cross-entropy decrease greater than 0.0001), or after pruning starts, beat the median validation of all trials up to that point and subsequently converge as defined above.
single hidden layer followed by single max pooling layer
square kernel size 2
batch size 1024
initial Adam learn rate ~ 0.026
$\beta_1$ ~ 0.28
$\beta_2$ ~ 0.93
I have posted updated demo code necessary to replicate my experiment; please replicate and post whether your results were similar. NB I am currently testing whether Adabelief will outperform Adam...that code is also posted, along with code for both Adam and Adabelief that attempts to implement Jeffreys priors for continuous hyper-parameters on only the first trial of the study (and fails to beat Optuna's native trial.suggest in the case of Adam). | Deep Learning: How does beta_1 and beta_2 in the Adam Optimizer affect it's learning? | The hyper-parameters $\beta_1$ and $\beta_2$ of Adam are initial decay rates used when estimating the first and second moments of the gradient, which are multiplied by themselves (exponentially) at th | Deep Learning: How does beta_1 and beta_2 in the Adam Optimizer affect it's learning?
The hyper-parameters $\beta_1$ and $\beta_2$ of Adam are initial decay rates used when estimating the first and second moments of the gradient, which are multiplied by themselves (exponentially) at the end of each training step (batch). Based on my read of Algorithm 1 in the paper, decreasing $\beta_1$ and $\beta_2$ of Adam will make the learning slower, so if training is going too fast, that could help.
People using Adam might set $\beta_1$ and $\beta_2$ to high values (above 0.9) because they are multiplied by themselves (i.e., exponentially) during training. Setting $\beta_1$ and/or $\beta_2$ of Adam below 0.5 will result in drastic decreases as the number of training steps/batches increases.
My experience is that $\beta_1$ and $\beta_2$ of Adam are definitely tweakable and can be tuned via Bayesian optimization. For that, I use Optuna and have found both of them need to be set much lower than the defaults for optimal MNIST classification (based on maximizing test data classification accuracy) with a deep network trained on 3,833 samples (randomly chosen) from the training data set and validated on the remainder (I explain my reason for choosing that size of training set in this question).
My experiment using Adam to classify MNIST (without allowing amsgrad) revealed the following settings maximized categorical accuracy on the test data (10,000 images, never used for either training or validation) after 500 trials. For the study, I implemented median pruning after the first 100 trials, and allowed each trial a maximum 500 epochs to either converge (defined as patience of 50 epochs with no validation categorical cross-entropy decrease greater than 0.0001), or after pruning starts, beat the median validation of all trials up to that point and subsequently converge as defined above.
single hidden layer followed by single max pooling layer
square kernel size 2
batch size 1024
initial Adam learn rate ~ 0.026
$\beta_1$ ~ 0.28
$\beta_2$ ~ 0.93
I have posted updated demo code necessary to replicate my experiment; please replicate and post whether your results were similar. NB I am currently testing whether Adabelief will outperform Adam...that code is also posted, along with code for both Adam and Adabelief that attempts to implement Jeffreys priors for continuous hyper-parameters on only the first trial of the study (and fails to beat Optuna's native trial.suggest in the case of Adam). | Deep Learning: How does beta_1 and beta_2 in the Adam Optimizer affect it's learning?
The hyper-parameters $\beta_1$ and $\beta_2$ of Adam are initial decay rates used when estimating the first and second moments of the gradient, which are multiplied by themselves (exponentially) at th |
17,737 | Deep Learning: How does beta_1 and beta_2 in the Adam Optimizer affect it's learning? | Simply put Betas are used as for smoothing the path to the convergence also providing some momentum to cross a local minima or saddle point.
Now how does it affects can be thought of as Beta default value 0.9 just averages the gradient or (square of the gradient) of previous 10 batches which is calculated by 1/(1-0.9) which means it represent how we are coming from last 10 batches down when minimizing the loss. So instead of tuning that you can always tune the batch size it will have almost same impact! | Deep Learning: How does beta_1 and beta_2 in the Adam Optimizer affect it's learning? | Simply put Betas are used as for smoothing the path to the convergence also providing some momentum to cross a local minima or saddle point.
Now how does it affects can be thought of as Beta default | Deep Learning: How does beta_1 and beta_2 in the Adam Optimizer affect it's learning?
Simply put Betas are used as for smoothing the path to the convergence also providing some momentum to cross a local minima or saddle point.
Now how does it affects can be thought of as Beta default value 0.9 just averages the gradient or (square of the gradient) of previous 10 batches which is calculated by 1/(1-0.9) which means it represent how we are coming from last 10 batches down when minimizing the loss. So instead of tuning that you can always tune the batch size it will have almost same impact! | Deep Learning: How does beta_1 and beta_2 in the Adam Optimizer affect it's learning?
Simply put Betas are used as for smoothing the path to the convergence also providing some momentum to cross a local minima or saddle point.
Now how does it affects can be thought of as Beta default |
17,738 | Reversing ridge regression: given response matrix and regression coefficients, find suitable predictors | Now that the question has converged on a more precise formulation of the problem of interest, I have found a solution for case 1 (known ridge parameter). This should also help for case 2 (not an analytical solution exactly, but a simple formula and some constraints).
Summary: Neither of the two inverse problem formulations has a unique answer. In case 2, where the ridge parameter $\mu\equiv\omega^2$ is unknown, there are infinitely many solutions $X_\omega$, for $\omega\in[0,\omega_\max]$. In case 1, where $\omega$ is given, there are a finite number of solutions for $X_\omega$, due to ambiguity in the singular-value spectrum.
(The derivation is a bit lengthy, so TL,DR: there is a working Matlab code at the end.)
Under-determined Case ("OLS")
The forward problem is
$$\min_B\|XB-Y\|^2$$
where $X\in\mathbb{R}^{n\times p}$, $B\in\mathbb{R}^{p\times q}$, and $Y\in\mathbb{R}^{n\times q}$.
Based on the updated question, we will assume $n<p<q$, so $B$ is under determined given $X$ and $Y$. As in the question, we will assume the "default" (minimum $L_2$-norm) solution
$$B=X^+Y$$
where $X^+$ is the pseudoinverse of $X$.
From the singular value decomposition (SVD) of $X$, given by*
$$X=USV^T=US_0V_0^T$$
the pseudoinverse can be computed as**
$$X^+=VS^+U^T=V_0S_0^{-1}U^T$$
(*The first expressions use the full SVD, while the second expressions use the reduced SVD. **For simplicity I assume $X$ has full rank, i.e. $S_0^{-1}$ exists.)
So the forward problem has solution
$$B\equiv X^+Y=\left(V_0S_0^{-1}U^T\right)Y$$
For future reference, I note that $S_0=\mathrm{diag}(\sigma_0)$, where $\sigma_0>0$ is the vector of singular values.
In the inverse problem, we are given $Y$ and $B$. We know that $B$ came from the above process, but we do not know $X$. The task is then to determine the appropriate $X$.
As noted in the updated question, in this case we can recover $X$ using essentially the same approach, i.e.
$$X_0=YB^+$$
now using the pseudoinverse of $B$.
Over-determined Case (Ridge estimator)
In the "OLS" case, the under-determined problem was solved by choosing the minimum-norm solution, i.e. our "unique" solution was implicitly regularized.
Rather than choose the minimum norm solution, here we introduce a parameter $\omega$ to control "how small" the norm should be, i.e. we use ridge regression.
In this case, we have a series of forward problems for $\beta_k$, $k=1,\ldots,q$, that are given by
$$\min_\beta\|X\beta-y_k\|^2+\omega^2\|\beta\|^2$$
Collecting the different left and right hand side vectors into
$$B_{\omega}=[\beta_1,\ldots,\beta_k] \quad,\quad Y=[y_1,\ldots,y_k]$$
this collection of problems can be reduced to the following "OLS" problem
$$\min_B\|\mathsf{X}_\omega B-\mathsf{Y}\|^2$$
where we have introduced the augmented matrices
$$\mathsf{X}_\omega=\begin{bmatrix}X \\ \omega I\end{bmatrix}
\quad , \quad \mathsf{Y}=\begin{bmatrix}Y \\ 0 \end{bmatrix}$$
In this over-determined case, the solution is still given by the pseudo-inverse
$$B_\omega = \mathsf{X}^+\mathsf{Y}$$
but the pseudo-inverse is now changed, resulting in*
$$B_\omega = \left(V_0S_\omega^{-2}U^T\right) Y$$
where the new "singularity spectrum" matrix has (inverse) diagonal**
$$ \sigma_\omega^2 = \frac{\sigma_0^2+\omega^2}{\sigma_0} $$
(*The somewhat involved calculation required to derive this has been omitted for the sake of brevity. It is similar to the exposition here for the $p\leq n$ case. **Here the entries of the $\sigma_\omega$ vector are expressed in terms of the $\sigma_0$ vector, where all operations are entry-wise.)
Now in this problem we can still formally recover a "base solution" as
$$X_\omega=YB_\omega^+$$
but this is not a true solution anymore.
However, the analogy still holds in that this "solution" has SVD
$$X_\omega=US_\omega^2V_0^T$$
with the singular values $\sigma_\omega^2$ given above.
So we can derive a quadratic equation relating the desired singular values $\sigma_0$ to the recoverable singular values $\sigma_\omega^2$ and the regularization parameter $\omega$. The solution is then
$$\sigma_0=\bar{\sigma} \pm \Delta\sigma \quad , \quad \bar{\sigma} = \tfrac{1}{2}\sigma_\omega^2 \quad , \quad \Delta\sigma = \sqrt{\left(\bar{\sigma}+\omega\right)\left(\bar{\sigma}-\omega\right)}$$
The Matlab demo below (tested online via Octave) shows that this solution method appears to work in practice as well as theory. The last line shows that all the singular values of $X$ are in the reconstruction $\bar{\sigma}\pm\Delta\sigma$, but I have not completely figured out which root to take (sgn = $+$ vs. $-$). For $\omega=0$ it will always be the $+$ root. This generally seems to hold for "small" $\omega$, whereas for "large" $\omega$ the $-$ root seems to take over. (Demo below is set to "large" case currently.)
% Matlab demo of "Reverse Ridge Regression"
n = 3; p = 5; q = 8; w = 1*sqrt(1e+1); sgn = -1;
Y = rand(n,q); X = rand(n,p);
I = eye(p); Z = zeros(p,q);
err = @(a,b)norm(a(:)-b(:),Inf);
B = pinv([X;w*I])*[Y;Z];
Xhat0 = Y*pinv(B);
dBres0 = err( pinv([Xhat0;w*I])*[Y;Z] , B )
[Uw,Sw2,Vw0] = svd(Xhat0, 'econ');
sw2 = diag(Sw2); s0mid = sw2/2;
ds0 = sqrt(max( 0 , s0mid.^2 - w^2 ));
s0 = s0mid + sgn * ds0;
Xhat = Uw*diag(s0)*Vw0';
dBres = err( pinv([Xhat;w*I])*[Y;Z] , B )
dXerr = err( Xhat , X )
sigX = svd(X)', sigHat = [s0mid+ds0,s0mid-ds0]' % all there, but which sign?
I cannot say how robust this solution is, as inverse problems are generally ill-posed, and analytical solutions can be very fragile. However cursory experiments polluting $B$ with Gaussian noise (i.e. so it has full rank $p$ vs. reduced rank $n$) seem to indicate the method is reasonably well behaved.
As for problem 2 (i.e. $\omega$ unknown), the above gives at least an upper bound on $\omega$. For the quadratic discriminant to be non-negative we must have
$$\omega \leq \omega_{\max} = \bar{\sigma}_n =
\min[\tfrac{1}{2}\sigma_\omega^2]$$
For the quadratic-root sign ambiguity, the following code snippet shows that independent of sign, any $\hat{X}$ will give the same forward $B$ ridge-solution, even when $\sigma_0$ differs from $\mathrm{SVD}[X]$.
Xrnd=Uw*diag(s0mid+sign(randn(n,1)).*ds0)*Vw0'; % random signs
dBrnd=err(pinv([Xrnd;w*I])*[Y;Z],B) % B is always consistent ...
dXrnd=err(Xrnd,X) % ... even when X is not | Reversing ridge regression: given response matrix and regression coefficients, find suitable predict | Now that the question has converged on a more precise formulation of the problem of interest, I have found a solution for case 1 (known ridge parameter). This should also help for case 2 (not an analy | Reversing ridge regression: given response matrix and regression coefficients, find suitable predictors
Now that the question has converged on a more precise formulation of the problem of interest, I have found a solution for case 1 (known ridge parameter). This should also help for case 2 (not an analytical solution exactly, but a simple formula and some constraints).
Summary: Neither of the two inverse problem formulations has a unique answer. In case 2, where the ridge parameter $\mu\equiv\omega^2$ is unknown, there are infinitely many solutions $X_\omega$, for $\omega\in[0,\omega_\max]$. In case 1, where $\omega$ is given, there are a finite number of solutions for $X_\omega$, due to ambiguity in the singular-value spectrum.
(The derivation is a bit lengthy, so TL,DR: there is a working Matlab code at the end.)
Under-determined Case ("OLS")
The forward problem is
$$\min_B\|XB-Y\|^2$$
where $X\in\mathbb{R}^{n\times p}$, $B\in\mathbb{R}^{p\times q}$, and $Y\in\mathbb{R}^{n\times q}$.
Based on the updated question, we will assume $n<p<q$, so $B$ is under determined given $X$ and $Y$. As in the question, we will assume the "default" (minimum $L_2$-norm) solution
$$B=X^+Y$$
where $X^+$ is the pseudoinverse of $X$.
From the singular value decomposition (SVD) of $X$, given by*
$$X=USV^T=US_0V_0^T$$
the pseudoinverse can be computed as**
$$X^+=VS^+U^T=V_0S_0^{-1}U^T$$
(*The first expressions use the full SVD, while the second expressions use the reduced SVD. **For simplicity I assume $X$ has full rank, i.e. $S_0^{-1}$ exists.)
So the forward problem has solution
$$B\equiv X^+Y=\left(V_0S_0^{-1}U^T\right)Y$$
For future reference, I note that $S_0=\mathrm{diag}(\sigma_0)$, where $\sigma_0>0$ is the vector of singular values.
In the inverse problem, we are given $Y$ and $B$. We know that $B$ came from the above process, but we do not know $X$. The task is then to determine the appropriate $X$.
As noted in the updated question, in this case we can recover $X$ using essentially the same approach, i.e.
$$X_0=YB^+$$
now using the pseudoinverse of $B$.
Over-determined Case (Ridge estimator)
In the "OLS" case, the under-determined problem was solved by choosing the minimum-norm solution, i.e. our "unique" solution was implicitly regularized.
Rather than choose the minimum norm solution, here we introduce a parameter $\omega$ to control "how small" the norm should be, i.e. we use ridge regression.
In this case, we have a series of forward problems for $\beta_k$, $k=1,\ldots,q$, that are given by
$$\min_\beta\|X\beta-y_k\|^2+\omega^2\|\beta\|^2$$
Collecting the different left and right hand side vectors into
$$B_{\omega}=[\beta_1,\ldots,\beta_k] \quad,\quad Y=[y_1,\ldots,y_k]$$
this collection of problems can be reduced to the following "OLS" problem
$$\min_B\|\mathsf{X}_\omega B-\mathsf{Y}\|^2$$
where we have introduced the augmented matrices
$$\mathsf{X}_\omega=\begin{bmatrix}X \\ \omega I\end{bmatrix}
\quad , \quad \mathsf{Y}=\begin{bmatrix}Y \\ 0 \end{bmatrix}$$
In this over-determined case, the solution is still given by the pseudo-inverse
$$B_\omega = \mathsf{X}^+\mathsf{Y}$$
but the pseudo-inverse is now changed, resulting in*
$$B_\omega = \left(V_0S_\omega^{-2}U^T\right) Y$$
where the new "singularity spectrum" matrix has (inverse) diagonal**
$$ \sigma_\omega^2 = \frac{\sigma_0^2+\omega^2}{\sigma_0} $$
(*The somewhat involved calculation required to derive this has been omitted for the sake of brevity. It is similar to the exposition here for the $p\leq n$ case. **Here the entries of the $\sigma_\omega$ vector are expressed in terms of the $\sigma_0$ vector, where all operations are entry-wise.)
Now in this problem we can still formally recover a "base solution" as
$$X_\omega=YB_\omega^+$$
but this is not a true solution anymore.
However, the analogy still holds in that this "solution" has SVD
$$X_\omega=US_\omega^2V_0^T$$
with the singular values $\sigma_\omega^2$ given above.
So we can derive a quadratic equation relating the desired singular values $\sigma_0$ to the recoverable singular values $\sigma_\omega^2$ and the regularization parameter $\omega$. The solution is then
$$\sigma_0=\bar{\sigma} \pm \Delta\sigma \quad , \quad \bar{\sigma} = \tfrac{1}{2}\sigma_\omega^2 \quad , \quad \Delta\sigma = \sqrt{\left(\bar{\sigma}+\omega\right)\left(\bar{\sigma}-\omega\right)}$$
The Matlab demo below (tested online via Octave) shows that this solution method appears to work in practice as well as theory. The last line shows that all the singular values of $X$ are in the reconstruction $\bar{\sigma}\pm\Delta\sigma$, but I have not completely figured out which root to take (sgn = $+$ vs. $-$). For $\omega=0$ it will always be the $+$ root. This generally seems to hold for "small" $\omega$, whereas for "large" $\omega$ the $-$ root seems to take over. (Demo below is set to "large" case currently.)
% Matlab demo of "Reverse Ridge Regression"
n = 3; p = 5; q = 8; w = 1*sqrt(1e+1); sgn = -1;
Y = rand(n,q); X = rand(n,p);
I = eye(p); Z = zeros(p,q);
err = @(a,b)norm(a(:)-b(:),Inf);
B = pinv([X;w*I])*[Y;Z];
Xhat0 = Y*pinv(B);
dBres0 = err( pinv([Xhat0;w*I])*[Y;Z] , B )
[Uw,Sw2,Vw0] = svd(Xhat0, 'econ');
sw2 = diag(Sw2); s0mid = sw2/2;
ds0 = sqrt(max( 0 , s0mid.^2 - w^2 ));
s0 = s0mid + sgn * ds0;
Xhat = Uw*diag(s0)*Vw0';
dBres = err( pinv([Xhat;w*I])*[Y;Z] , B )
dXerr = err( Xhat , X )
sigX = svd(X)', sigHat = [s0mid+ds0,s0mid-ds0]' % all there, but which sign?
I cannot say how robust this solution is, as inverse problems are generally ill-posed, and analytical solutions can be very fragile. However cursory experiments polluting $B$ with Gaussian noise (i.e. so it has full rank $p$ vs. reduced rank $n$) seem to indicate the method is reasonably well behaved.
As for problem 2 (i.e. $\omega$ unknown), the above gives at least an upper bound on $\omega$. For the quadratic discriminant to be non-negative we must have
$$\omega \leq \omega_{\max} = \bar{\sigma}_n =
\min[\tfrac{1}{2}\sigma_\omega^2]$$
For the quadratic-root sign ambiguity, the following code snippet shows that independent of sign, any $\hat{X}$ will give the same forward $B$ ridge-solution, even when $\sigma_0$ differs from $\mathrm{SVD}[X]$.
Xrnd=Uw*diag(s0mid+sign(randn(n,1)).*ds0)*Vw0'; % random signs
dBrnd=err(pinv([Xrnd;w*I])*[Y;Z],B) % B is always consistent ...
dXrnd=err(Xrnd,X) % ... even when X is not | Reversing ridge regression: given response matrix and regression coefficients, find suitable predict
Now that the question has converged on a more precise formulation of the problem of interest, I have found a solution for case 1 (known ridge parameter). This should also help for case 2 (not an analy |
17,739 | Statistical variation in two Formula 1 qualifying formats | I think it depends on the distribution of lap times.
Let $X,Y$ be independent, identically distributed.
If $P(X=0)=P(X=1)=\frac{1}{2}$, then $Var(\frac{X+Y}{2}) = \frac{1}{8} < Var( \min(X,Y)) = \frac{3}{16}.$
If, however, $P(X=0) = 0.9, P(X=100)=0.1$, then $Var(\frac{X+Y}{2}) = 450 > Var( \min(X,Y)) = 99.$
This is in line with the argument mentioned in the question about making a mistake (i.e., running an exceptionally long time with a small probability). Thus, we would have to know the distribution of lap times to decide. | Statistical variation in two Formula 1 qualifying formats | I think it depends on the distribution of lap times.
Let $X,Y$ be independent, identically distributed.
If $P(X=0)=P(X=1)=\frac{1}{2}$, then $Var(\frac{X+Y}{2}) = \frac{1}{8} < Var( \min(X,Y)) = \fr | Statistical variation in two Formula 1 qualifying formats
I think it depends on the distribution of lap times.
Let $X,Y$ be independent, identically distributed.
If $P(X=0)=P(X=1)=\frac{1}{2}$, then $Var(\frac{X+Y}{2}) = \frac{1}{8} < Var( \min(X,Y)) = \frac{3}{16}.$
If, however, $P(X=0) = 0.9, P(X=100)=0.1$, then $Var(\frac{X+Y}{2}) = 450 > Var( \min(X,Y)) = 99.$
This is in line with the argument mentioned in the question about making a mistake (i.e., running an exceptionally long time with a small probability). Thus, we would have to know the distribution of lap times to decide. | Statistical variation in two Formula 1 qualifying formats
I think it depends on the distribution of lap times.
Let $X,Y$ be independent, identically distributed.
If $P(X=0)=P(X=1)=\frac{1}{2}$, then $Var(\frac{X+Y}{2}) = \frac{1}{8} < Var( \min(X,Y)) = \fr |
17,740 | Statistical variation in two Formula 1 qualifying formats | Without loss of generality, assume $y \leq x$ and that both varaibles are drawn from the same distribution with a particular mean and variance.
$\{y,x\}$ improves on $\{x\}$ by,
case 1, mean: $\frac{y-x}{2}$,
case 2, min: $y-x$.
Therefore, the mean has half the effect on the improvement (which is driven by the variance) than the taking the minimum (for 2 trials). That is, the mean dampens the variability. | Statistical variation in two Formula 1 qualifying formats | Without loss of generality, assume $y \leq x$ and that both varaibles are drawn from the same distribution with a particular mean and variance.
$\{y,x\}$ improves on $\{x\}$ by,
case 1, mean: $\frac{ | Statistical variation in two Formula 1 qualifying formats
Without loss of generality, assume $y \leq x$ and that both varaibles are drawn from the same distribution with a particular mean and variance.
$\{y,x\}$ improves on $\{x\}$ by,
case 1, mean: $\frac{y-x}{2}$,
case 2, min: $y-x$.
Therefore, the mean has half the effect on the improvement (which is driven by the variance) than the taking the minimum (for 2 trials). That is, the mean dampens the variability. | Statistical variation in two Formula 1 qualifying formats
Without loss of generality, assume $y \leq x$ and that both varaibles are drawn from the same distribution with a particular mean and variance.
$\{y,x\}$ improves on $\{x\}$ by,
case 1, mean: $\frac{ |
17,741 | Statistical variation in two Formula 1 qualifying formats | Here is my proof of Var[Mean]
For 2 random variables x,y there is a relation between their mean and max and min.
$$2\,Mean(x,y) = Min(x,y) + Max(x,y)$$
Therefore
$$4\,Var[Mean] = Var[Min]+Var[Max]+2\,Cov[Min,Max]$$
If we now assume that the distribution is symmetric around the mean then $$Var[Min(x,y)]=Var[Max(x,y)] $$
Then $$ 4\,Var[Mean] = 2\,Var[Min] + 2\,Cov[Min,Max]$$
and $$Cov[Min,Max]<=sqrt(Var[Min]Var[Max])=Var[Min]$$
Therefore $$Var[Mean]<=Var[Min]$$
It is also easy to see from this derivation that in order to reverse this inequality you need a distribution with very sharp truncation of the distribution on the negative side of the mean. For example for the exponential distribution the mean has a larger variance than the min. | Statistical variation in two Formula 1 qualifying formats | Here is my proof of Var[Mean]
For 2 random variables x,y there is a relation between their mean and max and min.
$$2\,Mean(x,y) = Min(x,y) + Max(x,y)$$
Therefore
$$4\,Var[Mean] = Var[Min]+Var[Max]+ | Statistical variation in two Formula 1 qualifying formats
Here is my proof of Var[Mean]
For 2 random variables x,y there is a relation between their mean and max and min.
$$2\,Mean(x,y) = Min(x,y) + Max(x,y)$$
Therefore
$$4\,Var[Mean] = Var[Min]+Var[Max]+2\,Cov[Min,Max]$$
If we now assume that the distribution is symmetric around the mean then $$Var[Min(x,y)]=Var[Max(x,y)] $$
Then $$ 4\,Var[Mean] = 2\,Var[Min] + 2\,Cov[Min,Max]$$
and $$Cov[Min,Max]<=sqrt(Var[Min]Var[Max])=Var[Min]$$
Therefore $$Var[Mean]<=Var[Min]$$
It is also easy to see from this derivation that in order to reverse this inequality you need a distribution with very sharp truncation of the distribution on the negative side of the mean. For example for the exponential distribution the mean has a larger variance than the min. | Statistical variation in two Formula 1 qualifying formats
Here is my proof of Var[Mean]
For 2 random variables x,y there is a relation between their mean and max and min.
$$2\,Mean(x,y) = Min(x,y) + Max(x,y)$$
Therefore
$$4\,Var[Mean] = Var[Min]+Var[Max]+ |
17,742 | Statistical variation in two Formula 1 qualifying formats | Nice question, thank you! I agree with @sandris that distribution of lap times matters, but would like to emphasize that causal aspects of the question need to be addressed. My guess is that F1 wants to avoid a boring situation where the same team or driver dominates the sport year after year, and that they especially hope to introduce the (revenue-generating!) excitement of a real possibility that 'hot' new drivers can suddenly arise in the sport.
That is, my guess is that there is some hope to disrupt excessively stable rankings of teams/drivers. (Consider the analogy with raising the temperature in simulated annealing.) The question then becomes, what are the causal factors at work, and how are they distributed across the population of drivers/teams so as to create persistent advantage for current incumbents. (Consider the analogous question of levying high inheritance taxes to 'level the playing field' in society at large.)
Suppose incumbent teams are maintaining incumbency by a conservative strategy heavily dependent on driver experience, that emphasizes low variance in lap times at the expense of mean lap time. Suppose that by contrast the up-and-coming teams with (say) younger drivers, necessarily adopt a more aggressive (high-risk) strategy with larger variance, but that this involves some spectacular driving that sometimes 'hits it just right' and achieves a stunning lap time. Abstracting away from safety concerns, F1 would clearly like to see some such 'underdogs' in the race. In this causal scenario, it would seem that a best-of-n-laps policy (large $n$) would help give the upstarts a boost -- assuming that the experienced drivers are 'set in their ways', and so couldn't readily adapt their style to the new policy.
Suppose, on the other hand, that engine failure is an uncontrollable event with the same probability across all teams, and that the current rankings correctly reflect genuine gradation in driver/team quality across many other factors. In this case, the bad luck of an engine failure promises to be the lone 'leveling factor' that F1 could exploit to achieve greater equality of opportunity--at least without heavy-handed ranking manipulations that destroy the appearance of 'competition'. In this case, a policy that heavily penalizes engine failures (which are the only factor in this scenario not operating relatively in favor of the incumbents) promises to promote instability in rankings. In this case, the best-of-n policy mentioned above would be exactly the wrong policy to pursue. | Statistical variation in two Formula 1 qualifying formats | Nice question, thank you! I agree with @sandris that distribution of lap times matters, but would like to emphasize that causal aspects of the question need to be addressed. My guess is that F1 wants | Statistical variation in two Formula 1 qualifying formats
Nice question, thank you! I agree with @sandris that distribution of lap times matters, but would like to emphasize that causal aspects of the question need to be addressed. My guess is that F1 wants to avoid a boring situation where the same team or driver dominates the sport year after year, and that they especially hope to introduce the (revenue-generating!) excitement of a real possibility that 'hot' new drivers can suddenly arise in the sport.
That is, my guess is that there is some hope to disrupt excessively stable rankings of teams/drivers. (Consider the analogy with raising the temperature in simulated annealing.) The question then becomes, what are the causal factors at work, and how are they distributed across the population of drivers/teams so as to create persistent advantage for current incumbents. (Consider the analogous question of levying high inheritance taxes to 'level the playing field' in society at large.)
Suppose incumbent teams are maintaining incumbency by a conservative strategy heavily dependent on driver experience, that emphasizes low variance in lap times at the expense of mean lap time. Suppose that by contrast the up-and-coming teams with (say) younger drivers, necessarily adopt a more aggressive (high-risk) strategy with larger variance, but that this involves some spectacular driving that sometimes 'hits it just right' and achieves a stunning lap time. Abstracting away from safety concerns, F1 would clearly like to see some such 'underdogs' in the race. In this causal scenario, it would seem that a best-of-n-laps policy (large $n$) would help give the upstarts a boost -- assuming that the experienced drivers are 'set in their ways', and so couldn't readily adapt their style to the new policy.
Suppose, on the other hand, that engine failure is an uncontrollable event with the same probability across all teams, and that the current rankings correctly reflect genuine gradation in driver/team quality across many other factors. In this case, the bad luck of an engine failure promises to be the lone 'leveling factor' that F1 could exploit to achieve greater equality of opportunity--at least without heavy-handed ranking manipulations that destroy the appearance of 'competition'. In this case, a policy that heavily penalizes engine failures (which are the only factor in this scenario not operating relatively in favor of the incumbents) promises to promote instability in rankings. In this case, the best-of-n policy mentioned above would be exactly the wrong policy to pursue. | Statistical variation in two Formula 1 qualifying formats
Nice question, thank you! I agree with @sandris that distribution of lap times matters, but would like to emphasize that causal aspects of the question need to be addressed. My guess is that F1 wants |
17,743 | Statistical variation in two Formula 1 qualifying formats | I generally agree with other answers that the average of two runs will have a lower variance, but I believe they are leaving out important aspects underlying the problem. A lot has to do with how drivers react to the rules and their strategies for qualifying.
For instance, with only one lap to qualify, drivers would be more conservative, and therefore more predictable and more boring to watch. The idea with two laps is to allow the drivers to take chances on one to try to get that "perfect lap", with another available for a conservative run. More runs would use up a lot of time, which could also be boring. The current setup might just be the "sweet spot" to get the most action in the shortest time frame.
Also note that with an averaging approach, the driver needs to find the fastest repeatable lap time. With the min approach, the driver needs to drive as fast as possible for only one lap, probably pushing further than they would under the averaging approach.
This discussion is closer to game theory. Your question might get better answers when framed in that light. Then one could propose other techniques, like the option for a driver to drop the first lap time in favor of a second run, and possibly a faster or slower time. Etc.
Also note that a change in qualifying was attempted this year that generally pushed drivers into one conservative lap. https://en.wikipedia.org/wiki/2016_Formula_One_season#Qualifying The result was viewed as a disaster and quickly cancelled. | Statistical variation in two Formula 1 qualifying formats | I generally agree with other answers that the average of two runs will have a lower variance, but I believe they are leaving out important aspects underlying the problem. A lot has to do with how dri | Statistical variation in two Formula 1 qualifying formats
I generally agree with other answers that the average of two runs will have a lower variance, but I believe they are leaving out important aspects underlying the problem. A lot has to do with how drivers react to the rules and their strategies for qualifying.
For instance, with only one lap to qualify, drivers would be more conservative, and therefore more predictable and more boring to watch. The idea with two laps is to allow the drivers to take chances on one to try to get that "perfect lap", with another available for a conservative run. More runs would use up a lot of time, which could also be boring. The current setup might just be the "sweet spot" to get the most action in the shortest time frame.
Also note that with an averaging approach, the driver needs to find the fastest repeatable lap time. With the min approach, the driver needs to drive as fast as possible for only one lap, probably pushing further than they would under the averaging approach.
This discussion is closer to game theory. Your question might get better answers when framed in that light. Then one could propose other techniques, like the option for a driver to drop the first lap time in favor of a second run, and possibly a faster or slower time. Etc.
Also note that a change in qualifying was attempted this year that generally pushed drivers into one conservative lap. https://en.wikipedia.org/wiki/2016_Formula_One_season#Qualifying The result was viewed as a disaster and quickly cancelled. | Statistical variation in two Formula 1 qualifying formats
I generally agree with other answers that the average of two runs will have a lower variance, but I believe they are leaving out important aspects underlying the problem. A lot has to do with how dri |
17,744 | Probability distribution for a noisy sine wave | It depends on how the noise process is structured.
Assuming that I've understood your situation correctly, if the noise is additive, independent and identically distributed, you would just take the convolution of the noise density with the density of $Y$.
If $X_i$ is random uniform over a cycle, your noiseless process conditional on $x$ is $Y_i|X_i=x_i$, which is degenerate, with mean $\sin(x_i)$ and variance 0. The marginal distribution of $Y$ is a uniform mixture of those degenerate distributions; it looks like you have worked that distribution out correctly; let's call that density $g$.
If, for example your noise is $\epsilon_i\sim N(0,\sigma^2)$, which is to say $f(\epsilon)=\frac{1}{\sqrt{2\pi}\,\sigma}\exp({\frac{\epsilon^2}{2\sigma^2}})$, then $f*g$ is the density of the sum of the noise with that uniform mixture of noiseless variables.
$f_{Y+\epsilon}(z) = (f*g)(z) = \int_{-\infty}^{\infty} f_{Y}(y)f_{\epsilon}(z-y)dy=\int_{-\infty}^{\infty} f_{Y}(z-w)f_{\epsilon}(w)dw$
(this convolution was done numerically; I don't know how tractable that integral is in this example, because I didn't attempt it.) | Probability distribution for a noisy sine wave | It depends on how the noise process is structured.
Assuming that I've understood your situation correctly, if the noise is additive, independent and identically distributed, you would just take the co | Probability distribution for a noisy sine wave
It depends on how the noise process is structured.
Assuming that I've understood your situation correctly, if the noise is additive, independent and identically distributed, you would just take the convolution of the noise density with the density of $Y$.
If $X_i$ is random uniform over a cycle, your noiseless process conditional on $x$ is $Y_i|X_i=x_i$, which is degenerate, with mean $\sin(x_i)$ and variance 0. The marginal distribution of $Y$ is a uniform mixture of those degenerate distributions; it looks like you have worked that distribution out correctly; let's call that density $g$.
If, for example your noise is $\epsilon_i\sim N(0,\sigma^2)$, which is to say $f(\epsilon)=\frac{1}{\sqrt{2\pi}\,\sigma}\exp({\frac{\epsilon^2}{2\sigma^2}})$, then $f*g$ is the density of the sum of the noise with that uniform mixture of noiseless variables.
$f_{Y+\epsilon}(z) = (f*g)(z) = \int_{-\infty}^{\infty} f_{Y}(y)f_{\epsilon}(z-y)dy=\int_{-\infty}^{\infty} f_{Y}(z-w)f_{\epsilon}(w)dw$
(this convolution was done numerically; I don't know how tractable that integral is in this example, because I didn't attempt it.) | Probability distribution for a noisy sine wave
It depends on how the noise process is structured.
Assuming that I've understood your situation correctly, if the noise is additive, independent and identically distributed, you would just take the co |
17,745 | Probability distribution for a noisy sine wave | I think the derived expression for P(x) is off by a factor of two. Uniformly distributed sample time is equivalent to uniformly distributes phase over the interval -pi,pi. The trigonometricfunction distributes probability over the y interval {-1,1}. Integrating P(y) over this interval must = 1, not 2 as obtained using your integrand above. I think P(y) = 1/(pi Sqrt(1-y^2)) | Probability distribution for a noisy sine wave | I think the derived expression for P(x) is off by a factor of two. Uniformly distributed sample time is equivalent to uniformly distributes phase over the interval -pi,pi. The trigonometricfunction di | Probability distribution for a noisy sine wave
I think the derived expression for P(x) is off by a factor of two. Uniformly distributed sample time is equivalent to uniformly distributes phase over the interval -pi,pi. The trigonometricfunction distributes probability over the y interval {-1,1}. Integrating P(y) over this interval must = 1, not 2 as obtained using your integrand above. I think P(y) = 1/(pi Sqrt(1-y^2)) | Probability distribution for a noisy sine wave
I think the derived expression for P(x) is off by a factor of two. Uniformly distributed sample time is equivalent to uniformly distributes phase over the interval -pi,pi. The trigonometricfunction di |
17,746 | Canonical correlation analysis with rank correlation | I used restricted cubic spline expansions when computing canonical variates. You are adding nonlinear basis functions to the analysis exactly as you would be adding new features. This results in nonlinear principal component analysis. See the R Hmisc package's transcan function for an example. The R homals package takes this much further. | Canonical correlation analysis with rank correlation | I used restricted cubic spline expansions when computing canonical variates. You are adding nonlinear basis functions to the analysis exactly as you would be adding new features. This results in non | Canonical correlation analysis with rank correlation
I used restricted cubic spline expansions when computing canonical variates. You are adding nonlinear basis functions to the analysis exactly as you would be adding new features. This results in nonlinear principal component analysis. See the R Hmisc package's transcan function for an example. The R homals package takes this much further. | Canonical correlation analysis with rank correlation
I used restricted cubic spline expansions when computing canonical variates. You are adding nonlinear basis functions to the analysis exactly as you would be adding new features. This results in non |
17,747 | Canonical correlation analysis with rank correlation | The standard method of CCA works with product moment correlation coefficient matrix. For largest mgnitude CC it constructs two composite variables z1(n) and z2(n) by linear combination of two matixes (with n rows and m1 and m2 variables) such that abs(correlation(z1,z2)) is maximized. This objective function may be maximized directly even if correlation(z1,z2) is not product moment but defined differently.
Mishra, SK (2009) "A Note on the Ordinal Canonical Correlation Analysis of Two Sets of Ranking Scores"
http://papers.ssrn.com/sol3/papers.cfm?abstract_id=1328319 | Canonical correlation analysis with rank correlation | The standard method of CCA works with product moment correlation coefficient matrix. For largest mgnitude CC it constructs two composite variables z1(n) and z2(n) by linear combination of two matixes | Canonical correlation analysis with rank correlation
The standard method of CCA works with product moment correlation coefficient matrix. For largest mgnitude CC it constructs two composite variables z1(n) and z2(n) by linear combination of two matixes (with n rows and m1 and m2 variables) such that abs(correlation(z1,z2)) is maximized. This objective function may be maximized directly even if correlation(z1,z2) is not product moment but defined differently.
Mishra, SK (2009) "A Note on the Ordinal Canonical Correlation Analysis of Two Sets of Ranking Scores"
http://papers.ssrn.com/sol3/papers.cfm?abstract_id=1328319 | Canonical correlation analysis with rank correlation
The standard method of CCA works with product moment correlation coefficient matrix. For largest mgnitude CC it constructs two composite variables z1(n) and z2(n) by linear combination of two matixes |
17,748 | Meaning of output terms in gbm package? | You should find these are related to determining the best value for the number of basis functions - i.e. iterations - i.e. number of trees in the additive model. I cant find documentation describing exactly what these are but here is my best guess and maybe someone else can comment.
Take the following from the manual:
library(gbm)
# A least squares regression example
# create some data
N <- 1000
X1 <- runif(N)
X2 <- 2*runif(N)
X3 <- ordered(sample(letters[1:4],N,replace=TRUE),levels=letters[4:1])
X4 <- factor(sample(letters[1:6],N,replace=TRUE))
X5 <- factor(sample(letters[1:3],N,replace=TRUE))
X6 <- 3*runif(N)
mu <- c(-1,0,1,2)[as.numeric(X3)]
SNR <- 10 # signal-to-noise ratio
Y <- X1**1.5 + 2 * (X2**.5) + mu
sigma <- sqrt(var(Y)/SNR)
Y <- Y + rnorm(N,0,sigma)
# introduce some missing values
X1[sample(1:N,size=500)] <- NA
X4[sample(1:N,size=300)] <- NA
data <- data.frame(Y=Y,X1=X1,X2=X2,X3=X3,X4=X4,X5=X5,X6=X6)
# fit initial model
gbm1 <- gbm(Y~X1+X2+X3+X4+X5+X6, # formula
data=data, # dataset
var.monotone=c(0,0,0,0,0,0), # -1: monotone decrease,
# +1: monotone increase,
# 0: no monotone restrictions
distribution="gaussian", # bernoulli, adaboost, gaussian,
# poisson, coxph, and quantile available
n.trees=3000, # number of trees
shrinkage=0.005, # shrinkage or learning rate,
# 0.001 to 0.1 usually work
interaction.depth=3, # 1: additive model, 2: two-way interactions, etc.
bag.fraction = 0.5, # subsampling fraction, 0.5 is probably best
train.fraction = 0.5, # fraction of data for training,
# first train.fraction*N used for training
n.minobsinnode = 10, # minimum total weight needed in each node
cv.folds = 5, # do 5-fold cross-validation
keep.data=TRUE, # keep a copy of the dataset with the object
verbose=TRUE) # print out progress
The number of iterations (Iter) is 3000, which is the number of trees selected to be built (1 to 3000 although not every one is shown). The full process is repeated 5 times by the way because we selected cv.folds=5.
StepSize is the shrinkage or learning rate selected (0.005 here).
I believe that Improve is the reduction in the deviance (loss function) by adding another tree and is calculated using the out-of-bag (OOB) records (note it will not be calculated if bag.fraction is not <1).
Then for each iteration, the TrainDeviance ValidDeviance is the value of the loss function on the training data and hold out data (a single hold out set). The ValidDeviance will not be calculated if train.fraction is not <1.
Have you seen this which describes the 3 types of methods for determining the optimal number of trees? | Meaning of output terms in gbm package? | You should find these are related to determining the best value for the number of basis functions - i.e. iterations - i.e. number of trees in the additive model. I cant find documentation describing | Meaning of output terms in gbm package?
You should find these are related to determining the best value for the number of basis functions - i.e. iterations - i.e. number of trees in the additive model. I cant find documentation describing exactly what these are but here is my best guess and maybe someone else can comment.
Take the following from the manual:
library(gbm)
# A least squares regression example
# create some data
N <- 1000
X1 <- runif(N)
X2 <- 2*runif(N)
X3 <- ordered(sample(letters[1:4],N,replace=TRUE),levels=letters[4:1])
X4 <- factor(sample(letters[1:6],N,replace=TRUE))
X5 <- factor(sample(letters[1:3],N,replace=TRUE))
X6 <- 3*runif(N)
mu <- c(-1,0,1,2)[as.numeric(X3)]
SNR <- 10 # signal-to-noise ratio
Y <- X1**1.5 + 2 * (X2**.5) + mu
sigma <- sqrt(var(Y)/SNR)
Y <- Y + rnorm(N,0,sigma)
# introduce some missing values
X1[sample(1:N,size=500)] <- NA
X4[sample(1:N,size=300)] <- NA
data <- data.frame(Y=Y,X1=X1,X2=X2,X3=X3,X4=X4,X5=X5,X6=X6)
# fit initial model
gbm1 <- gbm(Y~X1+X2+X3+X4+X5+X6, # formula
data=data, # dataset
var.monotone=c(0,0,0,0,0,0), # -1: monotone decrease,
# +1: monotone increase,
# 0: no monotone restrictions
distribution="gaussian", # bernoulli, adaboost, gaussian,
# poisson, coxph, and quantile available
n.trees=3000, # number of trees
shrinkage=0.005, # shrinkage or learning rate,
# 0.001 to 0.1 usually work
interaction.depth=3, # 1: additive model, 2: two-way interactions, etc.
bag.fraction = 0.5, # subsampling fraction, 0.5 is probably best
train.fraction = 0.5, # fraction of data for training,
# first train.fraction*N used for training
n.minobsinnode = 10, # minimum total weight needed in each node
cv.folds = 5, # do 5-fold cross-validation
keep.data=TRUE, # keep a copy of the dataset with the object
verbose=TRUE) # print out progress
The number of iterations (Iter) is 3000, which is the number of trees selected to be built (1 to 3000 although not every one is shown). The full process is repeated 5 times by the way because we selected cv.folds=5.
StepSize is the shrinkage or learning rate selected (0.005 here).
I believe that Improve is the reduction in the deviance (loss function) by adding another tree and is calculated using the out-of-bag (OOB) records (note it will not be calculated if bag.fraction is not <1).
Then for each iteration, the TrainDeviance ValidDeviance is the value of the loss function on the training data and hold out data (a single hold out set). The ValidDeviance will not be calculated if train.fraction is not <1.
Have you seen this which describes the 3 types of methods for determining the optimal number of trees? | Meaning of output terms in gbm package?
You should find these are related to determining the best value for the number of basis functions - i.e. iterations - i.e. number of trees in the additive model. I cant find documentation describing |
17,749 | What are alternatives to VC-dimension for measuring the complexity of neural networks? | You might want to have a look at the paper "(Not) Bounding the True Error by John Langford & Rich Caruana (NIPS, 2001)
The abstract states:
We present a new approach to bounding the true error rate of a continuous valued classifier based upon PAC-Bayes bounds. The method first constructs a distribution over classifiers by determining how sensitive each parameter in the model is to noise. The true error rate of the stochastic classifier found with the sensitivity analysis can then be tightly bounded using a PAC-Bayes bound. In this paper we demonstrate the method on artificial neural networks with results of a 2 3 order of magnitude improvement vs. the best deterministic neural net bounds.
They show that you can apply PAC-Bayes style bounds to stochastic neural networks. However the analysis only applies to 2-layer feed-forward neural networks with a sigmoidal transfer function. In this case the complexity term only depends on the number of nodes and the variance of the weights. They show that for this setting the bound effectively predicts when over-training will occur. Unfortunately it doesn't really hit any of your "preferred" properties though! | What are alternatives to VC-dimension for measuring the complexity of neural networks? | You might want to have a look at the paper "(Not) Bounding the True Error by John Langford & Rich Caruana (NIPS, 2001)
The abstract states:
We present a new approach to bounding the true error rate o | What are alternatives to VC-dimension for measuring the complexity of neural networks?
You might want to have a look at the paper "(Not) Bounding the True Error by John Langford & Rich Caruana (NIPS, 2001)
The abstract states:
We present a new approach to bounding the true error rate of a continuous valued classifier based upon PAC-Bayes bounds. The method first constructs a distribution over classifiers by determining how sensitive each parameter in the model is to noise. The true error rate of the stochastic classifier found with the sensitivity analysis can then be tightly bounded using a PAC-Bayes bound. In this paper we demonstrate the method on artificial neural networks with results of a 2 3 order of magnitude improvement vs. the best deterministic neural net bounds.
They show that you can apply PAC-Bayes style bounds to stochastic neural networks. However the analysis only applies to 2-layer feed-forward neural networks with a sigmoidal transfer function. In this case the complexity term only depends on the number of nodes and the variance of the weights. They show that for this setting the bound effectively predicts when over-training will occur. Unfortunately it doesn't really hit any of your "preferred" properties though! | What are alternatives to VC-dimension for measuring the complexity of neural networks?
You might want to have a look at the paper "(Not) Bounding the True Error by John Langford & Rich Caruana (NIPS, 2001)
The abstract states:
We present a new approach to bounding the true error rate o |
17,750 | What are alternatives to VC-dimension for measuring the complexity of neural networks? | In addition, you might also have interest in the fat-shattering dimension work done by Professor Peter Bartlett.
Here is an introduction to the analysis of the neural network complexity, in a 1998 IEEE paper:
The Sample Complexity of Pattern Classification
with Neural Networks: The Size of the Weights is
More Important than the Size of the Network (Bartlett 1998)
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=661502] | What are alternatives to VC-dimension for measuring the complexity of neural networks? | In addition, you might also have interest in the fat-shattering dimension work done by Professor Peter Bartlett.
Here is an introduction to the analysis of the neural network complexity, in a 1998 IE | What are alternatives to VC-dimension for measuring the complexity of neural networks?
In addition, you might also have interest in the fat-shattering dimension work done by Professor Peter Bartlett.
Here is an introduction to the analysis of the neural network complexity, in a 1998 IEEE paper:
The Sample Complexity of Pattern Classification
with Neural Networks: The Size of the Weights is
More Important than the Size of the Network (Bartlett 1998)
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=661502] | What are alternatives to VC-dimension for measuring the complexity of neural networks?
In addition, you might also have interest in the fat-shattering dimension work done by Professor Peter Bartlett.
Here is an introduction to the analysis of the neural network complexity, in a 1998 IE |
17,751 | Probability theory books for self-study | I recommend Head First Statistics. The 'Head First' Series is of superior didactic quality and fun to read. It has a lot of exercises, and was one of the few books were I liked doing the exercises.
http://www.amazon.com/Head-First-Statistics-Dawn-Griffiths/dp/0596527586 | Probability theory books for self-study | I recommend Head First Statistics. The 'Head First' Series is of superior didactic quality and fun to read. It has a lot of exercises, and was one of the few books were I liked doing the exercises.
ht | Probability theory books for self-study
I recommend Head First Statistics. The 'Head First' Series is of superior didactic quality and fun to read. It has a lot of exercises, and was one of the few books were I liked doing the exercises.
http://www.amazon.com/Head-First-Statistics-Dawn-Griffiths/dp/0596527586 | Probability theory books for self-study
I recommend Head First Statistics. The 'Head First' Series is of superior didactic quality and fun to read. It has a lot of exercises, and was one of the few books were I liked doing the exercises.
ht |
17,752 | Probability theory books for self-study | I was looking for the same a week ago. I found from another post on stackexchange about this book Intuitive biostatistics: A Nonmathematical Guide to Statistical Thinking by Harvey Motulsky. I think the second part of the title is pretty lame. But generally I have/had no problems in understanding the math, but found none of them explaining concepts clear enough for me. I just ordered this book based on the reviews, so I can't give an opinion about it myself yet. There were good reviews on amazon and on stackexchange (although many preferred the 1st edition to 2nd). If you're looking for something totally different, this might interest you. | Probability theory books for self-study | I was looking for the same a week ago. I found from another post on stackexchange about this book Intuitive biostatistics: A Nonmathematical Guide to Statistical Thinking by Harvey Motulsky. I think t | Probability theory books for self-study
I was looking for the same a week ago. I found from another post on stackexchange about this book Intuitive biostatistics: A Nonmathematical Guide to Statistical Thinking by Harvey Motulsky. I think the second part of the title is pretty lame. But generally I have/had no problems in understanding the math, but found none of them explaining concepts clear enough for me. I just ordered this book based on the reviews, so I can't give an opinion about it myself yet. There were good reviews on amazon and on stackexchange (although many preferred the 1st edition to 2nd). If you're looking for something totally different, this might interest you. | Probability theory books for self-study
I was looking for the same a week ago. I found from another post on stackexchange about this book Intuitive biostatistics: A Nonmathematical Guide to Statistical Thinking by Harvey Motulsky. I think t |
17,753 | Probability theory books for self-study | Schaeffer's book from Duxbury press seems ok. Sheldon Ross' books are always awesome. Note, these are both books on Probability, not stats, which is what you asked. | Probability theory books for self-study | Schaeffer's book from Duxbury press seems ok. Sheldon Ross' books are always awesome. Note, these are both books on Probability, not stats, which is what you asked. | Probability theory books for self-study
Schaeffer's book from Duxbury press seems ok. Sheldon Ross' books are always awesome. Note, these are both books on Probability, not stats, which is what you asked. | Probability theory books for self-study
Schaeffer's book from Duxbury press seems ok. Sheldon Ross' books are always awesome. Note, these are both books on Probability, not stats, which is what you asked. |
17,754 | Probability theory books for self-study | I'd strongly recommend Bulmer's Principles of Statistics as a leaping-off point. It's a touch dated, but it's short, clear and available in a cheap Dover edition - around $10 from Amazon. For a more modern and to the point statistical book I'd suggest Wasserman's "All of Statistics". I got it a few months back and it's been a good survey of everything - I've not read the first few chapters in detail but it seems ok on a skim. I like some of the practical advice which would be useful in a self study context - e.g. "Unbiasdness used to receive much attention but these days is considered less important".
But this is assuming you want a practical statistics text which covers some probabilty rather than a probability theory text. For probability theory, I'd suggest reading a lot on measure theory and hit something on Lebegue integration first - but this doesn't sound like where you're at. | Probability theory books for self-study | I'd strongly recommend Bulmer's Principles of Statistics as a leaping-off point. It's a touch dated, but it's short, clear and available in a cheap Dover edition - around $10 from Amazon. For a more | Probability theory books for self-study
I'd strongly recommend Bulmer's Principles of Statistics as a leaping-off point. It's a touch dated, but it's short, clear and available in a cheap Dover edition - around $10 from Amazon. For a more modern and to the point statistical book I'd suggest Wasserman's "All of Statistics". I got it a few months back and it's been a good survey of everything - I've not read the first few chapters in detail but it seems ok on a skim. I like some of the practical advice which would be useful in a self study context - e.g. "Unbiasdness used to receive much attention but these days is considered less important".
But this is assuming you want a practical statistics text which covers some probabilty rather than a probability theory text. For probability theory, I'd suggest reading a lot on measure theory and hit something on Lebegue integration first - but this doesn't sound like where you're at. | Probability theory books for self-study
I'd strongly recommend Bulmer's Principles of Statistics as a leaping-off point. It's a touch dated, but it's short, clear and available in a cheap Dover edition - around $10 from Amazon. For a more |
17,755 | Probability theory books for self-study | https://www.crcpress.com/Introduction-to-Probability/Blitzstein-Hwang/p/book/9781466575578 - Introduction to Probability
I had no experience in probability before; this is a good book that explains the basic probability distributions with motivating context. Begins with discrete random variables and moves to continuous, which is good for the beginner. Builds your foundation up so you can tackle more advanced topics in the future. | Probability theory books for self-study | https://www.crcpress.com/Introduction-to-Probability/Blitzstein-Hwang/p/book/9781466575578 - Introduction to Probability
I had no experience in probability before; this is a good book that explains th | Probability theory books for self-study
https://www.crcpress.com/Introduction-to-Probability/Blitzstein-Hwang/p/book/9781466575578 - Introduction to Probability
I had no experience in probability before; this is a good book that explains the basic probability distributions with motivating context. Begins with discrete random variables and moves to continuous, which is good for the beginner. Builds your foundation up so you can tackle more advanced topics in the future. | Probability theory books for self-study
https://www.crcpress.com/Introduction-to-Probability/Blitzstein-Hwang/p/book/9781466575578 - Introduction to Probability
I had no experience in probability before; this is a good book that explains th |
17,756 | Probability theory books for self-study | Yes, I agree that the John Rice book is not good for self-study. It jumps around topics of varying difficulty, although it is obvious the author is a very experienced practitioner. For my level, it does more confusion than enlightenment.
I would highly recommend:
Dimitri Bertsekas
Sheldon Ross
Ron C. Mittelhammer
Richard Larsen
You can contact me if you want copies. | Probability theory books for self-study | Yes, I agree that the John Rice book is not good for self-study. It jumps around topics of varying difficulty, although it is obvious the author is a very experienced practitioner. For my level, it do | Probability theory books for self-study
Yes, I agree that the John Rice book is not good for self-study. It jumps around topics of varying difficulty, although it is obvious the author is a very experienced practitioner. For my level, it does more confusion than enlightenment.
I would highly recommend:
Dimitri Bertsekas
Sheldon Ross
Ron C. Mittelhammer
Richard Larsen
You can contact me if you want copies. | Probability theory books for self-study
Yes, I agree that the John Rice book is not good for self-study. It jumps around topics of varying difficulty, although it is obvious the author is a very experienced practitioner. For my level, it do |
17,757 | Analysis of cross correlation between point-processes | A standard method to analyze this problem in two or more dimensions is Ripley's (cross) K function, but there's no reason not to use it in one dimension, too. (A Google search does a good job of digging up references.) Essentially, it plots the CDF of all distances between points in the two realizations rather than a histogram approximation to the PDF of those distances. (A variant, the L function, plots the difference between K and the null distribution for two uniform uncorrelated processes.) This neatly sidesteps most of the issues you are confronting with the need to choose bins, to smooth, etc. Confidence bands for K are typically created through simulation. This is easy to do in R. Many spatial stats packages for R can be used directly or readily adapted to this 1D case. Roger Bivand's overview page on CRAN lists these packages: refer to the section on "Point Pattern Analysis." | Analysis of cross correlation between point-processes | A standard method to analyze this problem in two or more dimensions is Ripley's (cross) K function, but there's no reason not to use it in one dimension, too. (A Google search does a good job of digg | Analysis of cross correlation between point-processes
A standard method to analyze this problem in two or more dimensions is Ripley's (cross) K function, but there's no reason not to use it in one dimension, too. (A Google search does a good job of digging up references.) Essentially, it plots the CDF of all distances between points in the two realizations rather than a histogram approximation to the PDF of those distances. (A variant, the L function, plots the difference between K and the null distribution for two uniform uncorrelated processes.) This neatly sidesteps most of the issues you are confronting with the need to choose bins, to smooth, etc. Confidence bands for K are typically created through simulation. This is easy to do in R. Many spatial stats packages for R can be used directly or readily adapted to this 1D case. Roger Bivand's overview page on CRAN lists these packages: refer to the section on "Point Pattern Analysis." | Analysis of cross correlation between point-processes
A standard method to analyze this problem in two or more dimensions is Ripley's (cross) K function, but there's no reason not to use it in one dimension, too. (A Google search does a good job of digg |
17,758 | Should one be concerned about multi-collinearity when using non-linear models? | Multi-collinearity will not be a problem for certain models. Such as random forest or decision tree. For example, if we have two identical columns, decision tree / random forest will automatically "drop" one column at each split. And the model will still work well.
In addition, regularization is a way to "fix" Multi-collinearity problem. My answer Regularization methods for logistic regression gives details. | Should one be concerned about multi-collinearity when using non-linear models? | Multi-collinearity will not be a problem for certain models. Such as random forest or decision tree. For example, if we have two identical columns, decision tree / random forest will automatically "dr | Should one be concerned about multi-collinearity when using non-linear models?
Multi-collinearity will not be a problem for certain models. Such as random forest or decision tree. For example, if we have two identical columns, decision tree / random forest will automatically "drop" one column at each split. And the model will still work well.
In addition, regularization is a way to "fix" Multi-collinearity problem. My answer Regularization methods for logistic regression gives details. | Should one be concerned about multi-collinearity when using non-linear models?
Multi-collinearity will not be a problem for certain models. Such as random forest or decision tree. For example, if we have two identical columns, decision tree / random forest will automatically "dr |
17,759 | Should one be concerned about multi-collinearity when using non-linear models? | Late to the party, but here is my answer anyway, and it is "Yes", one should always be concerned about the collinearity, regardless of the model/method being linear or not, or the main task being prediction or classification.
Assume a number of linearly correlated covariates/features present in the data set and Random Forest as the method. Obviously, random selection per node may pick only (or mostly) collinear features which may/will result in a poor split, and this can happen repeatedly, thus negatively affecting the performance.
Now, the collinear features may be less informative of the outcome than the other (non-collinear) features and as such they should be considered for elimination from the feature set anyway. However, assume that the features are ranked high in the 'feature importance' list produced by RF.
As such they would be kept in the data set unnecessarily increasing the dimensionality. So, in practice, I'd always, as an exploratory step (out of many related) check the pairwise association of the features, including linear correlation. | Should one be concerned about multi-collinearity when using non-linear models? | Late to the party, but here is my answer anyway, and it is "Yes", one should always be concerned about the collinearity, regardless of the model/method being linear or not, or the main task being pred | Should one be concerned about multi-collinearity when using non-linear models?
Late to the party, but here is my answer anyway, and it is "Yes", one should always be concerned about the collinearity, regardless of the model/method being linear or not, or the main task being prediction or classification.
Assume a number of linearly correlated covariates/features present in the data set and Random Forest as the method. Obviously, random selection per node may pick only (or mostly) collinear features which may/will result in a poor split, and this can happen repeatedly, thus negatively affecting the performance.
Now, the collinear features may be less informative of the outcome than the other (non-collinear) features and as such they should be considered for elimination from the feature set anyway. However, assume that the features are ranked high in the 'feature importance' list produced by RF.
As such they would be kept in the data set unnecessarily increasing the dimensionality. So, in practice, I'd always, as an exploratory step (out of many related) check the pairwise association of the features, including linear correlation. | Should one be concerned about multi-collinearity when using non-linear models?
Late to the party, but here is my answer anyway, and it is "Yes", one should always be concerned about the collinearity, regardless of the model/method being linear or not, or the main task being pred |
17,760 | Should one be concerned about multi-collinearity when using non-linear models? | Should one still be concerned about multi-collinearity? Why?
If the non-linear model is tree-based model, then you shouldn't consider it serious. Different tree model will have different deal method, such as the random forest will keep them both (because they build the tree independently, and random select the feature for every trees), but it have no effect about the prediction performance, even you remove the redundant one. But for xgboost, it will choose anyone of them, and use it until the last tree build.
If the answer to the above is true, how should one fight it considering that one is using these types of non-linear models?
It just about the interpretation meaning, so remove the highly correlation variable is suggested. | Should one be concerned about multi-collinearity when using non-linear models? | Should one still be concerned about multi-collinearity? Why?
If the non-linear model is tree-based model, then you shouldn't consider it serious. Different tree model will have different deal method, | Should one be concerned about multi-collinearity when using non-linear models?
Should one still be concerned about multi-collinearity? Why?
If the non-linear model is tree-based model, then you shouldn't consider it serious. Different tree model will have different deal method, such as the random forest will keep them both (because they build the tree independently, and random select the feature for every trees), but it have no effect about the prediction performance, even you remove the redundant one. But for xgboost, it will choose anyone of them, and use it until the last tree build.
If the answer to the above is true, how should one fight it considering that one is using these types of non-linear models?
It just about the interpretation meaning, so remove the highly correlation variable is suggested. | Should one be concerned about multi-collinearity when using non-linear models?
Should one still be concerned about multi-collinearity? Why?
If the non-linear model is tree-based model, then you shouldn't consider it serious. Different tree model will have different deal method, |
17,761 | Should one be concerned about multi-collinearity when using non-linear models? | Multi-collinearity is always a possible problem. Variables that are predictors in the model will affect the prediction when they are linearly related (i.e., when collinearity is present). | Should one be concerned about multi-collinearity when using non-linear models? | Multi-collinearity is always a possible problem. Variables that are predictors in the model will affect the prediction when they are linearly related (i.e., when collinearity is present). | Should one be concerned about multi-collinearity when using non-linear models?
Multi-collinearity is always a possible problem. Variables that are predictors in the model will affect the prediction when they are linearly related (i.e., when collinearity is present). | Should one be concerned about multi-collinearity when using non-linear models?
Multi-collinearity is always a possible problem. Variables that are predictors in the model will affect the prediction when they are linearly related (i.e., when collinearity is present). |
17,762 | Conflicting approaches to variable selection: AIC, p-values or both? | A short answer.
The approach of doing data-driven model selection or tuning, then using standard inferential methods on the selected/tuned model (à la Zuur et al., and many other respected ecologists such as Crawley), will always give overoptimistic results: overly narrow confidence intervals (poor coverage), overly small p-values (high type I error). This is because standard inferential methods assume the model is specified a priori; they don't take the model tuning process into account.
This is why researchers like Frank Harrell (Regression Modeling Strategies) strongly disapprove of data-driven selection techniques like stepwise regression, and caution that one must do any reduction of the model complexity ("dimension reduction", e.g. computing a PCA of the predictor variables and selecting the first few PCA axes as predictors) by looking only at the predictor variables.
If you are interested only in finding the best predictive model (and aren't interested in any kind of reliable estimate of the uncertainty of your prediction, which falls in the realm of inference!), then data-driven model tuning is fine (although stepwise selection is rarely the best available option); machine learning/statistical learning algorithms do a lot of tuning to try to get the best predictive model. The "test" or "out-of-sample" error must be assessed on a separate, held-out sample, or any tuning methods need to be built into a cross-validation procedure.
There does seem to have been historical evolution in opinions on this topic; many classic statistical textbooks, especially those that focus on regression, present stepwise approaches followed by standard inferential procedures without taking the effects of model selection into account [citation needed ...]
There are many ways to quantify variable importance, and not all fall into the post-variable-selection trap.
Burnham and Anderson recommend summing AIC weights; there's quite a bit of disagreement over this approach.
You could fit the full model (with appropriately scaled/unitless predictors) and rank the predictors by estimated magnitude [biological effect size] or Z-score ["clarity"/statistical effect size]. | Conflicting approaches to variable selection: AIC, p-values or both? | A short answer.
The approach of doing data-driven model selection or tuning, then using standard inferential methods on the selected/tuned model (à la Zuur et al., and many other respected ecologists | Conflicting approaches to variable selection: AIC, p-values or both?
A short answer.
The approach of doing data-driven model selection or tuning, then using standard inferential methods on the selected/tuned model (à la Zuur et al., and many other respected ecologists such as Crawley), will always give overoptimistic results: overly narrow confidence intervals (poor coverage), overly small p-values (high type I error). This is because standard inferential methods assume the model is specified a priori; they don't take the model tuning process into account.
This is why researchers like Frank Harrell (Regression Modeling Strategies) strongly disapprove of data-driven selection techniques like stepwise regression, and caution that one must do any reduction of the model complexity ("dimension reduction", e.g. computing a PCA of the predictor variables and selecting the first few PCA axes as predictors) by looking only at the predictor variables.
If you are interested only in finding the best predictive model (and aren't interested in any kind of reliable estimate of the uncertainty of your prediction, which falls in the realm of inference!), then data-driven model tuning is fine (although stepwise selection is rarely the best available option); machine learning/statistical learning algorithms do a lot of tuning to try to get the best predictive model. The "test" or "out-of-sample" error must be assessed on a separate, held-out sample, or any tuning methods need to be built into a cross-validation procedure.
There does seem to have been historical evolution in opinions on this topic; many classic statistical textbooks, especially those that focus on regression, present stepwise approaches followed by standard inferential procedures without taking the effects of model selection into account [citation needed ...]
There are many ways to quantify variable importance, and not all fall into the post-variable-selection trap.
Burnham and Anderson recommend summing AIC weights; there's quite a bit of disagreement over this approach.
You could fit the full model (with appropriately scaled/unitless predictors) and rank the predictors by estimated magnitude [biological effect size] or Z-score ["clarity"/statistical effect size]. | Conflicting approaches to variable selection: AIC, p-values or both?
A short answer.
The approach of doing data-driven model selection or tuning, then using standard inferential methods on the selected/tuned model (à la Zuur et al., and many other respected ecologists |
17,763 | Conflicting approaches to variable selection: AIC, p-values or both? | I come from a biological background and am a biostatistician, working in in a university hospital. I read a lot on this, especially recently, including especially Harrell's opinions over the www, and his book Regression Modelling Strategies. Not referencing him anymore, but speaking from experience:
Primarily it's based on the current issue, which methods can even be used. Often data is highly correlated, so that no reasonable or reproducible "predictive" model could be found.
Second would be to get a good rational approach, so that your covariates/confounders should be intrepretable meaningful to express your predicted variable, by scientific experience.
Third would be to account for interactions (representable for non-linearities), which can be crucial, and often void any of the modern variable selection approaches
Only 4th is the actual method chosen, in my case with hospital data, that often has about x10^3 patients and x10^1 findings (e.g. deaths) in binomial logistic or semi-parametric cox regression, I used backwards stepwise AIC, Lasso, Ridge (no true variable selection) and Elastic Net regression against each other by AUC and admit: The methods vary per topic requested, but stepwise AIC is handling the issue aswell as Lasso and Elastic Net. Often doctors would report the AIC model as more reasonable.
(Sorry my first answer was very quickly typed)
And for the edit: I also tried eigenvalue-ranking by PCA, which gave most promising and reliable results for a general issue, but was still very far initial (and "reasonable") guesses. | Conflicting approaches to variable selection: AIC, p-values or both? | I come from a biological background and am a biostatistician, working in in a university hospital. I read a lot on this, especially recently, including especially Harrell's opinions over the www, and | Conflicting approaches to variable selection: AIC, p-values or both?
I come from a biological background and am a biostatistician, working in in a university hospital. I read a lot on this, especially recently, including especially Harrell's opinions over the www, and his book Regression Modelling Strategies. Not referencing him anymore, but speaking from experience:
Primarily it's based on the current issue, which methods can even be used. Often data is highly correlated, so that no reasonable or reproducible "predictive" model could be found.
Second would be to get a good rational approach, so that your covariates/confounders should be intrepretable meaningful to express your predicted variable, by scientific experience.
Third would be to account for interactions (representable for non-linearities), which can be crucial, and often void any of the modern variable selection approaches
Only 4th is the actual method chosen, in my case with hospital data, that often has about x10^3 patients and x10^1 findings (e.g. deaths) in binomial logistic or semi-parametric cox regression, I used backwards stepwise AIC, Lasso, Ridge (no true variable selection) and Elastic Net regression against each other by AUC and admit: The methods vary per topic requested, but stepwise AIC is handling the issue aswell as Lasso and Elastic Net. Often doctors would report the AIC model as more reasonable.
(Sorry my first answer was very quickly typed)
And for the edit: I also tried eigenvalue-ranking by PCA, which gave most promising and reliable results for a general issue, but was still very far initial (and "reasonable") guesses. | Conflicting approaches to variable selection: AIC, p-values or both?
I come from a biological background and am a biostatistician, working in in a university hospital. I read a lot on this, especially recently, including especially Harrell's opinions over the www, and |
17,764 | What is a good method for short text clustering? | That mostly depends on how much "state-of-the-art" (SOTA) you want versus how deep you wish to go (pun intended...).
If you can live with just shallow word embeddings as provided by word2vec, Glove, or fastText, I think the Word Mover Distance (WMD [yes, really...]) is a nice function for measuring (short) document distances [1]. I've even seen several Python Notebooks in the past that provide "tutorials" for this distance measure, so its really easy to get going.
However, if you are more interested in SOTA, you will have to look into deep (sequence representation) learning, using some kind of recurrent network that learns a topic model from your sentences. In addition to integrating (semantic) embeddings of words, these approaches go beyond the [good, old] "bag-of-words" approach by learning topic representations using the dependencies of the words in the sentence[s]. For example, the Sentence Level Recurrent Topic Model (SLRTM) is a pretty interesting deep, recurrent model based on the ideas of the more traditional LDA (by Blei et al.) or LSA (Landauer et al.), but it's only an arXiv paper (so all default "take-this-with-a-grain-of-salt warnings" about non-peer-reviewed research should apply...) [2]. None the less, the paper has many excellent pointer and references to get your research started should you want to go down this rabbit hole.
Finally, it should be clarified that I don't claim that these are the agreed upon best-performing methods for bag-of-words and sequence models, respectively. But they should get you pretty close to whatever the "best" SOTA might be, and at least should serve as a an excellent starting point.
[1] Matt J. Kusner et al. From Word Embeddings To Document Distances. Proceedings of the 32nd International Conference on Machine Learning, JMLR, 2015.
[2] Fei Tian et al. SLRTM: Letting Topics Speak for Themselves. arXiv 1604.02038, 2016. | What is a good method for short text clustering? | That mostly depends on how much "state-of-the-art" (SOTA) you want versus how deep you wish to go (pun intended...).
If you can live with just shallow word embeddings as provided by word2vec, Glove, o | What is a good method for short text clustering?
That mostly depends on how much "state-of-the-art" (SOTA) you want versus how deep you wish to go (pun intended...).
If you can live with just shallow word embeddings as provided by word2vec, Glove, or fastText, I think the Word Mover Distance (WMD [yes, really...]) is a nice function for measuring (short) document distances [1]. I've even seen several Python Notebooks in the past that provide "tutorials" for this distance measure, so its really easy to get going.
However, if you are more interested in SOTA, you will have to look into deep (sequence representation) learning, using some kind of recurrent network that learns a topic model from your sentences. In addition to integrating (semantic) embeddings of words, these approaches go beyond the [good, old] "bag-of-words" approach by learning topic representations using the dependencies of the words in the sentence[s]. For example, the Sentence Level Recurrent Topic Model (SLRTM) is a pretty interesting deep, recurrent model based on the ideas of the more traditional LDA (by Blei et al.) or LSA (Landauer et al.), but it's only an arXiv paper (so all default "take-this-with-a-grain-of-salt warnings" about non-peer-reviewed research should apply...) [2]. None the less, the paper has many excellent pointer and references to get your research started should you want to go down this rabbit hole.
Finally, it should be clarified that I don't claim that these are the agreed upon best-performing methods for bag-of-words and sequence models, respectively. But they should get you pretty close to whatever the "best" SOTA might be, and at least should serve as a an excellent starting point.
[1] Matt J. Kusner et al. From Word Embeddings To Document Distances. Proceedings of the 32nd International Conference on Machine Learning, JMLR, 2015.
[2] Fei Tian et al. SLRTM: Letting Topics Speak for Themselves. arXiv 1604.02038, 2016. | What is a good method for short text clustering?
That mostly depends on how much "state-of-the-art" (SOTA) you want versus how deep you wish to go (pun intended...).
If you can live with just shallow word embeddings as provided by word2vec, Glove, o |
17,765 | What is a good method for short text clustering? | https://github.com/RandyPen/TextCluster
This is a Cluster method specific to short text, which outperforms KMeans etc. No Need to set latent variable number.
The basic idea is to tokenize the sentence into words. Then direct to different bucket according to text component. In each bucket, calculate similarity between the sentence and the bucket. If the similarity score is higher than specific value, append this sentence into that bucket, else search for the next bucket. | What is a good method for short text clustering? | https://github.com/RandyPen/TextCluster
This is a Cluster method specific to short text, which outperforms KMeans etc. No Need to set latent variable number.
The basic idea is to tokenize the sentence | What is a good method for short text clustering?
https://github.com/RandyPen/TextCluster
This is a Cluster method specific to short text, which outperforms KMeans etc. No Need to set latent variable number.
The basic idea is to tokenize the sentence into words. Then direct to different bucket according to text component. In each bucket, calculate similarity between the sentence and the bucket. If the similarity score is higher than specific value, append this sentence into that bucket, else search for the next bucket. | What is a good method for short text clustering?
https://github.com/RandyPen/TextCluster
This is a Cluster method specific to short text, which outperforms KMeans etc. No Need to set latent variable number.
The basic idea is to tokenize the sentence |
17,766 | Prediction intervals for machine learning algorithms | To me it seems as good approach as any to quantify the uncertainties in the predictions. Just make sure to repeat all modeling steps (for a GBM that would be the parameter tuning) from scratch in every bootstrap resample. It could also be worthwile to bootstrap the importance rankings to quantify the uncertainty in the rankings.
I have found that sometimes the intervals do not contain the actual prediction, especially when estimating a probability. Increasing the minimal number of observations in each terminal node usually solves that, at least in the data that I have worked with.
Conformal prediction seems like a useful approach for quantifying the confidence in predictions on new data. I have only scratched the surface thus far and others are probably more suited to give an optinion on that.
There is some crude R-code in my reply to this post about finding a GBM prediction Interval.
Hope this helps! | Prediction intervals for machine learning algorithms | To me it seems as good approach as any to quantify the uncertainties in the predictions. Just make sure to repeat all modeling steps (for a GBM that would be the parameter tuning) from scratch in ever | Prediction intervals for machine learning algorithms
To me it seems as good approach as any to quantify the uncertainties in the predictions. Just make sure to repeat all modeling steps (for a GBM that would be the parameter tuning) from scratch in every bootstrap resample. It could also be worthwile to bootstrap the importance rankings to quantify the uncertainty in the rankings.
I have found that sometimes the intervals do not contain the actual prediction, especially when estimating a probability. Increasing the minimal number of observations in each terminal node usually solves that, at least in the data that I have worked with.
Conformal prediction seems like a useful approach for quantifying the confidence in predictions on new data. I have only scratched the surface thus far and others are probably more suited to give an optinion on that.
There is some crude R-code in my reply to this post about finding a GBM prediction Interval.
Hope this helps! | Prediction intervals for machine learning algorithms
To me it seems as good approach as any to quantify the uncertainties in the predictions. Just make sure to repeat all modeling steps (for a GBM that would be the parameter tuning) from scratch in ever |
17,767 | Prediction intervals for machine learning algorithms | You can split your uncertainty about the prediction to 'bias' and 'variance' terms. Bias term refers to misspecification of model: if you fit linear model for nonlinear function, you will always get some error. 'Variance' term refers to error in model parameters estimate. You approach account for variance part of uncertainty, while can not estimate the bias.
As suggested by @ErikL conformal prediction is theoretically justified approach which adopts an idea quite similar for bootstrap. Conformal prediction using reconstruction of model using a new point takes into account both bias and variance, while for regression they need significant computational resources. You can try it with Python using a nonconformist library. | Prediction intervals for machine learning algorithms | You can split your uncertainty about the prediction to 'bias' and 'variance' terms. Bias term refers to misspecification of model: if you fit linear model for nonlinear function, you will always get s | Prediction intervals for machine learning algorithms
You can split your uncertainty about the prediction to 'bias' and 'variance' terms. Bias term refers to misspecification of model: if you fit linear model for nonlinear function, you will always get some error. 'Variance' term refers to error in model parameters estimate. You approach account for variance part of uncertainty, while can not estimate the bias.
As suggested by @ErikL conformal prediction is theoretically justified approach which adopts an idea quite similar for bootstrap. Conformal prediction using reconstruction of model using a new point takes into account both bias and variance, while for regression they need significant computational resources. You can try it with Python using a nonconformist library. | Prediction intervals for machine learning algorithms
You can split your uncertainty about the prediction to 'bias' and 'variance' terms. Bias term refers to misspecification of model: if you fit linear model for nonlinear function, you will always get s |
17,768 | Prediction intervals for machine learning algorithms | No, it seems like a bad idea. First, as Alexey pointed out, there is bias and variance. Even for the best parameters choice, you cannot avoid the variance. Your method does not even try to address it. There is another very important issue, that some, and probably most, of the error of your model is in the data, rather than in the inherent randomness of the model. (Not to mention that some models, like plain linear regression, are not random at all, and for random models, the degree of randomness varies from model to model)
I suggest you to test your approach on some simple simulated data, and some model you know. I am sure that, for reasons I described, your estimated error will be much smaller than the real error (or your distribution will be much more narrow).
For estimating the error distribution you may use a good old cross-validation. | Prediction intervals for machine learning algorithms | No, it seems like a bad idea. First, as Alexey pointed out, there is bias and variance. Even for the best parameters choice, you cannot avoid the variance. Your method does not even try to address i | Prediction intervals for machine learning algorithms
No, it seems like a bad idea. First, as Alexey pointed out, there is bias and variance. Even for the best parameters choice, you cannot avoid the variance. Your method does not even try to address it. There is another very important issue, that some, and probably most, of the error of your model is in the data, rather than in the inherent randomness of the model. (Not to mention that some models, like plain linear regression, are not random at all, and for random models, the degree of randomness varies from model to model)
I suggest you to test your approach on some simple simulated data, and some model you know. I am sure that, for reasons I described, your estimated error will be much smaller than the real error (or your distribution will be much more narrow).
For estimating the error distribution you may use a good old cross-validation. | Prediction intervals for machine learning algorithms
No, it seems like a bad idea. First, as Alexey pointed out, there is bias and variance. Even for the best parameters choice, you cannot avoid the variance. Your method does not even try to address i |
17,769 | Prediction intervals for machine learning algorithms | I am thinking about this problem now. Here are my findings:
(1) Delta Method
(2) Bootstrap Resampling
(3) Bayesian method
(4) Mean-Variance Estimation (MVE)
The idea is trying to estimate the two sources of the prediction variability, uncertainty from the model parameter estimate and the irreducible error.
Here are several references:
Machine Learning approaches for estimation of prediction interval for the model output, Durga L. Shrestha, Dimitri P. Solomatine, 2006
A comparison of some error estimates for neural network models, Robert Tibshirani, 1995
Comprehensive Review of Neural Network-Based Prediction Intervals and New Advances, Abbas khosravi, Doug Creighton, 2011
Hope this helps and correct me any of the above is inappropriate. I'd like to hear more from others. | Prediction intervals for machine learning algorithms | I am thinking about this problem now. Here are my findings:
(1) Delta Method
(2) Bootstrap Resampling
(3) Bayesian method
(4) Mean-Variance Estimation (MVE)
The idea is trying to estimate the t | Prediction intervals for machine learning algorithms
I am thinking about this problem now. Here are my findings:
(1) Delta Method
(2) Bootstrap Resampling
(3) Bayesian method
(4) Mean-Variance Estimation (MVE)
The idea is trying to estimate the two sources of the prediction variability, uncertainty from the model parameter estimate and the irreducible error.
Here are several references:
Machine Learning approaches for estimation of prediction interval for the model output, Durga L. Shrestha, Dimitri P. Solomatine, 2006
A comparison of some error estimates for neural network models, Robert Tibshirani, 1995
Comprehensive Review of Neural Network-Based Prediction Intervals and New Advances, Abbas khosravi, Doug Creighton, 2011
Hope this helps and correct me any of the above is inappropriate. I'd like to hear more from others. | Prediction intervals for machine learning algorithms
I am thinking about this problem now. Here are my findings:
(1) Delta Method
(2) Bootstrap Resampling
(3) Bayesian method
(4) Mean-Variance Estimation (MVE)
The idea is trying to estimate the t |
17,770 | Regression when each point has its own uncertainty in both $x$ and $y$ | Let the true line $L$, given by an angle $\theta$ and a value $\gamma$, be the set
$$(x,y): \cos(\theta) x + \sin(\theta) y = \gamma.$$
The signed distance between any point $(x,y)$ and this line is
$$d(x,y;L) = \cos(\theta) x + \sin(\theta) y - \gamma.$$
Letting the variance of $x_i$ be $\sigma_i^2$ and that of $y_i$ be $\tau_i^2$, independence of $x_i$ and $y_i$ implies the variance of this distance is
$$\operatorname{Var}(d(x_i,y_i;L)) = \cos^2(\theta)\sigma_i^2 + \sin^2(\theta)\tau_i^2.$$
Let us therefore find $\theta$ and $\gamma$ for which the inverse variance weighted sum of squared distances is as small as possible: it will be the maximum likelihood solution if we assume the errors have bivariate normal distributions. This requires a numerical solution, but it's straightforward to find a with a few Newton-Raphson steps beginning with a value suggested by an ordinary least-squares fit.
Simulations suggest this solution is good even with small amounts of data and relatively large values of $\sigma_i$ and $\tau_i$. You can, of course, obtain standard errors for the parameters in the usual ways. If you're interested in the standard error of the position of the line, as well as the slope, then you might wish first to center both variables at $0$: that should eliminate almost all the correlation between the estimates of the two parameters.
The method works so well with the example of the question that the fitted line is almost distinguishable from the true line in the plot: they are within one unit or so of each other everywhere. Instead, in this example the $\tau_i$ are drawn iid from an exponential distribution and the $\sigma_i$ are drawn iid from an exponential distribution with twice the scale (so that most of the error tends to occur in the $x$ coordinate). There are only $n=8$ points, a small number. The true points are equally spaced along the line with unit spacing. This is a fairly severe test, because the potential errors are noticeable compared to the range of the points.
The true line is shown in dotted blue. Along it the original points are plotted as hollow circles. Gray arrows connect them to the observed points, plotted as solid black disks. The solution is drawn as a solid red line. Despite the presence of large deviations between observed and actual values, the solution is remarkably close to the correct line within this region.
#
# Generate data.
#
theta <- c(1, -2, 3) # The line is theta %*% c(x,y,-1) == 0
theta[-3] <- theta[-3]/sqrt(crossprod(theta[-3]))
n <- 8
set.seed(17)
sigma <- rexp(n, 1/2)
tau <- rexp(n, 1)
u <- 1:n
xy.0 <- t(outer(c(-theta[2], theta[1]), 0:(n-1)) + c(theta[3]/theta[1], 0))
xy <- xy.0 + cbind(rnorm(n, sd=sigma), rnorm(n, sd=tau))
#
# Fit a line.
#
x <- xy[, 1]
y <- xy[, 2]
f <- function(phi) { # Negative log likelihood, up to an additive constant
a <- phi[1]
gamma <- phi[2]
sum((x*cos(a) + y*sin(a) - gamma)^2 / ((sigma*cos(a))^2 + (tau*sin(a))^2))/2
}
fit <- lm(y ~ x) # Yields starting estimates
slope <- coef(fit)[2]
theta.0 <- atan2(1, -slope)
gamma.0 <- coef(fit)[1] / sqrt(1 + slope^2)
sol <- nlm(f,c(theta.0, gamma.0))
#
# Plot the data and the fit.
#
theta.hat <- sol$estimate[1] %% (2*pi)
gamma.hat <- sol$estimate[2]
plot(rbind(xy.0, xy), type="n", xlab="x", ylab="y")
invisible(sapply(1:n, function(i)
arrows(xy.0[i,1], xy.0[i,2], xy[i,1], xy[i,2],
length=0.15, angle=20, col="Gray")))
points(xy.0)
points(xy, pch=16)
abline(c(theta[3] / theta[2], -theta[1]/theta[2]), col="Blue", lwd=2, lty=3)
abline(c(gamma.hat / sin(theta.hat), -1/tan(theta.hat)), col="Red", lwd=2) | Regression when each point has its own uncertainty in both $x$ and $y$ | Let the true line $L$, given by an angle $\theta$ and a value $\gamma$, be the set
$$(x,y): \cos(\theta) x + \sin(\theta) y = \gamma.$$
The signed distance between any point $(x,y)$ and this line is
$ | Regression when each point has its own uncertainty in both $x$ and $y$
Let the true line $L$, given by an angle $\theta$ and a value $\gamma$, be the set
$$(x,y): \cos(\theta) x + \sin(\theta) y = \gamma.$$
The signed distance between any point $(x,y)$ and this line is
$$d(x,y;L) = \cos(\theta) x + \sin(\theta) y - \gamma.$$
Letting the variance of $x_i$ be $\sigma_i^2$ and that of $y_i$ be $\tau_i^2$, independence of $x_i$ and $y_i$ implies the variance of this distance is
$$\operatorname{Var}(d(x_i,y_i;L)) = \cos^2(\theta)\sigma_i^2 + \sin^2(\theta)\tau_i^2.$$
Let us therefore find $\theta$ and $\gamma$ for which the inverse variance weighted sum of squared distances is as small as possible: it will be the maximum likelihood solution if we assume the errors have bivariate normal distributions. This requires a numerical solution, but it's straightforward to find a with a few Newton-Raphson steps beginning with a value suggested by an ordinary least-squares fit.
Simulations suggest this solution is good even with small amounts of data and relatively large values of $\sigma_i$ and $\tau_i$. You can, of course, obtain standard errors for the parameters in the usual ways. If you're interested in the standard error of the position of the line, as well as the slope, then you might wish first to center both variables at $0$: that should eliminate almost all the correlation between the estimates of the two parameters.
The method works so well with the example of the question that the fitted line is almost distinguishable from the true line in the plot: they are within one unit or so of each other everywhere. Instead, in this example the $\tau_i$ are drawn iid from an exponential distribution and the $\sigma_i$ are drawn iid from an exponential distribution with twice the scale (so that most of the error tends to occur in the $x$ coordinate). There are only $n=8$ points, a small number. The true points are equally spaced along the line with unit spacing. This is a fairly severe test, because the potential errors are noticeable compared to the range of the points.
The true line is shown in dotted blue. Along it the original points are plotted as hollow circles. Gray arrows connect them to the observed points, plotted as solid black disks. The solution is drawn as a solid red line. Despite the presence of large deviations between observed and actual values, the solution is remarkably close to the correct line within this region.
#
# Generate data.
#
theta <- c(1, -2, 3) # The line is theta %*% c(x,y,-1) == 0
theta[-3] <- theta[-3]/sqrt(crossprod(theta[-3]))
n <- 8
set.seed(17)
sigma <- rexp(n, 1/2)
tau <- rexp(n, 1)
u <- 1:n
xy.0 <- t(outer(c(-theta[2], theta[1]), 0:(n-1)) + c(theta[3]/theta[1], 0))
xy <- xy.0 + cbind(rnorm(n, sd=sigma), rnorm(n, sd=tau))
#
# Fit a line.
#
x <- xy[, 1]
y <- xy[, 2]
f <- function(phi) { # Negative log likelihood, up to an additive constant
a <- phi[1]
gamma <- phi[2]
sum((x*cos(a) + y*sin(a) - gamma)^2 / ((sigma*cos(a))^2 + (tau*sin(a))^2))/2
}
fit <- lm(y ~ x) # Yields starting estimates
slope <- coef(fit)[2]
theta.0 <- atan2(1, -slope)
gamma.0 <- coef(fit)[1] / sqrt(1 + slope^2)
sol <- nlm(f,c(theta.0, gamma.0))
#
# Plot the data and the fit.
#
theta.hat <- sol$estimate[1] %% (2*pi)
gamma.hat <- sol$estimate[2]
plot(rbind(xy.0, xy), type="n", xlab="x", ylab="y")
invisible(sapply(1:n, function(i)
arrows(xy.0[i,1], xy.0[i,2], xy[i,1], xy[i,2],
length=0.15, angle=20, col="Gray")))
points(xy.0)
points(xy, pch=16)
abline(c(theta[3] / theta[2], -theta[1]/theta[2]), col="Blue", lwd=2, lty=3)
abline(c(gamma.hat / sin(theta.hat), -1/tan(theta.hat)), col="Red", lwd=2) | Regression when each point has its own uncertainty in both $x$ and $y$
Let the true line $L$, given by an angle $\theta$ and a value $\gamma$, be the set
$$(x,y): \cos(\theta) x + \sin(\theta) y = \gamma.$$
The signed distance between any point $(x,y)$ and this line is
$ |
17,771 | Regression when each point has its own uncertainty in both $x$ and $y$ | The maximum likelihood optimization for the case of uncertainties in x and y has been addressed by York (2004). Here is R code for his function.
"YorkFit", written by Rick Wehr, 2011, translated into R by Rachel Chang
Universal routine for finding the best straight line fit
to data with variable, correlated errors,
including error and goodness of fit estimates, following Eq. (13) of
York 2004, American Journal of Physics, which was based in turn on
York 1969, Earth and Planetary Sciences Letters
YorkFit <- function(X,Y, Xstd, Ystd, Ri=0, b0=0, printCoefs=0, makeLine=0,eps=1e-7)
X, Y, Xstd, Ystd: waves containing X points, Y points, and their standard deviations
WARNING: Xstd and Ystd cannot be zero as this will cause Xw or Yw to be NaN.
Use a very small value instead.
Ri: correlation coefficients for X and Y errors -- length 1 or length of X and Y
b0: rough initial guess for the slope (can be gotten from a standard least-squares fit without errors)
printCoefs: set equal to 1 to display results in the command window
makeLine: set equal to 1 to generate a Y wave for the fit line
Returns a matrix with the intercept and slope plus their uncertainties
If no initial guess for b0 is provided, then just use OLS
if (b0 == 0) {b0 = lm(Y~X)$coefficients[2]}
tol = abs(b0)*eps #the fit will stop iterating when the slope converges to within this value
a,b: final intercept and slope
a.err, b.err: estimated uncertainties in intercept and slope
# WAVE DEFINITIONS #
Xw = 1/(Xstd^2) #X weights
Yw = 1/(Ystd^2) #Y weights
# ITERATIVE CALCULATION OF SLOPE AND INTERCEPT #
b = b0
b.diff = tol + 1
while(b.diff>tol)
{
b.old = b
alpha.i = sqrt(Xw*Yw)
Wi = (Xw*Yw)/((b^2)*Yw + Xw - 2*b*Ri*alpha.i)
WiX = Wi*X
WiY = Wi*Y
sumWiX = sum(WiX, na.rm = TRUE)
sumWiY = sum(WiY, na.rm = TRUE)
sumWi = sum(Wi, na.rm = TRUE)
Xbar = sumWiX/sumWi
Ybar = sumWiY/sumWi
Ui = X - Xbar
Vi = Y - Ybar
Bi = Wi*((Ui/Yw) + (b*Vi/Xw) - (b*Ui+Vi)*Ri/alpha.i)
wTOPint = Bi*Wi*Vi
wBOTint = Bi*Wi*Ui
sumTOP = sum(wTOPint, na.rm=TRUE)
sumBOT = sum(wBOTint, na.rm=TRUE)
b = sumTOP/sumBOT
b.diff = abs(b-b.old)
}
a = Ybar - b*Xbar
wYorkFitCoefs = c(a,b)
# ERROR CALCULATION #
Xadj = Xbar + Bi
WiXadj = Wi*Xadj
sumWiXadj = sum(WiXadj, na.rm=TRUE)
Xadjbar = sumWiXadj/sumWi
Uadj = Xadj - Xadjbar
wErrorTerm = Wi*Uadj*Uadj
errorSum = sum(wErrorTerm, na.rm=TRUE)
b.err = sqrt(1/errorSum)
a.err = sqrt((1/sumWi) + (Xadjbar^2)*(b.err^2))
wYorkFitErrors = c(a.err,b.err)
# GOODNESS OF FIT CALCULATION #
lgth = length(X)
wSint = Wi*(Y - b*X - a)^2
sumSint = sum(wSint, na.rm=TRUE)
wYorkGOF = c(sumSint/(lgth-2),sqrt(2/(lgth-2))) #GOF (should equal 1 if assumptions are valid), #standard error in GOF
# OPTIONAL OUTPUTS #
if(printCoefs==1)
{
print(paste("intercept = ", a, " +/- ", a.err, sep=""))
print(paste("slope = ", b, " +/- ", b.err, sep=""))
}
if(makeLine==1)
{
wYorkFitLine = a + b*X
}
ans=rbind(c(a,a.err),c(b, b.err)); dimnames(ans)=list(c("Int","Slope"),c("Value","Sigma"))
return(ans)
} | Regression when each point has its own uncertainty in both $x$ and $y$ | The maximum likelihood optimization for the case of uncertainties in x and y has been addressed by York (2004). Here is R code for his function.
"YorkFit", written by Rick Wehr, 2011, translated into | Regression when each point has its own uncertainty in both $x$ and $y$
The maximum likelihood optimization for the case of uncertainties in x and y has been addressed by York (2004). Here is R code for his function.
"YorkFit", written by Rick Wehr, 2011, translated into R by Rachel Chang
Universal routine for finding the best straight line fit
to data with variable, correlated errors,
including error and goodness of fit estimates, following Eq. (13) of
York 2004, American Journal of Physics, which was based in turn on
York 1969, Earth and Planetary Sciences Letters
YorkFit <- function(X,Y, Xstd, Ystd, Ri=0, b0=0, printCoefs=0, makeLine=0,eps=1e-7)
X, Y, Xstd, Ystd: waves containing X points, Y points, and their standard deviations
WARNING: Xstd and Ystd cannot be zero as this will cause Xw or Yw to be NaN.
Use a very small value instead.
Ri: correlation coefficients for X and Y errors -- length 1 or length of X and Y
b0: rough initial guess for the slope (can be gotten from a standard least-squares fit without errors)
printCoefs: set equal to 1 to display results in the command window
makeLine: set equal to 1 to generate a Y wave for the fit line
Returns a matrix with the intercept and slope plus their uncertainties
If no initial guess for b0 is provided, then just use OLS
if (b0 == 0) {b0 = lm(Y~X)$coefficients[2]}
tol = abs(b0)*eps #the fit will stop iterating when the slope converges to within this value
a,b: final intercept and slope
a.err, b.err: estimated uncertainties in intercept and slope
# WAVE DEFINITIONS #
Xw = 1/(Xstd^2) #X weights
Yw = 1/(Ystd^2) #Y weights
# ITERATIVE CALCULATION OF SLOPE AND INTERCEPT #
b = b0
b.diff = tol + 1
while(b.diff>tol)
{
b.old = b
alpha.i = sqrt(Xw*Yw)
Wi = (Xw*Yw)/((b^2)*Yw + Xw - 2*b*Ri*alpha.i)
WiX = Wi*X
WiY = Wi*Y
sumWiX = sum(WiX, na.rm = TRUE)
sumWiY = sum(WiY, na.rm = TRUE)
sumWi = sum(Wi, na.rm = TRUE)
Xbar = sumWiX/sumWi
Ybar = sumWiY/sumWi
Ui = X - Xbar
Vi = Y - Ybar
Bi = Wi*((Ui/Yw) + (b*Vi/Xw) - (b*Ui+Vi)*Ri/alpha.i)
wTOPint = Bi*Wi*Vi
wBOTint = Bi*Wi*Ui
sumTOP = sum(wTOPint, na.rm=TRUE)
sumBOT = sum(wBOTint, na.rm=TRUE)
b = sumTOP/sumBOT
b.diff = abs(b-b.old)
}
a = Ybar - b*Xbar
wYorkFitCoefs = c(a,b)
# ERROR CALCULATION #
Xadj = Xbar + Bi
WiXadj = Wi*Xadj
sumWiXadj = sum(WiXadj, na.rm=TRUE)
Xadjbar = sumWiXadj/sumWi
Uadj = Xadj - Xadjbar
wErrorTerm = Wi*Uadj*Uadj
errorSum = sum(wErrorTerm, na.rm=TRUE)
b.err = sqrt(1/errorSum)
a.err = sqrt((1/sumWi) + (Xadjbar^2)*(b.err^2))
wYorkFitErrors = c(a.err,b.err)
# GOODNESS OF FIT CALCULATION #
lgth = length(X)
wSint = Wi*(Y - b*X - a)^2
sumSint = sum(wSint, na.rm=TRUE)
wYorkGOF = c(sumSint/(lgth-2),sqrt(2/(lgth-2))) #GOF (should equal 1 if assumptions are valid), #standard error in GOF
# OPTIONAL OUTPUTS #
if(printCoefs==1)
{
print(paste("intercept = ", a, " +/- ", a.err, sep=""))
print(paste("slope = ", b, " +/- ", b.err, sep=""))
}
if(makeLine==1)
{
wYorkFitLine = a + b*X
}
ans=rbind(c(a,a.err),c(b, b.err)); dimnames(ans)=list(c("Int","Slope"),c("Value","Sigma"))
return(ans)
} | Regression when each point has its own uncertainty in both $x$ and $y$
The maximum likelihood optimization for the case of uncertainties in x and y has been addressed by York (2004). Here is R code for his function.
"YorkFit", written by Rick Wehr, 2011, translated into |
17,772 | Assigning more weight to more recent observations in regression | How do I assign more weight to more recent observations in R?
I guess you have a timestamp associated with each observation. You can compute a variable timeElapsed = modelingTime - observationTime. Now you apply a simple exponential function as W=K*exp(-timeElapsed/T), where K is a scaling constant and T is the time-constant for the decay function. W works as case-weight.
To the best of my knowledge, many function in caret allow weight as a parameter, which is a column of case-weights to be provided to corresponding observation(thus having same length as #rows). | Assigning more weight to more recent observations in regression | How do I assign more weight to more recent observations in R?
I guess you have a timestamp associated with each observation. You can compute a variable timeElapsed = modelingTime - observationTime. No | Assigning more weight to more recent observations in regression
How do I assign more weight to more recent observations in R?
I guess you have a timestamp associated with each observation. You can compute a variable timeElapsed = modelingTime - observationTime. Now you apply a simple exponential function as W=K*exp(-timeElapsed/T), where K is a scaling constant and T is the time-constant for the decay function. W works as case-weight.
To the best of my knowledge, many function in caret allow weight as a parameter, which is a column of case-weights to be provided to corresponding observation(thus having same length as #rows). | Assigning more weight to more recent observations in regression
How do I assign more weight to more recent observations in R?
I guess you have a timestamp associated with each observation. You can compute a variable timeElapsed = modelingTime - observationTime. No |
17,773 | Assigning more weight to more recent observations in regression | The data (not the analyst making assumptions - guesses) can often suggest the form of the weighting scheme. This is done via GLS where the appropriate weights for the weighted least squares model are obtained from the statistically significant differences found in the error variance. Take a look at Change and outliers detection by means ARIMA (Tsay procedure) and here http://docplayer.net/12080848-Outliers-level-shifts-and-variance-changes-in-time-series.html . If you wish to post data please do so here and I will try and help further as I have routine access to software that might enlighten you.
There is an R version of the software I am using.
You might look at How to include control variables in an Intervention analysis with ARIMA? as it has example of how the weights are identified and used to stabilize the error variance thus effectively believing/dis-believing/discounting/weighting/trusting certain prior values. | Assigning more weight to more recent observations in regression | The data (not the analyst making assumptions - guesses) can often suggest the form of the weighting scheme. This is done via GLS where the appropriate weights for the weighted least squares model are | Assigning more weight to more recent observations in regression
The data (not the analyst making assumptions - guesses) can often suggest the form of the weighting scheme. This is done via GLS where the appropriate weights for the weighted least squares model are obtained from the statistically significant differences found in the error variance. Take a look at Change and outliers detection by means ARIMA (Tsay procedure) and here http://docplayer.net/12080848-Outliers-level-shifts-and-variance-changes-in-time-series.html . If you wish to post data please do so here and I will try and help further as I have routine access to software that might enlighten you.
There is an R version of the software I am using.
You might look at How to include control variables in an Intervention analysis with ARIMA? as it has example of how the weights are identified and used to stabilize the error variance thus effectively believing/dis-believing/discounting/weighting/trusting certain prior values. | Assigning more weight to more recent observations in regression
The data (not the analyst making assumptions - guesses) can often suggest the form of the weighting scheme. This is done via GLS where the appropriate weights for the weighted least squares model are |
17,774 | Is there any difference between distant supervision, self-training, self-supervised learning, and weak supervision? | There are two aspects to all the different terms you have given:
1] Process of obtaining training data
2] Algorithm that trains $f$ or the classifier
The algorithm that trains $f$, regardless of how the training data is obtained is supervised. The difference in distant supervision, self-learning, self-supervised or weak supervision, lie purely then in how the training data is obtained.
Traditionally, in any machine learning paper on supervised learning, one would find that the paper implicitly assumes that the training data is available and for what its worth, it is usually assumed that the labels are precise, and that there is no ambiguity in the labels that are given to the instances in the training data. However, with distant/weak supervision papers, people realized that their training data has imprecise labels and what they want to usually highlight in their work is that they obtain good results despite the obvious drawback of using imprecise labels (and they may have other algorithmic ways to overcome the issue of imprecise labels, by having additional filtering process etc. and usually the papers would like to highlight that these additional processes are important and useful). This gave rise to the terms "weak" or "distant" to indicate that the labels on the training data are imprecise. Note that this does not necessarily impact the learning aspect of the classifier. The classifier that these guys use still implicitly assumes that the labels are precise and the training algorithm is hardly ever changed.
Self-training on the other hand is somewhat special in that sense. As you have already observed, it obtains its labels from its own classifier and has a bit of a feedback loop for correction. Generally, we study supervised classifiers under a slightly large purview of "inductive" algorithms, where the classifier learnt is an inductive inference made from the training data about the entire data. People have studied another form, which we call as transductive inference, where a general inductive inference is not the output of the algorithm, but the algorithm collectively takes both training data and test data as input and produces labels on the test data. However, people figured why not use transductive inference within inductive learning to obtain a classifier with larger training data. This is simply referred to as induction with unlabeled data [1] and self-training comes under that.
Hopefully, I have not further confused you, feel free to comment and ask for more clarifications if necessary.
[1] Might be useful - http://www.is.tuebingen.mpg.de/fileadmin/user_upload/files/publications/pdf2527.pdf | Is there any difference between distant supervision, self-training, self-supervised learning, and we | There are two aspects to all the different terms you have given:
1] Process of obtaining training data
2] Algorithm that trains $f$ or the classifier
The algorithm that trains $f$, regardless of how t | Is there any difference between distant supervision, self-training, self-supervised learning, and weak supervision?
There are two aspects to all the different terms you have given:
1] Process of obtaining training data
2] Algorithm that trains $f$ or the classifier
The algorithm that trains $f$, regardless of how the training data is obtained is supervised. The difference in distant supervision, self-learning, self-supervised or weak supervision, lie purely then in how the training data is obtained.
Traditionally, in any machine learning paper on supervised learning, one would find that the paper implicitly assumes that the training data is available and for what its worth, it is usually assumed that the labels are precise, and that there is no ambiguity in the labels that are given to the instances in the training data. However, with distant/weak supervision papers, people realized that their training data has imprecise labels and what they want to usually highlight in their work is that they obtain good results despite the obvious drawback of using imprecise labels (and they may have other algorithmic ways to overcome the issue of imprecise labels, by having additional filtering process etc. and usually the papers would like to highlight that these additional processes are important and useful). This gave rise to the terms "weak" or "distant" to indicate that the labels on the training data are imprecise. Note that this does not necessarily impact the learning aspect of the classifier. The classifier that these guys use still implicitly assumes that the labels are precise and the training algorithm is hardly ever changed.
Self-training on the other hand is somewhat special in that sense. As you have already observed, it obtains its labels from its own classifier and has a bit of a feedback loop for correction. Generally, we study supervised classifiers under a slightly large purview of "inductive" algorithms, where the classifier learnt is an inductive inference made from the training data about the entire data. People have studied another form, which we call as transductive inference, where a general inductive inference is not the output of the algorithm, but the algorithm collectively takes both training data and test data as input and produces labels on the test data. However, people figured why not use transductive inference within inductive learning to obtain a classifier with larger training data. This is simply referred to as induction with unlabeled data [1] and self-training comes under that.
Hopefully, I have not further confused you, feel free to comment and ask for more clarifications if necessary.
[1] Might be useful - http://www.is.tuebingen.mpg.de/fileadmin/user_upload/files/publications/pdf2527.pdf | Is there any difference between distant supervision, self-training, self-supervised learning, and we
There are two aspects to all the different terms you have given:
1] Process of obtaining training data
2] Algorithm that trains $f$ or the classifier
The algorithm that trains $f$, regardless of how t |
17,775 | Distribution of the ratio of dependent chi-square random variables | This post elaborates on the answers in the comments to the question.
Let $X = (X_1, X_2, \ldots, X_n)$. Fix any $\mathbf{e}_1\in\mathbb{R}^n$ of unit length. Such a vector may always be completed to an orthonormal basis $(\mathbf{e}_1, \mathbf{e}_2, \ldots, \mathbf{e}_n)$ (by means of the Gram-Schmidt process, for instance). This change of basis (from the usual one) is orthogonal: it does not change lengths. Thus the distribution of
$$\frac{(\mathbf{e}_1\cdot X)^2}{||X||^2}=\frac{(\mathbf{e}_1\cdot X)^2}{X_1^2 + X_2^2 + \cdots + X_n^2} $$
does not depend on $\mathbf{e}_1$. Taking $\mathbf{e}_1 = (1,0,0,\ldots, 0)$ shows this has the same distribution as
$$\frac{X_1^2}{X_1^2 + X_2^2 + \cdots + X_n^2}.\tag{1} $$
Since the $X_i$ are iid Normal, they may be written as $\sigma$ times iid standard Normal variables $Y_1, \ldots, Y_n$ and their squares are $\sigma^2$ times $\Gamma(1/2)$ distributions. Since the sum of $n-1$ independent $\Gamma(1/2)$ distributions is $\Gamma((n-1)/2)$, we have determined that the distribution of $(1)$ is that of
$$\frac{\sigma^2 U}{\sigma^2 U + \sigma^2 V} = \frac{U}{U+V}$$
where $U = X_1^2/\sigma^2 \sim \Gamma(1/2)$ and $V = (X_2^2 + \cdots + X_n^2)/\sigma^2 \sim \Gamma((n-1)/2)$ are independent. It is well known that this ratio has a Beta$(1/2, (n-1)/2)$ distribution. (Also see the closely related thread at Distribution of $XY$ if $X \sim$ Beta$(1,K-1)$ and $Y \sim$ chi-squared with $2K$ degrees.)
Since $$X_1 + \cdots + X_n = (1,1,\ldots,1)\cdot (X_1, X_2, \cdots, X_n) = \sqrt{n}\,\mathbf{e}_1\cdot X$$
for the unit vector $\mathbf{e}_1=(1,1,\ldots,1)/\sqrt{n}$, we conclude that $Z$ is $(\sqrt{n})^2 = n$ times a Beta$(1/2, (n-1)/2)$ variate. For $n\ge 2$ it therefore has density function
$$f_Z(z) = \frac{n^{1-n/2}}{B\left(\frac{1}{2}, \frac{n-1}{2}\right)} \sqrt{\frac{(n-z)^{n-3}}{z}}$$
on the interval $(0,n)$ (and otherwise is zero).
As a check, I simulated $100,000$ independent realizations of $Z$ for $\sigma=1$ and $n=2,3,10$, plotted their histograms, and superimposed the graph of the corresponding Beta density (in red). The agreements are excellent.
Here is the R code. It carries out the simulation by means of the formula sum(x)^2 / sum(x^2) for $Z$, where x is a vector of length n generated by rnorm. The rest is just looping (for, apply) and plotting (hist, curve).
for (n in c(2, 3, 10)) {
z <- apply(matrix(rnorm(n*1e5), nrow=n), 2, function(x) sum(x)^2 / sum(x^2))
hist(z, freq=FALSE, breaks=seq(0, n, length.out=50), main=paste("n =", n), xlab="Z")
curve(dbeta(x/n, 1/2, (n-1)/2)/n, add=TRUE, col="Red", lwd=2)
} | Distribution of the ratio of dependent chi-square random variables | This post elaborates on the answers in the comments to the question.
Let $X = (X_1, X_2, \ldots, X_n)$. Fix any $\mathbf{e}_1\in\mathbb{R}^n$ of unit length. Such a vector may always be completed t | Distribution of the ratio of dependent chi-square random variables
This post elaborates on the answers in the comments to the question.
Let $X = (X_1, X_2, \ldots, X_n)$. Fix any $\mathbf{e}_1\in\mathbb{R}^n$ of unit length. Such a vector may always be completed to an orthonormal basis $(\mathbf{e}_1, \mathbf{e}_2, \ldots, \mathbf{e}_n)$ (by means of the Gram-Schmidt process, for instance). This change of basis (from the usual one) is orthogonal: it does not change lengths. Thus the distribution of
$$\frac{(\mathbf{e}_1\cdot X)^2}{||X||^2}=\frac{(\mathbf{e}_1\cdot X)^2}{X_1^2 + X_2^2 + \cdots + X_n^2} $$
does not depend on $\mathbf{e}_1$. Taking $\mathbf{e}_1 = (1,0,0,\ldots, 0)$ shows this has the same distribution as
$$\frac{X_1^2}{X_1^2 + X_2^2 + \cdots + X_n^2}.\tag{1} $$
Since the $X_i$ are iid Normal, they may be written as $\sigma$ times iid standard Normal variables $Y_1, \ldots, Y_n$ and their squares are $\sigma^2$ times $\Gamma(1/2)$ distributions. Since the sum of $n-1$ independent $\Gamma(1/2)$ distributions is $\Gamma((n-1)/2)$, we have determined that the distribution of $(1)$ is that of
$$\frac{\sigma^2 U}{\sigma^2 U + \sigma^2 V} = \frac{U}{U+V}$$
where $U = X_1^2/\sigma^2 \sim \Gamma(1/2)$ and $V = (X_2^2 + \cdots + X_n^2)/\sigma^2 \sim \Gamma((n-1)/2)$ are independent. It is well known that this ratio has a Beta$(1/2, (n-1)/2)$ distribution. (Also see the closely related thread at Distribution of $XY$ if $X \sim$ Beta$(1,K-1)$ and $Y \sim$ chi-squared with $2K$ degrees.)
Since $$X_1 + \cdots + X_n = (1,1,\ldots,1)\cdot (X_1, X_2, \cdots, X_n) = \sqrt{n}\,\mathbf{e}_1\cdot X$$
for the unit vector $\mathbf{e}_1=(1,1,\ldots,1)/\sqrt{n}$, we conclude that $Z$ is $(\sqrt{n})^2 = n$ times a Beta$(1/2, (n-1)/2)$ variate. For $n\ge 2$ it therefore has density function
$$f_Z(z) = \frac{n^{1-n/2}}{B\left(\frac{1}{2}, \frac{n-1}{2}\right)} \sqrt{\frac{(n-z)^{n-3}}{z}}$$
on the interval $(0,n)$ (and otherwise is zero).
As a check, I simulated $100,000$ independent realizations of $Z$ for $\sigma=1$ and $n=2,3,10$, plotted their histograms, and superimposed the graph of the corresponding Beta density (in red). The agreements are excellent.
Here is the R code. It carries out the simulation by means of the formula sum(x)^2 / sum(x^2) for $Z$, where x is a vector of length n generated by rnorm. The rest is just looping (for, apply) and plotting (hist, curve).
for (n in c(2, 3, 10)) {
z <- apply(matrix(rnorm(n*1e5), nrow=n), 2, function(x) sum(x)^2 / sum(x^2))
hist(z, freq=FALSE, breaks=seq(0, n, length.out=50), main=paste("n =", n), xlab="Z")
curve(dbeta(x/n, 1/2, (n-1)/2)/n, add=TRUE, col="Red", lwd=2)
} | Distribution of the ratio of dependent chi-square random variables
This post elaborates on the answers in the comments to the question.
Let $X = (X_1, X_2, \ldots, X_n)$. Fix any $\mathbf{e}_1\in\mathbb{R}^n$ of unit length. Such a vector may always be completed t |
17,776 | Is there any "standard" for statistical model notation? | Some recommended standards for statistical notation are presented in Halperin, Hartley and Hoel (1965) and Sanders and Pugh (1972). Most of the current notation comes from conventions that were established by the biometric statisticians in the late 19th and early 20th century (most of it was done by Pearson and Fisher and their associates). A useful list of early uses of notation is maintained by the economist John Aldrich here, and a historical account of the English biometric school is published in Aldrich (2003). (If you have further enquiries about this topic, Aldrich is probably the world's foremost living expert in the history of notation in statistics.)
Aside from this explicit work, there are a lot of books that give introductions to the field, and these are careful to define notation consistent with common conventions, defining notation as they go. There are many well-known conventions in this field that run consistently through the literature, and statisticians are well-acquainted with these through practice, even without having read the recommendations of these researchers.
Ambiguity of the distribution-centric notation: The use of the "distribution-centric" notation is a standard convention that is used throughout statistical literature. However, one interesting thing to point out about this notation is that there is a bit of wiggle-room as to what it actually means. The standard convention is to read the object on the right-hand-side of these statements as some kind of description of a probability measure (e.g, a distribution function, density function, etc.) and then read the $\sim$ relation with meaning "...has distribution..." or "...has probability measure...", etc. Under this interpretation the relation compares two distinct sets of things; the object on the left-hand-side is a random variable and the object on the right-hand-side is a description of a probability measure.
However, it is also equally valid to interpret the right-hand-side as a reference to a random variable (as opposed to a distribution) and read the $\sim$ relation as meaning "...has the same distribution as...". Under this interpretation the relation is an equivalence relation comparing random variables; the objects on the left- and right--hand-sides are both random variables and the relation is reflexive, symmetric and transitive.
This gives two possible (and equally valid) interpretations of a statement like:
$$X \sim \text{N}(\mu, \sigma^2).$$
Distributional interpretation: "$X$ has probability distribution $\text{N}(\mu, \sigma^2)$". This interpretation takes the latter object to be some description of a normal probability measure (e.g., its density function, distribution function, etc.).
Random variable interpretation: "$X$ has the same probability distribution as $\text{N}(\mu, \sigma^2)$". This interpretation takes the latter object to be a normal random variable.
Each interpretation has advantages and disadvantages. The advantage of the random-variable interpretation is that it uses the standard symbol $\sim$ to refer to an equivalence relation, but its disadvantage is that it requires reference to random variables with similar notation to their distribution functions. The advantage of the distributional interpretation is that it uses similar notation for the distributions as a whole, and their functional forms with a given argument value; the disadvantage is that it uses the $\sim$ symbol in a way that is not an equivalence relation.
Aldrich, J. (2003) The Language of the English Biometric School International Statistical Review 71(1), pp. 109-131.
Halperin, M., Hartley, H.O. and Hoel, P.G. (1965) Recommended Standards for Statistical Symbols and Notation. The American Statistician 19(3), pp. 12-14.
Sanders, J.R. and Pugh, R.C. (1972) Recommendation for a Standard Set of Statistical Symbols and Notations. Educational Researcher 1(11), pp. 15-16. | Is there any "standard" for statistical model notation? | Some recommended standards for statistical notation are presented in Halperin, Hartley and Hoel (1965) and Sanders and Pugh (1972). Most of the current notation comes from conventions that were estab | Is there any "standard" for statistical model notation?
Some recommended standards for statistical notation are presented in Halperin, Hartley and Hoel (1965) and Sanders and Pugh (1972). Most of the current notation comes from conventions that were established by the biometric statisticians in the late 19th and early 20th century (most of it was done by Pearson and Fisher and their associates). A useful list of early uses of notation is maintained by the economist John Aldrich here, and a historical account of the English biometric school is published in Aldrich (2003). (If you have further enquiries about this topic, Aldrich is probably the world's foremost living expert in the history of notation in statistics.)
Aside from this explicit work, there are a lot of books that give introductions to the field, and these are careful to define notation consistent with common conventions, defining notation as they go. There are many well-known conventions in this field that run consistently through the literature, and statisticians are well-acquainted with these through practice, even without having read the recommendations of these researchers.
Ambiguity of the distribution-centric notation: The use of the "distribution-centric" notation is a standard convention that is used throughout statistical literature. However, one interesting thing to point out about this notation is that there is a bit of wiggle-room as to what it actually means. The standard convention is to read the object on the right-hand-side of these statements as some kind of description of a probability measure (e.g, a distribution function, density function, etc.) and then read the $\sim$ relation with meaning "...has distribution..." or "...has probability measure...", etc. Under this interpretation the relation compares two distinct sets of things; the object on the left-hand-side is a random variable and the object on the right-hand-side is a description of a probability measure.
However, it is also equally valid to interpret the right-hand-side as a reference to a random variable (as opposed to a distribution) and read the $\sim$ relation as meaning "...has the same distribution as...". Under this interpretation the relation is an equivalence relation comparing random variables; the objects on the left- and right--hand-sides are both random variables and the relation is reflexive, symmetric and transitive.
This gives two possible (and equally valid) interpretations of a statement like:
$$X \sim \text{N}(\mu, \sigma^2).$$
Distributional interpretation: "$X$ has probability distribution $\text{N}(\mu, \sigma^2)$". This interpretation takes the latter object to be some description of a normal probability measure (e.g., its density function, distribution function, etc.).
Random variable interpretation: "$X$ has the same probability distribution as $\text{N}(\mu, \sigma^2)$". This interpretation takes the latter object to be a normal random variable.
Each interpretation has advantages and disadvantages. The advantage of the random-variable interpretation is that it uses the standard symbol $\sim$ to refer to an equivalence relation, but its disadvantage is that it requires reference to random variables with similar notation to their distribution functions. The advantage of the distributional interpretation is that it uses similar notation for the distributions as a whole, and their functional forms with a given argument value; the disadvantage is that it uses the $\sim$ symbol in a way that is not an equivalence relation.
Aldrich, J. (2003) The Language of the English Biometric School International Statistical Review 71(1), pp. 109-131.
Halperin, M., Hartley, H.O. and Hoel, P.G. (1965) Recommended Standards for Statistical Symbols and Notation. The American Statistician 19(3), pp. 12-14.
Sanders, J.R. and Pugh, R.C. (1972) Recommendation for a Standard Set of Statistical Symbols and Notations. Educational Researcher 1(11), pp. 15-16. | Is there any "standard" for statistical model notation?
Some recommended standards for statistical notation are presented in Halperin, Hartley and Hoel (1965) and Sanders and Pugh (1972). Most of the current notation comes from conventions that were estab |
17,777 | Poisson regression assumptions and how to test them in R | 1) Calculate the mean and the sample variance. $\frac{\bar{X}}{S^2}$ should be $\mathrm{F}(1,n-1)$ distributed, where $n$ is the size of the sample and the process is truly Poisson - since they are independent estimates of the same variance.
Note that this test ignores the covariates - so probably not the best way to check over-dispersion in that situation.
Note also that this test is probably weak against the zero-inflated hypothesis.
3) negative binomial in R: use glm.nb from the MASS package, or use the zeroinfl function from the pscl package using the negative binomial link.
4) zip (zero-inflated Poisson) is a mixture model. You have a binary outcome, according to which a subject belongs to group A (where a 0 is certain) or to group B (where counts are Poisson or neg binomial distributed). An observed 0 is due to subjects from group A + subjects from group B who just happened to be lucky. Both aspects of the model can depend on covariates: group membership is modeled like a logistic (log odds is linear in the covariates) and the Poisson part is modeled in the usual way: log mean is linear in the covariates. So you need the usual assumptions for a logistic (for the certain 0 part) and the usual assumptions for a Poisson. In other words, a zip model will not cure your overdispersion problems - it only cures a big gomp of zeroes.
5) not sure what the data set is and couldn't find the reference. zeroinfl needs a model for both the poisson part and the binary (certain 0 or not) part. The certain 0 part goes second. So m.a is saying that whether the person is a certain 0 or not depends on "persons" - and assuming the subject is not a certain 0, count is a function of camper and child. In other words log(mean) is a linear function of camper and child for those subjects not requiring a 0 count.
m.b is just a general linear model of count in terms of camper and child - both assumed to be fixed effects. The link function is Poisson. | Poisson regression assumptions and how to test them in R | 1) Calculate the mean and the sample variance. $\frac{\bar{X}}{S^2}$ should be $\mathrm{F}(1,n-1)$ distributed, where $n$ is the size of the sample and the process is truly Poisson - since they are in | Poisson regression assumptions and how to test them in R
1) Calculate the mean and the sample variance. $\frac{\bar{X}}{S^2}$ should be $\mathrm{F}(1,n-1)$ distributed, where $n$ is the size of the sample and the process is truly Poisson - since they are independent estimates of the same variance.
Note that this test ignores the covariates - so probably not the best way to check over-dispersion in that situation.
Note also that this test is probably weak against the zero-inflated hypothesis.
3) negative binomial in R: use glm.nb from the MASS package, or use the zeroinfl function from the pscl package using the negative binomial link.
4) zip (zero-inflated Poisson) is a mixture model. You have a binary outcome, according to which a subject belongs to group A (where a 0 is certain) or to group B (where counts are Poisson or neg binomial distributed). An observed 0 is due to subjects from group A + subjects from group B who just happened to be lucky. Both aspects of the model can depend on covariates: group membership is modeled like a logistic (log odds is linear in the covariates) and the Poisson part is modeled in the usual way: log mean is linear in the covariates. So you need the usual assumptions for a logistic (for the certain 0 part) and the usual assumptions for a Poisson. In other words, a zip model will not cure your overdispersion problems - it only cures a big gomp of zeroes.
5) not sure what the data set is and couldn't find the reference. zeroinfl needs a model for both the poisson part and the binary (certain 0 or not) part. The certain 0 part goes second. So m.a is saying that whether the person is a certain 0 or not depends on "persons" - and assuming the subject is not a certain 0, count is a function of camper and child. In other words log(mean) is a linear function of camper and child for those subjects not requiring a 0 count.
m.b is just a general linear model of count in terms of camper and child - both assumed to be fixed effects. The link function is Poisson. | Poisson regression assumptions and how to test them in R
1) Calculate the mean and the sample variance. $\frac{\bar{X}}{S^2}$ should be $\mathrm{F}(1,n-1)$ distributed, where $n$ is the size of the sample and the process is truly Poisson - since they are in |
17,778 | Poisson regression assumptions and how to test them in R | library(pastecs)
stat.desc(dep_var) - and then take a look if the mean and the variance are equal. From here you can also calculate the % of zeroes in your vector. | Poisson regression assumptions and how to test them in R | library(pastecs)
stat.desc(dep_var) - and then take a look if the mean and the variance are equal. From here you can also calculate the % of zeroes in your vector. | Poisson regression assumptions and how to test them in R
library(pastecs)
stat.desc(dep_var) - and then take a look if the mean and the variance are equal. From here you can also calculate the % of zeroes in your vector. | Poisson regression assumptions and how to test them in R
library(pastecs)
stat.desc(dep_var) - and then take a look if the mean and the variance are equal. From here you can also calculate the % of zeroes in your vector. |
17,779 | When/where to use functional data analysis? | Functional Data Analysis (FDA) can model phase variation (differences in timing), whereas the alternatives that you mention cannot. An example of phase variation is the variability in timing in the onset of puberty in children. Ignoring phase variation (which is standard practice) mismodels puberty. FDA models phase variation by time warping, where the time axis is locally stretched or compressed to fit a target. In this way, FDA can give a realistic and useful description of the process. FDA requires relatively dense data, but nowadays we see these more and more. In my opinion, FDA has great potential and is vastly underused. | When/where to use functional data analysis? | Functional Data Analysis (FDA) can model phase variation (differences in timing), whereas the alternatives that you mention cannot. An example of phase variation is the variability in timing in the on | When/where to use functional data analysis?
Functional Data Analysis (FDA) can model phase variation (differences in timing), whereas the alternatives that you mention cannot. An example of phase variation is the variability in timing in the onset of puberty in children. Ignoring phase variation (which is standard practice) mismodels puberty. FDA models phase variation by time warping, where the time axis is locally stretched or compressed to fit a target. In this way, FDA can give a realistic and useful description of the process. FDA requires relatively dense data, but nowadays we see these more and more. In my opinion, FDA has great potential and is vastly underused. | When/where to use functional data analysis?
Functional Data Analysis (FDA) can model phase variation (differences in timing), whereas the alternatives that you mention cannot. An example of phase variation is the variability in timing in the on |
17,780 | Identity of moment-generating functions | Yes.
In an exercise, Stuart & Ord (Kendall's Advanced Theory of Statistics, 5th Ed., Ex. 3.12) quote a 1918 result of TJ Stieltjes (which apparently appears in his Oeuvres Completes,):
If $f$ is an odd function of period $\frac{1}{2}$, show that
$$\int_0^\infty x^r x^{-\log x} f(\log x) dx = 0$$
for all integral values of $r$. Hence show that the distributions
$$dF = x^{-\log x}(1 - \lambda \sin(4\pi \log x))\ dx, \quad 0 \le x \lt \infty;\quad 0 \le |\lambda| \le 1,$$
have the same moments whatever the value of $\lambda$.
(In the original, $|\lambda|$ appears only as $\lambda$; the restriction on the size of $\lambda$ arises from the requirement to keep all values of the density function $dF$ non-negative.) The exercise is easy to solve via the substitution $x = \exp(y)$ and completing the square. The case $\lambda=0$ is the well-known lognormal distribution.
The blue curve corresponds to $\lambda=0$, a lognormal distribution. For the red curve, $\lambda = -1/4$ and for the gold curve, $\lambda = 1/2$. | Identity of moment-generating functions | Yes.
In an exercise, Stuart & Ord (Kendall's Advanced Theory of Statistics, 5th Ed., Ex. 3.12) quote a 1918 result of TJ Stieltjes (which apparently appears in his Oeuvres Completes,):
If $f$ is an o | Identity of moment-generating functions
Yes.
In an exercise, Stuart & Ord (Kendall's Advanced Theory of Statistics, 5th Ed., Ex. 3.12) quote a 1918 result of TJ Stieltjes (which apparently appears in his Oeuvres Completes,):
If $f$ is an odd function of period $\frac{1}{2}$, show that
$$\int_0^\infty x^r x^{-\log x} f(\log x) dx = 0$$
for all integral values of $r$. Hence show that the distributions
$$dF = x^{-\log x}(1 - \lambda \sin(4\pi \log x))\ dx, \quad 0 \le x \lt \infty;\quad 0 \le |\lambda| \le 1,$$
have the same moments whatever the value of $\lambda$.
(In the original, $|\lambda|$ appears only as $\lambda$; the restriction on the size of $\lambda$ arises from the requirement to keep all values of the density function $dF$ non-negative.) The exercise is easy to solve via the substitution $x = \exp(y)$ and completing the square. The case $\lambda=0$ is the well-known lognormal distribution.
The blue curve corresponds to $\lambda=0$, a lognormal distribution. For the red curve, $\lambda = -1/4$ and for the gold curve, $\lambda = 1/2$. | Identity of moment-generating functions
Yes.
In an exercise, Stuart & Ord (Kendall's Advanced Theory of Statistics, 5th Ed., Ex. 3.12) quote a 1918 result of TJ Stieltjes (which apparently appears in his Oeuvres Completes,):
If $f$ is an o |
17,781 | Is it at all defensible to stratify a data set by the size of the residual and do a two-sample comparison? | Comparing the means is too weak: instead, compare the distributions.
There is also a question concerning whether it is more desirable to compare the sizes of the residuals (as stated) or to compare the residuals themselves. Therefore, I evaluate both.
To be specific about what is meant, here is some R code to compare $(x,y)$ data (given in parallel arrays x and y) by regressing $y$ on $x$, dividing the residuals into three groups by cutting them below quantile $q_0$ and above quantile $q_1\gt q_0$, and (by means of a qq plot) comparing the distributions of $x$ values associated with those two groups.
test <- function(y, x, q0, q1, abs0=abs, ...) {
y.res <- abs0(residuals(lm(y~x)))
y.groups <- cut(y.res, quantile(y.res, c(0,q0,q1,1)))
x.groups <- split(x, y.groups)
xy <- qqplot(x.groups[[1]], x.groups[[3]], plot.it=FALSE)
lines(xy, xlab="Low residual", ylab="High residual", ...)
}
The fifth argument to this function, abs0, by default uses the sizes (absolute values) of the residuals to form the groups. Later we can replace that by a function that uses the residuals themselves.
Residuals are used to detect many things: outliers, possible correlations with exogenous variables, goodness of fit, and homoscedasticity. Outliers, by their nature, should be few and isolated and thus are not going to play a meaningful role here. To keep this analysis simple, let's explore the last two: goodness of fit (that is, linearity of the $x$-$y$ relationship) and homoscedasticity (that is, constancy of the size of the residuals). We can do this through simulation:
simulate <- function(n, beta0=0, beta1=1, beta2=0, sd=1, q0=1/3, q1=2/3, abs0=abs,
n.trials=99, ...) {
x <- 1:n - (n+1)/2
y <- beta0 + beta1 * x + beta2 * x^2 + rnorm(n, sd=sd)
plot(x,y, ylab="y", cex=0.8, pch=19, ...)
plot(x, res <- residuals(lm(y ~ x)), cex=0.8, col="Gray", ylab="", main="Residuals")
res.abs <- abs0(res)
r0 <- quantile(res.abs, q0); r1 <- quantile(res.abs, q1)
points(x[res.abs < r0], res[res.abs < r0], col="Blue")
points(x[res.abs > r1], res[res.abs > r1], col="Red")
plot(x,x, main="QQ Plot of X",
xlab="Low residual", ylab="High residual",
type="n")
abline(0,1, col="Red", lwd=2)
temp <- replicate(n.trials, test(beta0 + beta1 * x + beta2 * x^2 + rnorm(n, sd=sd),
x, q0=q0, q1=q1, abs0=abs0, lwd=1.25, lty=3, col="Gray"))
test(y, x, q0=q0, q1=q1, abs0=abs0, lwd=2, col="Black")
}
This code accepts arguments determining the linear model: its coefficients $y \sim \beta_0 + \beta_1 x + \beta_2 x^2$, the standard deviations of the error terms sd, the quantiles $q_0$ and $q_1$, the size function abs0, and the number of independent trials in the simulation, n.trials. The first argument n is the amount of data to simulate in each trial. It produces a set of plots--of the $(x,y)$ data, of their residuals, and qq plots of multiple trials--to help us understand how the proposed tests work for a given model (as determined by n, the beta,s and sd). Examples of these plots appear below.
Let us now use these tools to explore some realistic combinations of nonlinearity and heteroscedasticity, using the absolute values of the residuals:
n <- 100
beta0 <- 1
beta1 <- -1/n
sigma <- 1/n
size <- function(x) abs(x)
set.seed(17)
par(mfcol=c(3,4))
simulate(n, beta0, beta1, 0, sigma*sqrt(n), abs0=size, main="Linear Homoscedastic")
simulate(n, beta0, beta1, 0, 0.5*sigma*(n:1), abs0=size, main="Linear Heteroscedastic")
simulate(n, beta0, beta1, 1/n^2, sigma*sqrt(n), abs0=size, main="Quadratic Homoscedastic")
simulate(n, beta0, beta1, 1/n^2, 5*sigma*sqrt(1:n), abs0=size, main="Quadratic Heteroscedastic")
The output is a set of plots. The top row shows one simulated dataset, the second row shows a scatterplot of its residuals against $x$ (color-coded by quantile: red for large values, blue for small values, gray for any intermediate values not further used), and the third row shows the qq plots for all trials, with the qq plot for the one simulated dataset shown in black. An individual qq plot compares the $x$ values associated with high residuals to the $x$ values associated with low residuals; after many trials, a gray envelope of likely qq plots emerges. We are interested in how, and how strongly, these envelopes vary with departures from the basic linear model: strong variation implies good discrimination.
The differences between the last three and the first columns make it clear this method is able to detect heteroscedasticity, but it might not be so effective in identifying a moderate nonlinearity. It could easily confuse the nonlinearity with heteroscedasticity. This is because the form of heteroscedasticity simulated here (which is common) is one where the expected sizes of the residuals trend with $x$. That trend is easy to detect. Quadratic nonlinearity, on the other hand, will create large residuals at both ends and in the middle of the range of $x$ values. This is hard to distinguish just by looking at the distributions of the affected $x$ values.
Let's do the same thing, using exactly the same data, but analyzing the residuals themselves. To do this, the previous block of code was rerun after making this modification:
size <- function(x) x
This variation does not detect heteroscedasticity well: see how similar the qq plots are in the first two columns. However, it does a good job of detecting nonlinearity. This is because the residuals separate the $x$'s into a middle portion and an outer portion, which will be fairly different. As shown in the rightmost column, however, heteroscedasticity can mask nonlinearities.
Perhaps combining both these techniques would work. These simulations (and variations of them, which the interested reader can run at leisure) demonstrate that these techniques are not without merit.
In general, however, one is far better served by examining the residuals in standard ways. For automated work, formal tests have been developed to detect the kinds of things we look for in residual plots. For instance, the Breusch-Pagan test regresses the squared residuals (rather than their absolute values) against $x$. The tests proposed in this question can be understood in the same spirit. However, by binning the data into just two groups and thereby neglecting most of the bivariate information afforded by the $(x, \hat{y}-x)$ pairs, we can expect the proposed tests to be less powerful than regression-based tests like the Breusch-Pagan. | Is it at all defensible to stratify a data set by the size of the residual and do a two-sample compa | Comparing the means is too weak: instead, compare the distributions.
There is also a question concerning whether it is more desirable to compare the sizes of the residuals (as stated) or to compare th | Is it at all defensible to stratify a data set by the size of the residual and do a two-sample comparison?
Comparing the means is too weak: instead, compare the distributions.
There is also a question concerning whether it is more desirable to compare the sizes of the residuals (as stated) or to compare the residuals themselves. Therefore, I evaluate both.
To be specific about what is meant, here is some R code to compare $(x,y)$ data (given in parallel arrays x and y) by regressing $y$ on $x$, dividing the residuals into three groups by cutting them below quantile $q_0$ and above quantile $q_1\gt q_0$, and (by means of a qq plot) comparing the distributions of $x$ values associated with those two groups.
test <- function(y, x, q0, q1, abs0=abs, ...) {
y.res <- abs0(residuals(lm(y~x)))
y.groups <- cut(y.res, quantile(y.res, c(0,q0,q1,1)))
x.groups <- split(x, y.groups)
xy <- qqplot(x.groups[[1]], x.groups[[3]], plot.it=FALSE)
lines(xy, xlab="Low residual", ylab="High residual", ...)
}
The fifth argument to this function, abs0, by default uses the sizes (absolute values) of the residuals to form the groups. Later we can replace that by a function that uses the residuals themselves.
Residuals are used to detect many things: outliers, possible correlations with exogenous variables, goodness of fit, and homoscedasticity. Outliers, by their nature, should be few and isolated and thus are not going to play a meaningful role here. To keep this analysis simple, let's explore the last two: goodness of fit (that is, linearity of the $x$-$y$ relationship) and homoscedasticity (that is, constancy of the size of the residuals). We can do this through simulation:
simulate <- function(n, beta0=0, beta1=1, beta2=0, sd=1, q0=1/3, q1=2/3, abs0=abs,
n.trials=99, ...) {
x <- 1:n - (n+1)/2
y <- beta0 + beta1 * x + beta2 * x^2 + rnorm(n, sd=sd)
plot(x,y, ylab="y", cex=0.8, pch=19, ...)
plot(x, res <- residuals(lm(y ~ x)), cex=0.8, col="Gray", ylab="", main="Residuals")
res.abs <- abs0(res)
r0 <- quantile(res.abs, q0); r1 <- quantile(res.abs, q1)
points(x[res.abs < r0], res[res.abs < r0], col="Blue")
points(x[res.abs > r1], res[res.abs > r1], col="Red")
plot(x,x, main="QQ Plot of X",
xlab="Low residual", ylab="High residual",
type="n")
abline(0,1, col="Red", lwd=2)
temp <- replicate(n.trials, test(beta0 + beta1 * x + beta2 * x^2 + rnorm(n, sd=sd),
x, q0=q0, q1=q1, abs0=abs0, lwd=1.25, lty=3, col="Gray"))
test(y, x, q0=q0, q1=q1, abs0=abs0, lwd=2, col="Black")
}
This code accepts arguments determining the linear model: its coefficients $y \sim \beta_0 + \beta_1 x + \beta_2 x^2$, the standard deviations of the error terms sd, the quantiles $q_0$ and $q_1$, the size function abs0, and the number of independent trials in the simulation, n.trials. The first argument n is the amount of data to simulate in each trial. It produces a set of plots--of the $(x,y)$ data, of their residuals, and qq plots of multiple trials--to help us understand how the proposed tests work for a given model (as determined by n, the beta,s and sd). Examples of these plots appear below.
Let us now use these tools to explore some realistic combinations of nonlinearity and heteroscedasticity, using the absolute values of the residuals:
n <- 100
beta0 <- 1
beta1 <- -1/n
sigma <- 1/n
size <- function(x) abs(x)
set.seed(17)
par(mfcol=c(3,4))
simulate(n, beta0, beta1, 0, sigma*sqrt(n), abs0=size, main="Linear Homoscedastic")
simulate(n, beta0, beta1, 0, 0.5*sigma*(n:1), abs0=size, main="Linear Heteroscedastic")
simulate(n, beta0, beta1, 1/n^2, sigma*sqrt(n), abs0=size, main="Quadratic Homoscedastic")
simulate(n, beta0, beta1, 1/n^2, 5*sigma*sqrt(1:n), abs0=size, main="Quadratic Heteroscedastic")
The output is a set of plots. The top row shows one simulated dataset, the second row shows a scatterplot of its residuals against $x$ (color-coded by quantile: red for large values, blue for small values, gray for any intermediate values not further used), and the third row shows the qq plots for all trials, with the qq plot for the one simulated dataset shown in black. An individual qq plot compares the $x$ values associated with high residuals to the $x$ values associated with low residuals; after many trials, a gray envelope of likely qq plots emerges. We are interested in how, and how strongly, these envelopes vary with departures from the basic linear model: strong variation implies good discrimination.
The differences between the last three and the first columns make it clear this method is able to detect heteroscedasticity, but it might not be so effective in identifying a moderate nonlinearity. It could easily confuse the nonlinearity with heteroscedasticity. This is because the form of heteroscedasticity simulated here (which is common) is one where the expected sizes of the residuals trend with $x$. That trend is easy to detect. Quadratic nonlinearity, on the other hand, will create large residuals at both ends and in the middle of the range of $x$ values. This is hard to distinguish just by looking at the distributions of the affected $x$ values.
Let's do the same thing, using exactly the same data, but analyzing the residuals themselves. To do this, the previous block of code was rerun after making this modification:
size <- function(x) x
This variation does not detect heteroscedasticity well: see how similar the qq plots are in the first two columns. However, it does a good job of detecting nonlinearity. This is because the residuals separate the $x$'s into a middle portion and an outer portion, which will be fairly different. As shown in the rightmost column, however, heteroscedasticity can mask nonlinearities.
Perhaps combining both these techniques would work. These simulations (and variations of them, which the interested reader can run at leisure) demonstrate that these techniques are not without merit.
In general, however, one is far better served by examining the residuals in standard ways. For automated work, formal tests have been developed to detect the kinds of things we look for in residual plots. For instance, the Breusch-Pagan test regresses the squared residuals (rather than their absolute values) against $x$. The tests proposed in this question can be understood in the same spirit. However, by binning the data into just two groups and thereby neglecting most of the bivariate information afforded by the $(x, \hat{y}-x)$ pairs, we can expect the proposed tests to be less powerful than regression-based tests like the Breusch-Pagan. | Is it at all defensible to stratify a data set by the size of the residual and do a two-sample compa
Comparing the means is too weak: instead, compare the distributions.
There is also a question concerning whether it is more desirable to compare the sizes of the residuals (as stated) or to compare th |
17,782 | Is it at all defensible to stratify a data set by the size of the residual and do a two-sample comparison? | I agree with both of your points. If the model is inadequate the residuals might not be approximately independent and identically distributed. Important variables could have been left out or the functional form of the regressor variables could be wrong. If that is the case I would use the standard regression diagnostics to identify the problem rather than this. Also you could have the right variables in the model with the right functional form but still have a nonconstant variance. This might be apparent just by plotting the $e_{i}$ against $x_i$. I can see a point to say wanting to find outliers in the model through some form of residual but then I would recommend an influence function approach for detecting them. I don't see what this procedure accomplishes.
Others have commented that this may be just an exploratory tool to see if the two data sets should be modelled separately. If that is the case this and possibly other exploratory approaches might be okay. But the question then becomes what do you do next? If you are going to then do two separate regressions and draw inference about the samples I think you need to somehow take account of the way you split the sample. | Is it at all defensible to stratify a data set by the size of the residual and do a two-sample compa | I agree with both of your points. If the model is inadequate the residuals might not be approximately independent and identically distributed. Important variables could have been left out or the fun | Is it at all defensible to stratify a data set by the size of the residual and do a two-sample comparison?
I agree with both of your points. If the model is inadequate the residuals might not be approximately independent and identically distributed. Important variables could have been left out or the functional form of the regressor variables could be wrong. If that is the case I would use the standard regression diagnostics to identify the problem rather than this. Also you could have the right variables in the model with the right functional form but still have a nonconstant variance. This might be apparent just by plotting the $e_{i}$ against $x_i$. I can see a point to say wanting to find outliers in the model through some form of residual but then I would recommend an influence function approach for detecting them. I don't see what this procedure accomplishes.
Others have commented that this may be just an exploratory tool to see if the two data sets should be modelled separately. If that is the case this and possibly other exploratory approaches might be okay. But the question then becomes what do you do next? If you are going to then do two separate regressions and draw inference about the samples I think you need to somehow take account of the way you split the sample. | Is it at all defensible to stratify a data set by the size of the residual and do a two-sample compa
I agree with both of your points. If the model is inadequate the residuals might not be approximately independent and identically distributed. Important variables could have been left out or the fun |
17,783 | Is it at all defensible to stratify a data set by the size of the residual and do a two-sample comparison? | I guess there might be several motivations to do this e.g. assuming that the residuals are consistent then the method you mention may help identify outlying observations, thus the second step provides with "corrected" estimators. But, there are more rigorous techniques that perform outlyers detection or that provide estimators that are robust to the presence of such observations, like quantile regressions, LMS (least median of squares) or M-estimators etc. where all of these methods have well defined and known statistical properties. (This has been addresed by @Michael Chernik)
Other motivation might be cluster identification but this is primitive when compared with the available techniques for cluster detection which are also well defined and widely implemented.
In both cases, using the residuals seems informal and primitive, but might still be tolerated as an exploratory tool. It also depends on readers' domain. I would find this acceptable for some social sciences where quantitative tools may be less popular. | Is it at all defensible to stratify a data set by the size of the residual and do a two-sample compa | I guess there might be several motivations to do this e.g. assuming that the residuals are consistent then the method you mention may help identify outlying observations, thus the second step provides | Is it at all defensible to stratify a data set by the size of the residual and do a two-sample comparison?
I guess there might be several motivations to do this e.g. assuming that the residuals are consistent then the method you mention may help identify outlying observations, thus the second step provides with "corrected" estimators. But, there are more rigorous techniques that perform outlyers detection or that provide estimators that are robust to the presence of such observations, like quantile regressions, LMS (least median of squares) or M-estimators etc. where all of these methods have well defined and known statistical properties. (This has been addresed by @Michael Chernik)
Other motivation might be cluster identification but this is primitive when compared with the available techniques for cluster detection which are also well defined and widely implemented.
In both cases, using the residuals seems informal and primitive, but might still be tolerated as an exploratory tool. It also depends on readers' domain. I would find this acceptable for some social sciences where quantitative tools may be less popular. | Is it at all defensible to stratify a data set by the size of the residual and do a two-sample compa
I guess there might be several motivations to do this e.g. assuming that the residuals are consistent then the method you mention may help identify outlying observations, thus the second step provides |
17,784 | Area under the "pdf" in kernel density estimation in R | Think about the trapezoid rule integrate.xy() uses. For the normal distribution, it will underestimate the area under the curve in the interval (-1,1) where the density is concave (and hence the linear interpolation is below the true density), and overestimate it elsewhere (as the linear interpolation goes on top of the true density). Since the latter region is larger (in Lesbegue measure, if you like), the trapezoid rule tends to overestimate the integral. Now, as you move to smaller bandwidths, pretty much all of your estimate is piecewise convex, with a lot of narrow spikes corresponding to the data points, and valleys between them. That's where the trapezoid rule breaks down especially badly. | Area under the "pdf" in kernel density estimation in R | Think about the trapezoid rule integrate.xy() uses. For the normal distribution, it will underestimate the area under the curve in the interval (-1,1) where the density is concave (and hence the linea | Area under the "pdf" in kernel density estimation in R
Think about the trapezoid rule integrate.xy() uses. For the normal distribution, it will underestimate the area under the curve in the interval (-1,1) where the density is concave (and hence the linear interpolation is below the true density), and overestimate it elsewhere (as the linear interpolation goes on top of the true density). Since the latter region is larger (in Lesbegue measure, if you like), the trapezoid rule tends to overestimate the integral. Now, as you move to smaller bandwidths, pretty much all of your estimate is piecewise convex, with a lot of narrow spikes corresponding to the data points, and valleys between them. That's where the trapezoid rule breaks down especially badly. | Area under the "pdf" in kernel density estimation in R
Think about the trapezoid rule integrate.xy() uses. For the normal distribution, it will underestimate the area under the curve in the interval (-1,1) where the density is concave (and hence the linea |
17,785 | Area under the "pdf" in kernel density estimation in R | Ive been integrating using the automatic bandwidth and getting answers ranging from .1 to 7 , not particularly trustworty. | Area under the "pdf" in kernel density estimation in R | Ive been integrating using the automatic bandwidth and getting answers ranging from .1 to 7 , not particularly trustworty. | Area under the "pdf" in kernel density estimation in R
Ive been integrating using the automatic bandwidth and getting answers ranging from .1 to 7 , not particularly trustworty. | Area under the "pdf" in kernel density estimation in R
Ive been integrating using the automatic bandwidth and getting answers ranging from .1 to 7 , not particularly trustworty. |
17,786 | Area under the "pdf" in kernel density estimation in R | Use the KDE function in the utilties package instead
Note: This answer is adapted from a silmiar answer here.
The problem you are encountering is that the density function in the stats package gives you an output that is just a vector of density values at a finite number of points --- it is not actually giving you a full density function that you can integrate effectively. This is a reasonable way to give a density output if you just want to plot the density reasonable well, but as you can see, it leads to a value that is slightly different to one when you try to integrate it.
To get around this deficiency, you can use the KDE function in the utilties package. This function generates the KDE in the same way as the density function in R,$^\dagger$ but instead of producing an output computed over a relatively small set of points, it produces an output that includes the probability functions for the KDE. You can also call the function in such a way that it loads those probability functions directly to the global environment, so that you can easily call them just like any other density function in R. This will give you a full density function that you can call at any set of points, and also a cumulative distribution function where the integration of the density has already been done for you.
Below I give an example of how to generate the KDE using this function, and how to call the cumulative distribution function over an arbitrary set of values. As you can see, the KDE function produces a set of probability functions (dkde, pkde, qkde, and rkde) that can be called just like the probability functions for any of the pre-programmed families of distributions. This allows you to compute the cumulative distribution from pkde at any point you want, including points that are far outside the data range used to generate the KDE.
#Load the package
library(utilities)
#Generate some mock data
set.seed(1)
DATA <- rnorm(40)
#Create a KDE and show its output
MY_KDE <- KDE(DATA, to.environment = TRUE)
MY_KDE
Kernel Density Estimator (KDE)
Computed from 40 data points in the input 'DATA'
Estimated bandwidth = 0.367412
Input degrees-of-freedom = Inf
Probability functions for the KDE are the following:
Density function: dkde *
Distribution function: pkde *
Quantile function: qkde *
Random generation function: rkde *
* This function is presently loaded in the global environment
#Call the CDF over a set of points (including points far in the tails)
POINTS <- -10:10
pkde(POINTS)
[1] 1.489573e-101 4.685332e-78 9.132757e-58 1.112228e-40 8.584043e-27 4.322183e-16
[7] 1.529301e-08 4.819333e-04 3.326124e-02 1.236576e-01 4.251039e-01 8.352227e-01
[13] 9.927698e-01 9.999976e-01 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00
[19] 1.000000e+00 1.000000e+00 1.000000e+00
From the outputs of the CDF you can see that the density function integrates to one over the full range. (If you're unsure, just call pkde(Inf) to see the CDF value integrating over the whole range.)
$^\dagger$ The KDE function has the advantage of giving a more useful output (in my opinion) but it is not as general as the density function in the base package. It does not accomodate as wide a range of kernel types or bandwidth estimation methods. Both functions can produce a KDE using the normal kernel. | Area under the "pdf" in kernel density estimation in R | Use the KDE function in the utilties package instead
Note: This answer is adapted from a silmiar answer here.
The problem you are encountering is that the density function in the stats package gives y | Area under the "pdf" in kernel density estimation in R
Use the KDE function in the utilties package instead
Note: This answer is adapted from a silmiar answer here.
The problem you are encountering is that the density function in the stats package gives you an output that is just a vector of density values at a finite number of points --- it is not actually giving you a full density function that you can integrate effectively. This is a reasonable way to give a density output if you just want to plot the density reasonable well, but as you can see, it leads to a value that is slightly different to one when you try to integrate it.
To get around this deficiency, you can use the KDE function in the utilties package. This function generates the KDE in the same way as the density function in R,$^\dagger$ but instead of producing an output computed over a relatively small set of points, it produces an output that includes the probability functions for the KDE. You can also call the function in such a way that it loads those probability functions directly to the global environment, so that you can easily call them just like any other density function in R. This will give you a full density function that you can call at any set of points, and also a cumulative distribution function where the integration of the density has already been done for you.
Below I give an example of how to generate the KDE using this function, and how to call the cumulative distribution function over an arbitrary set of values. As you can see, the KDE function produces a set of probability functions (dkde, pkde, qkde, and rkde) that can be called just like the probability functions for any of the pre-programmed families of distributions. This allows you to compute the cumulative distribution from pkde at any point you want, including points that are far outside the data range used to generate the KDE.
#Load the package
library(utilities)
#Generate some mock data
set.seed(1)
DATA <- rnorm(40)
#Create a KDE and show its output
MY_KDE <- KDE(DATA, to.environment = TRUE)
MY_KDE
Kernel Density Estimator (KDE)
Computed from 40 data points in the input 'DATA'
Estimated bandwidth = 0.367412
Input degrees-of-freedom = Inf
Probability functions for the KDE are the following:
Density function: dkde *
Distribution function: pkde *
Quantile function: qkde *
Random generation function: rkde *
* This function is presently loaded in the global environment
#Call the CDF over a set of points (including points far in the tails)
POINTS <- -10:10
pkde(POINTS)
[1] 1.489573e-101 4.685332e-78 9.132757e-58 1.112228e-40 8.584043e-27 4.322183e-16
[7] 1.529301e-08 4.819333e-04 3.326124e-02 1.236576e-01 4.251039e-01 8.352227e-01
[13] 9.927698e-01 9.999976e-01 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00
[19] 1.000000e+00 1.000000e+00 1.000000e+00
From the outputs of the CDF you can see that the density function integrates to one over the full range. (If you're unsure, just call pkde(Inf) to see the CDF value integrating over the whole range.)
$^\dagger$ The KDE function has the advantage of giving a more useful output (in my opinion) but it is not as general as the density function in the base package. It does not accomodate as wide a range of kernel types or bandwidth estimation methods. Both functions can produce a KDE using the normal kernel. | Area under the "pdf" in kernel density estimation in R
Use the KDE function in the utilties package instead
Note: This answer is adapted from a silmiar answer here.
The problem you are encountering is that the density function in the stats package gives y |
17,787 | Area under the "pdf" in kernel density estimation in R | That's okay, you can fix it shifting and scaling; add the smallest number such that the density is non-negative, then multiply the whole thing by a constant such that the area is unity. This is the easy way.
The optimal $L_2$ solution involves "water pouring"; finding the constant $c$ such that $\left[\phi(x)-c\right]^+$ integrates to unity. | Area under the "pdf" in kernel density estimation in R | That's okay, you can fix it shifting and scaling; add the smallest number such that the density is non-negative, then multiply the whole thing by a constant such that the area is unity. This is the ea | Area under the "pdf" in kernel density estimation in R
That's okay, you can fix it shifting and scaling; add the smallest number such that the density is non-negative, then multiply the whole thing by a constant such that the area is unity. This is the easy way.
The optimal $L_2$ solution involves "water pouring"; finding the constant $c$ such that $\left[\phi(x)-c\right]^+$ integrates to unity. | Area under the "pdf" in kernel density estimation in R
That's okay, you can fix it shifting and scaling; add the smallest number such that the density is non-negative, then multiply the whole thing by a constant such that the area is unity. This is the ea |
17,788 | Sampling distribution from two independent Bernoulli populations | Put
$a=\frac{\sqrt{\theta_1(1-\theta_1)}}{\sqrt{n_1}}$, $b=\frac{\sqrt{\theta_2(1-\theta_2)}}{\sqrt{n_2}}$,
$A=(\bar{X}_1-\theta_1)/a$,
$B=(\bar{X}_2-\theta_2)/b$. We have
$A\to_d N(0,1),\ B\to_d N(0,1)$.
In terms of characteristic functions it means
$$ \phi_A(t)\equiv {\bf E}e^{itA}\to e^{-t^2/2},\ \phi_B(t)\to e^{-t^2/2}.$$
We want to prove that
$$D:=\frac{a}{\sqrt{a^2+b^2}}A-\frac{b}{\sqrt{a^2+b^2}}B\to_d N(0,1) $$
Since $A$ and $B$ are independent,
$$\phi_D(t)=\phi_A\left(\frac{a}{\sqrt{a^2+b^2}}t\right)\phi_B\left(-\frac{b}{\sqrt{a^2+b^2}}t\right)\to e^{-t^2/2},
$$
as we wish it to be.
This proof is incomplete. Here we need some estimates for uniform convergence of characteristic functions. However in the case under consideration we can do explicit calculations. Put $p=\theta_1,\ m=n_1$.
\begin{align}
\phi_{X_{1,1}}(t) &= 1+p(e^{it}-1), \\
\phi_{\bar X_{1}}(t) &= (1+p(e^{it/m}-1))^m, \\
\phi_{\bar X_{1}-\theta_1}(t) &= (1+p(e^{it/m}-1))^m e^{-ipt}, \\
\phi_{A}(t) &= (1+p(e^{it/\sqrt{mp(1-p)}}-1))^m e^{-ipt\sqrt{m}/\sqrt{p(1-p)}} \\[5pt]
&= \left( \left(1+p(e^{it/\sqrt{mp(1-p)}}-1)\right)e^{-ipt/\sqrt{mp(1-p)}}\right)^m \\[5pt]
&=\left( 1-\frac{t^2}{2m}+O(t^3m^{-3/2}) \right)^m
\end{align}
as $t^3m^{-3/2}\to 0$. Thus, for a fixed $t$,
$$\phi_D(t)=\left( 1-\frac{a^2t^2}{2(a^2+b^2)n_1}+O(n_1^{-3/2}) \right)^{n_1}
\left( 1-\frac{b^2t^2}{2(a^2+b^2)n_2}+O(n_2^{-3/2}) \right)^{n_2} \to e^{-t^2/2}
$$
(even if $a\to 0$ or $b\to 0$), since $\left|e^{-y}-(1-y/m)^m\right|\le {y^2}/{2m}\ $ when $\ y/m<1/2$ (see https://math.stackexchange.com/questions/2566469/uniform-bounds-for-1-y-nn-exp-y/ ).
Note that similar calculations may be done for arbitrary (not necessarily Bernoulli) distributions with finite second moments, using the expansion of characteristic function in terms of the first two moments. | Sampling distribution from two independent Bernoulli populations | Put
$a=\frac{\sqrt{\theta_1(1-\theta_1)}}{\sqrt{n_1}}$, $b=\frac{\sqrt{\theta_2(1-\theta_2)}}{\sqrt{n_2}}$,
$A=(\bar{X}_1-\theta_1)/a$,
$B=(\bar{X}_2-\theta_2)/b$. We have
$A\to_d N(0,1),\ B\to_d N( | Sampling distribution from two independent Bernoulli populations
Put
$a=\frac{\sqrt{\theta_1(1-\theta_1)}}{\sqrt{n_1}}$, $b=\frac{\sqrt{\theta_2(1-\theta_2)}}{\sqrt{n_2}}$,
$A=(\bar{X}_1-\theta_1)/a$,
$B=(\bar{X}_2-\theta_2)/b$. We have
$A\to_d N(0,1),\ B\to_d N(0,1)$.
In terms of characteristic functions it means
$$ \phi_A(t)\equiv {\bf E}e^{itA}\to e^{-t^2/2},\ \phi_B(t)\to e^{-t^2/2}.$$
We want to prove that
$$D:=\frac{a}{\sqrt{a^2+b^2}}A-\frac{b}{\sqrt{a^2+b^2}}B\to_d N(0,1) $$
Since $A$ and $B$ are independent,
$$\phi_D(t)=\phi_A\left(\frac{a}{\sqrt{a^2+b^2}}t\right)\phi_B\left(-\frac{b}{\sqrt{a^2+b^2}}t\right)\to e^{-t^2/2},
$$
as we wish it to be.
This proof is incomplete. Here we need some estimates for uniform convergence of characteristic functions. However in the case under consideration we can do explicit calculations. Put $p=\theta_1,\ m=n_1$.
\begin{align}
\phi_{X_{1,1}}(t) &= 1+p(e^{it}-1), \\
\phi_{\bar X_{1}}(t) &= (1+p(e^{it/m}-1))^m, \\
\phi_{\bar X_{1}-\theta_1}(t) &= (1+p(e^{it/m}-1))^m e^{-ipt}, \\
\phi_{A}(t) &= (1+p(e^{it/\sqrt{mp(1-p)}}-1))^m e^{-ipt\sqrt{m}/\sqrt{p(1-p)}} \\[5pt]
&= \left( \left(1+p(e^{it/\sqrt{mp(1-p)}}-1)\right)e^{-ipt/\sqrt{mp(1-p)}}\right)^m \\[5pt]
&=\left( 1-\frac{t^2}{2m}+O(t^3m^{-3/2}) \right)^m
\end{align}
as $t^3m^{-3/2}\to 0$. Thus, for a fixed $t$,
$$\phi_D(t)=\left( 1-\frac{a^2t^2}{2(a^2+b^2)n_1}+O(n_1^{-3/2}) \right)^{n_1}
\left( 1-\frac{b^2t^2}{2(a^2+b^2)n_2}+O(n_2^{-3/2}) \right)^{n_2} \to e^{-t^2/2}
$$
(even if $a\to 0$ or $b\to 0$), since $\left|e^{-y}-(1-y/m)^m\right|\le {y^2}/{2m}\ $ when $\ y/m<1/2$ (see https://math.stackexchange.com/questions/2566469/uniform-bounds-for-1-y-nn-exp-y/ ).
Note that similar calculations may be done for arbitrary (not necessarily Bernoulli) distributions with finite second moments, using the expansion of characteristic function in terms of the first two moments. | Sampling distribution from two independent Bernoulli populations
Put
$a=\frac{\sqrt{\theta_1(1-\theta_1)}}{\sqrt{n_1}}$, $b=\frac{\sqrt{\theta_2(1-\theta_2)}}{\sqrt{n_2}}$,
$A=(\bar{X}_1-\theta_1)/a$,
$B=(\bar{X}_2-\theta_2)/b$. We have
$A\to_d N(0,1),\ B\to_d N( |
17,789 | Sampling distribution from two independent Bernoulli populations | Proving your statement is equivalent to proving the (Levy-Lindenberg) Central Limit Theorem which states
If $\{Z_i\}_{i=1}^n$ is a sequence of i.i.d random variable with finite mean $\mathbb{E}(Z_i) = \mu $ and finite variance $\mathbb{V}(Z_i) = \sigma^2$ then $$ \sqrt{n}(\bar{Z} - \mu) \to^d N(0,\sigma^2)$$
Here $\bar{Z} = \sum_i Z_i/n$ that is the sample variance.
Then it is easy to see that if we put
$$ Z_i = X_1i - X_2i $$ with $X_{1i}, X_{2i}$ following a $Ber(\theta_1)$ and $Ber(\theta_2)$ respectively the conditions for the theorem are satisfied, in particular
$$ \mathbb{E}(Z_i) = \theta_1 - \theta_2 = \mu $$
and
$$ \mathbb{V}(Z_i)= \theta_1(1-\theta_1) +\theta_2(1-\theta_2)= \sigma^2 $$
(There's a last passage, and you have to adjust this a bit for the general case where $n_1 \neq n_2$ but I have to go now, will finish tomorrow or you can edit the question with the final passage as an exercise ) | Sampling distribution from two independent Bernoulli populations | Proving your statement is equivalent to proving the (Levy-Lindenberg) Central Limit Theorem which states
If $\{Z_i\}_{i=1}^n$ is a sequence of i.i.d random variable with finite mean $\mathbb{E}(Z_i) = | Sampling distribution from two independent Bernoulli populations
Proving your statement is equivalent to proving the (Levy-Lindenberg) Central Limit Theorem which states
If $\{Z_i\}_{i=1}^n$ is a sequence of i.i.d random variable with finite mean $\mathbb{E}(Z_i) = \mu $ and finite variance $\mathbb{V}(Z_i) = \sigma^2$ then $$ \sqrt{n}(\bar{Z} - \mu) \to^d N(0,\sigma^2)$$
Here $\bar{Z} = \sum_i Z_i/n$ that is the sample variance.
Then it is easy to see that if we put
$$ Z_i = X_1i - X_2i $$ with $X_{1i}, X_{2i}$ following a $Ber(\theta_1)$ and $Ber(\theta_2)$ respectively the conditions for the theorem are satisfied, in particular
$$ \mathbb{E}(Z_i) = \theta_1 - \theta_2 = \mu $$
and
$$ \mathbb{V}(Z_i)= \theta_1(1-\theta_1) +\theta_2(1-\theta_2)= \sigma^2 $$
(There's a last passage, and you have to adjust this a bit for the general case where $n_1 \neq n_2$ but I have to go now, will finish tomorrow or you can edit the question with the final passage as an exercise ) | Sampling distribution from two independent Bernoulli populations
Proving your statement is equivalent to proving the (Levy-Lindenberg) Central Limit Theorem which states
If $\{Z_i\}_{i=1}^n$ is a sequence of i.i.d random variable with finite mean $\mathbb{E}(Z_i) = |
17,790 | What's the difference between asymptotic unbiasedness and consistency? | In the related post over at math.se, the answerer takes as given that the definition for asymptotic unbiasedness is $\lim_{n\to \infty} E(\hat \theta_n-\theta) = 0$.
Intuitively, I disagree: "unbiasedness" is a term we first learn in relation to a distribution (finite sample). It appears then more natural to consider "asymptotic unbiasedness" in relation to an asymptotic distribution. And in fact, this is what Lehmann & Casella in "Theory of Point Estimation (1998, 2nd ed) do, p. 438 Definition 2.1 (simplified notation):
$$\text{If} \;\;\;k_n(\hat \theta_n - \theta )\to_d H$$
for some sequence $k_n$ and for some random variable $H$, the estimator $\hat \theta_n$ is
asymptotically unbiased if the expected value of $H$ is zero.
Given this definition, we can argue that consistency implies asymptotic unbiasedness since
$$\hat \theta_n \to_{p}\theta \implies \hat \theta_n - \theta \to_{p}0 \implies \hat \theta_n - \theta \to_{d}0$$
...and the degenerate distribution that is equal to zero has expected value equal to zero (here the $k_n$ sequence is a sequence of ones).
But I suspect that this is not really useful, it is just a by-product of a definition of asymptotic unbiasedness that allows for degenerate random variables. Essentially we would like to know whether, if we had an expression involving the estimator that converges to a non-degenrate rv, consistency would still imply asymptotic unbiasedness.
Earlier in the book (p. 431 Definition 1.2), the authors call the property $\lim_{n\to \infty} E(\hat \theta_n-\theta) = 0$ as "unbiasedness in the limit", and it does not coincide with asymptotic unbiasedness.
Consistency occurs whenever—
the estimator is unbiased in the limit, and
the sequence of estimator variances goes to zero (implying that the variance exists in the first place).
These make up a sufficient, but not necessary condition.
For the intricacies related to concistency with non-zero variance (a bit mind-boggling), visit this post. | What's the difference between asymptotic unbiasedness and consistency? | In the related post over at math.se, the answerer takes as given that the definition for asymptotic unbiasedness is $\lim_{n\to \infty} E(\hat \theta_n-\theta) = 0$.
Intuitively, I disagree: "unbiase | What's the difference between asymptotic unbiasedness and consistency?
In the related post over at math.se, the answerer takes as given that the definition for asymptotic unbiasedness is $\lim_{n\to \infty} E(\hat \theta_n-\theta) = 0$.
Intuitively, I disagree: "unbiasedness" is a term we first learn in relation to a distribution (finite sample). It appears then more natural to consider "asymptotic unbiasedness" in relation to an asymptotic distribution. And in fact, this is what Lehmann & Casella in "Theory of Point Estimation (1998, 2nd ed) do, p. 438 Definition 2.1 (simplified notation):
$$\text{If} \;\;\;k_n(\hat \theta_n - \theta )\to_d H$$
for some sequence $k_n$ and for some random variable $H$, the estimator $\hat \theta_n$ is
asymptotically unbiased if the expected value of $H$ is zero.
Given this definition, we can argue that consistency implies asymptotic unbiasedness since
$$\hat \theta_n \to_{p}\theta \implies \hat \theta_n - \theta \to_{p}0 \implies \hat \theta_n - \theta \to_{d}0$$
...and the degenerate distribution that is equal to zero has expected value equal to zero (here the $k_n$ sequence is a sequence of ones).
But I suspect that this is not really useful, it is just a by-product of a definition of asymptotic unbiasedness that allows for degenerate random variables. Essentially we would like to know whether, if we had an expression involving the estimator that converges to a non-degenrate rv, consistency would still imply asymptotic unbiasedness.
Earlier in the book (p. 431 Definition 1.2), the authors call the property $\lim_{n\to \infty} E(\hat \theta_n-\theta) = 0$ as "unbiasedness in the limit", and it does not coincide with asymptotic unbiasedness.
Consistency occurs whenever—
the estimator is unbiased in the limit, and
the sequence of estimator variances goes to zero (implying that the variance exists in the first place).
These make up a sufficient, but not necessary condition.
For the intricacies related to concistency with non-zero variance (a bit mind-boggling), visit this post. | What's the difference between asymptotic unbiasedness and consistency?
In the related post over at math.se, the answerer takes as given that the definition for asymptotic unbiasedness is $\lim_{n\to \infty} E(\hat \theta_n-\theta) = 0$.
Intuitively, I disagree: "unbiase |
17,791 | How to do forecasting with detection of outliers in R? - Time series analysis procedure and Method | This answer is also related to the points 6 and 7 of your other question.
The outliers are understood as observations that are not explained by
the model, so their role in the forecasts is limited in the sense that the presence of new outliers will not be predicted. All you need to do is to include these outliers in the forecast equation.
In the case of an additive outlier (which affects a single observation),
the variable containing this outlier will be simply filled with zeros, since the outlier was detected for an observation in the sample; in the case of a level shift (a permanent change in the data), the variable will be filled with ones in order to keep the shift in the forecasts.
Next, I show how to obtain forecasts in R upon an ARIMA model with the outliers detected by 'tsoutliers'. The key is to the define properly the argument newxreg that is passed to predict.
(This is only to illustrate the answer to your question about how to treat outliers when forecasting, I don't address the issue whether the resulting model or forecasts are the best solution.)
require(tsoutliers)
x <- c(
7.55, 7.63, 7.62, 7.50, 7.47, 7.53, 7.55, 7.47, 7.65, 7.72, 7.78, 7.81,
7.71, 7.67, 7.85, 7.82, 7.91, 7.91, 8.00, 7.82, 7.90, 7.93, 7.99, 7.93,
8.46, 8.48, 9.03, 9.43, 11.58, 12.19, 12.23, 11.98, 12.26, 12.31, 12.13, 11.99,
11.51, 11.75, 11.87, 11.91, 11.87, 11.69, 11.66, 11.23, 11.37, 11.71, 11.88, 11.93,
11.99, 11.84, 12.33, 12.55, 12.58, 12.67, 12.57, 12.35, 12.30, 12.67, 12.71, 12.63,
12.60, 12.41, 12.68, 12.48, 12.50, 12.30, 12.39, 12.16, 12.38, 12.36, 12.52, 12.63)
x <- ts(x, frequency=12, start=c(2006,1))
res <- tso(x, types=c("AO","LS","TC"))
# define the variables containing the outliers for
# the observations outside the sample
npred <- 12 # number of periods ahead to forecast
newxreg <- outliers.effects(res$outliers, length(x) + npred)
newxreg <- ts(newxreg[-seq_along(x),], start = c(2012, 1))
# obtain the forecasts
p <- predict(res$fit, n.ahead=npred, newxreg=newxreg)
# display forecasts
plot(cbind(x, p$pred), plot.type = "single", ylab = "", type = "n", ylim=c(7,13))
lines(x)
lines(p$pred, type = "l", col = "blue")
lines(p$pred + 1.96 * p$se, type = "l", col = "red", lty = 2)
lines(p$pred - 1.96 * p$se, type = "l", col = "red", lty = 2)
legend("topleft", legend = c("observed data",
"forecasts", "95% confidence bands"), lty = c(1,1,2,2),
col = c("black", "blue", "red", "red"), bty = "n")
Edit
The function predict as used above returns forecasts based on the chosen ARIMA model, ARIMA(2,0,0) stored in res$fit and the detected outliers, res$outliers. We have a model equation like this:
$$
y_t = \sum_{j=1}^m \omega_j L_j(B) I_t(t_j) + \frac{\theta(B)}{\phi(B) \alpha(B)} \epsilon_t \,, \quad \epsilon_t \sim NID(0, \sigma^2) \,,
$$
where $L_j$ is the polynomial related to the $j$-th outlier (see the documentation of tsoutliers or the original paper by Chen and Liu cited in my answer to you other question); $I_t$ is an indicator variable; and the last term consist of the polynomials that define the ARMA model. | How to do forecasting with detection of outliers in R? - Time series analysis procedure and Method | This answer is also related to the points 6 and 7 of your other question.
The outliers are understood as observations that are not explained by
the model, so their role in the forecasts is limited in | How to do forecasting with detection of outliers in R? - Time series analysis procedure and Method
This answer is also related to the points 6 and 7 of your other question.
The outliers are understood as observations that are not explained by
the model, so their role in the forecasts is limited in the sense that the presence of new outliers will not be predicted. All you need to do is to include these outliers in the forecast equation.
In the case of an additive outlier (which affects a single observation),
the variable containing this outlier will be simply filled with zeros, since the outlier was detected for an observation in the sample; in the case of a level shift (a permanent change in the data), the variable will be filled with ones in order to keep the shift in the forecasts.
Next, I show how to obtain forecasts in R upon an ARIMA model with the outliers detected by 'tsoutliers'. The key is to the define properly the argument newxreg that is passed to predict.
(This is only to illustrate the answer to your question about how to treat outliers when forecasting, I don't address the issue whether the resulting model or forecasts are the best solution.)
require(tsoutliers)
x <- c(
7.55, 7.63, 7.62, 7.50, 7.47, 7.53, 7.55, 7.47, 7.65, 7.72, 7.78, 7.81,
7.71, 7.67, 7.85, 7.82, 7.91, 7.91, 8.00, 7.82, 7.90, 7.93, 7.99, 7.93,
8.46, 8.48, 9.03, 9.43, 11.58, 12.19, 12.23, 11.98, 12.26, 12.31, 12.13, 11.99,
11.51, 11.75, 11.87, 11.91, 11.87, 11.69, 11.66, 11.23, 11.37, 11.71, 11.88, 11.93,
11.99, 11.84, 12.33, 12.55, 12.58, 12.67, 12.57, 12.35, 12.30, 12.67, 12.71, 12.63,
12.60, 12.41, 12.68, 12.48, 12.50, 12.30, 12.39, 12.16, 12.38, 12.36, 12.52, 12.63)
x <- ts(x, frequency=12, start=c(2006,1))
res <- tso(x, types=c("AO","LS","TC"))
# define the variables containing the outliers for
# the observations outside the sample
npred <- 12 # number of periods ahead to forecast
newxreg <- outliers.effects(res$outliers, length(x) + npred)
newxreg <- ts(newxreg[-seq_along(x),], start = c(2012, 1))
# obtain the forecasts
p <- predict(res$fit, n.ahead=npred, newxreg=newxreg)
# display forecasts
plot(cbind(x, p$pred), plot.type = "single", ylab = "", type = "n", ylim=c(7,13))
lines(x)
lines(p$pred, type = "l", col = "blue")
lines(p$pred + 1.96 * p$se, type = "l", col = "red", lty = 2)
lines(p$pred - 1.96 * p$se, type = "l", col = "red", lty = 2)
legend("topleft", legend = c("observed data",
"forecasts", "95% confidence bands"), lty = c(1,1,2,2),
col = c("black", "blue", "red", "red"), bty = "n")
Edit
The function predict as used above returns forecasts based on the chosen ARIMA model, ARIMA(2,0,0) stored in res$fit and the detected outliers, res$outliers. We have a model equation like this:
$$
y_t = \sum_{j=1}^m \omega_j L_j(B) I_t(t_j) + \frac{\theta(B)}{\phi(B) \alpha(B)} \epsilon_t \,, \quad \epsilon_t \sim NID(0, \sigma^2) \,,
$$
where $L_j$ is the polynomial related to the $j$-th outlier (see the documentation of tsoutliers or the original paper by Chen and Liu cited in my answer to you other question); $I_t$ is an indicator variable; and the last term consist of the polynomials that define the ARMA model. | How to do forecasting with detection of outliers in R? - Time series analysis procedure and Method
This answer is also related to the points 6 and 7 of your other question.
The outliers are understood as observations that are not explained by
the model, so their role in the forecasts is limited in |
17,792 | How to do forecasting with detection of outliers in R? - Time series analysis procedure and Method | Using a piece of software that I have helped develop a reasonable model for your 72 observations would include a power transform (logs) as the error variance is linkable to the expected value. This is also fairly obvious from the original plot where the eye can detect increased variance at the higher level. with actual.fit/forecast and a plot of the final residuals . Note the more realistic confidence limits taking into account the power transform . Although this response doesn't use R it does
raise the bar as to what a reasonable model using R might include. | How to do forecasting with detection of outliers in R? - Time series analysis procedure and Method | Using a piece of software that I have helped develop a reasonable model for your 72 observations would include a power transform (logs) as the error variance is linkable to the expected value. This is | How to do forecasting with detection of outliers in R? - Time series analysis procedure and Method
Using a piece of software that I have helped develop a reasonable model for your 72 observations would include a power transform (logs) as the error variance is linkable to the expected value. This is also fairly obvious from the original plot where the eye can detect increased variance at the higher level. with actual.fit/forecast and a plot of the final residuals . Note the more realistic confidence limits taking into account the power transform . Although this response doesn't use R it does
raise the bar as to what a reasonable model using R might include. | How to do forecasting with detection of outliers in R? - Time series analysis procedure and Method
Using a piece of software that I have helped develop a reasonable model for your 72 observations would include a power transform (logs) as the error variance is linkable to the expected value. This is |
17,793 | How to interpret height of density plot | You need to be careful with your wording here. Assuming x is a continuous variable, the probability of any individual value is precisely zero. Talking, as you did, about the probability of a value lying around some point is fine, though you might want to be a bit more precise. Your second statement, in which you provided the interval along with the probability is something I would be looking for.
In essence, an integral of density function with respect to x will tell you about the probability itself (that's why it's called density). Obviously, the interval over which you will integrate may be arbitrarily small, so you can get close to a point to an arbitrary degree. That said, when the density function is varying very slowly over that interval, you can approximate the integral by some numerical technique, such as the trapezoidal rule.
To summarize: the height of the density function is just that, its height. Anything you might want to conclude about probability will have to include integrating of some form or another. | How to interpret height of density plot | You need to be careful with your wording here. Assuming x is a continuous variable, the probability of any individual value is precisely zero. Talking, as you did, about the probability of a value lyi | How to interpret height of density plot
You need to be careful with your wording here. Assuming x is a continuous variable, the probability of any individual value is precisely zero. Talking, as you did, about the probability of a value lying around some point is fine, though you might want to be a bit more precise. Your second statement, in which you provided the interval along with the probability is something I would be looking for.
In essence, an integral of density function with respect to x will tell you about the probability itself (that's why it's called density). Obviously, the interval over which you will integrate may be arbitrarily small, so you can get close to a point to an arbitrary degree. That said, when the density function is varying very slowly over that interval, you can approximate the integral by some numerical technique, such as the trapezoidal rule.
To summarize: the height of the density function is just that, its height. Anything you might want to conclude about probability will have to include integrating of some form or another. | How to interpret height of density plot
You need to be careful with your wording here. Assuming x is a continuous variable, the probability of any individual value is precisely zero. Talking, as you did, about the probability of a value lyi |
17,794 | Early stopping vs cross validation | Cross Validation is a method for estimating the generalisation accuracy of a supervised learning algorithm.
Early stopping is a method for avoiding overfitting and requires a method to assess the relationship between the generalisation accuracy of the learned model and the training accuracy.
So you could use cross validation to replace the validation set, mentioned in the paper you cite, within an early stopping framework. Ten fold cross validation for instance would be more accurate than using a single validation set, and would normally be a better estimate of generalisation error.
So to summarise, cross validation is a generalisation accuracy measure which could be used as part of an early stopping framework. | Early stopping vs cross validation | Cross Validation is a method for estimating the generalisation accuracy of a supervised learning algorithm.
Early stopping is a method for avoiding overfitting and requires a method to assess the rela | Early stopping vs cross validation
Cross Validation is a method for estimating the generalisation accuracy of a supervised learning algorithm.
Early stopping is a method for avoiding overfitting and requires a method to assess the relationship between the generalisation accuracy of the learned model and the training accuracy.
So you could use cross validation to replace the validation set, mentioned in the paper you cite, within an early stopping framework. Ten fold cross validation for instance would be more accurate than using a single validation set, and would normally be a better estimate of generalisation error.
So to summarise, cross validation is a generalisation accuracy measure which could be used as part of an early stopping framework. | Early stopping vs cross validation
Cross Validation is a method for estimating the generalisation accuracy of a supervised learning algorithm.
Early stopping is a method for avoiding overfitting and requires a method to assess the rela |
17,795 | Early stopping vs cross validation | In addition to the two generalization approaches you mention, there are many others.
adding regularization terms in your loss (cost) function that minimize the number and magnitude of your nonzero model parameters
randomly dropping (zeroing out) some portion of the weights/parameters in your model with each training epoch
adding a layer of stochastic nodes in your model (e.g., sampling from the "probabilities" given by the outputs of logistic functions)
Many of these approaches (including your cross-validation and early-stopping approaches) can be combined together to maximize model performance on unseen data (generalization performance).
One note on the early-stopping approach. For neural nets, Geoffrey Hinton recommends stopping training when the test set accuracy reaches its maximum (test set loss, excluding regularization terms, is at a minimum). One additional "tweak" to Hinton's approach is to not stop if the test_set accuracy is better (loss is smaller) than for your training set, even if the test set accuracy has stopped improving (test set loss has stopped declining). This is unlikely to gain you more than one epoch of training, but sometimes that can help a bit, especially for small test_sets. Don't do this for extremely small test sets (smaller than a representative sample set, like is sometimes used in K-folds training and cross-validation). | Early stopping vs cross validation | In addition to the two generalization approaches you mention, there are many others.
adding regularization terms in your loss (cost) function that minimize the number and magnitude of your nonzero mo | Early stopping vs cross validation
In addition to the two generalization approaches you mention, there are many others.
adding regularization terms in your loss (cost) function that minimize the number and magnitude of your nonzero model parameters
randomly dropping (zeroing out) some portion of the weights/parameters in your model with each training epoch
adding a layer of stochastic nodes in your model (e.g., sampling from the "probabilities" given by the outputs of logistic functions)
Many of these approaches (including your cross-validation and early-stopping approaches) can be combined together to maximize model performance on unseen data (generalization performance).
One note on the early-stopping approach. For neural nets, Geoffrey Hinton recommends stopping training when the test set accuracy reaches its maximum (test set loss, excluding regularization terms, is at a minimum). One additional "tweak" to Hinton's approach is to not stop if the test_set accuracy is better (loss is smaller) than for your training set, even if the test set accuracy has stopped improving (test set loss has stopped declining). This is unlikely to gain you more than one epoch of training, but sometimes that can help a bit, especially for small test_sets. Don't do this for extremely small test sets (smaller than a representative sample set, like is sometimes used in K-folds training and cross-validation). | Early stopping vs cross validation
In addition to the two generalization approaches you mention, there are many others.
adding regularization terms in your loss (cost) function that minimize the number and magnitude of your nonzero mo |
17,796 | Early stopping vs cross validation | you cannot use early stopping and K-fold cross validation in combination. because the early stopping select best model from validation set, the performance needs to be verified by test set. but in K-fold cross validation, there is not test set, if you using early stopping to select best model from validation set, and it will verified again in validation set. the K-fold cross validation is getting the average performance (measured by accuracy) of best model, and it is meanless. | Early stopping vs cross validation | you cannot use early stopping and K-fold cross validation in combination. because the early stopping select best model from validation set, the performance needs to be verified by test set. but in K-f | Early stopping vs cross validation
you cannot use early stopping and K-fold cross validation in combination. because the early stopping select best model from validation set, the performance needs to be verified by test set. but in K-fold cross validation, there is not test set, if you using early stopping to select best model from validation set, and it will verified again in validation set. the K-fold cross validation is getting the average performance (measured by accuracy) of best model, and it is meanless. | Early stopping vs cross validation
you cannot use early stopping and K-fold cross validation in combination. because the early stopping select best model from validation set, the performance needs to be verified by test set. but in K-f |
17,797 | Distance correlation versus mutual information | Information / mutual information does not depend on the possible values, it depends only on the probabilities therefore it is less sensitive. Distance correlation is more powerful and simpler to compute. For a comparision see
http://www-stat.stanford.edu/~tibs/reshef/comment.pdf | Distance correlation versus mutual information | Information / mutual information does not depend on the possible values, it depends only on the probabilities therefore it is less sensitive. Distance correlation is more powerful and simpler to compu | Distance correlation versus mutual information
Information / mutual information does not depend on the possible values, it depends only on the probabilities therefore it is less sensitive. Distance correlation is more powerful and simpler to compute. For a comparision see
http://www-stat.stanford.edu/~tibs/reshef/comment.pdf | Distance correlation versus mutual information
Information / mutual information does not depend on the possible values, it depends only on the probabilities therefore it is less sensitive. Distance correlation is more powerful and simpler to compu |
17,798 | Deriving total (within class + between class) scatter matrix | If you assume
$$\frac{1}{N}\sum_{t=1}^Nx_t^{i}=\mu_i$$
Then
$$\sum_{i=1}^C\sum_{t=1}^N(x_t^i-\mu_i)(\mu_i-\mu)^T=\sum_{i=1}^C\left(\sum_{t=1}^N(x_t^i-\mu_i)\right)(\mu_i-\mu)^T=0$$
and formula holds. You deal with the second term in the similar way. | Deriving total (within class + between class) scatter matrix | If you assume
$$\frac{1}{N}\sum_{t=1}^Nx_t^{i}=\mu_i$$
Then
$$\sum_{i=1}^C\sum_{t=1}^N(x_t^i-\mu_i)(\mu_i-\mu)^T=\sum_{i=1}^C\left(\sum_{t=1}^N(x_t^i-\mu_i)\right)(\mu_i-\mu)^T=0$$
and formula holds | Deriving total (within class + between class) scatter matrix
If you assume
$$\frac{1}{N}\sum_{t=1}^Nx_t^{i}=\mu_i$$
Then
$$\sum_{i=1}^C\sum_{t=1}^N(x_t^i-\mu_i)(\mu_i-\mu)^T=\sum_{i=1}^C\left(\sum_{t=1}^N(x_t^i-\mu_i)\right)(\mu_i-\mu)^T=0$$
and formula holds. You deal with the second term in the similar way. | Deriving total (within class + between class) scatter matrix
If you assume
$$\frac{1}{N}\sum_{t=1}^Nx_t^{i}=\mu_i$$
Then
$$\sum_{i=1}^C\sum_{t=1}^N(x_t^i-\mu_i)(\mu_i-\mu)^T=\sum_{i=1}^C\left(\sum_{t=1}^N(x_t^i-\mu_i)\right)(\mu_i-\mu)^T=0$$
and formula holds |
17,799 | Managing error with GPS routes (theoretical framework?) | This is a well studied problem in geospatial science--you can find discussions of it on GIS forums.
First, note that the wiggles do not necessarily increase the route's length, because many of them actually cut inside curves. (I have evaluated this by having an entire classroom of students digitize the same path and then I compared the paths.) There really is a lot of cancellation. Also, we can expect that readings taken just a few seconds apart will have strongly, positively, correlated errors. Thus the measured path should wiggle only gradually around the true path. Even large departures don't affect the length much. For example, if you deviate by (say) 5 meters laterally in the middle of a 100 m straight stretch, your estimate of the length only goes up to $2 \sqrt{50^2 + 5^2} = 100.5$, a 0.5% error.
It is difficult to compare two arbitrary paths in an objective way. One of the better methods, I believe, is a form of bootstrapping: subsample (or otherwise generalize) the most detailed path you have. Plot its length as a function of the amount of subsampling. If you express the subsampling as a typical vertex-to-vertex distance, you can extrapolate a fit to a zero distance, which can provide an excellent estimate of the path length.
With multiple recordings, you can create a 2D kernel smooth of each, sum the smooths, and subject that to a topographic analysis to look for a "ridgeline." You won't get a single connected line, usually, but you can often patch the ridges together into a continuous path. People have used this method to average hurricane tracks, for example. | Managing error with GPS routes (theoretical framework?) | This is a well studied problem in geospatial science--you can find discussions of it on GIS forums.
First, note that the wiggles do not necessarily increase the route's length, because many of them ac | Managing error with GPS routes (theoretical framework?)
This is a well studied problem in geospatial science--you can find discussions of it on GIS forums.
First, note that the wiggles do not necessarily increase the route's length, because many of them actually cut inside curves. (I have evaluated this by having an entire classroom of students digitize the same path and then I compared the paths.) There really is a lot of cancellation. Also, we can expect that readings taken just a few seconds apart will have strongly, positively, correlated errors. Thus the measured path should wiggle only gradually around the true path. Even large departures don't affect the length much. For example, if you deviate by (say) 5 meters laterally in the middle of a 100 m straight stretch, your estimate of the length only goes up to $2 \sqrt{50^2 + 5^2} = 100.5$, a 0.5% error.
It is difficult to compare two arbitrary paths in an objective way. One of the better methods, I believe, is a form of bootstrapping: subsample (or otherwise generalize) the most detailed path you have. Plot its length as a function of the amount of subsampling. If you express the subsampling as a typical vertex-to-vertex distance, you can extrapolate a fit to a zero distance, which can provide an excellent estimate of the path length.
With multiple recordings, you can create a 2D kernel smooth of each, sum the smooths, and subject that to a topographic analysis to look for a "ridgeline." You won't get a single connected line, usually, but you can often patch the ridges together into a continuous path. People have used this method to average hurricane tracks, for example. | Managing error with GPS routes (theoretical framework?)
This is a well studied problem in geospatial science--you can find discussions of it on GIS forums.
First, note that the wiggles do not necessarily increase the route's length, because many of them ac |
17,800 | Managing error with GPS routes (theoretical framework?) | Within a single dataset you can smooth the results, but this is not always a reduction in error (a consistent bias is appealing when viewing a trajectory or continuous time series from a single receiver).
Yes, higher frequency samples can lead to better performance if the device actually observes at higher frequencies. At this level of comparison, chipsets, firmware, and low-level filtering can differentiate cheap GPS modules.
Consider using professionally surveyed measurements for your ground-truth path calculations. Ortho-aerial imagery (like on google maps) must maintain close registration to reality than a GPS wristwatch. Use those tools to find the 2d distance rather than one or two experiments using a low-cost gps module on a wristwatch with a poor antenna.
In the case the route is not predefined, please state such in the question, otherwise it is incomplete. | Managing error with GPS routes (theoretical framework?) | Within a single dataset you can smooth the results, but this is not always a reduction in error (a consistent bias is appealing when viewing a trajectory or continuous time series from a single receiv | Managing error with GPS routes (theoretical framework?)
Within a single dataset you can smooth the results, but this is not always a reduction in error (a consistent bias is appealing when viewing a trajectory or continuous time series from a single receiver).
Yes, higher frequency samples can lead to better performance if the device actually observes at higher frequencies. At this level of comparison, chipsets, firmware, and low-level filtering can differentiate cheap GPS modules.
Consider using professionally surveyed measurements for your ground-truth path calculations. Ortho-aerial imagery (like on google maps) must maintain close registration to reality than a GPS wristwatch. Use those tools to find the 2d distance rather than one or two experiments using a low-cost gps module on a wristwatch with a poor antenna.
In the case the route is not predefined, please state such in the question, otherwise it is incomplete. | Managing error with GPS routes (theoretical framework?)
Within a single dataset you can smooth the results, but this is not always a reduction in error (a consistent bias is appealing when viewing a trajectory or continuous time series from a single receiv |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.