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
|
|---|---|---|---|---|---|---|
43,401
|
Which binomial confidence interval is correct?
|
You need to report the back-transformed ones. This is because the original proportions are very small, you need to transform them and then transform them back into proportions.
|
Which binomial confidence interval is correct?
|
You need to report the back-transformed ones. This is because the original proportions are very small, you need to transform them and then transform them back into proportions.
|
Which binomial confidence interval is correct?
You need to report the back-transformed ones. This is because the original proportions are very small, you need to transform them and then transform them back into proportions.
|
Which binomial confidence interval is correct?
You need to report the back-transformed ones. This is because the original proportions are very small, you need to transform them and then transform them back into proportions.
|
43,402
|
Bias and variance properties of $L^1$ vs $L^2$ normalization
|
The variance will increase, the problem with L1 regularisation is some of the coefficients are highly unpredictable.
The answer depends on how severe is your regularisation($\lambda$ value).
I generated sin wave with gaussian noise with different seeds and what is observed is as lower $\lambda$ value the l1 norm has a lower variance as $\lambda$ values increases the l2 norm has lower variance.
As you can see in the image, the alpha is the regularization coefficient. at $\alpha = 1e-15$ the corresponding we see the large difference between Rigde regression coefficients but, as alpha increases the deviation in ridge decreases drastically.
but when $\alpha = 10$ the lasso and ridge both have lower variance.
So as the alpha decreases the variance of ridge increases drastically.
PS: I have experimented with this setup multiple times and the trend is consistent.
So answering your question the variance will increase when you switch from L1 to L2 regularizer(and the scale of increase depends on $\lambda$ value.)
also i have added the dot products of $W$ vector.just to see how diffrent the $w$.
the diagonal entries are -ve which says theres a lot of diffrence between the $Ws$.
this will be further extended with more detailed anaylsis.
|
Bias and variance properties of $L^1$ vs $L^2$ normalization
|
The variance will increase, the problem with L1 regularisation is some of the coefficients are highly unpredictable.
The answer depends on how severe is your regularisation($\lambda$ value).
I generat
|
Bias and variance properties of $L^1$ vs $L^2$ normalization
The variance will increase, the problem with L1 regularisation is some of the coefficients are highly unpredictable.
The answer depends on how severe is your regularisation($\lambda$ value).
I generated sin wave with gaussian noise with different seeds and what is observed is as lower $\lambda$ value the l1 norm has a lower variance as $\lambda$ values increases the l2 norm has lower variance.
As you can see in the image, the alpha is the regularization coefficient. at $\alpha = 1e-15$ the corresponding we see the large difference between Rigde regression coefficients but, as alpha increases the deviation in ridge decreases drastically.
but when $\alpha = 10$ the lasso and ridge both have lower variance.
So as the alpha decreases the variance of ridge increases drastically.
PS: I have experimented with this setup multiple times and the trend is consistent.
So answering your question the variance will increase when you switch from L1 to L2 regularizer(and the scale of increase depends on $\lambda$ value.)
also i have added the dot products of $W$ vector.just to see how diffrent the $w$.
the diagonal entries are -ve which says theres a lot of diffrence between the $Ws$.
this will be further extended with more detailed anaylsis.
|
Bias and variance properties of $L^1$ vs $L^2$ normalization
The variance will increase, the problem with L1 regularisation is some of the coefficients are highly unpredictable.
The answer depends on how severe is your regularisation($\lambda$ value).
I generat
|
43,403
|
Use Importance Sampling and Monte carlo for estimating a summation
|
As stated your question does not make complete sense: if you are only interested in$$\mathfrak{A} =\sum_{c=1}^{C} a(c)$$and if $C$ is too large for the computation to be done, then representing $\mathfrak{A}$ as an expectation$$\mathfrak{A}=\mathbb{E}[\mathscr{A}(X)]$$can be a way to approximate $\mathfrak{A}$ by a Monte Carlo approximation: by the Law of Large Numbers, generating a sample $X_1,\ldots,X_n$ from the distribution associated with the expectation $\mathbb{E}[\mathscr{A}(X)]$ leads to a converging (in $n$) estimator$$\hat{\mathfrak{A}}_n=\frac{1}{n}\sum_{i=1}^n\mathscr{A}(X_i)]$$The key notion in Monte Carlo approximations is that the said distribution is almost arbitrary. One naïve solution is to see $\mathfrak{A}$ as the expectation of $C a(\cdot)$ against the Uniform distribution on $\{1,\ldots,C\}$. But almost any other choice is acceptable, in that, given a probability distribution $q(\cdot)$ positive everywhere on $\{1,\ldots,C\}$, the identity $$\mathfrak{A}=\mathbb{E}_q[\mathscr{A}(X)/q(X)]$$stands. This means that generating from $q$, i.e., producing a sample $X_1,\ldots,X_n$ distributed from $q$, the approximation$$\hat{\mathfrak{A}}_n=\frac{1}{n}\sum_{i=1}^n\mathscr{A}(X_i)]/q(X_i)$$also is a converging (in $n$) estimator. The choice of $q$ matters: The closer $q$ is to $|a|$, the better the approximation.
|
Use Importance Sampling and Monte carlo for estimating a summation
|
As stated your question does not make complete sense: if you are only interested in$$\mathfrak{A} =\sum_{c=1}^{C} a(c)$$and if $C$ is too large for the computation to be done, then representing $\math
|
Use Importance Sampling and Monte carlo for estimating a summation
As stated your question does not make complete sense: if you are only interested in$$\mathfrak{A} =\sum_{c=1}^{C} a(c)$$and if $C$ is too large for the computation to be done, then representing $\mathfrak{A}$ as an expectation$$\mathfrak{A}=\mathbb{E}[\mathscr{A}(X)]$$can be a way to approximate $\mathfrak{A}$ by a Monte Carlo approximation: by the Law of Large Numbers, generating a sample $X_1,\ldots,X_n$ from the distribution associated with the expectation $\mathbb{E}[\mathscr{A}(X)]$ leads to a converging (in $n$) estimator$$\hat{\mathfrak{A}}_n=\frac{1}{n}\sum_{i=1}^n\mathscr{A}(X_i)]$$The key notion in Monte Carlo approximations is that the said distribution is almost arbitrary. One naïve solution is to see $\mathfrak{A}$ as the expectation of $C a(\cdot)$ against the Uniform distribution on $\{1,\ldots,C\}$. But almost any other choice is acceptable, in that, given a probability distribution $q(\cdot)$ positive everywhere on $\{1,\ldots,C\}$, the identity $$\mathfrak{A}=\mathbb{E}_q[\mathscr{A}(X)/q(X)]$$stands. This means that generating from $q$, i.e., producing a sample $X_1,\ldots,X_n$ distributed from $q$, the approximation$$\hat{\mathfrak{A}}_n=\frac{1}{n}\sum_{i=1}^n\mathscr{A}(X_i)]/q(X_i)$$also is a converging (in $n$) estimator. The choice of $q$ matters: The closer $q$ is to $|a|$, the better the approximation.
|
Use Importance Sampling and Monte carlo for estimating a summation
As stated your question does not make complete sense: if you are only interested in$$\mathfrak{A} =\sum_{c=1}^{C} a(c)$$and if $C$ is too large for the computation to be done, then representing $\math
|
43,404
|
Fitted value versus probability for logistic regression
|
It is in fact fine to use logistic regression to summarize observed proportions lying in the range of [0-1] inclusive.
In the past, such approaches were discredited when the data were in fact hierarchical and the goal of the analysis was to summarize individual level exposures which were aggregated up to a cluster level. In this particular case, it is incorrect to apply logistic regression because of ecological fallacy and non-collapsibility of the odds ratio as a measure of association.
The logistic regression estimating equations are appropriate to apply to any analysis where the linear model for the log of the mean minus the log of one minus the mean is appropriate (the logit link) and when the variance of the proportion is equal to the proportion times one minus the proportion (binomial variance assumption). It turns out the latter is a rather stringent requirement, so typically analysts use a more flexible variance estimator like a quasibinomial likelihood equation, or generalized estimating equations.
A problem with logistic regression (and its variants) is that it is not clear how you will validate the model. If you summarize predictive accuracy with mean squared error--a valid approach for many reasons--a non-linear least squares (NLS) estimator for the logit curve should be used instead. NLS will find the optimal S-shaped curve(s) that summarize association(s) with model predictors by minimizing the sum of squared differences from the predicted response surface. Alternately, if the desire is to apply some threshold based on a linear combination of covariates to classify subsets of fields which were over or under fertilized, linear discriminant analysis will provide superior classifications. A logistic model can be suboptimal according to a large number of predictive metrics.
So ultimately, it is not the structure of the data that should determine the analysis, but the question the analyst is trying to assess.
|
Fitted value versus probability for logistic regression
|
It is in fact fine to use logistic regression to summarize observed proportions lying in the range of [0-1] inclusive.
In the past, such approaches were discredited when the data were in fact hierarch
|
Fitted value versus probability for logistic regression
It is in fact fine to use logistic regression to summarize observed proportions lying in the range of [0-1] inclusive.
In the past, such approaches were discredited when the data were in fact hierarchical and the goal of the analysis was to summarize individual level exposures which were aggregated up to a cluster level. In this particular case, it is incorrect to apply logistic regression because of ecological fallacy and non-collapsibility of the odds ratio as a measure of association.
The logistic regression estimating equations are appropriate to apply to any analysis where the linear model for the log of the mean minus the log of one minus the mean is appropriate (the logit link) and when the variance of the proportion is equal to the proportion times one minus the proportion (binomial variance assumption). It turns out the latter is a rather stringent requirement, so typically analysts use a more flexible variance estimator like a quasibinomial likelihood equation, or generalized estimating equations.
A problem with logistic regression (and its variants) is that it is not clear how you will validate the model. If you summarize predictive accuracy with mean squared error--a valid approach for many reasons--a non-linear least squares (NLS) estimator for the logit curve should be used instead. NLS will find the optimal S-shaped curve(s) that summarize association(s) with model predictors by minimizing the sum of squared differences from the predicted response surface. Alternately, if the desire is to apply some threshold based on a linear combination of covariates to classify subsets of fields which were over or under fertilized, linear discriminant analysis will provide superior classifications. A logistic model can be suboptimal according to a large number of predictive metrics.
So ultimately, it is not the structure of the data that should determine the analysis, but the question the analyst is trying to assess.
|
Fitted value versus probability for logistic regression
It is in fact fine to use logistic regression to summarize observed proportions lying in the range of [0-1] inclusive.
In the past, such approaches were discredited when the data were in fact hierarch
|
43,405
|
How to model multiple inputs to multiple outputs?
|
tl;dr I recommend this, but only pending extensive visual data exploration.
Your problem as univariate classification
I was about to write an overview of supervised multivariate techniques, but then I realized I'd rather recast your problem.
Given $X$=(charge, hydrophobicity, beta-sheet propensity, ...) and $Y$=(pH, ionic strength, sugar, NaCl concentration, etc.), predict $Z$(=1 if stable, otherwise 0).
This tidily addresses the possibility of multiple $Y$ values for a given $X$, and now you have a "simple" univariate prediction problem. You mentioned logistic regression and neural networks, and those would be good baseline methods to try... if you have any examples with $Z=0$.
Your problem as unsupervised learning
So what if you only have examples where $Z=1$? You can't train a classifier. All you can do is assume that there is something generalizable about the points in your dataset -- some set of relationships that hold up across all the proteins and their stabilizing conditions. For example, maybe sugar concentration minus salt concentration always equals inverse hydrophobicity (I'm just bullshitting, of course). Common tools for uncovering structure in data include:
autoencoders: a neural net with your data as both input and output, and a bottleneck layer in the middle.
Principal components analysis or principal curves
The graphical lasso and its cousins, which convert the observed correlation structure into a network with a limited number of edges. I talk more about my favorite options below.
Missing data overview
Regarding your missing data, it's helpful to know what it was caused by. In a clinical trial, patients might drop out due to side effects and thereby skew the results irreparably. You mentioned resource limitations, which means your missingness pattern might be independent of the missing values. (This is especially true if hydrophobic proteins are no more or less expensive to measure that the rest, and so on for all your measurements.) If that is a leap you're willing to make, then not only can you fill in the missing data; you can reasonably quantify the uncertainty in your model parameters.
One way to do this is multiple imputation:
formulate a probabilistic model for the missing data
simulate missing data from that model
complete your task as if no data were missing
repeat this many times and combine the resulting estimates via Rubin's Formulas (slide 7).
This page contains tons of information on missing data and multiple imputation. But, if you just want a point estimate, keep reading.
Specific models for missing data
In this situation, I might try a rank $r$ regression model
$$E[M] = RL$$,
where $M$ is $[X|Y]$ ($n$ rows, $p$ columns), $R$ is an unknown $n$ by $r$ matrix, $L$ is an unknown $r$ by $p$ matrix, and $E[]$ is the expectation operator. (Substitute in your preferred likelihood function or data transform.) You can fit this model despite the missing entries: using a simple squared loss as an example, minimize $$\sum_{i,j \in \Omega} (M_{ij} - \sum_k R_{ik}L_{kj})$$ (where $\Omega$ is the set of observed entries). You can alternate between updating $R$ and updating $L$, so that each update is just a regression problem, and you'll probably do well.
Rather than low rank, another option is to use a flexible distribution based on a sparse inverse covariance matrix. (Why inverse covariance? It's the Markov random field representation.) This solution seems to accommodate all of your needs at once, so I linked to it in the tl;dr.
Do due diligence
Finally, please do not fit complex models to your data without first visualizing it and exploring it. I recommend scrutinizing all of the pairwise relationships by plotting them somehow (scatterplots for continuous, contingency tables for categorical, and side-by-side boxplots for mixed). This might reveal outliers or physically implausible trends that bear investigation. It might reveal that my answer is off track or requires modification: perhaps you'll end up with a couple of protein clusters that behave very differently, so you decide to model them each separately. Perhaps the data are just really ugly, and there's nothing to see other than "super acidic and salty things are unstable." I'm interested to know what you find.
|
How to model multiple inputs to multiple outputs?
|
tl;dr I recommend this, but only pending extensive visual data exploration.
Your problem as univariate classification
I was about to write an overview of supervised multivariate techniques, but then I
|
How to model multiple inputs to multiple outputs?
tl;dr I recommend this, but only pending extensive visual data exploration.
Your problem as univariate classification
I was about to write an overview of supervised multivariate techniques, but then I realized I'd rather recast your problem.
Given $X$=(charge, hydrophobicity, beta-sheet propensity, ...) and $Y$=(pH, ionic strength, sugar, NaCl concentration, etc.), predict $Z$(=1 if stable, otherwise 0).
This tidily addresses the possibility of multiple $Y$ values for a given $X$, and now you have a "simple" univariate prediction problem. You mentioned logistic regression and neural networks, and those would be good baseline methods to try... if you have any examples with $Z=0$.
Your problem as unsupervised learning
So what if you only have examples where $Z=1$? You can't train a classifier. All you can do is assume that there is something generalizable about the points in your dataset -- some set of relationships that hold up across all the proteins and their stabilizing conditions. For example, maybe sugar concentration minus salt concentration always equals inverse hydrophobicity (I'm just bullshitting, of course). Common tools for uncovering structure in data include:
autoencoders: a neural net with your data as both input and output, and a bottleneck layer in the middle.
Principal components analysis or principal curves
The graphical lasso and its cousins, which convert the observed correlation structure into a network with a limited number of edges. I talk more about my favorite options below.
Missing data overview
Regarding your missing data, it's helpful to know what it was caused by. In a clinical trial, patients might drop out due to side effects and thereby skew the results irreparably. You mentioned resource limitations, which means your missingness pattern might be independent of the missing values. (This is especially true if hydrophobic proteins are no more or less expensive to measure that the rest, and so on for all your measurements.) If that is a leap you're willing to make, then not only can you fill in the missing data; you can reasonably quantify the uncertainty in your model parameters.
One way to do this is multiple imputation:
formulate a probabilistic model for the missing data
simulate missing data from that model
complete your task as if no data were missing
repeat this many times and combine the resulting estimates via Rubin's Formulas (slide 7).
This page contains tons of information on missing data and multiple imputation. But, if you just want a point estimate, keep reading.
Specific models for missing data
In this situation, I might try a rank $r$ regression model
$$E[M] = RL$$,
where $M$ is $[X|Y]$ ($n$ rows, $p$ columns), $R$ is an unknown $n$ by $r$ matrix, $L$ is an unknown $r$ by $p$ matrix, and $E[]$ is the expectation operator. (Substitute in your preferred likelihood function or data transform.) You can fit this model despite the missing entries: using a simple squared loss as an example, minimize $$\sum_{i,j \in \Omega} (M_{ij} - \sum_k R_{ik}L_{kj})$$ (where $\Omega$ is the set of observed entries). You can alternate between updating $R$ and updating $L$, so that each update is just a regression problem, and you'll probably do well.
Rather than low rank, another option is to use a flexible distribution based on a sparse inverse covariance matrix. (Why inverse covariance? It's the Markov random field representation.) This solution seems to accommodate all of your needs at once, so I linked to it in the tl;dr.
Do due diligence
Finally, please do not fit complex models to your data without first visualizing it and exploring it. I recommend scrutinizing all of the pairwise relationships by plotting them somehow (scatterplots for continuous, contingency tables for categorical, and side-by-side boxplots for mixed). This might reveal outliers or physically implausible trends that bear investigation. It might reveal that my answer is off track or requires modification: perhaps you'll end up with a couple of protein clusters that behave very differently, so you decide to model them each separately. Perhaps the data are just really ugly, and there's nothing to see other than "super acidic and salty things are unstable." I'm interested to know what you find.
|
How to model multiple inputs to multiple outputs?
tl;dr I recommend this, but only pending extensive visual data exploration.
Your problem as univariate classification
I was about to write an overview of supervised multivariate techniques, but then I
|
43,406
|
Calculating test-time perplexity for seq2seq (RNN) language models
|
How can we get a good but fair decoder hidden state $\hat h_i$ to predict word $\hat w_i$? How can it encode as much as possible about the history?
Once the language model has been trained the $\hat h_i$ can be got from the previous words $w_0, w_1, ..., w_{i-1}$ where $w_0$ represents the start of sentence token. The history information is encoded in the cell updated by all the previous words. We do not use the predicted $\hat w_i$ and hence will not affect the results, and the character we input into the model at each time step is the ground truth.
For example, when we calculating the probability of $w_i$(for i >= 1) the input is $h_{i-1}$(which is only affected by $w_0$ to $w_{i-2}$), $w_{i-1}$, and we can get a probability distribution for $w_{i}$ and we just index the probabilty($p(w_i|w_0, ..., w_{i-1})$) using $w_i$ and don't do the others(we don't get the word with max probability $\hat w_i$) and input ground truth $w_i$ for the next time step as the input.
And the probability of each character is indexed by the ground truth character in the softmax output and the mean perplexity is then calculated by this:
\begin{align}
\text{Perplexity}(w_1, ..., w_n) &= \sqrt[n]{\frac{1}{\prod_{i=1}^{n} p(w_{i})}} \\
&= 2^{\log_{2}{[\prod_{i=1}^{n} p(w_i|w_0, ..., w_{i-1})]}^{-n}} \\
&= 2^{-\frac{1}{n}\log_{2}{[\prod_{i=1}^{n} p(w_i|w_0, ..., w_{i-1})]}} \\
&= 2^{-\frac{1}{n}\sum_{i=1}^{n}\log_{2}{p(w_i|w_0, ..., w_{i-1})}}
\end{align}
For the detailed derivation please refer to this article: N-gramLanguage Models.
|
Calculating test-time perplexity for seq2seq (RNN) language models
|
How can we get a good but fair decoder hidden state $\hat h_i$ to predict word $\hat w_i$? How can it encode as much as possible about the history?
Once the language model has been trained the $\hat
|
Calculating test-time perplexity for seq2seq (RNN) language models
How can we get a good but fair decoder hidden state $\hat h_i$ to predict word $\hat w_i$? How can it encode as much as possible about the history?
Once the language model has been trained the $\hat h_i$ can be got from the previous words $w_0, w_1, ..., w_{i-1}$ where $w_0$ represents the start of sentence token. The history information is encoded in the cell updated by all the previous words. We do not use the predicted $\hat w_i$ and hence will not affect the results, and the character we input into the model at each time step is the ground truth.
For example, when we calculating the probability of $w_i$(for i >= 1) the input is $h_{i-1}$(which is only affected by $w_0$ to $w_{i-2}$), $w_{i-1}$, and we can get a probability distribution for $w_{i}$ and we just index the probabilty($p(w_i|w_0, ..., w_{i-1})$) using $w_i$ and don't do the others(we don't get the word with max probability $\hat w_i$) and input ground truth $w_i$ for the next time step as the input.
And the probability of each character is indexed by the ground truth character in the softmax output and the mean perplexity is then calculated by this:
\begin{align}
\text{Perplexity}(w_1, ..., w_n) &= \sqrt[n]{\frac{1}{\prod_{i=1}^{n} p(w_{i})}} \\
&= 2^{\log_{2}{[\prod_{i=1}^{n} p(w_i|w_0, ..., w_{i-1})]}^{-n}} \\
&= 2^{-\frac{1}{n}\log_{2}{[\prod_{i=1}^{n} p(w_i|w_0, ..., w_{i-1})]}} \\
&= 2^{-\frac{1}{n}\sum_{i=1}^{n}\log_{2}{p(w_i|w_0, ..., w_{i-1})}}
\end{align}
For the detailed derivation please refer to this article: N-gramLanguage Models.
|
Calculating test-time perplexity for seq2seq (RNN) language models
How can we get a good but fair decoder hidden state $\hat h_i$ to predict word $\hat w_i$? How can it encode as much as possible about the history?
Once the language model has been trained the $\hat
|
43,407
|
Calculating test-time perplexity for seq2seq (RNN) language models
|
At test time, for decoding, choose the word with highest Softmax probability as the input to the next time step. The perplexity is calculated as
p(sentence)^(-1/N)
where N is number of words in the sentence.
|
Calculating test-time perplexity for seq2seq (RNN) language models
|
At test time, for decoding, choose the word with highest Softmax probability as the input to the next time step. The perplexity is calculated as
p(sentence)^(-1/N)
where N is number of words in the s
|
Calculating test-time perplexity for seq2seq (RNN) language models
At test time, for decoding, choose the word with highest Softmax probability as the input to the next time step. The perplexity is calculated as
p(sentence)^(-1/N)
where N is number of words in the sentence.
|
Calculating test-time perplexity for seq2seq (RNN) language models
At test time, for decoding, choose the word with highest Softmax probability as the input to the next time step. The perplexity is calculated as
p(sentence)^(-1/N)
where N is number of words in the s
|
43,408
|
Lambda value for BoxCox transformation in time series analysis
|
You probably want to look at When (and why) should you take the log of a distribution (of numbers)? which discusses power transforms. Unwarranted or incorrect transformations including differences should be studiously avoided as they are often an ill-fashioned /ill-conceived attempt to deal with unidentified anomalies/level shifts/time trends or changes in parameters or changes in error variance
A classic example of this is discussed starting at slide 60 here http://www.autobox.com/cms/index.php/afs-university/intro-to-forecasting/doc_download/53-capabilities-presentation where three pulse anomalies (untreated) led to an unwarranted log transformation by early researchers. Unfortunately some of our current researchers are still making the same mistake.
The issue here ( as suggested by the op) is to be very wary of assumptions.
|
Lambda value for BoxCox transformation in time series analysis
|
You probably want to look at When (and why) should you take the log of a distribution (of numbers)? which discusses power transforms. Unwarranted or incorrect transformations including differences sho
|
Lambda value for BoxCox transformation in time series analysis
You probably want to look at When (and why) should you take the log of a distribution (of numbers)? which discusses power transforms. Unwarranted or incorrect transformations including differences should be studiously avoided as they are often an ill-fashioned /ill-conceived attempt to deal with unidentified anomalies/level shifts/time trends or changes in parameters or changes in error variance
A classic example of this is discussed starting at slide 60 here http://www.autobox.com/cms/index.php/afs-university/intro-to-forecasting/doc_download/53-capabilities-presentation where three pulse anomalies (untreated) led to an unwarranted log transformation by early researchers. Unfortunately some of our current researchers are still making the same mistake.
The issue here ( as suggested by the op) is to be very wary of assumptions.
|
Lambda value for BoxCox transformation in time series analysis
You probably want to look at When (and why) should you take the log of a distribution (of numbers)? which discusses power transforms. Unwarranted or incorrect transformations including differences sho
|
43,409
|
Is there a measure to describe the degree of linear separability?
|
As noted in the question and comments, a dataset of $m$ points $(\boldsymbol{x}_i,y_i)$ with $\boldsymbol{x}_i\in\mathbb{R}^n$ and $y_i\in\{-1,+1\}$ is linearly separable if we can find a normal vector $\boldsymbol{a}$ and scalar bias $b$ such that the linear inequality
$$y_i(\boldsymbol{a}^T\boldsymbol{x}_i+b)\geq 1$$
is satisfied for all $i=1,\ldots,m$. Physically this says that for each point $\boldsymbol{x}_i$, the signed distance $d_i$ to the separating plane has sign $y_i$ and magnitude at least $\|\boldsymbol{a}\|$.
This can be written also as
$$\boldsymbol{w}^T\boldsymbol{z}_i \geq 1$$
where
$$\boldsymbol{z}_i = \begin{bmatrix}\boldsymbol{x}_i \\ 1\end{bmatrix} y_i
\text{ , } \boldsymbol{w}=\begin{bmatrix}\boldsymbol{a} \\ b\end{bmatrix}$$
As noted in the question, this is essentially a linear program with a "0" objective function.
The proposed "degree of separability" measure $S_\min$ can be expressed as
$$ \min_{\boldsymbol{\sigma},\boldsymbol{w}} S[\boldsymbol{\sigma}] $$
where $\boldsymbol{\sigma}\in\{0,1\}^m$, the function $S$ is defined by
$$ S[\boldsymbol{\sigma}] = \sum_i\sigma_i = \boldsymbol{1}^T\boldsymbol{\sigma} $$
and the minimization is subject to the constraint
$$ \sigma_i(\boldsymbol{w}^T\boldsymbol{z}_i - 1) \geq 0 \text{ , } i=1,\ldots,m$$
This is a (slightly nonlinear) "mixed integer programming" problem, a problem class which is NP hard (even in the linear & binary case).
Now a more feasible alternative could be to solve a "soft-margin" classification problem using a standard approach like SVM*. The tolerance and/or lagrange multiplier variables could then be used to quantify "degree of separability".
(*For $\lambda\approx 0$ the SVM will essentially reduce to a "softened" version of the linear program above. However to get meaningful distances, you will have to normalize tolerances by $\|\boldsymbol{a}\|$.)
Update: Using something like soft-margin SVM can give you an idea of which points are "hard" to separate, but it would not necessarily address your question of "how many points must be removed to allow a hard-margin split?"
However, I think that if you pre-process the $\boldsymbol{X}$ matrix by whitening, then it should be possible to get some more consistent results. (In terms of numerical offset-scales and directional clustering of the problem points.)
|
Is there a measure to describe the degree of linear separability?
|
As noted in the question and comments, a dataset of $m$ points $(\boldsymbol{x}_i,y_i)$ with $\boldsymbol{x}_i\in\mathbb{R}^n$ and $y_i\in\{-1,+1\}$ is linearly separable if we can find a normal vecto
|
Is there a measure to describe the degree of linear separability?
As noted in the question and comments, a dataset of $m$ points $(\boldsymbol{x}_i,y_i)$ with $\boldsymbol{x}_i\in\mathbb{R}^n$ and $y_i\in\{-1,+1\}$ is linearly separable if we can find a normal vector $\boldsymbol{a}$ and scalar bias $b$ such that the linear inequality
$$y_i(\boldsymbol{a}^T\boldsymbol{x}_i+b)\geq 1$$
is satisfied for all $i=1,\ldots,m$. Physically this says that for each point $\boldsymbol{x}_i$, the signed distance $d_i$ to the separating plane has sign $y_i$ and magnitude at least $\|\boldsymbol{a}\|$.
This can be written also as
$$\boldsymbol{w}^T\boldsymbol{z}_i \geq 1$$
where
$$\boldsymbol{z}_i = \begin{bmatrix}\boldsymbol{x}_i \\ 1\end{bmatrix} y_i
\text{ , } \boldsymbol{w}=\begin{bmatrix}\boldsymbol{a} \\ b\end{bmatrix}$$
As noted in the question, this is essentially a linear program with a "0" objective function.
The proposed "degree of separability" measure $S_\min$ can be expressed as
$$ \min_{\boldsymbol{\sigma},\boldsymbol{w}} S[\boldsymbol{\sigma}] $$
where $\boldsymbol{\sigma}\in\{0,1\}^m$, the function $S$ is defined by
$$ S[\boldsymbol{\sigma}] = \sum_i\sigma_i = \boldsymbol{1}^T\boldsymbol{\sigma} $$
and the minimization is subject to the constraint
$$ \sigma_i(\boldsymbol{w}^T\boldsymbol{z}_i - 1) \geq 0 \text{ , } i=1,\ldots,m$$
This is a (slightly nonlinear) "mixed integer programming" problem, a problem class which is NP hard (even in the linear & binary case).
Now a more feasible alternative could be to solve a "soft-margin" classification problem using a standard approach like SVM*. The tolerance and/or lagrange multiplier variables could then be used to quantify "degree of separability".
(*For $\lambda\approx 0$ the SVM will essentially reduce to a "softened" version of the linear program above. However to get meaningful distances, you will have to normalize tolerances by $\|\boldsymbol{a}\|$.)
Update: Using something like soft-margin SVM can give you an idea of which points are "hard" to separate, but it would not necessarily address your question of "how many points must be removed to allow a hard-margin split?"
However, I think that if you pre-process the $\boldsymbol{X}$ matrix by whitening, then it should be possible to get some more consistent results. (In terms of numerical offset-scales and directional clustering of the problem points.)
|
Is there a measure to describe the degree of linear separability?
As noted in the question and comments, a dataset of $m$ points $(\boldsymbol{x}_i,y_i)$ with $\boldsymbol{x}_i\in\mathbb{R}^n$ and $y_i\in\{-1,+1\}$ is linearly separable if we can find a normal vecto
|
43,410
|
equivalence test - why isn't it more common?
|
I did some more thinking on the consequences of using a "point" null hypothesis. I plotted some power curves below:
Basically for a fixed alpha when doing the usual point null hypothesis, as n increases, the power for small true parameters increases. This just doesn't seem like a great property to me in many situations in which we want to decide whether the true effect is "meaningful" (i.e practical /economic significance vs statistical significance).
For example, imagine an academic journal accepting entries on the basis of "statistical significance." Even if it has power requirements, it'll tend to just end up with papers having a lot of small true effects, not very interesting.
In contrast, the power curves for the "two one sided tests" constructed below become better suited to their purpose as n-increases. If we fix Power(epsilon) = 0.05, as n increases Power(epsilon + delta) -> 1 for a small delta. A journal that accepted entries on this rule would (hypothetically) end up with lots of results that are actually economically significant (obviously I'm assuming the ideal case in which researchers aren't doing multiple hypothesis testing, are preregistering experimental design, etc...)
|
equivalence test - why isn't it more common?
|
I did some more thinking on the consequences of using a "point" null hypothesis. I plotted some power curves below:
Basically for a fixed alpha when doing the usual point null hypothesis, as n increa
|
equivalence test - why isn't it more common?
I did some more thinking on the consequences of using a "point" null hypothesis. I plotted some power curves below:
Basically for a fixed alpha when doing the usual point null hypothesis, as n increases, the power for small true parameters increases. This just doesn't seem like a great property to me in many situations in which we want to decide whether the true effect is "meaningful" (i.e practical /economic significance vs statistical significance).
For example, imagine an academic journal accepting entries on the basis of "statistical significance." Even if it has power requirements, it'll tend to just end up with papers having a lot of small true effects, not very interesting.
In contrast, the power curves for the "two one sided tests" constructed below become better suited to their purpose as n-increases. If we fix Power(epsilon) = 0.05, as n increases Power(epsilon + delta) -> 1 for a small delta. A journal that accepted entries on this rule would (hypothetically) end up with lots of results that are actually economically significant (obviously I'm assuming the ideal case in which researchers aren't doing multiple hypothesis testing, are preregistering experimental design, etc...)
|
equivalence test - why isn't it more common?
I did some more thinking on the consequences of using a "point" null hypothesis. I plotted some power curves below:
Basically for a fixed alpha when doing the usual point null hypothesis, as n increa
|
43,411
|
Can I use mean absolute scaled error (MASE) from the accuracy function for time series cross validation?
|
accuracy() uses the training sample on which a particular forecast is based. As you note, this will change in each iteration of your rolling origin evaluation. So indeed, you need to "roll your own".
This is less onerous than it looks like. Note that the MASE is the MAE or MAD, divided by some scaling factor. accuracy() will give you the MAE. (Of course you can use this in rolling origin evaluation.) So you only need to calculate a single scaling factor for each time series, which you will then apply to the rolling origin MAEs.
For instance, the "classical" scaling factor Hyndman & Koehler (2006) originally proposed is simply the in-sample MAE of the naive random walk forecast. If the data you want to base this on (e.g., the "common" history) is
foo <- ts(rnorm(1,20))
then you can calculate this very easily by
mean(abs(foo[-1]-foo[-20]))
(Note: it should be possible to use tail(foo,-1)-head(foo,-1), but this yields a vector of all zeros... I wonder whether something is buggy here, though both tail(foo,-1) and head(foo,-1) look fine. Weird.)
(Update: tail(foo,-1)-head(foo,-1) works on plain vanilla R, but not if I load the forecast 8.5 package. Sounds like a bug. I'll inform Rob Hyndman.)
(Update 2: I got the following answer back from Rob -
This is a feature, not a bug.
By defining head.ts and tail.ts, we are ensuring that head() and tail() on ts objects now retain their class (essential for plotting, etc.).
By retaining the "ts" class, the - operation will now use Ops.ts. This will compute math operations with respect to time rather than with respect to position in the vector.
)
|
Can I use mean absolute scaled error (MASE) from the accuracy function for time series cross validat
|
accuracy() uses the training sample on which a particular forecast is based. As you note, this will change in each iteration of your rolling origin evaluation. So indeed, you need to "roll your own".
|
Can I use mean absolute scaled error (MASE) from the accuracy function for time series cross validation?
accuracy() uses the training sample on which a particular forecast is based. As you note, this will change in each iteration of your rolling origin evaluation. So indeed, you need to "roll your own".
This is less onerous than it looks like. Note that the MASE is the MAE or MAD, divided by some scaling factor. accuracy() will give you the MAE. (Of course you can use this in rolling origin evaluation.) So you only need to calculate a single scaling factor for each time series, which you will then apply to the rolling origin MAEs.
For instance, the "classical" scaling factor Hyndman & Koehler (2006) originally proposed is simply the in-sample MAE of the naive random walk forecast. If the data you want to base this on (e.g., the "common" history) is
foo <- ts(rnorm(1,20))
then you can calculate this very easily by
mean(abs(foo[-1]-foo[-20]))
(Note: it should be possible to use tail(foo,-1)-head(foo,-1), but this yields a vector of all zeros... I wonder whether something is buggy here, though both tail(foo,-1) and head(foo,-1) look fine. Weird.)
(Update: tail(foo,-1)-head(foo,-1) works on plain vanilla R, but not if I load the forecast 8.5 package. Sounds like a bug. I'll inform Rob Hyndman.)
(Update 2: I got the following answer back from Rob -
This is a feature, not a bug.
By defining head.ts and tail.ts, we are ensuring that head() and tail() on ts objects now retain their class (essential for plotting, etc.).
By retaining the "ts" class, the - operation will now use Ops.ts. This will compute math operations with respect to time rather than with respect to position in the vector.
)
|
Can I use mean absolute scaled error (MASE) from the accuracy function for time series cross validat
accuracy() uses the training sample on which a particular forecast is based. As you note, this will change in each iteration of your rolling origin evaluation. So indeed, you need to "roll your own".
|
43,412
|
Testing for Benford Law in real time
|
Sambridge et al. (2010) outline a method for assessing the conformance of time series data to Benford's law. Although your use case is a bit different, it may work for you too.
Their method works as you basically describe: group your data into observation windows and test each window for conformance. This method has been used (and published) by the same authors in other articles, so it's at least sound enough to pass peer review a few times.
Although they have their own goodness of fit measure, I don't see any reason why you couldn't use any measure that would typically work for benford's analysis. You will want to be sure that your measure has good properties for the window or sample size you selected.
|
Testing for Benford Law in real time
|
Sambridge et al. (2010) outline a method for assessing the conformance of time series data to Benford's law. Although your use case is a bit different, it may work for you too.
Their method works as y
|
Testing for Benford Law in real time
Sambridge et al. (2010) outline a method for assessing the conformance of time series data to Benford's law. Although your use case is a bit different, it may work for you too.
Their method works as you basically describe: group your data into observation windows and test each window for conformance. This method has been used (and published) by the same authors in other articles, so it's at least sound enough to pass peer review a few times.
Although they have their own goodness of fit measure, I don't see any reason why you couldn't use any measure that would typically work for benford's analysis. You will want to be sure that your measure has good properties for the window or sample size you selected.
|
Testing for Benford Law in real time
Sambridge et al. (2010) outline a method for assessing the conformance of time series data to Benford's law. Although your use case is a bit different, it may work for you too.
Their method works as y
|
43,413
|
Instrument Variables and Exclusion Restriction from a Mediation perspective
|
You correctly state that under the LATE-style IV assumptions with a causal effect of the IV Z on the treatment S, exogenous instrument, and no direct effect on the outcome Y, your treatment effect B of S on Y is identified as
$Cov(Y,Z)/Cov(S,Z) = ITT/Compliance Rate$
So clearly,
$ITT = Cov(Y, Z)$,
and not $Cov(S,Z)⋅Cov(Y,S)+Cov(Y,Z)$, as you mistakenly state. This is also intuitively clear because if the instrument is exogenous with respect to the treatment and the outcome, its causal effects are identified and (under linearity) are simply the correlation between the instrument and the outcome.
You further seem to imply that the IV and Y should be unrelated in a regression of Y on the treatment and the IV. This is not the case if treatment S is actually endogenous. Then, it is a collider, as it is caused by the IV and the unobserved error term of Y. Conditioning on the treatment makes the IV and the error term dependent, and therefore also the IV and Y. So you get a non-zero regression coefficient even if the exclusion restriction is valid. This should be very clear if you draw the causal graph.
If it was not the case, we could actually test the exclusion restriction, but of course we know we usually can't test it! (At least not that easily).
|
Instrument Variables and Exclusion Restriction from a Mediation perspective
|
You correctly state that under the LATE-style IV assumptions with a causal effect of the IV Z on the treatment S, exogenous instrument, and no direct effect on the outcome Y, your treatment effect B o
|
Instrument Variables and Exclusion Restriction from a Mediation perspective
You correctly state that under the LATE-style IV assumptions with a causal effect of the IV Z on the treatment S, exogenous instrument, and no direct effect on the outcome Y, your treatment effect B of S on Y is identified as
$Cov(Y,Z)/Cov(S,Z) = ITT/Compliance Rate$
So clearly,
$ITT = Cov(Y, Z)$,
and not $Cov(S,Z)⋅Cov(Y,S)+Cov(Y,Z)$, as you mistakenly state. This is also intuitively clear because if the instrument is exogenous with respect to the treatment and the outcome, its causal effects are identified and (under linearity) are simply the correlation between the instrument and the outcome.
You further seem to imply that the IV and Y should be unrelated in a regression of Y on the treatment and the IV. This is not the case if treatment S is actually endogenous. Then, it is a collider, as it is caused by the IV and the unobserved error term of Y. Conditioning on the treatment makes the IV and the error term dependent, and therefore also the IV and Y. So you get a non-zero regression coefficient even if the exclusion restriction is valid. This should be very clear if you draw the causal graph.
If it was not the case, we could actually test the exclusion restriction, but of course we know we usually can't test it! (At least not that easily).
|
Instrument Variables and Exclusion Restriction from a Mediation perspective
You correctly state that under the LATE-style IV assumptions with a causal effect of the IV Z on the treatment S, exogenous instrument, and no direct effect on the outcome Y, your treatment effect B o
|
43,414
|
How does a U-Net group pixel classifications into a single spatial region?
|
It incorporates "prior knowledge" by training the network over a training dataset which will update the weights of the convolution filters. This is how most neural networks are trained with standard backprop. Where the loss to be backproped is based on the segmenation loss in this case.
Here's a link to better show a deconvolution visualization viz. It doesn't show how it is trained because that is the same as how regular convolution is trained and there are other resources for that such as here backprop.
|
How does a U-Net group pixel classifications into a single spatial region?
|
It incorporates "prior knowledge" by training the network over a training dataset which will update the weights of the convolution filters. This is how most neural networks are trained with standard
|
How does a U-Net group pixel classifications into a single spatial region?
It incorporates "prior knowledge" by training the network over a training dataset which will update the weights of the convolution filters. This is how most neural networks are trained with standard backprop. Where the loss to be backproped is based on the segmenation loss in this case.
Here's a link to better show a deconvolution visualization viz. It doesn't show how it is trained because that is the same as how regular convolution is trained and there are other resources for that such as here backprop.
|
How does a U-Net group pixel classifications into a single spatial region?
It incorporates "prior knowledge" by training the network over a training dataset which will update the weights of the convolution filters. This is how most neural networks are trained with standard
|
43,415
|
What is the correct way for correlation and auto correlation plot?
|
tl;dr: Your time axis is wrong and the correlation values could be rescaled.
Time Axis
The cross-correlation of two continuous signals $F$ and $G$ is
$$(F \star G)(\tau) = \int_{-\infty}^{\infty} F^*(t)G(t+\tau)dt$$
In other words, it is the dot product between $F$ (or its complex conjugate $F^*$ for complex-valued signals) and a version of $G$ that has been shifted forwards and backwards. (It's very much like convolution, except that for convolution, one of them is also reversed: $t+\tau$ becomes $t-\tau$ for convolution).
This implies that your cross-correlation plot has zero at its center, rather than on one edge. You constructed the time axis yourself, so you could change the code to put 0 at the center, -1 and +1 on either side, etc. Matlab also does this for you as the second argument from xcorr (docs):
[CST, lags] = xcorr(phit, phi);
plot(lags, CST); title('Cross-correlation');
[AST, langs] = xcorr(phi, phi);
plot(lags, AST); title('Autocorrelation');
Rescaling
The formula above assumes that your signals are infinite, but your actual data probably is not. As you "push" one array past the other, they become different lengths and you can no longer compare them. One approach is to shift one array circularly (i.e., G(1) becomes G(2), G(2) becomes G(3), ...., G(N-1) becomes G(N), and G(N) becomes G(1)).
Matlab doesn't do that. Instead, it pads them with zeros (it actually does the computation in the frequency domain, and the fft call does the padding). If your signal has a non-zero mean, it becomes a strangely-shaped little "step" in the midst of zeros. The convolution or cross-correlation of the two steps produces that weird triangular shape. There are a few ways of dealing with it:
Standardizing your signal so it has zero mean and unit variance helps
You can also get an unbiased estimate of the cross-correlation by rescaling $R(\tau)$ by $\frac{1}{N-|\tau|}$. Matlab does this if you add a third option to the function call xcorr(F,G,'unbiased') (there are a few other normalization options too).
Incidentally, you might want to play around with a less pathological pair of "signals" for practice so you can see by eye what the result should be.
|
What is the correct way for correlation and auto correlation plot?
|
tl;dr: Your time axis is wrong and the correlation values could be rescaled.
Time Axis
The cross-correlation of two continuous signals $F$ and $G$ is
$$(F \star G)(\tau) = \int_{-\infty}^{\infty} F^*
|
What is the correct way for correlation and auto correlation plot?
tl;dr: Your time axis is wrong and the correlation values could be rescaled.
Time Axis
The cross-correlation of two continuous signals $F$ and $G$ is
$$(F \star G)(\tau) = \int_{-\infty}^{\infty} F^*(t)G(t+\tau)dt$$
In other words, it is the dot product between $F$ (or its complex conjugate $F^*$ for complex-valued signals) and a version of $G$ that has been shifted forwards and backwards. (It's very much like convolution, except that for convolution, one of them is also reversed: $t+\tau$ becomes $t-\tau$ for convolution).
This implies that your cross-correlation plot has zero at its center, rather than on one edge. You constructed the time axis yourself, so you could change the code to put 0 at the center, -1 and +1 on either side, etc. Matlab also does this for you as the second argument from xcorr (docs):
[CST, lags] = xcorr(phit, phi);
plot(lags, CST); title('Cross-correlation');
[AST, langs] = xcorr(phi, phi);
plot(lags, AST); title('Autocorrelation');
Rescaling
The formula above assumes that your signals are infinite, but your actual data probably is not. As you "push" one array past the other, they become different lengths and you can no longer compare them. One approach is to shift one array circularly (i.e., G(1) becomes G(2), G(2) becomes G(3), ...., G(N-1) becomes G(N), and G(N) becomes G(1)).
Matlab doesn't do that. Instead, it pads them with zeros (it actually does the computation in the frequency domain, and the fft call does the padding). If your signal has a non-zero mean, it becomes a strangely-shaped little "step" in the midst of zeros. The convolution or cross-correlation of the two steps produces that weird triangular shape. There are a few ways of dealing with it:
Standardizing your signal so it has zero mean and unit variance helps
You can also get an unbiased estimate of the cross-correlation by rescaling $R(\tau)$ by $\frac{1}{N-|\tau|}$. Matlab does this if you add a third option to the function call xcorr(F,G,'unbiased') (there are a few other normalization options too).
Incidentally, you might want to play around with a less pathological pair of "signals" for practice so you can see by eye what the result should be.
|
What is the correct way for correlation and auto correlation plot?
tl;dr: Your time axis is wrong and the correlation values could be rescaled.
Time Axis
The cross-correlation of two continuous signals $F$ and $G$ is
$$(F \star G)(\tau) = \int_{-\infty}^{\infty} F^*
|
43,416
|
Normalization factor in multivariate Gaussian
|
Indeed the formula $$|2πΣ|=(2π)^d|Σ|$$ is correct.
In practice, one would compute $|Σ|$
and then multiply it by $(2π)^d$, rather than multiply $Σ$ by $2π$, which involves $d^2$ operations, and then compute its determinant.
|
Normalization factor in multivariate Gaussian
|
Indeed the formula $$|2πΣ|=(2π)^d|Σ|$$ is correct.
In practice, one would compute $|Σ|$
and then multiply it by $(2π)^d$, rather than multiply $Σ$ by $2π$, which involves $d^2$ operations, and then c
|
Normalization factor in multivariate Gaussian
Indeed the formula $$|2πΣ|=(2π)^d|Σ|$$ is correct.
In practice, one would compute $|Σ|$
and then multiply it by $(2π)^d$, rather than multiply $Σ$ by $2π$, which involves $d^2$ operations, and then compute its determinant.
|
Normalization factor in multivariate Gaussian
Indeed the formula $$|2πΣ|=(2π)^d|Σ|$$ is correct.
In practice, one would compute $|Σ|$
and then multiply it by $(2π)^d$, rather than multiply $Σ$ by $2π$, which involves $d^2$ operations, and then c
|
43,417
|
Logistic Regression with R
|
My overall question: Why isn't logistic regression (including "family
= "binomial") producing results as expected, but a "NOT-logistic" regression (not including "family = "binomial") does?
You get different results as the linear models minimizes
$$
\sum_{i = 1}^n (y_i - \eta_i)^2
$$
whereas the logistic regression minimizes:
$$
\sum_{i = 1}^n
y_i \log(\frac{1}{1 + \exp(-\eta_i)}) +
(1 - y_i) \log(1 - \frac{1}{1 + \exp(-\eta_i)})
$$
where
$$
\eta_i = \beta_0 + \beta_1 UV_1 + \beta_2 UV_2
$$
There is no reason the results should be the same.
But why does the correlation influence the results of the logistic
regression and not the results of the "not-logistic" regression?
It is going to affect both. I presume you also see lower Std. Errors in the linear model. This is an issue with multicollinearity though you might not call this multicollinearity when you only have two variables with correlation $.56$.
|
Logistic Regression with R
|
My overall question: Why isn't logistic regression (including "family
= "binomial") producing results as expected, but a "NOT-logistic" regression (not including "family = "binomial") does?
You get
|
Logistic Regression with R
My overall question: Why isn't logistic regression (including "family
= "binomial") producing results as expected, but a "NOT-logistic" regression (not including "family = "binomial") does?
You get different results as the linear models minimizes
$$
\sum_{i = 1}^n (y_i - \eta_i)^2
$$
whereas the logistic regression minimizes:
$$
\sum_{i = 1}^n
y_i \log(\frac{1}{1 + \exp(-\eta_i)}) +
(1 - y_i) \log(1 - \frac{1}{1 + \exp(-\eta_i)})
$$
where
$$
\eta_i = \beta_0 + \beta_1 UV_1 + \beta_2 UV_2
$$
There is no reason the results should be the same.
But why does the correlation influence the results of the logistic
regression and not the results of the "not-logistic" regression?
It is going to affect both. I presume you also see lower Std. Errors in the linear model. This is an issue with multicollinearity though you might not call this multicollinearity when you only have two variables with correlation $.56$.
|
Logistic Regression with R
My overall question: Why isn't logistic regression (including "family
= "binomial") producing results as expected, but a "NOT-logistic" regression (not including "family = "binomial") does?
You get
|
43,418
|
Comparing approaches of MLE estimates of a Weibull distribution
|
Weibull parameter estimation is typically done with gradient-descent-related algorithms. As far as I know most packages implements this by doing a location-scale transformation and then running the procedure on the resulting Gumbel-log-likelihood.
Check related
|
Comparing approaches of MLE estimates of a Weibull distribution
|
Weibull parameter estimation is typically done with gradient-descent-related algorithms. As far as I know most packages implements this by doing a location-scale transformation and then running the pr
|
Comparing approaches of MLE estimates of a Weibull distribution
Weibull parameter estimation is typically done with gradient-descent-related algorithms. As far as I know most packages implements this by doing a location-scale transformation and then running the procedure on the resulting Gumbel-log-likelihood.
Check related
|
Comparing approaches of MLE estimates of a Weibull distribution
Weibull parameter estimation is typically done with gradient-descent-related algorithms. As far as I know most packages implements this by doing a location-scale transformation and then running the pr
|
43,419
|
Determine if two distributions are the same
|
Kolmogorov–Smirnov statistic may help you in this case.
Following is an implementation which uses Kolmogorov-Smirnov statistic and the function returns the probability of similarity.
#include <math.h>
#define EPS1 0.001
#define EPS2 1.0e-8
float kstest(float alam) {
int j;
float a2, fac = 2.0, sum = 0.0, term, termbf = 0.0;
a2 = -2.0 * alam * alam;
for (j = 1; j <= 100; j++) {
term = fac * exp(a2 * j * j);
sum += term;
if (fabs(term) <= EPS1 * termbf || fabs(term) <= EPS2 * sum)
return sum;
fac = -fac;
termbf = fabs(term);
}
return 1.0;
}
void checkSameDist(float data1[], unsigned long n1, float data2[],
unsigned long n2, float *d, float *prob) {
float kstest(float alam);
void sort(unsigned long n, float arr[]);
unsigned long j1 = 1,
j2 = 1;
float d1, d2, dt, en1, en2, en, fn1 = 0.0, fn2 = 0.0;
sort(n1, data1);
sort(n2, data2);
en1 = n1;
en2 = n2;
*d = 0.0;
while (j1 <= n1 && j2 <= n2) {
if ((d1 = data1[j1]) <= (d2 = data2[j2]))
fn1 = j1++ / en1;
if (d2 <= d1)
fn2 = j2++ / en2;
if ((dt = fabs(fn2 - fn1)) > *d)
*d = dt;
}
en = sqrt(en1 * en2 / (en1 + en2));
*prob = kstest((en + 0.12 + 0.11 / en) * (*d));
}
Also check, following function checks if a particular distribution is normal, you could modify it a little bit (this would give you more intuition about the statistic and how can you implement it from scratch
(https://walteis.wordpress.com/2012/04/26/a-kolmogorov-smirnov-implementation/)
public bool IsNormal
{
get
{
// This method uses the Kolmogorov-Smirnov test to determine a normal distribution.
// The level of significance (alpha) used is .05, and the critical values used are from Table 1 of:
// The Kolmogorov-Smirnov Test for Goodness of Fit
// Frank J. Massey, Jr.
// Journal of the American Statistical Association
// Vol. 46, No. 253 (Mar., 1951) (pp. 68-78)
if (DataSet.Count == 0)
return false;
List<double> vals = DataSet.Values.ToList();
Accumulator acc = new Accumulator(vals.ToArray());
double dmax = double.MinValue;
double cv = 0;
MathNet.Numerics.Distributions.NormalDistribution test = new MathNet.Numerics.Distributions.NormalDistribution(acc.Mean, acc.Sigma);
// the 0 entry is to force the list to be a base 1 index table.
List<double> cvTable = new List<double>() { 0, .975, .842, .708, .624, .565,
.521, .486, .457, .432, .410,
.391, .375, .361, .349, .338,
.328, .318, .309, .301, .294};
test.EstimateDistributionParameters(DataSet.Values.ToArray());
vals.Sort();
for (int i = 0; i < vals.Count; i++)
{
double dr = Math.Abs(((i + 1) / (double)vals.Count) - test.CumulativeDistribution(vals[i]));
double dl = Math.Abs(test.CumulativeDistribution(vals[i]) - (i / (double)vals.Count));
dmax = Math.Max(dmax, Math.Max(dl, dr));
}
// get critical value and compare to d(N)
if (vals.Count <= 10)
cv = cvTable[vals.Count];
else if (vals.Count > 10)
cv = 1.36 / Math.Sqrt(vals.Count);
return (dmax < cv);
}
}
Best of Luck
|
Determine if two distributions are the same
|
Kolmogorov–Smirnov statistic may help you in this case.
Following is an implementation which uses Kolmogorov-Smirnov statistic and the function returns the probability of similarity.
#include <math.h>
|
Determine if two distributions are the same
Kolmogorov–Smirnov statistic may help you in this case.
Following is an implementation which uses Kolmogorov-Smirnov statistic and the function returns the probability of similarity.
#include <math.h>
#define EPS1 0.001
#define EPS2 1.0e-8
float kstest(float alam) {
int j;
float a2, fac = 2.0, sum = 0.0, term, termbf = 0.0;
a2 = -2.0 * alam * alam;
for (j = 1; j <= 100; j++) {
term = fac * exp(a2 * j * j);
sum += term;
if (fabs(term) <= EPS1 * termbf || fabs(term) <= EPS2 * sum)
return sum;
fac = -fac;
termbf = fabs(term);
}
return 1.0;
}
void checkSameDist(float data1[], unsigned long n1, float data2[],
unsigned long n2, float *d, float *prob) {
float kstest(float alam);
void sort(unsigned long n, float arr[]);
unsigned long j1 = 1,
j2 = 1;
float d1, d2, dt, en1, en2, en, fn1 = 0.0, fn2 = 0.0;
sort(n1, data1);
sort(n2, data2);
en1 = n1;
en2 = n2;
*d = 0.0;
while (j1 <= n1 && j2 <= n2) {
if ((d1 = data1[j1]) <= (d2 = data2[j2]))
fn1 = j1++ / en1;
if (d2 <= d1)
fn2 = j2++ / en2;
if ((dt = fabs(fn2 - fn1)) > *d)
*d = dt;
}
en = sqrt(en1 * en2 / (en1 + en2));
*prob = kstest((en + 0.12 + 0.11 / en) * (*d));
}
Also check, following function checks if a particular distribution is normal, you could modify it a little bit (this would give you more intuition about the statistic and how can you implement it from scratch
(https://walteis.wordpress.com/2012/04/26/a-kolmogorov-smirnov-implementation/)
public bool IsNormal
{
get
{
// This method uses the Kolmogorov-Smirnov test to determine a normal distribution.
// The level of significance (alpha) used is .05, and the critical values used are from Table 1 of:
// The Kolmogorov-Smirnov Test for Goodness of Fit
// Frank J. Massey, Jr.
// Journal of the American Statistical Association
// Vol. 46, No. 253 (Mar., 1951) (pp. 68-78)
if (DataSet.Count == 0)
return false;
List<double> vals = DataSet.Values.ToList();
Accumulator acc = new Accumulator(vals.ToArray());
double dmax = double.MinValue;
double cv = 0;
MathNet.Numerics.Distributions.NormalDistribution test = new MathNet.Numerics.Distributions.NormalDistribution(acc.Mean, acc.Sigma);
// the 0 entry is to force the list to be a base 1 index table.
List<double> cvTable = new List<double>() { 0, .975, .842, .708, .624, .565,
.521, .486, .457, .432, .410,
.391, .375, .361, .349, .338,
.328, .318, .309, .301, .294};
test.EstimateDistributionParameters(DataSet.Values.ToArray());
vals.Sort();
for (int i = 0; i < vals.Count; i++)
{
double dr = Math.Abs(((i + 1) / (double)vals.Count) - test.CumulativeDistribution(vals[i]));
double dl = Math.Abs(test.CumulativeDistribution(vals[i]) - (i / (double)vals.Count));
dmax = Math.Max(dmax, Math.Max(dl, dr));
}
// get critical value and compare to d(N)
if (vals.Count <= 10)
cv = cvTable[vals.Count];
else if (vals.Count > 10)
cv = 1.36 / Math.Sqrt(vals.Count);
return (dmax < cv);
}
}
Best of Luck
|
Determine if two distributions are the same
Kolmogorov–Smirnov statistic may help you in this case.
Following is an implementation which uses Kolmogorov-Smirnov statistic and the function returns the probability of similarity.
#include <math.h>
|
43,420
|
Approximate Metropolis algorithm - does it make sense?
|
No, I don't see why this is a bad idea. It seems to me that it is a natural (and interesting) extension to draw samples from a CDF.
However, I believe that the acceptance should be
$$ \min\left( \frac{F(Y+\varepsilon) - F(Y)}{F(x^{(t)}+\varepsilon) - F(x^{(t)})} , 1 \right) $$
because by definition
$$ \lim_{\varepsilon\rightarrow 0}\frac{F(x + \varepsilon) - F(x)}{\varepsilon} = PDF(x)$$
Nevertheless, it is the first time I see this. With a strong case for sampling from a non-trivial CDF, this could become an interesting publication.
|
Approximate Metropolis algorithm - does it make sense?
|
No, I don't see why this is a bad idea. It seems to me that it is a natural (and interesting) extension to draw samples from a CDF.
However, I believe that the acceptance should be
$$ \min\left( \fr
|
Approximate Metropolis algorithm - does it make sense?
No, I don't see why this is a bad idea. It seems to me that it is a natural (and interesting) extension to draw samples from a CDF.
However, I believe that the acceptance should be
$$ \min\left( \frac{F(Y+\varepsilon) - F(Y)}{F(x^{(t)}+\varepsilon) - F(x^{(t)})} , 1 \right) $$
because by definition
$$ \lim_{\varepsilon\rightarrow 0}\frac{F(x + \varepsilon) - F(x)}{\varepsilon} = PDF(x)$$
Nevertheless, it is the first time I see this. With a strong case for sampling from a non-trivial CDF, this could become an interesting publication.
|
Approximate Metropolis algorithm - does it make sense?
No, I don't see why this is a bad idea. It seems to me that it is a natural (and interesting) extension to draw samples from a CDF.
However, I believe that the acceptance should be
$$ \min\left( \fr
|
43,421
|
Aggregation of Correlations Coefficients (Spearman)
|
I'm curious, since you have these ranks, why are you calculating correlation coefficients? I think a better approach would be to use a procedure that is designed to deal with ranks.
The Mann Whitney U test (or Wilcoxon Rank Sum test, they're the same thing) tests. This test concerns itself with whether or not the observations in group A are more likely to be greater than the observations in group B. In this test, the null hypothesis is the P(A > B) = P (B > A) (i.e. the observations from each population are equally likely to be larger than the other). If the test rejects, it's more likely that one group tends to have larger ranks than the other.
This seems to be exactly what your research question is, so I'd recommend this test instead of calculating correlation coefficients with these ranks. It's a fairly well known, commonly used test, so you shouldn't have any trouble justifying it to anyone either.
Let me know if you have any questions.
|
Aggregation of Correlations Coefficients (Spearman)
|
I'm curious, since you have these ranks, why are you calculating correlation coefficients? I think a better approach would be to use a procedure that is designed to deal with ranks.
The Mann Whitney U
|
Aggregation of Correlations Coefficients (Spearman)
I'm curious, since you have these ranks, why are you calculating correlation coefficients? I think a better approach would be to use a procedure that is designed to deal with ranks.
The Mann Whitney U test (or Wilcoxon Rank Sum test, they're the same thing) tests. This test concerns itself with whether or not the observations in group A are more likely to be greater than the observations in group B. In this test, the null hypothesis is the P(A > B) = P (B > A) (i.e. the observations from each population are equally likely to be larger than the other). If the test rejects, it's more likely that one group tends to have larger ranks than the other.
This seems to be exactly what your research question is, so I'd recommend this test instead of calculating correlation coefficients with these ranks. It's a fairly well known, commonly used test, so you shouldn't have any trouble justifying it to anyone either.
Let me know if you have any questions.
|
Aggregation of Correlations Coefficients (Spearman)
I'm curious, since you have these ranks, why are you calculating correlation coefficients? I think a better approach would be to use a procedure that is designed to deal with ranks.
The Mann Whitney U
|
43,422
|
Aggregation of Correlations Coefficients (Spearman)
|
Mhhhh, so you would like to compare the distributions of correlation coefficients? How about to use a Kolmogorov-Smirnov test?
correpl <- t(replicate(1000, {
scores <- rnorm(15)
a <- rank(scores, ties.method = "r")
### experiment with sd = x to give some weights closer or farther to a
b <- rank(scores + rnorm(15, sd = 5), ties.method = "r")
c <- rank(scores + rnorm(15, sd = 6), ties.method = "r")
return(c(cor(a,b), cor(b, c)))
}))
c1 <- correpl[,1]
c2 <- correpl[,2]
curve(ecdf(c1)(x), from = -1, to = 1)
curve(ecdf(c2)(x), from = -1, to = 1, col = "red", add = T)
ks.test(c1, c2)
It is sensitive enough (too sensitive for my taste) to spot slightest differences and it is non-parametric. Try to experiment with the alternative setting.
|
Aggregation of Correlations Coefficients (Spearman)
|
Mhhhh, so you would like to compare the distributions of correlation coefficients? How about to use a Kolmogorov-Smirnov test?
correpl <- t(replicate(1000, {
scores <- rnorm(15)
a <- rank(scor
|
Aggregation of Correlations Coefficients (Spearman)
Mhhhh, so you would like to compare the distributions of correlation coefficients? How about to use a Kolmogorov-Smirnov test?
correpl <- t(replicate(1000, {
scores <- rnorm(15)
a <- rank(scores, ties.method = "r")
### experiment with sd = x to give some weights closer or farther to a
b <- rank(scores + rnorm(15, sd = 5), ties.method = "r")
c <- rank(scores + rnorm(15, sd = 6), ties.method = "r")
return(c(cor(a,b), cor(b, c)))
}))
c1 <- correpl[,1]
c2 <- correpl[,2]
curve(ecdf(c1)(x), from = -1, to = 1)
curve(ecdf(c2)(x), from = -1, to = 1, col = "red", add = T)
ks.test(c1, c2)
It is sensitive enough (too sensitive for my taste) to spot slightest differences and it is non-parametric. Try to experiment with the alternative setting.
|
Aggregation of Correlations Coefficients (Spearman)
Mhhhh, so you would like to compare the distributions of correlation coefficients? How about to use a Kolmogorov-Smirnov test?
correpl <- t(replicate(1000, {
scores <- rnorm(15)
a <- rank(scor
|
43,423
|
Fractional dependent variable: Why not use Poisson regression?
|
One reason not to use Poisson regression here is that, since each employee can have at most one account, the number of accounts is bounded by the number of employees. A Poisson distribution would allow nonzero probability for the number of accounts exceeding the number of employees. My understanding is that although Poisson regressions are robust to a lot of violations of assumptions, you'd at least get a loss of efficiency from using a Poisson regression compared to something more appropriate.
The question then should be: wouldn't a binomial regression be more appropriate? (Assuming the same participation rate $p$ for each employee, the number of plans $y$ should be distributed as $Binomial(n,p)$ where $n$ is the number of employees.) IIRC, the reason a binomial regression can't be employed in this case is that the number of employees is not known; only the participation rate itself is known. That rules out binomial regression---and would also rule out Poisson regression with an offset, even if it were appropriate.
|
Fractional dependent variable: Why not use Poisson regression?
|
One reason not to use Poisson regression here is that, since each employee can have at most one account, the number of accounts is bounded by the number of employees. A Poisson distribution would all
|
Fractional dependent variable: Why not use Poisson regression?
One reason not to use Poisson regression here is that, since each employee can have at most one account, the number of accounts is bounded by the number of employees. A Poisson distribution would allow nonzero probability for the number of accounts exceeding the number of employees. My understanding is that although Poisson regressions are robust to a lot of violations of assumptions, you'd at least get a loss of efficiency from using a Poisson regression compared to something more appropriate.
The question then should be: wouldn't a binomial regression be more appropriate? (Assuming the same participation rate $p$ for each employee, the number of plans $y$ should be distributed as $Binomial(n,p)$ where $n$ is the number of employees.) IIRC, the reason a binomial regression can't be employed in this case is that the number of employees is not known; only the participation rate itself is known. That rules out binomial regression---and would also rule out Poisson regression with an offset, even if it were appropriate.
|
Fractional dependent variable: Why not use Poisson regression?
One reason not to use Poisson regression here is that, since each employee can have at most one account, the number of accounts is bounded by the number of employees. A Poisson distribution would all
|
43,424
|
Clustering very small datasets
|
For tiny data sets, hierarchical clustering is the method of choice.
The dendrogram visualization allows you to visually verify how well the data clusters, if there are outliers, how clusters nest, and how many clusters exist.
|
Clustering very small datasets
|
For tiny data sets, hierarchical clustering is the method of choice.
The dendrogram visualization allows you to visually verify how well the data clusters, if there are outliers, how clusters nest, an
|
Clustering very small datasets
For tiny data sets, hierarchical clustering is the method of choice.
The dendrogram visualization allows you to visually verify how well the data clusters, if there are outliers, how clusters nest, and how many clusters exist.
|
Clustering very small datasets
For tiny data sets, hierarchical clustering is the method of choice.
The dendrogram visualization allows you to visually verify how well the data clusters, if there are outliers, how clusters nest, an
|
43,425
|
What is the best form (Gaussian, Multinomial) of Naive Bayes to use with categorical (one-hot encoded) features?
|
As others mentioned, there isn't a "right" model. However, since you used one-hot encoding, you are basically dealing with boolean features now. In other words each term/feature is following a Bernoulli distribution. That being said, I would use a multivariate Bernoulli NB or a multinomial NB with boolean features (which you already have). Gaussian NB seems a bit off here since you don't deal with real-valued features.
This excellent paper has a lot of information on different NB variants and when to use which.
|
What is the best form (Gaussian, Multinomial) of Naive Bayes to use with categorical (one-hot encode
|
As others mentioned, there isn't a "right" model. However, since you used one-hot encoding, you are basically dealing with boolean features now. In other words each term/feature is following a Bernoul
|
What is the best form (Gaussian, Multinomial) of Naive Bayes to use with categorical (one-hot encoded) features?
As others mentioned, there isn't a "right" model. However, since you used one-hot encoding, you are basically dealing with boolean features now. In other words each term/feature is following a Bernoulli distribution. That being said, I would use a multivariate Bernoulli NB or a multinomial NB with boolean features (which you already have). Gaussian NB seems a bit off here since you don't deal with real-valued features.
This excellent paper has a lot of information on different NB variants and when to use which.
|
What is the best form (Gaussian, Multinomial) of Naive Bayes to use with categorical (one-hot encode
As others mentioned, there isn't a "right" model. However, since you used one-hot encoding, you are basically dealing with boolean features now. In other words each term/feature is following a Bernoul
|
43,426
|
What is the best form (Gaussian, Multinomial) of Naive Bayes to use with categorical (one-hot encoded) features?
|
Your choice of statistical model in classification (Gaussian NB, Multinomial NB, etc) depends on the distribution of your input variables. You should plot the histogram of each input parameter in order to determine their distribution.
You can use Pandas to do this by creating a dataframe on your input matrix and running .hist() on it, as follows:
X_frame = pd.DataFrame(X, index=natural_index(dataset))
X_frame.hist()
|
What is the best form (Gaussian, Multinomial) of Naive Bayes to use with categorical (one-hot encode
|
Your choice of statistical model in classification (Gaussian NB, Multinomial NB, etc) depends on the distribution of your input variables. You should plot the histogram of each input parameter in ord
|
What is the best form (Gaussian, Multinomial) of Naive Bayes to use with categorical (one-hot encoded) features?
Your choice of statistical model in classification (Gaussian NB, Multinomial NB, etc) depends on the distribution of your input variables. You should plot the histogram of each input parameter in order to determine their distribution.
You can use Pandas to do this by creating a dataframe on your input matrix and running .hist() on it, as follows:
X_frame = pd.DataFrame(X, index=natural_index(dataset))
X_frame.hist()
|
What is the best form (Gaussian, Multinomial) of Naive Bayes to use with categorical (one-hot encode
Your choice of statistical model in classification (Gaussian NB, Multinomial NB, etc) depends on the distribution of your input variables. You should plot the histogram of each input parameter in ord
|
43,427
|
What is the best form (Gaussian, Multinomial) of Naive Bayes to use with categorical (one-hot encoded) features?
|
If you're using real-world data, it's very unlikely that any model will be "right," so rather than try to find a model that is "right," you should try to find a model that is accurate. To decide between those two models, you can use cross validation to get an estimate of the accuracy of each model and choose the better one. At the end of the day, you can't be be confident about which model will perform best on your data without actually running the models on your data in some capacity, even if one model is used in similar applications.
I would also suggest a third Naive Bayes model that you could try. Instead of using a one-hot encoder, let the class-conditional density of each feature be a categorical distribution.
More precisely, suppose $Y_i \in \{1, ..., C\}$ is the label for data point $i$. Suppose $X_i$ is the data for data point $i$ and suppose that each feature is $X_{ij} \in \{1, ..., K\}$. In other words, suppose that each feature is categorical with $K$ values. You could use the model $P(X_{ij} = k|Y_{i} = c, \theta) = \theta_{cjk}$ where $\forall c \forall j$, $\sum_{k=1}^K \theta_{cjk} = 1$.
|
What is the best form (Gaussian, Multinomial) of Naive Bayes to use with categorical (one-hot encode
|
If you're using real-world data, it's very unlikely that any model will be "right," so rather than try to find a model that is "right," you should try to find a model that is accurate. To decide betwe
|
What is the best form (Gaussian, Multinomial) of Naive Bayes to use with categorical (one-hot encoded) features?
If you're using real-world data, it's very unlikely that any model will be "right," so rather than try to find a model that is "right," you should try to find a model that is accurate. To decide between those two models, you can use cross validation to get an estimate of the accuracy of each model and choose the better one. At the end of the day, you can't be be confident about which model will perform best on your data without actually running the models on your data in some capacity, even if one model is used in similar applications.
I would also suggest a third Naive Bayes model that you could try. Instead of using a one-hot encoder, let the class-conditional density of each feature be a categorical distribution.
More precisely, suppose $Y_i \in \{1, ..., C\}$ is the label for data point $i$. Suppose $X_i$ is the data for data point $i$ and suppose that each feature is $X_{ij} \in \{1, ..., K\}$. In other words, suppose that each feature is categorical with $K$ values. You could use the model $P(X_{ij} = k|Y_{i} = c, \theta) = \theta_{cjk}$ where $\forall c \forall j$, $\sum_{k=1}^K \theta_{cjk} = 1$.
|
What is the best form (Gaussian, Multinomial) of Naive Bayes to use with categorical (one-hot encode
If you're using real-world data, it's very unlikely that any model will be "right," so rather than try to find a model that is "right," you should try to find a model that is accurate. To decide betwe
|
43,428
|
What is the best form (Gaussian, Multinomial) of Naive Bayes to use with categorical (one-hot encoded) features?
|
I would suggest to plot a histogram. For a quick histogram you can do this:
Load data into a pandas dataframe:
df = pandas.Dataframe( data, optional parameters)
df.hist()
If most of your features are following a bernoulli distribution , you should be good to use Multinomial (Bernoulli) NB and if they are following a Gaussian (Normal) distribution, Gaussian Bayes should be good.
In case your distributions of features seems to be complex (a mixture of different distributions), it would be good to consider dimensionality reduction to make sure you have most, though not all, features to have similar distribution.
|
What is the best form (Gaussian, Multinomial) of Naive Bayes to use with categorical (one-hot encode
|
I would suggest to plot a histogram. For a quick histogram you can do this:
Load data into a pandas dataframe:
df = pandas.Dataframe( data, optional parameters)
df.hist()
If most of your features ar
|
What is the best form (Gaussian, Multinomial) of Naive Bayes to use with categorical (one-hot encoded) features?
I would suggest to plot a histogram. For a quick histogram you can do this:
Load data into a pandas dataframe:
df = pandas.Dataframe( data, optional parameters)
df.hist()
If most of your features are following a bernoulli distribution , you should be good to use Multinomial (Bernoulli) NB and if they are following a Gaussian (Normal) distribution, Gaussian Bayes should be good.
In case your distributions of features seems to be complex (a mixture of different distributions), it would be good to consider dimensionality reduction to make sure you have most, though not all, features to have similar distribution.
|
What is the best form (Gaussian, Multinomial) of Naive Bayes to use with categorical (one-hot encode
I would suggest to plot a histogram. For a quick histogram you can do this:
Load data into a pandas dataframe:
df = pandas.Dataframe( data, optional parameters)
df.hist()
If most of your features ar
|
43,429
|
Why does Bayesian p-value involve the parameters in addition to the data?
|
The p-value is used to express the outcome in a test of a model and it's parameters (to test a hypothesis). Typically it relates to some statistic that measures a discrepancy (e.g. distance from the expected mean).
$P(T> t_{observed}|H_0)$
The probability that an observation of the statistic $T$ given the null hypothesis $H_0$ is larger than the observed value of the statistic $t_{observed}$.
The Bayesian p-value is much the same. It is used in the tests of the assumptions that are used to fit the model. And in this way is like a test for goodness of fit (for instance like a Pearson's Chi-squared test). The main difference with the Bayesian p-value/hypothesis is that the model is not with fixed parameters, but instead the parameters are variables themselves.
I don't quite understand why it makes sense to have the test statistic be a function of the parameters, $\theta$
The statistic that is used to compared the observation with the hypothetical model is often a pivotal quantity.
You do not compare two observations. E.g. whether $Y_{rep} > Y$
But instead you compare two observations in relation to the hypothetical model. E.g. whether $|Y_{rep}-\mu| > |Y-\mu|$. Whether the difference of the observation $Y$ from the mode of the model, is comparable to a likely random fluctuation $Y_{rep}$ or whether it is an unlikely value for which the we should consider the observation as a anomaly.
I hope this difference of observation and model makes intuitive sense. These statistics used for computing p-values can be somewhat arbitrary. The likelihood ratio test makes this a bit more formal.
Why don't we use the following test statistic instead, relying purely on the data?
$$
T(y, \theta) = | y_{(61)} - \bar y | - |y_{(6)} - \bar y |
$$
We do not make the statistic purely based on data because we want to test the data with relation to the model. It needs to be dependent on $\theta$ or otherwise it will not be a goodness of fit for $\theta$.
You can have in some way an expression for a statistic that tests data with "data".
$$
T(y, \theta) = | y_{(61)} - \hat y | - |y_{(6)} - \hat y |
$$
here $\hat y$ is the estimated value of $y$.
|
Why does Bayesian p-value involve the parameters in addition to the data?
|
The p-value is used to express the outcome in a test of a model and it's parameters (to test a hypothesis). Typically it relates to some statistic that measures a discrepancy (e.g. distance from the e
|
Why does Bayesian p-value involve the parameters in addition to the data?
The p-value is used to express the outcome in a test of a model and it's parameters (to test a hypothesis). Typically it relates to some statistic that measures a discrepancy (e.g. distance from the expected mean).
$P(T> t_{observed}|H_0)$
The probability that an observation of the statistic $T$ given the null hypothesis $H_0$ is larger than the observed value of the statistic $t_{observed}$.
The Bayesian p-value is much the same. It is used in the tests of the assumptions that are used to fit the model. And in this way is like a test for goodness of fit (for instance like a Pearson's Chi-squared test). The main difference with the Bayesian p-value/hypothesis is that the model is not with fixed parameters, but instead the parameters are variables themselves.
I don't quite understand why it makes sense to have the test statistic be a function of the parameters, $\theta$
The statistic that is used to compared the observation with the hypothetical model is often a pivotal quantity.
You do not compare two observations. E.g. whether $Y_{rep} > Y$
But instead you compare two observations in relation to the hypothetical model. E.g. whether $|Y_{rep}-\mu| > |Y-\mu|$. Whether the difference of the observation $Y$ from the mode of the model, is comparable to a likely random fluctuation $Y_{rep}$ or whether it is an unlikely value for which the we should consider the observation as a anomaly.
I hope this difference of observation and model makes intuitive sense. These statistics used for computing p-values can be somewhat arbitrary. The likelihood ratio test makes this a bit more formal.
Why don't we use the following test statistic instead, relying purely on the data?
$$
T(y, \theta) = | y_{(61)} - \bar y | - |y_{(6)} - \bar y |
$$
We do not make the statistic purely based on data because we want to test the data with relation to the model. It needs to be dependent on $\theta$ or otherwise it will not be a goodness of fit for $\theta$.
You can have in some way an expression for a statistic that tests data with "data".
$$
T(y, \theta) = | y_{(61)} - \hat y | - |y_{(6)} - \hat y |
$$
here $\hat y$ is the estimated value of $y$.
|
Why does Bayesian p-value involve the parameters in addition to the data?
The p-value is used to express the outcome in a test of a model and it's parameters (to test a hypothesis). Typically it relates to some statistic that measures a discrepancy (e.g. distance from the e
|
43,430
|
Why does Bayesian p-value involve the parameters in addition to the data?
|
There is nothing stopping you from using test statistics based solely on the replicate data.
The point in the example is that the model assumes $y_i$ is normally distributed around a mean $\theta$ not around $\overline{y}$. Thus the test statistic provided in Gelman et. al. tests something about the normality assumption whereas its not really clear what your test statistic is testing.
|
Why does Bayesian p-value involve the parameters in addition to the data?
|
There is nothing stopping you from using test statistics based solely on the replicate data.
The point in the example is that the model assumes $y_i$ is normally distributed around a mean $\theta$ no
|
Why does Bayesian p-value involve the parameters in addition to the data?
There is nothing stopping you from using test statistics based solely on the replicate data.
The point in the example is that the model assumes $y_i$ is normally distributed around a mean $\theta$ not around $\overline{y}$. Thus the test statistic provided in Gelman et. al. tests something about the normality assumption whereas its not really clear what your test statistic is testing.
|
Why does Bayesian p-value involve the parameters in addition to the data?
There is nothing stopping you from using test statistics based solely on the replicate data.
The point in the example is that the model assumes $y_i$ is normally distributed around a mean $\theta$ no
|
43,431
|
Measure-Theoretic Definition of MLE
|
That definition of the likelihood function is an approximation. Typically, you have $n$ observations, which are subject to a measurement error. So, in practice, instead of observing $x_j$, you observe $x_j\pm\epsilon$, where $\epsilon\gt 0$ is the measurement error. So, if you have a sample of $n$ i.i.d. observations, the likelihood function, for a parametric probability model ${\mathbb P}(;\theta)$, is written as:
$$L(\theta;x_1,\dots,x_n) = \prod_{j=1}^n {\mathbb P}[(x_j-\epsilon,x_j+\epsilon);\theta].$$
The maximum likelihood estimator is then, the value of the parameter that maximizes the probability under the sample of interest.
Suppose that $F(;\theta)$ is the distribution associated to the probabilities ${\mathbb P}(;\theta)$, then, you get that
$$L(\theta;x_1,\dots,x_n) = \prod_{j=1}^n \{F[x_j+\epsilon;\theta]-F[x_j-\epsilon;\theta]\}.$$
If $\epsilon$ is small enough, by the mean value theorem you have that
$$F[x_j+\epsilon;\theta]-F[x_j-\epsilon;\theta]\approx 2\epsilon f(x_j),$$
Consequently, you obtain the continuous approximation to the likelihood function
$$L(\theta;x_1,\dots,x_n) \propto \prod_{j=1}^n f(x_j;\theta).$$
This relationship is explained in:
Probability and Statistical Inference II: 002 (Universitext) Paperback – 7 Jan 1980
by J.G. Kalbfleisch
|
Measure-Theoretic Definition of MLE
|
That definition of the likelihood function is an approximation. Typically, you have $n$ observations, which are subject to a measurement error. So, in practice, instead of observing $x_j$, you observe
|
Measure-Theoretic Definition of MLE
That definition of the likelihood function is an approximation. Typically, you have $n$ observations, which are subject to a measurement error. So, in practice, instead of observing $x_j$, you observe $x_j\pm\epsilon$, where $\epsilon\gt 0$ is the measurement error. So, if you have a sample of $n$ i.i.d. observations, the likelihood function, for a parametric probability model ${\mathbb P}(;\theta)$, is written as:
$$L(\theta;x_1,\dots,x_n) = \prod_{j=1}^n {\mathbb P}[(x_j-\epsilon,x_j+\epsilon);\theta].$$
The maximum likelihood estimator is then, the value of the parameter that maximizes the probability under the sample of interest.
Suppose that $F(;\theta)$ is the distribution associated to the probabilities ${\mathbb P}(;\theta)$, then, you get that
$$L(\theta;x_1,\dots,x_n) = \prod_{j=1}^n \{F[x_j+\epsilon;\theta]-F[x_j-\epsilon;\theta]\}.$$
If $\epsilon$ is small enough, by the mean value theorem you have that
$$F[x_j+\epsilon;\theta]-F[x_j-\epsilon;\theta]\approx 2\epsilon f(x_j),$$
Consequently, you obtain the continuous approximation to the likelihood function
$$L(\theta;x_1,\dots,x_n) \propto \prod_{j=1}^n f(x_j;\theta).$$
This relationship is explained in:
Probability and Statistical Inference II: 002 (Universitext) Paperback – 7 Jan 1980
by J.G. Kalbfleisch
|
Measure-Theoretic Definition of MLE
That definition of the likelihood function is an approximation. Typically, you have $n$ observations, which are subject to a measurement error. So, in practice, instead of observing $x_j$, you observe
|
43,432
|
Measure-Theoretic Definition of MLE
|
You need the Radon–Nikodym theorem..
In the measure-theoretic problem, you are estimating a distribution $F_0$ that is defined on the sigma-algebra on the sample set, not on the sample set itself. Now suppose you have a parametric model $F(\cdot\mid\theta)$. If this model is dominated by a $\sigma$-finite measure $\mu$, then (by Radon–Nikodym) we can safely move to the associated family of density functions $f(\cdot \mid \theta)$, satisfying $F(A\mid\theta) = \int_A f(y\mid\theta) \, d\mu(y)$.
Clearly, if your measurement lies in a null set for every distribution in your model, your model or your observation is wrong (since the probability of your observation is zero in all distribution that are considered). On the other hand, if there is a distribution for which your measurement does not lie in any null set, then it also can't lie in a null set of $\mu$, and so you are not free to redefine your densities at your observation.
Note, however, that existence nor uniqueness of the MLE are guaranteed.
|
Measure-Theoretic Definition of MLE
|
You need the Radon–Nikodym theorem..
In the measure-theoretic problem, you are estimating a distribution $F_0$ that is defined on the sigma-algebra on the sample set, not on the sample set itself. Now
|
Measure-Theoretic Definition of MLE
You need the Radon–Nikodym theorem..
In the measure-theoretic problem, you are estimating a distribution $F_0$ that is defined on the sigma-algebra on the sample set, not on the sample set itself. Now suppose you have a parametric model $F(\cdot\mid\theta)$. If this model is dominated by a $\sigma$-finite measure $\mu$, then (by Radon–Nikodym) we can safely move to the associated family of density functions $f(\cdot \mid \theta)$, satisfying $F(A\mid\theta) = \int_A f(y\mid\theta) \, d\mu(y)$.
Clearly, if your measurement lies in a null set for every distribution in your model, your model or your observation is wrong (since the probability of your observation is zero in all distribution that are considered). On the other hand, if there is a distribution for which your measurement does not lie in any null set, then it also can't lie in a null set of $\mu$, and so you are not free to redefine your densities at your observation.
Note, however, that existence nor uniqueness of the MLE are guaranteed.
|
Measure-Theoretic Definition of MLE
You need the Radon–Nikodym theorem..
In the measure-theoretic problem, you are estimating a distribution $F_0$ that is defined on the sigma-algebra on the sample set, not on the sample set itself. Now
|
43,433
|
What is the relationship between LATE and TOT?
|
Writing out the estimands may help. With $Y$ as the observed outcome, $A$ is the treatment of interest, $Z$ is the instrument, and $Y^a$ is the potential outcome under treatment plan $A=a$.
For the TOT (or average treatment effect in the treated, ATT), the estimand is
$$E[Y^{a=1} - Y^{a=0} |A=1]$$
For LATE
$$E[Y^{a=1} - Y^{a=0} | A^{z=1} = 1, A^{z=0}=0]$$
From this, we can see that the TOT is estimated in the population all treated ($A=1$) individuals, whereas LATE applies to a subset of the treated individuals in the population. More specifically, LATE applies only to compliers as defined by $Z$
|
What is the relationship between LATE and TOT?
|
Writing out the estimands may help. With $Y$ as the observed outcome, $A$ is the treatment of interest, $Z$ is the instrument, and $Y^a$ is the potential outcome under treatment plan $A=a$.
For the T
|
What is the relationship between LATE and TOT?
Writing out the estimands may help. With $Y$ as the observed outcome, $A$ is the treatment of interest, $Z$ is the instrument, and $Y^a$ is the potential outcome under treatment plan $A=a$.
For the TOT (or average treatment effect in the treated, ATT), the estimand is
$$E[Y^{a=1} - Y^{a=0} |A=1]$$
For LATE
$$E[Y^{a=1} - Y^{a=0} | A^{z=1} = 1, A^{z=0}=0]$$
From this, we can see that the TOT is estimated in the population all treated ($A=1$) individuals, whereas LATE applies to a subset of the treated individuals in the population. More specifically, LATE applies only to compliers as defined by $Z$
|
What is the relationship between LATE and TOT?
Writing out the estimands may help. With $Y$ as the observed outcome, $A$ is the treatment of interest, $Z$ is the instrument, and $Y^a$ is the potential outcome under treatment plan $A=a$.
For the T
|
43,434
|
What is the relationship between LATE and TOT?
|
LATE is a subset of TOT....I quote from Mastering 'Metrics by Angrist and Pischke:
"Researchers and policy makers are sometimes interested in average causal effects for the entire treated population, as well as in LATE. This average causal effect is called the treatment effect on the treated (TOT for short)" (Chapter 3 Section 1)
|
What is the relationship between LATE and TOT?
|
LATE is a subset of TOT....I quote from Mastering 'Metrics by Angrist and Pischke:
"Researchers and policy makers are sometimes interested in average causal effects for the entire treated population,
|
What is the relationship between LATE and TOT?
LATE is a subset of TOT....I quote from Mastering 'Metrics by Angrist and Pischke:
"Researchers and policy makers are sometimes interested in average causal effects for the entire treated population, as well as in LATE. This average causal effect is called the treatment effect on the treated (TOT for short)" (Chapter 3 Section 1)
|
What is the relationship between LATE and TOT?
LATE is a subset of TOT....I quote from Mastering 'Metrics by Angrist and Pischke:
"Researchers and policy makers are sometimes interested in average causal effects for the entire treated population,
|
43,435
|
Deep Learning for Ordinal Classification
|
There are a few approaches. One is to do a one in hot encoding:
https://arxiv.org/pdf/0704.1028.pdf
But there should be other approaches. In classical ordinal regression, we fit cut off values st:
$ P(X=1) = P(Z \leq \theta_1) = F(\theta_1)$
$ P(X=2) = P(\theta_1 \leq Z \leq \theta_2) = F(\theta_2) - F(\theta_1)$
$ P(X=3) = P(Z \geq \theta_2) = 1- F(\theta_2)$
Where Z is some latent variable and F is the CDF of the latent variable. It should be possible to directly apply this approach where Z is the second to last layer (the layer before the softmax).
|
Deep Learning for Ordinal Classification
|
There are a few approaches. One is to do a one in hot encoding:
https://arxiv.org/pdf/0704.1028.pdf
But there should be other approaches. In classical ordinal regression, we fit cut off values st:
$
|
Deep Learning for Ordinal Classification
There are a few approaches. One is to do a one in hot encoding:
https://arxiv.org/pdf/0704.1028.pdf
But there should be other approaches. In classical ordinal regression, we fit cut off values st:
$ P(X=1) = P(Z \leq \theta_1) = F(\theta_1)$
$ P(X=2) = P(\theta_1 \leq Z \leq \theta_2) = F(\theta_2) - F(\theta_1)$
$ P(X=3) = P(Z \geq \theta_2) = 1- F(\theta_2)$
Where Z is some latent variable and F is the CDF of the latent variable. It should be possible to directly apply this approach where Z is the second to last layer (the layer before the softmax).
|
Deep Learning for Ordinal Classification
There are a few approaches. One is to do a one in hot encoding:
https://arxiv.org/pdf/0704.1028.pdf
But there should be other approaches. In classical ordinal regression, we fit cut off values st:
$
|
43,436
|
Accuracy of a polygon fitting algorithm
|
Maybe a different error metric will give you what you want. You can use the F1 score, which is the harmonic mean of precision and recall. Recall is the percentage of the area of the polygon that is contained in the rectangle. Precision is the percentage of area inside the rectangle that is within the polygon.
$F1 = \frac{P * R}{P + R}$
|
Accuracy of a polygon fitting algorithm
|
Maybe a different error metric will give you what you want. You can use the F1 score, which is the harmonic mean of precision and recall. Recall is the percentage of the area of the polygon that is co
|
Accuracy of a polygon fitting algorithm
Maybe a different error metric will give you what you want. You can use the F1 score, which is the harmonic mean of precision and recall. Recall is the percentage of the area of the polygon that is contained in the rectangle. Precision is the percentage of area inside the rectangle that is within the polygon.
$F1 = \frac{P * R}{P + R}$
|
Accuracy of a polygon fitting algorithm
Maybe a different error metric will give you what you want. You can use the F1 score, which is the harmonic mean of precision and recall. Recall is the percentage of the area of the polygon that is co
|
43,437
|
Why must linear regressions only generate linear functions that resemble "lines or planes" (*Introduction to Statistical Learning* question)?
|
Unfortunatelly my rating is too low to add a comment, that's why I have to answer.
Just imagine that there is some feature $Z$. $X_1 = \sin Z, \ X_2 = \cos Z$, and $f(X) = \beta_0 + \beta_1 X_1 + \beta_2 X_2 = \beta_0 + \beta_1 \sin Z + \beta_2 \cos Z$.
Will $f(X)$ be linear if the coordinate system is $(Y, Z)$? And what about $(Y, X_1, X_2)$?
|
Why must linear regressions only generate linear functions that resemble "lines or planes" (*Introdu
|
Unfortunatelly my rating is too low to add a comment, that's why I have to answer.
Just imagine that there is some feature $Z$. $X_1 = \sin Z, \ X_2 = \cos Z$, and $f(X) = \beta_0 + \beta_1 X_1 + \be
|
Why must linear regressions only generate linear functions that resemble "lines or planes" (*Introduction to Statistical Learning* question)?
Unfortunatelly my rating is too low to add a comment, that's why I have to answer.
Just imagine that there is some feature $Z$. $X_1 = \sin Z, \ X_2 = \cos Z$, and $f(X) = \beta_0 + \beta_1 X_1 + \beta_2 X_2 = \beta_0 + \beta_1 \sin Z + \beta_2 \cos Z$.
Will $f(X)$ be linear if the coordinate system is $(Y, Z)$? And what about $(Y, X_1, X_2)$?
|
Why must linear regressions only generate linear functions that resemble "lines or planes" (*Introdu
Unfortunatelly my rating is too low to add a comment, that's why I have to answer.
Just imagine that there is some feature $Z$. $X_1 = \sin Z, \ X_2 = \cos Z$, and $f(X) = \beta_0 + \beta_1 X_1 + \be
|
43,438
|
Does leaving out an important predictor in a mixed linear model violate the independence assumption?
|
We shouldn't leave out any variables that have a (significant) effect if we are interested in the causal effect and the design is not orthogonal.
If a variable is left out and this variable is correlated with an included variable, then the coefficient of the included variable includes part of the effect of the left out variable. This is standard missing confounder, omitted variable problem with typical text book case in Simpson's paradox.
"That is, if I have two samples of the same valence, I can predict that they will be more similar than two samples with different values."
This is the idea behind matching estimator, like for example propensity score matching, in that we want to remove the effect of left out confounders by comparing only similar individuals.
On the other hand, if the design is orthogonal with respect to the left out variables, i.e. those are not correlated with the included variables, then there is no distorting effect on the included coefficients.
|
Does leaving out an important predictor in a mixed linear model violate the independence assumption?
|
We shouldn't leave out any variables that have a (significant) effect if we are interested in the causal effect and the design is not orthogonal.
If a variable is left out and this variable is correla
|
Does leaving out an important predictor in a mixed linear model violate the independence assumption?
We shouldn't leave out any variables that have a (significant) effect if we are interested in the causal effect and the design is not orthogonal.
If a variable is left out and this variable is correlated with an included variable, then the coefficient of the included variable includes part of the effect of the left out variable. This is standard missing confounder, omitted variable problem with typical text book case in Simpson's paradox.
"That is, if I have two samples of the same valence, I can predict that they will be more similar than two samples with different values."
This is the idea behind matching estimator, like for example propensity score matching, in that we want to remove the effect of left out confounders by comparing only similar individuals.
On the other hand, if the design is orthogonal with respect to the left out variables, i.e. those are not correlated with the included variables, then there is no distorting effect on the included coefficients.
|
Does leaving out an important predictor in a mixed linear model violate the independence assumption?
We shouldn't leave out any variables that have a (significant) effect if we are interested in the causal effect and the design is not orthogonal.
If a variable is left out and this variable is correla
|
43,439
|
Does leaving out an important predictor in a mixed linear model violate the independence assumption?
|
First of all independence has nothing to do with the fact of dropping or adding a variable; remember that there is not a such test to prove the independence assumption, since it is related with your experimental design. Imagine this silly (but illustrative) example: “A political scientist is interested on people’s opinion about candidates for the next election in her county. For this study 100 participants were chosen randomly and they were interviewed and recorded during at most 5 minutes individually in a meeting room. During the study, the participants were asked to arrive at different times because the waiting room has only a capacity for 15 people. Also, it was possible for the participants on the waiting room to listen the opinion of the person who was being recorded at that moment in the meeting room.” On this case the independence assumption was totally violated since a participant’s opinion could be clearly influenced by the previous one. As you can see the data analysis has not even started and the independence assumption is already breached. So, remember independence has to do with your experimental design and not with your variables.
On the other hand, if you want to drop out the variable Valence you can do it and you will not violate the independence assumption, however it is possible that you will lose valuable information. Suppose that you find a model “A” that uses all the variables: valence, group, timepoint, predictability and some of their interactions (all significant). Suppose too that you obtain another model “B”, which only drops valence, you also observed that the coefficients for effects and interactions are significant. In theory both models would be a valid way to explain the variability in your response variable. Which one would be better? You would have to analyze how much variability is being explained by your independent variables in “A” and then repeat the same for “B”, if the difference is noticeable then valence would explain a great proportion of the total variability.
Personally, I would test more models using stepwise regression. At the end if you have several models you can also check for goodness of fit metrics like AIC or R2 in order to decide which one is better for you.
I hope this could be useful for you.
Good luck.
|
Does leaving out an important predictor in a mixed linear model violate the independence assumption?
|
First of all independence has nothing to do with the fact of dropping or adding a variable; remember that there is not a such test to prove the independence assumption, since it is related with your e
|
Does leaving out an important predictor in a mixed linear model violate the independence assumption?
First of all independence has nothing to do with the fact of dropping or adding a variable; remember that there is not a such test to prove the independence assumption, since it is related with your experimental design. Imagine this silly (but illustrative) example: “A political scientist is interested on people’s opinion about candidates for the next election in her county. For this study 100 participants were chosen randomly and they were interviewed and recorded during at most 5 minutes individually in a meeting room. During the study, the participants were asked to arrive at different times because the waiting room has only a capacity for 15 people. Also, it was possible for the participants on the waiting room to listen the opinion of the person who was being recorded at that moment in the meeting room.” On this case the independence assumption was totally violated since a participant’s opinion could be clearly influenced by the previous one. As you can see the data analysis has not even started and the independence assumption is already breached. So, remember independence has to do with your experimental design and not with your variables.
On the other hand, if you want to drop out the variable Valence you can do it and you will not violate the independence assumption, however it is possible that you will lose valuable information. Suppose that you find a model “A” that uses all the variables: valence, group, timepoint, predictability and some of their interactions (all significant). Suppose too that you obtain another model “B”, which only drops valence, you also observed that the coefficients for effects and interactions are significant. In theory both models would be a valid way to explain the variability in your response variable. Which one would be better? You would have to analyze how much variability is being explained by your independent variables in “A” and then repeat the same for “B”, if the difference is noticeable then valence would explain a great proportion of the total variability.
Personally, I would test more models using stepwise regression. At the end if you have several models you can also check for goodness of fit metrics like AIC or R2 in order to decide which one is better for you.
I hope this could be useful for you.
Good luck.
|
Does leaving out an important predictor in a mixed linear model violate the independence assumption?
First of all independence has nothing to do with the fact of dropping or adding a variable; remember that there is not a such test to prove the independence assumption, since it is related with your e
|
43,440
|
Does leaving out an important predictor in a mixed linear model violate the independence assumption?
|
You can still see the effects of group + timepoint + predictability and their interactions even when valence is left in the model. Keep in mind that interpreting interaction terms of continuous variables is quite difficult to interpret.
The condition of independence is that we are assuming that our data is a random sample from the population of interest. As a contrast to this condition, suppose we are interested in the number of pieces in a jigsaw puzzle and the time it takes to complete it. If all our data come from one person (e.g., multiple puzzles), who happens to be very good at jigsaw puzzles. Then our estimate of the line will be much lower than it should be, because this person will finish all the puzzles quickly, i.e. small values for $y_i$. However, had our data been independent, then we have the chance of also getting someone who is very bad at jigsaw puzzles and things even out in some way.
So what you need to ask yourself is, does leaving out valence violate the possibility of getting a random sample from the population of interest? (The answer is no.)
If your goal here is to build a linear model, I would suggest just performing some type of subset model selection. antoniom suggested stepwise regression, this would work...
library(MASS)
fit <- lm(y~(x1+x2+x3)^2 + x4, data = mydata)
step <- stepAIC(fit, direction="both")
step$anova # display results
Other options could be nested F-tests backward selection...
lm1 <- lm(y~(x1+x2+x3)^2 + x4, data = mydata)
drop1(lm1, test = "F")
If your goal is to predict, you can do CV with best subset...
library(leaps)
regfit.best=regsubsets(y~(x1+x2+x3)^2 + x4,data=Hitters[train ,], nvmax=)
test.mat=model.matrix(Salary∼.,data=Hitters [test ,])
val.errors =rep(NA ,nvmax)
for(i in 1:nvmax){coefi=coef(regfit.best ,id=i)
pred=test.mat[,names(coefi)]%*%coefi
val.errors[i]=mean(( Hitters$Salary[test]-pred)^2)
}
which.min(val.errors)
this gives best subset model's number of coefficients, then to find the model...
coef(regfit.best ,which.min(val.errors))
All of these methods will tell you valuable information about the relationships between variables without having to remove valence in the beginning.
|
Does leaving out an important predictor in a mixed linear model violate the independence assumption?
|
You can still see the effects of group + timepoint + predictability and their interactions even when valence is left in the model. Keep in mind that interpreting interaction terms of continuous variab
|
Does leaving out an important predictor in a mixed linear model violate the independence assumption?
You can still see the effects of group + timepoint + predictability and their interactions even when valence is left in the model. Keep in mind that interpreting interaction terms of continuous variables is quite difficult to interpret.
The condition of independence is that we are assuming that our data is a random sample from the population of interest. As a contrast to this condition, suppose we are interested in the number of pieces in a jigsaw puzzle and the time it takes to complete it. If all our data come from one person (e.g., multiple puzzles), who happens to be very good at jigsaw puzzles. Then our estimate of the line will be much lower than it should be, because this person will finish all the puzzles quickly, i.e. small values for $y_i$. However, had our data been independent, then we have the chance of also getting someone who is very bad at jigsaw puzzles and things even out in some way.
So what you need to ask yourself is, does leaving out valence violate the possibility of getting a random sample from the population of interest? (The answer is no.)
If your goal here is to build a linear model, I would suggest just performing some type of subset model selection. antoniom suggested stepwise regression, this would work...
library(MASS)
fit <- lm(y~(x1+x2+x3)^2 + x4, data = mydata)
step <- stepAIC(fit, direction="both")
step$anova # display results
Other options could be nested F-tests backward selection...
lm1 <- lm(y~(x1+x2+x3)^2 + x4, data = mydata)
drop1(lm1, test = "F")
If your goal is to predict, you can do CV with best subset...
library(leaps)
regfit.best=regsubsets(y~(x1+x2+x3)^2 + x4,data=Hitters[train ,], nvmax=)
test.mat=model.matrix(Salary∼.,data=Hitters [test ,])
val.errors =rep(NA ,nvmax)
for(i in 1:nvmax){coefi=coef(regfit.best ,id=i)
pred=test.mat[,names(coefi)]%*%coefi
val.errors[i]=mean(( Hitters$Salary[test]-pred)^2)
}
which.min(val.errors)
this gives best subset model's number of coefficients, then to find the model...
coef(regfit.best ,which.min(val.errors))
All of these methods will tell you valuable information about the relationships between variables without having to remove valence in the beginning.
|
Does leaving out an important predictor in a mixed linear model violate the independence assumption?
You can still see the effects of group + timepoint + predictability and their interactions even when valence is left in the model. Keep in mind that interpreting interaction terms of continuous variab
|
43,441
|
Does leaving out an important predictor in a mixed linear model violate the independence assumption?
|
No, leaving out a dependent variable does not violate any independence assumption.
Consider a very simple example where I'm examining the effect of height, weight, baseball batting average on points scored per basketball game. We know that height is a great predictor of basketball skills, but maybe we want to see how batting average and weight do as a predictor. There is no prohibition against dropping any number of variables in order to build a model that examines the relationship between two variables.
Think of it like this: there are millions of data out there that predict things like my income, height, weight and country of birth, however, it's possible to build a highly accurate model in which you predict any of these with very minimal data or with loads of data. There could be a "valence" out there that predicts my height or country of birth perfectly!
The thing to remember about modeling/prediction in general is that your goal is to make predictions better than you would by random. If you're doing that part correctly (i.e. cross validating, testing on "wild" data) then you've met the goals of the task.
|
Does leaving out an important predictor in a mixed linear model violate the independence assumption?
|
No, leaving out a dependent variable does not violate any independence assumption.
Consider a very simple example where I'm examining the effect of height, weight, baseball batting average on points s
|
Does leaving out an important predictor in a mixed linear model violate the independence assumption?
No, leaving out a dependent variable does not violate any independence assumption.
Consider a very simple example where I'm examining the effect of height, weight, baseball batting average on points scored per basketball game. We know that height is a great predictor of basketball skills, but maybe we want to see how batting average and weight do as a predictor. There is no prohibition against dropping any number of variables in order to build a model that examines the relationship between two variables.
Think of it like this: there are millions of data out there that predict things like my income, height, weight and country of birth, however, it's possible to build a highly accurate model in which you predict any of these with very minimal data or with loads of data. There could be a "valence" out there that predicts my height or country of birth perfectly!
The thing to remember about modeling/prediction in general is that your goal is to make predictions better than you would by random. If you're doing that part correctly (i.e. cross validating, testing on "wild" data) then you've met the goals of the task.
|
Does leaving out an important predictor in a mixed linear model violate the independence assumption?
No, leaving out a dependent variable does not violate any independence assumption.
Consider a very simple example where I'm examining the effect of height, weight, baseball batting average on points s
|
43,442
|
In the coupon collector's problem with group drawings, why does the probability decrease with increasing samples?
|
While late to the game I believe I understand the issue you are having. The case is not, as the comments suggest, because the equation is for exactly the number of stickers, but rather due to the nature of your particular example where $n < l$.
If we re-read Wolfgang Stadie's paper where this equation is drawn from, $X_k (A)$ is defined as, "the number of distinct elements of A which are contained in at least one of the (packs drawn)".
So when $n$ (the number of distinct stickers we want) is equal to $l$ (the total number of stickers available), the equation will behaviour exactly as you are expecting. As $k$ (the number of packs we buy) increases, the chances of completing the set heads towards $1$.
However in your case $l=3$ and $n=2$. This means that there are three distinct stickers in the entire set, and you are seeking the probability of obtaining 2 of them ($P(X_k (A) = 2$).
As such, of course you would expect your probability to tend to $0$ as $k$ increases. With every pack you buy you are increasing the chance of drawing that third sticker, which would complete your set and invalidate the result you were after.
The results you have provided show that your odds of only ever having two of the three stickers in the set are best after buying only one or two packs of stickers, where your probability is $2/3$. After that your probability will tend to $0$. Hope that helps, even if it's two years late!
|
In the coupon collector's problem with group drawings, why does the probability decrease with increa
|
While late to the game I believe I understand the issue you are having. The case is not, as the comments suggest, because the equation is for exactly the number of stickers, but rather due to the natu
|
In the coupon collector's problem with group drawings, why does the probability decrease with increasing samples?
While late to the game I believe I understand the issue you are having. The case is not, as the comments suggest, because the equation is for exactly the number of stickers, but rather due to the nature of your particular example where $n < l$.
If we re-read Wolfgang Stadie's paper where this equation is drawn from, $X_k (A)$ is defined as, "the number of distinct elements of A which are contained in at least one of the (packs drawn)".
So when $n$ (the number of distinct stickers we want) is equal to $l$ (the total number of stickers available), the equation will behaviour exactly as you are expecting. As $k$ (the number of packs we buy) increases, the chances of completing the set heads towards $1$.
However in your case $l=3$ and $n=2$. This means that there are three distinct stickers in the entire set, and you are seeking the probability of obtaining 2 of them ($P(X_k (A) = 2$).
As such, of course you would expect your probability to tend to $0$ as $k$ increases. With every pack you buy you are increasing the chance of drawing that third sticker, which would complete your set and invalidate the result you were after.
The results you have provided show that your odds of only ever having two of the three stickers in the set are best after buying only one or two packs of stickers, where your probability is $2/3$. After that your probability will tend to $0$. Hope that helps, even if it's two years late!
|
In the coupon collector's problem with group drawings, why does the probability decrease with increa
While late to the game I believe I understand the issue you are having. The case is not, as the comments suggest, because the equation is for exactly the number of stickers, but rather due to the natu
|
43,443
|
Statistical methods to validate the performance of a linear Kalman filter algorithm [duplicate]
|
There are methods to check on the performance of the filter in the absence of truth data. One method is to recompute the measurement residuals after the state update (the a posteriori residual). Once the filter covariance has stabilized, and with constant measurement noise variance (R), the a posteriori residuals should be zero-mean normally distributed. If they're not, something is wrong. It could be an unmodeled state, non-Gaussian state or measurement noise, or non-linearity. One can't really say what's wrong but it is at least a fault-detection mechanism.
|
Statistical methods to validate the performance of a linear Kalman filter algorithm [duplicate]
|
There are methods to check on the performance of the filter in the absence of truth data. One method is to recompute the measurement residuals after the state update (the a posteriori residual). Onc
|
Statistical methods to validate the performance of a linear Kalman filter algorithm [duplicate]
There are methods to check on the performance of the filter in the absence of truth data. One method is to recompute the measurement residuals after the state update (the a posteriori residual). Once the filter covariance has stabilized, and with constant measurement noise variance (R), the a posteriori residuals should be zero-mean normally distributed. If they're not, something is wrong. It could be an unmodeled state, non-Gaussian state or measurement noise, or non-linearity. One can't really say what's wrong but it is at least a fault-detection mechanism.
|
Statistical methods to validate the performance of a linear Kalman filter algorithm [duplicate]
There are methods to check on the performance of the filter in the absence of truth data. One method is to recompute the measurement residuals after the state update (the a posteriori residual). Onc
|
43,444
|
A modeling technique combining $k$ nearest neighbors and multiple linear regression
|
There was a paper
https://projecteuclid.org/euclid.aos/1176325632
Ann. Statist.
Volume 22, Number 3 (1994), 1346-1370.
"Multivariate Locally Weighted Least Squares Regression"
by D. Ruppert and M. P. Wand
discussing a multiple regression where the weights on observations are not 0 or 1 as in your method but vary with the distance from the case you are trying to predict. Multivariate local regression is also discussed in section 2.1.2 of the book "Local Regression and Likelihood" (1999) by Clive Loader. The R package locfit implements univariate and multivariate local regression.
|
A modeling technique combining $k$ nearest neighbors and multiple linear regression
|
There was a paper
https://projecteuclid.org/euclid.aos/1176325632
Ann. Statist.
Volume 22, Number 3 (1994), 1346-1370.
"Multivariate Locally Weighted Least Squares Regression"
by D. Ruppert and M. P.
|
A modeling technique combining $k$ nearest neighbors and multiple linear regression
There was a paper
https://projecteuclid.org/euclid.aos/1176325632
Ann. Statist.
Volume 22, Number 3 (1994), 1346-1370.
"Multivariate Locally Weighted Least Squares Regression"
by D. Ruppert and M. P. Wand
discussing a multiple regression where the weights on observations are not 0 or 1 as in your method but vary with the distance from the case you are trying to predict. Multivariate local regression is also discussed in section 2.1.2 of the book "Local Regression and Likelihood" (1999) by Clive Loader. The R package locfit implements univariate and multivariate local regression.
|
A modeling technique combining $k$ nearest neighbors and multiple linear regression
There was a paper
https://projecteuclid.org/euclid.aos/1176325632
Ann. Statist.
Volume 22, Number 3 (1994), 1346-1370.
"Multivariate Locally Weighted Least Squares Regression"
by D. Ruppert and M. P.
|
43,445
|
A modeling technique combining $k$ nearest neighbors and multiple linear regression
|
As @Fortranner said, what you describe is locally weighted regression. A particular case, where distances are in a geographical sense, is geographically weighted regression: a reference is Geographically Weighted Regression: The Analysis of Spatially Varying Relationships by A. Stewart Fotheringham, Chris Brunsdon, Martin Charlton, Wiley.
Notice that locally weighted regression affords great flexibility but on the other hand consumes many more degrees of freedom and is prone to overfitting. One is always well advised to test the model(s) on a validation sample.
|
A modeling technique combining $k$ nearest neighbors and multiple linear regression
|
As @Fortranner said, what you describe is locally weighted regression. A particular case, where distances are in a geographical sense, is geographically weighted regression: a reference is Geographica
|
A modeling technique combining $k$ nearest neighbors and multiple linear regression
As @Fortranner said, what you describe is locally weighted regression. A particular case, where distances are in a geographical sense, is geographically weighted regression: a reference is Geographically Weighted Regression: The Analysis of Spatially Varying Relationships by A. Stewart Fotheringham, Chris Brunsdon, Martin Charlton, Wiley.
Notice that locally weighted regression affords great flexibility but on the other hand consumes many more degrees of freedom and is prone to overfitting. One is always well advised to test the model(s) on a validation sample.
|
A modeling technique combining $k$ nearest neighbors and multiple linear regression
As @Fortranner said, what you describe is locally weighted regression. A particular case, where distances are in a geographical sense, is geographically weighted regression: a reference is Geographica
|
43,446
|
Can you perform hypothesis testing on mutual information values?
|
Permutation testing seems like a viable option.
You have $n_0$ vectors $Y_{0,1},\dots,Y_{0, n_0}$ in group $0$ and $n_1$ vectors $Y_{1,1},\dots,Y_{1, n_1}$. Calculate the mutual information in each group, and then calculate the difference.
Next, permute the group labels, and calculate the difference in mutual information between permuted group $0$ and permuted group $1$.
Do it again.
Do it again.
Do it again.
Now that you've done it many times, you have a distribution of mutual information differences under the null hypothesis of the groups having the same mutual information within them. That is, the difference in mutual information is zero (which is not the same as saying that the mutual information within each group is zero).
The original difference in mutual information is the test statistic, and we have a distribution under the null hypothesis. Now we can calculate a p-value!
|
Can you perform hypothesis testing on mutual information values?
|
Permutation testing seems like a viable option.
You have $n_0$ vectors $Y_{0,1},\dots,Y_{0, n_0}$ in group $0$ and $n_1$ vectors $Y_{1,1},\dots,Y_{1, n_1}$. Calculate the mutual information in each gr
|
Can you perform hypothesis testing on mutual information values?
Permutation testing seems like a viable option.
You have $n_0$ vectors $Y_{0,1},\dots,Y_{0, n_0}$ in group $0$ and $n_1$ vectors $Y_{1,1},\dots,Y_{1, n_1}$. Calculate the mutual information in each group, and then calculate the difference.
Next, permute the group labels, and calculate the difference in mutual information between permuted group $0$ and permuted group $1$.
Do it again.
Do it again.
Do it again.
Now that you've done it many times, you have a distribution of mutual information differences under the null hypothesis of the groups having the same mutual information within them. That is, the difference in mutual information is zero (which is not the same as saying that the mutual information within each group is zero).
The original difference in mutual information is the test statistic, and we have a distribution under the null hypothesis. Now we can calculate a p-value!
|
Can you perform hypothesis testing on mutual information values?
Permutation testing seems like a viable option.
You have $n_0$ vectors $Y_{0,1},\dots,Y_{0, n_0}$ in group $0$ and $n_1$ vectors $Y_{1,1},\dots,Y_{1, n_1}$. Calculate the mutual information in each gr
|
43,447
|
Estimate number of unique items by number of duplicates in a sample
|
There is a python package estndv for this task. For example, the population has 1e6 items and your sample is [1,1,1,3,5,5,12]:
from estndv import ndvEstimator
estimator = ndvEstimator()
ndv = estimator.sample_predict(S=[1,1,1,3,5,5,12], N=1e6)
ndv is the estimated number of unique/distinct values for the population.
This method achieves the best results on sampled-based estimation for the number of unique values, see the paper: https://vldb.org/pvldb/vol15/p272-wu.pdf
A similar question is asked here: https://stats.stackexchange.com/a/569670/141900
|
Estimate number of unique items by number of duplicates in a sample
|
There is a python package estndv for this task. For example, the population has 1e6 items and your sample is [1,1,1,3,5,5,12]:
from estndv import ndvEstimator
estimator = ndvEstimator()
ndv = estimato
|
Estimate number of unique items by number of duplicates in a sample
There is a python package estndv for this task. For example, the population has 1e6 items and your sample is [1,1,1,3,5,5,12]:
from estndv import ndvEstimator
estimator = ndvEstimator()
ndv = estimator.sample_predict(S=[1,1,1,3,5,5,12], N=1e6)
ndv is the estimated number of unique/distinct values for the population.
This method achieves the best results on sampled-based estimation for the number of unique values, see the paper: https://vldb.org/pvldb/vol15/p272-wu.pdf
A similar question is asked here: https://stats.stackexchange.com/a/569670/141900
|
Estimate number of unique items by number of duplicates in a sample
There is a python package estndv for this task. For example, the population has 1e6 items and your sample is [1,1,1,3,5,5,12]:
from estndv import ndvEstimator
estimator = ndvEstimator()
ndv = estimato
|
43,448
|
Parametrisation invariance/covariance of the Jeffreys prior
|
It is simply a matter of normalization. The improper prior distribution is $$p(\sigma) \propto 1/\sigma \\\propto n/\sigma,$$
which bears out the claim of invariance under power transformations.
In general, we can we can ignore constants when characterizing closed form probability distributions. For example, to derive the posterior distribution for $\sigma^2$ when $Y_1, ..., Y_n \stackrel{iid}{\sim} N(m, \sigma^2)$ (known mean) under this Jeffrey's prior:
$$ p(\sigma^2|y) \propto p(\sigma^2)\times p(Y|\sigma)\\
\propto 1/\sigma^2 \times 1/\sigma^n \times \exp\left\{\frac{-1}{\sigma^2} \; \frac{\sum_{i=1}^{n}(y_i-m)^2}{2}\right\}\\
=\left(\sigma^2\right)^{-n/2 - 1}\times\exp\left\{\frac{-1}{\sigma^2} \; \frac{\sum_{i=1}^{n}(y_i-m)^2}{2}\right\},$$
which implies that $\sigma^2|Y$ is $IG\left(\frac{n}{2}, \frac{\sum_{i=1}^{n}(y_i-m)^2}{2}\right)$.
|
Parametrisation invariance/covariance of the Jeffreys prior
|
It is simply a matter of normalization. The improper prior distribution is $$p(\sigma) \propto 1/\sigma \\\propto n/\sigma,$$
which bears out the claim of invariance under power transformations.
In ge
|
Parametrisation invariance/covariance of the Jeffreys prior
It is simply a matter of normalization. The improper prior distribution is $$p(\sigma) \propto 1/\sigma \\\propto n/\sigma,$$
which bears out the claim of invariance under power transformations.
In general, we can we can ignore constants when characterizing closed form probability distributions. For example, to derive the posterior distribution for $\sigma^2$ when $Y_1, ..., Y_n \stackrel{iid}{\sim} N(m, \sigma^2)$ (known mean) under this Jeffrey's prior:
$$ p(\sigma^2|y) \propto p(\sigma^2)\times p(Y|\sigma)\\
\propto 1/\sigma^2 \times 1/\sigma^n \times \exp\left\{\frac{-1}{\sigma^2} \; \frac{\sum_{i=1}^{n}(y_i-m)^2}{2}\right\}\\
=\left(\sigma^2\right)^{-n/2 - 1}\times\exp\left\{\frac{-1}{\sigma^2} \; \frac{\sum_{i=1}^{n}(y_i-m)^2}{2}\right\},$$
which implies that $\sigma^2|Y$ is $IG\left(\frac{n}{2}, \frac{\sum_{i=1}^{n}(y_i-m)^2}{2}\right)$.
|
Parametrisation invariance/covariance of the Jeffreys prior
It is simply a matter of normalization. The improper prior distribution is $$p(\sigma) \propto 1/\sigma \\\propto n/\sigma,$$
which bears out the claim of invariance under power transformations.
In ge
|
43,449
|
Inferring likely dates based on other related dates in incomplete data set
|
You have described a missing data problem, and specifically one of censoring. (As a mnemonic device to keep censoring straight in my head from the similar phenomenon of truncation, I like to think of text in a report blacked-out by 'censors'. You know there was a word or sentence there, but you just don't know what it said; this is your own situation with your 'graduation dates'. By contrast, if the last 2 chapters of the report were silently omitted, then the report has been truncated. In this case, not only would you not know what was in those chapters, but you wouldn't even know if there had been any chapters. Of note, @whuber's question above was about nailing down this distinction in your data.)
In this particular missing data problem, you have what sounds like a pretty straightforward missing data mechanism: the date is missing precisely when 'graduation' occurred before 2014. If you are dealing with a time-homogenous problem lacking any important secular trends, then you can regard this fact as an advantage. In that case, you don't have a situation where data are missing for some reason that would be informative about some terribly important characteristics of the 'students'.
In missing data lingo, the specific term for what you are trying to do is to impute the missing dates. The aim of imputation is of course to permit you to retain the records with missing values, to avoid the medieval practice of so-called complete-case analysis, which involves cruelly executing the wonderful data in other fields of your data frame for the 'crime' of 'associating' with a missing date value. (I've assumed that you do in fact have numerous columns in your data which you have omitted from your example data frame; it is the existence of the valuable information in these additional columns that would justify a desire to perform such imputation.)
As far as some good reading on missing data, doing Wikipedia lookups of the various italicized terms in my answer would be a good start. The canonical reference on "Inference and missing data" is Rubin 1976. If you are of a Bayesian disposition then the fine (albeit challenging) treatment in Chapter 8 of BDA3 may be of use to you. You might instead enjoy a practical introduction to imputation through exploring software like MICE. (Sorry I'm unaware of Pythonic options in this regard, but I must suppose there are some.)
To address a question asked by @CliffAB in comment below, it may be helpful to contrast your chosen, imputation-based approach with other, 'fancier' approaches to censoring. The most common example of censoring in data analysis occurs in the context of survival (time-to-event) models. (See here for why this is so.) Survival models employ an estimate of the survival function, whether obtained in a parametric or non-parametric fashion, and these process models support inference without performing explicit imputation of the missing event times. You might very well attack your data with approaches like these, and never have to impute a single value!
One final point: I put 'fancier' in scare-quotes above for a reason. Suppose you made the awesomest time-to-event model ever, for your current problem. Suppose your model is so awesome, in fact, that you can't estimate is by any means short of MCMC. Your MCMC code will invariably treat the missing times as latent variables, and sure enough there will be a line in your code where you generate a pseudorandom number and use it to fill in that latent variable. Thus, you'd find yourself 'imputing' your missing data, albeit in the most highly principled and coherent way imaginable.
|
Inferring likely dates based on other related dates in incomplete data set
|
You have described a missing data problem, and specifically one of censoring. (As a mnemonic device to keep censoring straight in my head from the similar phenomenon of truncation, I like to think of
|
Inferring likely dates based on other related dates in incomplete data set
You have described a missing data problem, and specifically one of censoring. (As a mnemonic device to keep censoring straight in my head from the similar phenomenon of truncation, I like to think of text in a report blacked-out by 'censors'. You know there was a word or sentence there, but you just don't know what it said; this is your own situation with your 'graduation dates'. By contrast, if the last 2 chapters of the report were silently omitted, then the report has been truncated. In this case, not only would you not know what was in those chapters, but you wouldn't even know if there had been any chapters. Of note, @whuber's question above was about nailing down this distinction in your data.)
In this particular missing data problem, you have what sounds like a pretty straightforward missing data mechanism: the date is missing precisely when 'graduation' occurred before 2014. If you are dealing with a time-homogenous problem lacking any important secular trends, then you can regard this fact as an advantage. In that case, you don't have a situation where data are missing for some reason that would be informative about some terribly important characteristics of the 'students'.
In missing data lingo, the specific term for what you are trying to do is to impute the missing dates. The aim of imputation is of course to permit you to retain the records with missing values, to avoid the medieval practice of so-called complete-case analysis, which involves cruelly executing the wonderful data in other fields of your data frame for the 'crime' of 'associating' with a missing date value. (I've assumed that you do in fact have numerous columns in your data which you have omitted from your example data frame; it is the existence of the valuable information in these additional columns that would justify a desire to perform such imputation.)
As far as some good reading on missing data, doing Wikipedia lookups of the various italicized terms in my answer would be a good start. The canonical reference on "Inference and missing data" is Rubin 1976. If you are of a Bayesian disposition then the fine (albeit challenging) treatment in Chapter 8 of BDA3 may be of use to you. You might instead enjoy a practical introduction to imputation through exploring software like MICE. (Sorry I'm unaware of Pythonic options in this regard, but I must suppose there are some.)
To address a question asked by @CliffAB in comment below, it may be helpful to contrast your chosen, imputation-based approach with other, 'fancier' approaches to censoring. The most common example of censoring in data analysis occurs in the context of survival (time-to-event) models. (See here for why this is so.) Survival models employ an estimate of the survival function, whether obtained in a parametric or non-parametric fashion, and these process models support inference without performing explicit imputation of the missing event times. You might very well attack your data with approaches like these, and never have to impute a single value!
One final point: I put 'fancier' in scare-quotes above for a reason. Suppose you made the awesomest time-to-event model ever, for your current problem. Suppose your model is so awesome, in fact, that you can't estimate is by any means short of MCMC. Your MCMC code will invariably treat the missing times as latent variables, and sure enough there will be a line in your code where you generate a pseudorandom number and use it to fill in that latent variable. Thus, you'd find yourself 'imputing' your missing data, albeit in the most highly principled and coherent way imaginable.
|
Inferring likely dates based on other related dates in incomplete data set
You have described a missing data problem, and specifically one of censoring. (As a mnemonic device to keep censoring straight in my head from the similar phenomenon of truncation, I like to think of
|
43,450
|
SVM predicts everything in one class
|
Interesting.. Hard to answer the question directly. Two things I would try to diagnose would be:
1) How do logistic regression and random forest fare?
2) By "fare", I suggest you look at the calibrations of the classifiers. What do the bins look like? Binarized posterior class probabilities will not be very helpful.
|
SVM predicts everything in one class
|
Interesting.. Hard to answer the question directly. Two things I would try to diagnose would be:
1) How do logistic regression and random forest fare?
2) By "fare", I suggest you look at the calibrat
|
SVM predicts everything in one class
Interesting.. Hard to answer the question directly. Two things I would try to diagnose would be:
1) How do logistic regression and random forest fare?
2) By "fare", I suggest you look at the calibrations of the classifiers. What do the bins look like? Binarized posterior class probabilities will not be very helpful.
|
SVM predicts everything in one class
Interesting.. Hard to answer the question directly. Two things I would try to diagnose would be:
1) How do logistic regression and random forest fare?
2) By "fare", I suggest you look at the calibrat
|
43,451
|
SVM predicts everything in one class
|
I'm not sure, but I would suggest trying to add values to c and gamma parameters when tuning them.
The reason I say that is because gamma defines a sort of "smoothness" of classification. That's to say a very small value of gamma means any close point will be considered having the same target (thus putting everything in one class when they are a bit similar).
While it is great that you used a logarithmic scale for your tuning, we actually go further than "0.05" for gamma. I usually range from ($2^{-15}$ to $2^5$). Try to add ( $0.5 , 5$ ) for exemple.
(Ps : You could use 10^(-10:5) wich I find easier to write in R)
Not so long ago, I had a classifier that had ($C= 100 , gamma= 10$) as it's best parameters, and it appeared that it gave very poor results for $gamma<10$ .
I hope this helps. If it doesn't, could you post your results for a linear kernel svm ?
|
SVM predicts everything in one class
|
I'm not sure, but I would suggest trying to add values to c and gamma parameters when tuning them.
The reason I say that is because gamma defines a sort of "smoothness" of classification. That's to sa
|
SVM predicts everything in one class
I'm not sure, but I would suggest trying to add values to c and gamma parameters when tuning them.
The reason I say that is because gamma defines a sort of "smoothness" of classification. That's to say a very small value of gamma means any close point will be considered having the same target (thus putting everything in one class when they are a bit similar).
While it is great that you used a logarithmic scale for your tuning, we actually go further than "0.05" for gamma. I usually range from ($2^{-15}$ to $2^5$). Try to add ( $0.5 , 5$ ) for exemple.
(Ps : You could use 10^(-10:5) wich I find easier to write in R)
Not so long ago, I had a classifier that had ($C= 100 , gamma= 10$) as it's best parameters, and it appeared that it gave very poor results for $gamma<10$ .
I hope this helps. If it doesn't, could you post your results for a linear kernel svm ?
|
SVM predicts everything in one class
I'm not sure, but I would suggest trying to add values to c and gamma parameters when tuning them.
The reason I say that is because gamma defines a sort of "smoothness" of classification. That's to sa
|
43,452
|
Visualizing interrater disagreement
|
This isn't as sexy as your plot, but it might make it easier to read off actual frequency data.
Simulated data -- color indicates the number of raters who initially agreed with the eventual common rating (i.e. 0, 1 or 2).
Code:
library(ggplot2)
theme_set(theme_bw())
theme_update(strip.background=element_rect(colour="white"))
theme_update(panel.border=element_blank())
## Simulated data with similar format
n <- 10^3
df <- data.frame(common=sample(letters[1:6], size=n, replace=T, prob=c(1, 2, 3, 4, 4, 4)),
stringsAsFactors=F)
df$rater1 <- ifelse(runif(n) < 0.5, df$common, sample(letters[1:6], size=n, replace=T))
df$rater2 <- ifelse(runif(n) < 0.5, df$common, sample(letters[1:6], size=n, replace=T))
for(var in c("common", "rater1", "rater2")) {
df[, var] <- factor(df[, var], levels=letters[1:6])
}
df$rater1_label <- sprintf(ifelse(df$rater1 == "a", "rater1 = %s", "%s"), df$rater1)
df$rater1_label <- factor(df$rater1_label, levels=c("rater1 = a", letters[2:6]))
df$rater2_label <- sprintf(ifelse(df$rater2 == "a", "rater2 = %s", "%s"), df$rater2)
df$rater2_label <- factor(df$rater2_label, levels=c("rater2 = a", letters[2:6]))
df$agree_with_common <- as.character(1*(df$rater1 == df$common) + 1*(df$rater2 == df$common))
p <- (ggplot(df, aes(x=common, color=agree_with_common)) +
scale_color_manual("", guide=F,
values=c("0"="#D55E00", "1"="#0072B2", "2"="#009E73")) +
xlab("common rating") + ylab("count") +
geom_histogram(fill="white") +
facet_grid(rater1_label ~ rater2_label) +
ggtitle("Histogram of common rating conditional on individual ratings"))
p
ggsave("ratings.png", p, width=10, height=8)
|
Visualizing interrater disagreement
|
This isn't as sexy as your plot, but it might make it easier to read off actual frequency data.
Simulated data -- color indicates the number of raters who initially agreed with the eventual common ra
|
Visualizing interrater disagreement
This isn't as sexy as your plot, but it might make it easier to read off actual frequency data.
Simulated data -- color indicates the number of raters who initially agreed with the eventual common rating (i.e. 0, 1 or 2).
Code:
library(ggplot2)
theme_set(theme_bw())
theme_update(strip.background=element_rect(colour="white"))
theme_update(panel.border=element_blank())
## Simulated data with similar format
n <- 10^3
df <- data.frame(common=sample(letters[1:6], size=n, replace=T, prob=c(1, 2, 3, 4, 4, 4)),
stringsAsFactors=F)
df$rater1 <- ifelse(runif(n) < 0.5, df$common, sample(letters[1:6], size=n, replace=T))
df$rater2 <- ifelse(runif(n) < 0.5, df$common, sample(letters[1:6], size=n, replace=T))
for(var in c("common", "rater1", "rater2")) {
df[, var] <- factor(df[, var], levels=letters[1:6])
}
df$rater1_label <- sprintf(ifelse(df$rater1 == "a", "rater1 = %s", "%s"), df$rater1)
df$rater1_label <- factor(df$rater1_label, levels=c("rater1 = a", letters[2:6]))
df$rater2_label <- sprintf(ifelse(df$rater2 == "a", "rater2 = %s", "%s"), df$rater2)
df$rater2_label <- factor(df$rater2_label, levels=c("rater2 = a", letters[2:6]))
df$agree_with_common <- as.character(1*(df$rater1 == df$common) + 1*(df$rater2 == df$common))
p <- (ggplot(df, aes(x=common, color=agree_with_common)) +
scale_color_manual("", guide=F,
values=c("0"="#D55E00", "1"="#0072B2", "2"="#009E73")) +
xlab("common rating") + ylab("count") +
geom_histogram(fill="white") +
facet_grid(rater1_label ~ rater2_label) +
ggtitle("Histogram of common rating conditional on individual ratings"))
p
ggsave("ratings.png", p, width=10, height=8)
|
Visualizing interrater disagreement
This isn't as sexy as your plot, but it might make it easier to read off actual frequency data.
Simulated data -- color indicates the number of raters who initially agreed with the eventual common ra
|
43,453
|
Is the Akaike information criterion inversely proportional to the chi-squared statistic?
|
Check your formula for AIC against the Wikipedia AIC page, equal-variances case. The negative sign before your first term seems to be in error. (That section of the Wikipedia page omits the correction from AIC to AICc, the third term of your equation, which is discussed higher up on that page.)
There might be some confusion because the calculated AIC values will then appear to be negative, which would seem to be wrong. That's because the formula that you intended to use omits a constant, as explained on the Wikipedia page. For model comparisons on the same data set the constant can be ignored and you still base your selection on the lowest calculated AIC.
Also, note that yours aren't nested models in the usual sense, as many have the same number of parameters. Usually the "nested" terminology refers to a set of models with one large set of predictor variables in the first model, the second model containing only a proper subset of those predictors, the third containing a subset of the predictors in the second model, and so forth in strictly decreasing numbers of predictors. So there cannot be 2 of a set of nested models having the same number of predictors. There is some dispute over the validity of AIC for non-nested models, as noted on this Cross-Validated page.
|
Is the Akaike information criterion inversely proportional to the chi-squared statistic?
|
Check your formula for AIC against the Wikipedia AIC page, equal-variances case. The negative sign before your first term seems to be in error. (That section of the Wikipedia page omits the correction
|
Is the Akaike information criterion inversely proportional to the chi-squared statistic?
Check your formula for AIC against the Wikipedia AIC page, equal-variances case. The negative sign before your first term seems to be in error. (That section of the Wikipedia page omits the correction from AIC to AICc, the third term of your equation, which is discussed higher up on that page.)
There might be some confusion because the calculated AIC values will then appear to be negative, which would seem to be wrong. That's because the formula that you intended to use omits a constant, as explained on the Wikipedia page. For model comparisons on the same data set the constant can be ignored and you still base your selection on the lowest calculated AIC.
Also, note that yours aren't nested models in the usual sense, as many have the same number of parameters. Usually the "nested" terminology refers to a set of models with one large set of predictor variables in the first model, the second model containing only a proper subset of those predictors, the third containing a subset of the predictors in the second model, and so forth in strictly decreasing numbers of predictors. So there cannot be 2 of a set of nested models having the same number of predictors. There is some dispute over the validity of AIC for non-nested models, as noted on this Cross-Validated page.
|
Is the Akaike information criterion inversely proportional to the chi-squared statistic?
Check your formula for AIC against the Wikipedia AIC page, equal-variances case. The negative sign before your first term seems to be in error. (That section of the Wikipedia page omits the correction
|
43,454
|
Is there a measure of how well a Markov chain allows movement between states?
|
Maybe the conductance of the Markov chain is the right notion to look at. Let $P\in[0,1]^{n\times n}$ be a transition matrix with stationary distribution $\pi$ (in your cases, $\pi$ is always the uniform distribution). The conductance of $P$ is
$$\Phi(P):=\min_{S\subset [n], \pi(S)\le\frac{1}{2}}\frac{\sum_{i\in S,j\in S^c} \pi(i)\cdot P_{i,j}}{\pi(S)}.$$
See for example "Conductance and Rapidly Mixing Markov Chains" by James King.
Your examples yield $\Phi(A)=0.5$, $\Phi(B)=0.1$, and $\Phi(C)=0.99$.
|
Is there a measure of how well a Markov chain allows movement between states?
|
Maybe the conductance of the Markov chain is the right notion to look at. Let $P\in[0,1]^{n\times n}$ be a transition matrix with stationary distribution $\pi$ (in your cases, $\pi$ is always the unif
|
Is there a measure of how well a Markov chain allows movement between states?
Maybe the conductance of the Markov chain is the right notion to look at. Let $P\in[0,1]^{n\times n}$ be a transition matrix with stationary distribution $\pi$ (in your cases, $\pi$ is always the uniform distribution). The conductance of $P$ is
$$\Phi(P):=\min_{S\subset [n], \pi(S)\le\frac{1}{2}}\frac{\sum_{i\in S,j\in S^c} \pi(i)\cdot P_{i,j}}{\pi(S)}.$$
See for example "Conductance and Rapidly Mixing Markov Chains" by James King.
Your examples yield $\Phi(A)=0.5$, $\Phi(B)=0.1$, and $\Phi(C)=0.99$.
|
Is there a measure of how well a Markov chain allows movement between states?
Maybe the conductance of the Markov chain is the right notion to look at. Let $P\in[0,1]^{n\times n}$ be a transition matrix with stationary distribution $\pi$ (in your cases, $\pi$ is always the unif
|
43,455
|
Is there a measure of how well a Markov chain allows movement between states?
|
If the transition graph is strongly connected (i.e. given an initial state, any other state is reachable with p>0, possibly via intermediate states) , then as time goes to infinity the probability to find the system in a given state does not depend on the initial state. That is to say, there is a chance $$p_i(X)$$ to find the system in state X after i steps, which converges to some constant $$p(X)$$ which is a function only of the transition matrix (The stationary distribution $\pi$ in Tobias's answer).
For all 3 your examples, this $\pi$ is simply (.5, .5) as both states are equally likely. This makes sense: $$\left( \begin{matrix} .5 \\ .5 \end{matrix} \right) \left( \begin{matrix} .5 & .5 \\ .5 & .5 \end{matrix} \right) = \left( \begin{matrix} .5 \\ .5 \end{matrix} \right)$$ but also $$\left( \begin{matrix} .5 \\ .5 \end{matrix} \right) \left( \begin{matrix} .9 & .1 \\ .1 & .9 \end{matrix} \right) = \left( \begin{matrix} .5 \\ .5 \end{matrix} \right)$$ but in general this need not hold. Not all states have to be equally likely. Simple example: $$\left( \begin{matrix} .5 & .5 & 0 \\ .25 & .5 & .25 \\ 0 & .5 & .5 \end{matrix} \right) $$ with probabilities (.25, .5, .25). You can think of this as a Left<->Middle<->Right triplet of states, with a 50% chance of moving but not directly from left to right. Since you always have to go through the middle, it's most likely.
Now, as the comments on the question already indicated, you can use this probability to weigh the chances of staying in each different state.
In your simple examples, the respective results would be 0.5, 0.99 and 0.1, simply because the chances to stay in the same state (values of the diagonal) are the same on the diagonal. For non-trivial matrices, it would be a weighted average of the diagonal.
This means that the exact off-diagonal values do not matter. I believe this reflects the intent of the question, which does not differentiate between different kind of state transitions either.
|
Is there a measure of how well a Markov chain allows movement between states?
|
If the transition graph is strongly connected (i.e. given an initial state, any other state is reachable with p>0, possibly via intermediate states) , then as time goes to infinity the probability to
|
Is there a measure of how well a Markov chain allows movement between states?
If the transition graph is strongly connected (i.e. given an initial state, any other state is reachable with p>0, possibly via intermediate states) , then as time goes to infinity the probability to find the system in a given state does not depend on the initial state. That is to say, there is a chance $$p_i(X)$$ to find the system in state X after i steps, which converges to some constant $$p(X)$$ which is a function only of the transition matrix (The stationary distribution $\pi$ in Tobias's answer).
For all 3 your examples, this $\pi$ is simply (.5, .5) as both states are equally likely. This makes sense: $$\left( \begin{matrix} .5 \\ .5 \end{matrix} \right) \left( \begin{matrix} .5 & .5 \\ .5 & .5 \end{matrix} \right) = \left( \begin{matrix} .5 \\ .5 \end{matrix} \right)$$ but also $$\left( \begin{matrix} .5 \\ .5 \end{matrix} \right) \left( \begin{matrix} .9 & .1 \\ .1 & .9 \end{matrix} \right) = \left( \begin{matrix} .5 \\ .5 \end{matrix} \right)$$ but in general this need not hold. Not all states have to be equally likely. Simple example: $$\left( \begin{matrix} .5 & .5 & 0 \\ .25 & .5 & .25 \\ 0 & .5 & .5 \end{matrix} \right) $$ with probabilities (.25, .5, .25). You can think of this as a Left<->Middle<->Right triplet of states, with a 50% chance of moving but not directly from left to right. Since you always have to go through the middle, it's most likely.
Now, as the comments on the question already indicated, you can use this probability to weigh the chances of staying in each different state.
In your simple examples, the respective results would be 0.5, 0.99 and 0.1, simply because the chances to stay in the same state (values of the diagonal) are the same on the diagonal. For non-trivial matrices, it would be a weighted average of the diagonal.
This means that the exact off-diagonal values do not matter. I believe this reflects the intent of the question, which does not differentiate between different kind of state transitions either.
|
Is there a measure of how well a Markov chain allows movement between states?
If the transition graph is strongly connected (i.e. given an initial state, any other state is reachable with p>0, possibly via intermediate states) , then as time goes to infinity the probability to
|
43,456
|
Calculating the integral of a PDF inside a closed contour of constant density
|
A Monte Carlo approach offers an easy solution to this problem.
First we need to generate a sample from the PDF - this can be done through interpolation and rejection sampling. Rather than keeping the coordinates of each sample, we need to store the probability density of each sample.
Let $z$ be the density of the contour inside which we want to calculate the integral. If $N$ is the total number of samples, and $m$ is the number of samples which have a density value greater than $z$, then
$$
\idotsint\limits_{P(\underline{x}) \ge z} P(\underline{x}) \; \mathrm{d}\underline{x} \approx \frac{m}{N}
$$
The number of samples can be increased to achieve whatever accuracy is required, as the error in the calculation is proportional to $1 / \sqrt{N}$.
|
Calculating the integral of a PDF inside a closed contour of constant density
|
A Monte Carlo approach offers an easy solution to this problem.
First we need to generate a sample from the PDF - this can be done through interpolation and rejection sampling. Rather than keeping the
|
Calculating the integral of a PDF inside a closed contour of constant density
A Monte Carlo approach offers an easy solution to this problem.
First we need to generate a sample from the PDF - this can be done through interpolation and rejection sampling. Rather than keeping the coordinates of each sample, we need to store the probability density of each sample.
Let $z$ be the density of the contour inside which we want to calculate the integral. If $N$ is the total number of samples, and $m$ is the number of samples which have a density value greater than $z$, then
$$
\idotsint\limits_{P(\underline{x}) \ge z} P(\underline{x}) \; \mathrm{d}\underline{x} \approx \frac{m}{N}
$$
The number of samples can be increased to achieve whatever accuracy is required, as the error in the calculation is proportional to $1 / \sqrt{N}$.
|
Calculating the integral of a PDF inside a closed contour of constant density
A Monte Carlo approach offers an easy solution to this problem.
First we need to generate a sample from the PDF - this can be done through interpolation and rejection sampling. Rather than keeping the
|
43,457
|
Modeling linear regression with covariate dependent error
|
You could use iterative feasible generalized least squares.
Start by setting weights for each datapoint to 1, i.e. no weighting.
Fit a weighted regression model for each dataset using weights.
Create a single dataset combining residuals/errors and their respective x values.
Fit $e_i^2 = a\cdot x_i + b$. If the noise is zero mean, $e_i^2$ is equal to the variance of the error at $x_i$.
Update your weights with the squared errors prediction model
Go back to 1 until convergence.
|
Modeling linear regression with covariate dependent error
|
You could use iterative feasible generalized least squares.
Start by setting weights for each datapoint to 1, i.e. no weighting.
Fit a weighted regression model for each dataset using weights.
Create
|
Modeling linear regression with covariate dependent error
You could use iterative feasible generalized least squares.
Start by setting weights for each datapoint to 1, i.e. no weighting.
Fit a weighted regression model for each dataset using weights.
Create a single dataset combining residuals/errors and their respective x values.
Fit $e_i^2 = a\cdot x_i + b$. If the noise is zero mean, $e_i^2$ is equal to the variance of the error at $x_i$.
Update your weights with the squared errors prediction model
Go back to 1 until convergence.
|
Modeling linear regression with covariate dependent error
You could use iterative feasible generalized least squares.
Start by setting weights for each datapoint to 1, i.e. no weighting.
Fit a weighted regression model for each dataset using weights.
Create
|
43,458
|
Modeling linear regression with covariate dependent error
|
If the distribution of your error term can be described by two independent parameters, for example a Gaussian distribution with mean independent of the variance then your problem is familiar. Since $E(error|x)=0$ we can only have the variance/scale of your error depending on $x$. In that case your regression model has heteroskedascity. GLS (Generalized Least Squares) are suitable for this problem as opposed to LS (Least Squares) who assume homoskedascity.
|
Modeling linear regression with covariate dependent error
|
If the distribution of your error term can be described by two independent parameters, for example a Gaussian distribution with mean independent of the variance then your problem is familiar. Since $
|
Modeling linear regression with covariate dependent error
If the distribution of your error term can be described by two independent parameters, for example a Gaussian distribution with mean independent of the variance then your problem is familiar. Since $E(error|x)=0$ we can only have the variance/scale of your error depending on $x$. In that case your regression model has heteroskedascity. GLS (Generalized Least Squares) are suitable for this problem as opposed to LS (Least Squares) who assume homoskedascity.
|
Modeling linear regression with covariate dependent error
If the distribution of your error term can be described by two independent parameters, for example a Gaussian distribution with mean independent of the variance then your problem is familiar. Since $
|
43,459
|
Predictions for random walk in ARIMA model
|
Thanks to the help on this forum i was also able to ask this consolidated form of the original question to one of the profs at my university who is teaching a time-series class this semester....which i should have taken :-)
I thought his answer was pretty good, and also has some echos of other comments posted for this question.
I'm not so sure I should accept this answer officially...but at least want to share it here.
Prof Answer:
You have some strange patterns in your data… it looks like there is some type of “structural break” (the form or pattern of the time process changes around time point 3000). It might make sense to break the time series into two pieces and analyze each separately, if everything else is not working so well.
If covariances are indeed changing over time, then you would be violating the Box-Jenkins model.
I would try some intermediate steps. First just difference your time series: compute Y_t= X_t - X_{t-1} (after log transformation) and see if it looks like there’s some similar pattern throughout. If so, then you could try fitting a ARMA model to the difference. Are you using a software package that computes ARMA models? Can you fit such models on the differences Y_t?
Sometimes software packages will compute the k-step forecasts for the future… if you had those, then you could undo the differencing to get your predictions on-line. So for example, you get predictions in the future for Y_{n+1},…,Y_{n+k} and you know Y_{n+i} = X_{n+i}- X_{n+i-1} so you can find X_{n+i} = Y_{n+i}+X_{n+i-1} for i=1,…,k by the predictions for the differences Y_{n+i} and the observation you have for X_n. Otherwise, you might have to resort to Kalman filtering, which can be ok too.
If you have any outliers you could just delete them in fitting the model. Essentially, you would have no information at that time point, but that’s better than misleading information.
I guess that I just wonder (based on your initial graph) about how the fit of the time series model might improve if you considered breaking the time series into two pieces. Maybe you would do a better job of capturing extremes in the 2nd portion of the series.
|
Predictions for random walk in ARIMA model
|
Thanks to the help on this forum i was also able to ask this consolidated form of the original question to one of the profs at my university who is teaching a time-series class this semester....which
|
Predictions for random walk in ARIMA model
Thanks to the help on this forum i was also able to ask this consolidated form of the original question to one of the profs at my university who is teaching a time-series class this semester....which i should have taken :-)
I thought his answer was pretty good, and also has some echos of other comments posted for this question.
I'm not so sure I should accept this answer officially...but at least want to share it here.
Prof Answer:
You have some strange patterns in your data… it looks like there is some type of “structural break” (the form or pattern of the time process changes around time point 3000). It might make sense to break the time series into two pieces and analyze each separately, if everything else is not working so well.
If covariances are indeed changing over time, then you would be violating the Box-Jenkins model.
I would try some intermediate steps. First just difference your time series: compute Y_t= X_t - X_{t-1} (after log transformation) and see if it looks like there’s some similar pattern throughout. If so, then you could try fitting a ARMA model to the difference. Are you using a software package that computes ARMA models? Can you fit such models on the differences Y_t?
Sometimes software packages will compute the k-step forecasts for the future… if you had those, then you could undo the differencing to get your predictions on-line. So for example, you get predictions in the future for Y_{n+1},…,Y_{n+k} and you know Y_{n+i} = X_{n+i}- X_{n+i-1} so you can find X_{n+i} = Y_{n+i}+X_{n+i-1} for i=1,…,k by the predictions for the differences Y_{n+i} and the observation you have for X_n. Otherwise, you might have to resort to Kalman filtering, which can be ok too.
If you have any outliers you could just delete them in fitting the model. Essentially, you would have no information at that time point, but that’s better than misleading information.
I guess that I just wonder (based on your initial graph) about how the fit of the time series model might improve if you considered breaking the time series into two pieces. Maybe you would do a better job of capturing extremes in the 2nd portion of the series.
|
Predictions for random walk in ARIMA model
Thanks to the help on this forum i was also able to ask this consolidated form of the original question to one of the profs at my university who is teaching a time-series class this semester....which
|
43,460
|
Predictions for random walk in ARIMA model
|
" did notice my residuals show a change in variance, so if that violates some kind of ARIMA model assumptions or something let me know."
Your residuals suggest non-constant error variance and thusly you should employ a Generalized Least Squares (GLS0) model as suggested by http://www.unc.edu/~jbhill/tsay.pdf . Your selection of a log transform is probably unwarranted . AUTOBOX a piece of software that I have helped develop can seamlessly put together a solution that includes a minimally sufficient ARIMA model , level shifts/local time trends , outliers and the GLS that you apparently need. A seconD thought is that perhaps your ARIMA coefficients are time-varying which can also induce/create the appearance of non-constant errors . This facility/capability is also available
If you share this with your Professor he may have something to say about Tsay .
|
Predictions for random walk in ARIMA model
|
" did notice my residuals show a change in variance, so if that violates some kind of ARIMA model assumptions or something let me know."
Your residuals suggest non-constant error variance and thusly y
|
Predictions for random walk in ARIMA model
" did notice my residuals show a change in variance, so if that violates some kind of ARIMA model assumptions or something let me know."
Your residuals suggest non-constant error variance and thusly you should employ a Generalized Least Squares (GLS0) model as suggested by http://www.unc.edu/~jbhill/tsay.pdf . Your selection of a log transform is probably unwarranted . AUTOBOX a piece of software that I have helped develop can seamlessly put together a solution that includes a minimally sufficient ARIMA model , level shifts/local time trends , outliers and the GLS that you apparently need. A seconD thought is that perhaps your ARIMA coefficients are time-varying which can also induce/create the appearance of non-constant errors . This facility/capability is also available
If you share this with your Professor he may have something to say about Tsay .
|
Predictions for random walk in ARIMA model
" did notice my residuals show a change in variance, so if that violates some kind of ARIMA model assumptions or something let me know."
Your residuals suggest non-constant error variance and thusly y
|
43,461
|
Chi-square/G-test/Fisher exact with replicates
|
Testing species frequencies
I understand the OP's first question to be "Are the proportions of species 1, 2, and 3 identical across all six columns?" I think a chi-square test of independence of rows and columns would be applicable if the cell counts are sufficiently high (that's a whole other topic).
When can count data be combined?
My reading on this topic suggests that one can combine count data if one can show that the data (replicates) are homogeneous. Zar [1] describes combining multiple tests of goodness of fit (section 22.6) or multiple 2x2 contingency tables (section 23.4) through a heterogeneity chi-square. This test is performed by calculating the chi-square statistics for each replicate separately, and then comparing the sum of those chi-square statistics to the chi-square statistic one derives from pooling the data. Zar describes the steps in detail and this page does so as well.
[1]: Jerold H. Zar. 1999. Biostatistical Analysis, 4th edition.
|
Chi-square/G-test/Fisher exact with replicates
|
Testing species frequencies
I understand the OP's first question to be "Are the proportions of species 1, 2, and 3 identical across all six columns?" I think a chi-square test of independence of rows
|
Chi-square/G-test/Fisher exact with replicates
Testing species frequencies
I understand the OP's first question to be "Are the proportions of species 1, 2, and 3 identical across all six columns?" I think a chi-square test of independence of rows and columns would be applicable if the cell counts are sufficiently high (that's a whole other topic).
When can count data be combined?
My reading on this topic suggests that one can combine count data if one can show that the data (replicates) are homogeneous. Zar [1] describes combining multiple tests of goodness of fit (section 22.6) or multiple 2x2 contingency tables (section 23.4) through a heterogeneity chi-square. This test is performed by calculating the chi-square statistics for each replicate separately, and then comparing the sum of those chi-square statistics to the chi-square statistic one derives from pooling the data. Zar describes the steps in detail and this page does so as well.
[1]: Jerold H. Zar. 1999. Biostatistical Analysis, 4th edition.
|
Chi-square/G-test/Fisher exact with replicates
Testing species frequencies
I understand the OP's first question to be "Are the proportions of species 1, 2, and 3 identical across all six columns?" I think a chi-square test of independence of rows
|
43,462
|
Estimating the prediction variance in kernel ridge regression
|
For anyone interested, this paper helped me a lot further:
Estimating Predictive Variances with Kernel Ridge Regression by G. C. Cawley
, N. L. C. Talbot and O. Chapelle
Note that this paper explains how to do it for heteroscedastic noise, however you can also use it for homogeous noise as follows.
The first method, KRR + LOO:
Train the KRR model on the data
For each sample, compute the LOO error
To estimate the $\sigma^2$ compute the sum of squared residuals that were found in step 2
A more detailed method is KRR + LOO + KRR.
Train the KRR model on the data
For each sample, compute the LOO error
Train a KRR model on the squared residuals that were found in step 2
The predictions of the second model are the prediction variances, however now we have to regularize two models, but we do get heteroscedastic variances. I guess I could also take the mean prediction of the second KRR model to find the homogeous noise term $\sigma^2$, but I'm unsure if this is useful or better than the above method.
Finally, they propose a new model, that will directly take heteroscedastic noise into account. This way, the model can be regularized more in noisy regions in feature space, and thus this model is expected to perform better.
In the end what I am really interested in is to estimate the probability distribution of the prediction on unseen / new data. The methods that I am now considering are:
Performing the KRR + LOO method to estimate $\sigma^2$. Now I can estimate the variance of new data using:
$$ \hat{y_{new}} = K_{x_{new},X_{trainset}} (K_{X_{trainset},X_{trainset}} + \lambda I)^{-1} y_{train} = P y_{train}$$
Using the identity:
$$ Cov(Xa) = X^T Cov(a) X$$
I obtain:
$$ Cov(\hat{y_{new}}) = P_{train}^T P_{train} \sigma^2 $$
I use the prediction on unseen data of the regular KRR model as the mean for the distribution.
Performing KRR + LOO + KRR. I have two choices, I either estimate $\sigma^2$ by averaging the outputs of the second KRR model and use the above formula, or I directly use the prediction of the second KRR model on new data to estimate the prediction variance of a new point.
I use the prediction on unseen data of the regular KRR model as the mean for the distribution.
I use their new model to estimate the mean and variance at unseen data.
I use bootstrapping to train multiple models, and I compute the variance of their predictions on the traindata. This way I can compute $\sigma^2$. Then I use the same formula as in 1. I use the prediction on unseen data of the regular KRR model as the mean for the distribution.
I use bootstrapping to train multiple models, and I compute their predictions on my new data. I compute the variance of those predictions, to compute the prediction variance of each point.
I use the prediction on unseen data of the regular KRR model as the mean for the distribution.
What I am a bit confused about is the actual distribution of the prediction on data at a new point. Is this distribution actually a Gaussian / normally distributed?
|
Estimating the prediction variance in kernel ridge regression
|
For anyone interested, this paper helped me a lot further:
Estimating Predictive Variances with Kernel Ridge Regression by G. C. Cawley
, N. L. C. Talbot and O. Chapelle
Note that this paper explains
|
Estimating the prediction variance in kernel ridge regression
For anyone interested, this paper helped me a lot further:
Estimating Predictive Variances with Kernel Ridge Regression by G. C. Cawley
, N. L. C. Talbot and O. Chapelle
Note that this paper explains how to do it for heteroscedastic noise, however you can also use it for homogeous noise as follows.
The first method, KRR + LOO:
Train the KRR model on the data
For each sample, compute the LOO error
To estimate the $\sigma^2$ compute the sum of squared residuals that were found in step 2
A more detailed method is KRR + LOO + KRR.
Train the KRR model on the data
For each sample, compute the LOO error
Train a KRR model on the squared residuals that were found in step 2
The predictions of the second model are the prediction variances, however now we have to regularize two models, but we do get heteroscedastic variances. I guess I could also take the mean prediction of the second KRR model to find the homogeous noise term $\sigma^2$, but I'm unsure if this is useful or better than the above method.
Finally, they propose a new model, that will directly take heteroscedastic noise into account. This way, the model can be regularized more in noisy regions in feature space, and thus this model is expected to perform better.
In the end what I am really interested in is to estimate the probability distribution of the prediction on unseen / new data. The methods that I am now considering are:
Performing the KRR + LOO method to estimate $\sigma^2$. Now I can estimate the variance of new data using:
$$ \hat{y_{new}} = K_{x_{new},X_{trainset}} (K_{X_{trainset},X_{trainset}} + \lambda I)^{-1} y_{train} = P y_{train}$$
Using the identity:
$$ Cov(Xa) = X^T Cov(a) X$$
I obtain:
$$ Cov(\hat{y_{new}}) = P_{train}^T P_{train} \sigma^2 $$
I use the prediction on unseen data of the regular KRR model as the mean for the distribution.
Performing KRR + LOO + KRR. I have two choices, I either estimate $\sigma^2$ by averaging the outputs of the second KRR model and use the above formula, or I directly use the prediction of the second KRR model on new data to estimate the prediction variance of a new point.
I use the prediction on unseen data of the regular KRR model as the mean for the distribution.
I use their new model to estimate the mean and variance at unseen data.
I use bootstrapping to train multiple models, and I compute the variance of their predictions on the traindata. This way I can compute $\sigma^2$. Then I use the same formula as in 1. I use the prediction on unseen data of the regular KRR model as the mean for the distribution.
I use bootstrapping to train multiple models, and I compute their predictions on my new data. I compute the variance of those predictions, to compute the prediction variance of each point.
I use the prediction on unseen data of the regular KRR model as the mean for the distribution.
What I am a bit confused about is the actual distribution of the prediction on data at a new point. Is this distribution actually a Gaussian / normally distributed?
|
Estimating the prediction variance in kernel ridge regression
For anyone interested, this paper helped me a lot further:
Estimating Predictive Variances with Kernel Ridge Regression by G. C. Cawley
, N. L. C. Talbot and O. Chapelle
Note that this paper explains
|
43,463
|
Accounting for overdispersion in binomial glm using proportions, without quasibinomial
|
Overdispersion occurs for a number of reasons, but often the case of presence/absence data is because of clustering of observations and correlations between observations.
Taken from Brostrom & Holmberg (2011) Generalised Linear Models with Clustered Data: Fixed and random effects models with glmmML
"Generally speaking, a random effects model is appropriate if the observed clusters may be regarded as a random sample from a (large, possibly infinite) pool of possible clusters. The observed clusters are of no practical interest per se, but the distribution in the pool is. Or this distribution is regarded as a nuisance that needs to be controlled for."
https://cran.r-project.org/web/packages/eha/vignettes/glmmML.pdf
library(lme4)
library(RVAideMemoire)
Data$obs <- factor(formatC(1:nrow(Data), flag="0", width = 3))
model.glmm <- glmer(cbind(number_pres,number_abs) ~ Var1+Var2+Var3+Var4...+
(1|obs),family = binomial (link = logit),data = Data)
overdisp.glmer(model.glmm) #Overdispersion for GLMM
|
Accounting for overdispersion in binomial glm using proportions, without quasibinomial
|
Overdispersion occurs for a number of reasons, but often the case of presence/absence data is because of clustering of observations and correlations between observations.
Taken from Brostrom & Holmb
|
Accounting for overdispersion in binomial glm using proportions, without quasibinomial
Overdispersion occurs for a number of reasons, but often the case of presence/absence data is because of clustering of observations and correlations between observations.
Taken from Brostrom & Holmberg (2011) Generalised Linear Models with Clustered Data: Fixed and random effects models with glmmML
"Generally speaking, a random effects model is appropriate if the observed clusters may be regarded as a random sample from a (large, possibly infinite) pool of possible clusters. The observed clusters are of no practical interest per se, but the distribution in the pool is. Or this distribution is regarded as a nuisance that needs to be controlled for."
https://cran.r-project.org/web/packages/eha/vignettes/glmmML.pdf
library(lme4)
library(RVAideMemoire)
Data$obs <- factor(formatC(1:nrow(Data), flag="0", width = 3))
model.glmm <- glmer(cbind(number_pres,number_abs) ~ Var1+Var2+Var3+Var4...+
(1|obs),family = binomial (link = logit),data = Data)
overdisp.glmer(model.glmm) #Overdispersion for GLMM
|
Accounting for overdispersion in binomial glm using proportions, without quasibinomial
Overdispersion occurs for a number of reasons, but often the case of presence/absence data is because of clustering of observations and correlations between observations.
Taken from Brostrom & Holmb
|
43,464
|
Intuitive explanation of the F-statistic formula?
|
Note that if there were no population effect (the population means were identical at every combination of the regressors), there would still be some estimated effect -- the RegressionSS would be nonzero -- it would tend to increase if the error variance increased, or if you added more regressors.
Indeed, if there were no effects, you could estimate $\sigma^2$ from the Regression sum of squares; $\hat{\sigma}^2=RSS/p$. So under the null hypothesis we're taking the ratio of two independent estimates of $\sigma^2$, and in that case (under the assumption of iid normal errors), the ratio turns out to have an F-distribution. However, if there are any effects, then the estimator based on the Regression SS will tend to be "too large" - there's an additional term in the variance estimate from the vatiation in conditional population means. So when $H_0$ is false the test statistic will tend to fall more often into the upper tail of the null distribution than when the null hypothesis is true - that's why it makes intuitive sense to use F-tests in this situation.
|
Intuitive explanation of the F-statistic formula?
|
Note that if there were no population effect (the population means were identical at every combination of the regressors), there would still be some estimated effect -- the RegressionSS would be nonze
|
Intuitive explanation of the F-statistic formula?
Note that if there were no population effect (the population means were identical at every combination of the regressors), there would still be some estimated effect -- the RegressionSS would be nonzero -- it would tend to increase if the error variance increased, or if you added more regressors.
Indeed, if there were no effects, you could estimate $\sigma^2$ from the Regression sum of squares; $\hat{\sigma}^2=RSS/p$. So under the null hypothesis we're taking the ratio of two independent estimates of $\sigma^2$, and in that case (under the assumption of iid normal errors), the ratio turns out to have an F-distribution. However, if there are any effects, then the estimator based on the Regression SS will tend to be "too large" - there's an additional term in the variance estimate from the vatiation in conditional population means. So when $H_0$ is false the test statistic will tend to fall more often into the upper tail of the null distribution than when the null hypothesis is true - that's why it makes intuitive sense to use F-tests in this situation.
|
Intuitive explanation of the F-statistic formula?
Note that if there were no population effect (the population means were identical at every combination of the regressors), there would still be some estimated effect -- the RegressionSS would be nonze
|
43,465
|
Intuitive explanation of the F-statistic formula?
|
(I typed this thinking you were talking about analysis of variance, but the idea is essentially the same for a more general regression model.)
The data you imagine where there is zero between group variation is possible but extremely unlikely. (You may be conflating true values of parameters with their sample estimates.) There will naturally arise certain variation between groups which is entirely attributed to the irreducible variance of the error term $\epsilon$, and the numerator and denominator both turn out to be unbiased estimates of this variance when the null model holds.
You can try a simulation to convince yourself that this is true. Generate data under the model,
$$
Y_{ij} = \mu + \epsilon_{ij} ,
$$
where $\epsilon_{ij} \sim$ normal$(0, \sigma^2)$, $i \in \{1, \ldots , p \}$, $j \in \{1 , \ldots , n \}$, and $\mu$ is entirely arbitrary. Notice how membership within the different groups has no meaning and you're just generating i.i.d. normal variates. Next fit a one way ANOVA to these data and check the mean square within groups and the mean square between. You should find that both are close to the value you chose for $\sigma^2$.
|
Intuitive explanation of the F-statistic formula?
|
(I typed this thinking you were talking about analysis of variance, but the idea is essentially the same for a more general regression model.)
The data you imagine where there is zero between group va
|
Intuitive explanation of the F-statistic formula?
(I typed this thinking you were talking about analysis of variance, but the idea is essentially the same for a more general regression model.)
The data you imagine where there is zero between group variation is possible but extremely unlikely. (You may be conflating true values of parameters with their sample estimates.) There will naturally arise certain variation between groups which is entirely attributed to the irreducible variance of the error term $\epsilon$, and the numerator and denominator both turn out to be unbiased estimates of this variance when the null model holds.
You can try a simulation to convince yourself that this is true. Generate data under the model,
$$
Y_{ij} = \mu + \epsilon_{ij} ,
$$
where $\epsilon_{ij} \sim$ normal$(0, \sigma^2)$, $i \in \{1, \ldots , p \}$, $j \in \{1 , \ldots , n \}$, and $\mu$ is entirely arbitrary. Notice how membership within the different groups has no meaning and you're just generating i.i.d. normal variates. Next fit a one way ANOVA to these data and check the mean square within groups and the mean square between. You should find that both are close to the value you chose for $\sigma^2$.
|
Intuitive explanation of the F-statistic formula?
(I typed this thinking you were talking about analysis of variance, but the idea is essentially the same for a more general regression model.)
The data you imagine where there is zero between group va
|
43,466
|
How to prove the properties of penalized likelihood estimator in Fan and Li (2001) paper
|
A sufficient condition for sparsity is that $\min_{\theta \neq 0} [ |\theta| + p'_\lambda (|\theta|) ]$ is positive.
The reason for this condition is explained on p. 1350 of the paper, but it is only a brief outline, as the authors have chosen to omit most of the demonstration of the asserted results. I will try to fill in the blanks of what they have omitted.
The mathematical problem being solved here is to find a value $\hat{\theta} > 0$ that minimises a particular objective function for a fixed value of $z > 0$. The objective function specified in equation $(2.3)$ is:
$$\begin{equation} \begin{aligned}
F(z,\theta)
&\equiv \tfrac{1}{2} (z-\theta)^2 + p_\lambda(|\theta|) \\[6pt]
&= \tfrac{1}{2} z^2 - z \theta + \tfrac{1}{2} \theta^2 + p_\lambda(|\theta|) \\[6pt]
&= \tfrac{1}{2} \theta^2 - z \theta + p_\lambda(|\theta|) + \text{const.} \\[6pt]
\end{aligned} \end{equation}$$
Finding the minimising argument is done by ordinary calculus techniques. To facilitate this analysis, we define the function $H_\lambda(\theta) \equiv |\theta| + p'_\lambda (|\theta|)$. Using the chain rule, for all $\theta \neq 0$ the first derivative of this objective function is:
$$\begin{equation} \begin{aligned}
\quad \text{ } \text{ } F'(z,\theta)
&= \theta + \text{sgn}(\theta) \cdot p'_\lambda (|\theta|) -z \\[6pt]
&= \text{sgn}(\theta) \cdot |\theta| + \text{sgn}(\theta) \cdot p'_\lambda (|\theta|) -z \\[6pt]
&= \text{sgn}(\theta) \Big[ |\theta| + p'_\lambda (|\theta|) \Big] -z \\[6pt]
&= \text{sgn}(\theta) \cdot H_\lambda(\theta) -z. \\[6pt]
\end{aligned} \end{equation}$$
This gets us to the point where the derivative of the objective function depends on the function $H_\lambda(\theta)$, which is the function subject to the condition in question.
To complete the examination of the minimisation problem, the authors look at what happens in different cases when the minimum of this function is positive, negative, or zero. This discussion occurs on p. 1350 of the paper, and with the above form for the derivative of the objective function, it should now be easier to understand.
(As some other commentators have also noted, Figure 3 appears to me to be intended as a generic figure, rather than one corresponding to a specific form of probability function.)
|
How to prove the properties of penalized likelihood estimator in Fan and Li (2001) paper
|
A sufficient condition for sparsity is that $\min_{\theta \neq 0} [ |\theta| + p'_\lambda (|\theta|) ]$ is positive.
The reason for this condition is explained on p. 1350 of the paper, but it is only
|
How to prove the properties of penalized likelihood estimator in Fan and Li (2001) paper
A sufficient condition for sparsity is that $\min_{\theta \neq 0} [ |\theta| + p'_\lambda (|\theta|) ]$ is positive.
The reason for this condition is explained on p. 1350 of the paper, but it is only a brief outline, as the authors have chosen to omit most of the demonstration of the asserted results. I will try to fill in the blanks of what they have omitted.
The mathematical problem being solved here is to find a value $\hat{\theta} > 0$ that minimises a particular objective function for a fixed value of $z > 0$. The objective function specified in equation $(2.3)$ is:
$$\begin{equation} \begin{aligned}
F(z,\theta)
&\equiv \tfrac{1}{2} (z-\theta)^2 + p_\lambda(|\theta|) \\[6pt]
&= \tfrac{1}{2} z^2 - z \theta + \tfrac{1}{2} \theta^2 + p_\lambda(|\theta|) \\[6pt]
&= \tfrac{1}{2} \theta^2 - z \theta + p_\lambda(|\theta|) + \text{const.} \\[6pt]
\end{aligned} \end{equation}$$
Finding the minimising argument is done by ordinary calculus techniques. To facilitate this analysis, we define the function $H_\lambda(\theta) \equiv |\theta| + p'_\lambda (|\theta|)$. Using the chain rule, for all $\theta \neq 0$ the first derivative of this objective function is:
$$\begin{equation} \begin{aligned}
\quad \text{ } \text{ } F'(z,\theta)
&= \theta + \text{sgn}(\theta) \cdot p'_\lambda (|\theta|) -z \\[6pt]
&= \text{sgn}(\theta) \cdot |\theta| + \text{sgn}(\theta) \cdot p'_\lambda (|\theta|) -z \\[6pt]
&= \text{sgn}(\theta) \Big[ |\theta| + p'_\lambda (|\theta|) \Big] -z \\[6pt]
&= \text{sgn}(\theta) \cdot H_\lambda(\theta) -z. \\[6pt]
\end{aligned} \end{equation}$$
This gets us to the point where the derivative of the objective function depends on the function $H_\lambda(\theta)$, which is the function subject to the condition in question.
To complete the examination of the minimisation problem, the authors look at what happens in different cases when the minimum of this function is positive, negative, or zero. This discussion occurs on p. 1350 of the paper, and with the above form for the derivative of the objective function, it should now be easier to understand.
(As some other commentators have also noted, Figure 3 appears to me to be intended as a generic figure, rather than one corresponding to a specific form of probability function.)
|
How to prove the properties of penalized likelihood estimator in Fan and Li (2001) paper
A sufficient condition for sparsity is that $\min_{\theta \neq 0} [ |\theta| + p'_\lambda (|\theta|) ]$ is positive.
The reason for this condition is explained on p. 1350 of the paper, but it is only
|
43,467
|
How to prove the properties of penalized likelihood estimator in Fan and Li (2001) paper
|
For conclusion A sufficient condition for sparsity is $\text{min}_{\theta \neq 0} \{|\theta| + p_\lambda'(\theta)\} \gt 0$, I think I got some thoughts.
Given the condition (2) $\text{min}_{\theta \neq 0} \{|\theta| + p_\lambda'(\theta)\} \gt 0$, then we have two cases regarding $|z|$.
If $|z| \lt \text{min}_{\theta \neq 0} \{|\theta| + p_\lambda'(\theta)\}$, then according to Figure 3, the first-order derivative is positive for $\theta > 0$, and negative for $\theta < 0$. That is, the objective function is monotonously decreasing in $(-\infty, 0)$, and increasing in $(0, +\infty)$. Therefore, the penalized estimator $\hat{\theta} = 0$ in this case. Note that the objective function could be nondifferentiable at $\theta = 0$. Note also that $|z| = |\hat{\theta}^{OLS}|$ in the orthonormal case. That means, when the least square estimates are small enough (within a range), then the penalized estimates would be shrunk to 0, which leads to sparsity.
If $|z| \gt \text{min}_{\theta \neq 0} \{|\theta| + p_\lambda'(\theta)\}$, then according to Figure 3, there are two roots, say $r_1, r_2$, to the first-order equation. Thus, the objective function first increases untill $\theta = r_1$, then decreases until $\theta = r_2$, then increases again. That is, $\theta = r_2$ is the minimizer, thus the penalized estimator. Since $|z|$ is sufficiently large, we actually don't need to shrink the estimator since $\hat{\theta} = z$ is approximately unbiased if condition (1) is satisfied.
On the other hand, if the sufficient condition doesn't hold, we then cannot find a situation where the objective function can be monotonously decreasing in $(-\infty, 0)$ and increasing $(0, +\infty)$. That is, the penalized estimator will not be zero.
|
How to prove the properties of penalized likelihood estimator in Fan and Li (2001) paper
|
For conclusion A sufficient condition for sparsity is $\text{min}_{\theta \neq 0} \{|\theta| + p_\lambda'(\theta)\} \gt 0$, I think I got some thoughts.
Given the condition (2) $\text{min}_{\theta \n
|
How to prove the properties of penalized likelihood estimator in Fan and Li (2001) paper
For conclusion A sufficient condition for sparsity is $\text{min}_{\theta \neq 0} \{|\theta| + p_\lambda'(\theta)\} \gt 0$, I think I got some thoughts.
Given the condition (2) $\text{min}_{\theta \neq 0} \{|\theta| + p_\lambda'(\theta)\} \gt 0$, then we have two cases regarding $|z|$.
If $|z| \lt \text{min}_{\theta \neq 0} \{|\theta| + p_\lambda'(\theta)\}$, then according to Figure 3, the first-order derivative is positive for $\theta > 0$, and negative for $\theta < 0$. That is, the objective function is monotonously decreasing in $(-\infty, 0)$, and increasing in $(0, +\infty)$. Therefore, the penalized estimator $\hat{\theta} = 0$ in this case. Note that the objective function could be nondifferentiable at $\theta = 0$. Note also that $|z| = |\hat{\theta}^{OLS}|$ in the orthonormal case. That means, when the least square estimates are small enough (within a range), then the penalized estimates would be shrunk to 0, which leads to sparsity.
If $|z| \gt \text{min}_{\theta \neq 0} \{|\theta| + p_\lambda'(\theta)\}$, then according to Figure 3, there are two roots, say $r_1, r_2$, to the first-order equation. Thus, the objective function first increases untill $\theta = r_1$, then decreases until $\theta = r_2$, then increases again. That is, $\theta = r_2$ is the minimizer, thus the penalized estimator. Since $|z|$ is sufficiently large, we actually don't need to shrink the estimator since $\hat{\theta} = z$ is approximately unbiased if condition (1) is satisfied.
On the other hand, if the sufficient condition doesn't hold, we then cannot find a situation where the objective function can be monotonously decreasing in $(-\infty, 0)$ and increasing $(0, +\infty)$. That is, the penalized estimator will not be zero.
|
How to prove the properties of penalized likelihood estimator in Fan and Li (2001) paper
For conclusion A sufficient condition for sparsity is $\text{min}_{\theta \neq 0} \{|\theta| + p_\lambda'(\theta)\} \gt 0$, I think I got some thoughts.
Given the condition (2) $\text{min}_{\theta \n
|
43,468
|
Maximum likelihood estimation for Gaussian mixture
|
First regarding the practical issue of vanishing variance most implementations of GMM will have a limit on how small the variance can get, you can set the minimum to some small value based on your specific problem.
Secondly EM is guaranteed to improve on the objective function (Likelihood in the case of ML) or remain the same. After each iteration the parameters are updated. If the parameters have converged you have a local optimum, which is your final solution. The short answer is there is nothing preventing you form finding such a solution - If you have the necessary precautions to prevent variance going to zero.
|
Maximum likelihood estimation for Gaussian mixture
|
First regarding the practical issue of vanishing variance most implementations of GMM will have a limit on how small the variance can get, you can set the minimum to some small value based on your spe
|
Maximum likelihood estimation for Gaussian mixture
First regarding the practical issue of vanishing variance most implementations of GMM will have a limit on how small the variance can get, you can set the minimum to some small value based on your specific problem.
Secondly EM is guaranteed to improve on the objective function (Likelihood in the case of ML) or remain the same. After each iteration the parameters are updated. If the parameters have converged you have a local optimum, which is your final solution. The short answer is there is nothing preventing you form finding such a solution - If you have the necessary precautions to prevent variance going to zero.
|
Maximum likelihood estimation for Gaussian mixture
First regarding the practical issue of vanishing variance most implementations of GMM will have a limit on how small the variance can get, you can set the minimum to some small value based on your spe
|
43,469
|
Maximum likelihood estimation for Gaussian mixture
|
In such a case (like many others : HMM, ME) you should be careful to use a logistic representation of you likelyhoods, ie store log(v) instead of v for a value v. The important point is to avoid floating point underflow/overflow.
|
Maximum likelihood estimation for Gaussian mixture
|
In such a case (like many others : HMM, ME) you should be careful to use a logistic representation of you likelyhoods, ie store log(v) instead of v for a value v. The important point is to avoid float
|
Maximum likelihood estimation for Gaussian mixture
In such a case (like many others : HMM, ME) you should be careful to use a logistic representation of you likelyhoods, ie store log(v) instead of v for a value v. The important point is to avoid floating point underflow/overflow.
|
Maximum likelihood estimation for Gaussian mixture
In such a case (like many others : HMM, ME) you should be careful to use a logistic representation of you likelyhoods, ie store log(v) instead of v for a value v. The important point is to avoid float
|
43,470
|
chi-squared to test if two variables have the same frequency distribution
|
It is quite clear that something went wrong with your experiment. Specifically, it is likely that what went wrong was that the support of the two distributions you generated are not the same, and therefore, you are getting a pretty weird result from the chi-square test. Another issue is that the chi-square test is meant to compare a distribution to a unknown set of frequencies, when comparing two distributions the variability due to the estimation of the frequencies of $X$ are not accounted for.
In general, whenever you get degrees of freedom of NA and a p-value of 1 you should be pretty certain that something went wrong.
If your two random variables are indeed continuous, then the tests proposed in the comments (Kolmogorov-Smirnoff etc...) are best. If the distributions of interest are discrete then a generalized-likelihood ratio test might work well. Assume that we observe two random variables taking $p$ values each. Denote by $x_i$, $i\in\{1,...,p\}$ the number of observation of type $i$ observed from $x$, $y_i$ the number of observation of type $i$ from $y$ and by $n_x$ and $n_y$ the total number of observations. Then the likelihood ratio statistic is given by:
$$
2\log \frac{\prod_{i=1}^{p} \left(\frac{x_i}{n_x}\right)^{x_i}
\left(\frac{y_i}{n_y}\right)^{y_i}}
{\prod_{i=1}^{p} \left(\frac{y_i + x_i}{n_y + n_x}\right)^{y_i + x_i}}
\sim \chi^{2}_{p-1}.
$$
This test statistic essentially compares the fit of the model assuming two different distributions to the model assuming a single distribution for the two sets of observations. The proposed test is implemented in the following code:
discreteLR <- function(x, y, exact = FALSE) {
if(length(x) != length(y)) stop("Length of x and y must be equal!")
nx <- sum(x)
ny <- sum(y)
loglikX <- sum(x * log(x / nx))
loglikY <- sum(y * log(y / ny))
joint <- sum((y + x) * log((y + x)/ (nx + ny)))
chisq <- 2 * (loglikX + loglikY - joint)
pval <- pchisq(chisq, length(x) - 1, lower.tail = FALSE)
return(c(chisqStat = chisq, pval = pval))
}
set.seed(1)
p <- runif(5)
p <- p / sum(p)
nx <- 100
ny <- 150
reps <- 10^3
x <- rmultinom(reps, nx, p)
y <- rmultinom(reps, ny, p)
pvalues <- numeric(reps)
exact <- numeric(reps)
for(i in 1:reps) {
pvalues[i] <- discreteLR(x[, i], y[, i])[2]
}
qqplot(qunif(ppoints(reps)), pvalues,
xlab = "uniform quantiles",
ylab = "simulated p-values")
abline(a = 0, b = 1)
|
chi-squared to test if two variables have the same frequency distribution
|
It is quite clear that something went wrong with your experiment. Specifically, it is likely that what went wrong was that the support of the two distributions you generated are not the same, and ther
|
chi-squared to test if two variables have the same frequency distribution
It is quite clear that something went wrong with your experiment. Specifically, it is likely that what went wrong was that the support of the two distributions you generated are not the same, and therefore, you are getting a pretty weird result from the chi-square test. Another issue is that the chi-square test is meant to compare a distribution to a unknown set of frequencies, when comparing two distributions the variability due to the estimation of the frequencies of $X$ are not accounted for.
In general, whenever you get degrees of freedom of NA and a p-value of 1 you should be pretty certain that something went wrong.
If your two random variables are indeed continuous, then the tests proposed in the comments (Kolmogorov-Smirnoff etc...) are best. If the distributions of interest are discrete then a generalized-likelihood ratio test might work well. Assume that we observe two random variables taking $p$ values each. Denote by $x_i$, $i\in\{1,...,p\}$ the number of observation of type $i$ observed from $x$, $y_i$ the number of observation of type $i$ from $y$ and by $n_x$ and $n_y$ the total number of observations. Then the likelihood ratio statistic is given by:
$$
2\log \frac{\prod_{i=1}^{p} \left(\frac{x_i}{n_x}\right)^{x_i}
\left(\frac{y_i}{n_y}\right)^{y_i}}
{\prod_{i=1}^{p} \left(\frac{y_i + x_i}{n_y + n_x}\right)^{y_i + x_i}}
\sim \chi^{2}_{p-1}.
$$
This test statistic essentially compares the fit of the model assuming two different distributions to the model assuming a single distribution for the two sets of observations. The proposed test is implemented in the following code:
discreteLR <- function(x, y, exact = FALSE) {
if(length(x) != length(y)) stop("Length of x and y must be equal!")
nx <- sum(x)
ny <- sum(y)
loglikX <- sum(x * log(x / nx))
loglikY <- sum(y * log(y / ny))
joint <- sum((y + x) * log((y + x)/ (nx + ny)))
chisq <- 2 * (loglikX + loglikY - joint)
pval <- pchisq(chisq, length(x) - 1, lower.tail = FALSE)
return(c(chisqStat = chisq, pval = pval))
}
set.seed(1)
p <- runif(5)
p <- p / sum(p)
nx <- 100
ny <- 150
reps <- 10^3
x <- rmultinom(reps, nx, p)
y <- rmultinom(reps, ny, p)
pvalues <- numeric(reps)
exact <- numeric(reps)
for(i in 1:reps) {
pvalues[i] <- discreteLR(x[, i], y[, i])[2]
}
qqplot(qunif(ppoints(reps)), pvalues,
xlab = "uniform quantiles",
ylab = "simulated p-values")
abline(a = 0, b = 1)
|
chi-squared to test if two variables have the same frequency distribution
It is quite clear that something went wrong with your experiment. Specifically, it is likely that what went wrong was that the support of the two distributions you generated are not the same, and ther
|
43,471
|
Correlation between principal components
|
I assume each matrix $A $ and $B $ consist of random variables and observations as columns and rows or viceversa.
You can do that analysis of comparing the eigenvectors of the covariance matrices of $A $ and $B $, using the angle between them as a measure of the correlation between them. But I don't know if it is going to provide anything else that a qualitative idea. Of course this only applies if the random variables both matrices are the same, otherwise is nonsense.
Since $A $ and $B $ represent different observations from two random vectors $v_A $ and $v_B $, you may get more info from the covariance matrix of the vectors.
|
Correlation between principal components
|
I assume each matrix $A $ and $B $ consist of random variables and observations as columns and rows or viceversa.
You can do that analysis of comparing the eigenvectors of the covariance matrices of $
|
Correlation between principal components
I assume each matrix $A $ and $B $ consist of random variables and observations as columns and rows or viceversa.
You can do that analysis of comparing the eigenvectors of the covariance matrices of $A $ and $B $, using the angle between them as a measure of the correlation between them. But I don't know if it is going to provide anything else that a qualitative idea. Of course this only applies if the random variables both matrices are the same, otherwise is nonsense.
Since $A $ and $B $ represent different observations from two random vectors $v_A $ and $v_B $, you may get more info from the covariance matrix of the vectors.
|
Correlation between principal components
I assume each matrix $A $ and $B $ consist of random variables and observations as columns and rows or viceversa.
You can do that analysis of comparing the eigenvectors of the covariance matrices of $
|
43,472
|
How to evaluate uncertainty estimates in regression?
|
In regression, there are two different kinds of "uncertainties", which correspond to the difference (and frequently, confusion) between confidence intervals and prediction intervals:
You could have uncertainties in parameter estimates. These are captured in confidence-intervals. These, in turn, are hard to evaluate, because we usually do not know the true values of parameters. Thus, the most we can usually do is theoretical quality guarantees of CIs, frequently only in large sample limits.
You could have uncertainties in future observables, which are captured in prediction-intervals or more generally in predictive densities. These can be evaluated much more easily, because we will actually observe those observables at some point.
This previous thread discusses the evaluation of prediction intervals - the most common tool is the interval score. Predictive densities, in turn, are evaluated using proper scoring rules.
More information and pointers to literature can be found in Petropoulos et al. (2021), Forecasting: theory and practice (recently accepted for publication in the International Journal of Forecasting), specifically in section 2.12.2 for prediction intervals (full disclosure: I wrote that section) and in section 2.12.4 by Florian Ziel on predictive densities.
|
How to evaluate uncertainty estimates in regression?
|
In regression, there are two different kinds of "uncertainties", which correspond to the difference (and frequently, confusion) between confidence intervals and prediction intervals:
You could have u
|
How to evaluate uncertainty estimates in regression?
In regression, there are two different kinds of "uncertainties", which correspond to the difference (and frequently, confusion) between confidence intervals and prediction intervals:
You could have uncertainties in parameter estimates. These are captured in confidence-intervals. These, in turn, are hard to evaluate, because we usually do not know the true values of parameters. Thus, the most we can usually do is theoretical quality guarantees of CIs, frequently only in large sample limits.
You could have uncertainties in future observables, which are captured in prediction-intervals or more generally in predictive densities. These can be evaluated much more easily, because we will actually observe those observables at some point.
This previous thread discusses the evaluation of prediction intervals - the most common tool is the interval score. Predictive densities, in turn, are evaluated using proper scoring rules.
More information and pointers to literature can be found in Petropoulos et al. (2021), Forecasting: theory and practice (recently accepted for publication in the International Journal of Forecasting), specifically in section 2.12.2 for prediction intervals (full disclosure: I wrote that section) and in section 2.12.4 by Florian Ziel on predictive densities.
|
How to evaluate uncertainty estimates in regression?
In regression, there are two different kinds of "uncertainties", which correspond to the difference (and frequently, confusion) between confidence intervals and prediction intervals:
You could have u
|
43,473
|
Why use a mixture model with RNN instead of just directly predictive real values?
|
I am very new in the area so please take my comments with care !
I saw a lecture from Alex in this youtube channel https://www.youtube.com/channel/UC0z_jCi0XWqI8awUuQRFnyw
In this video, the first objective of Alex was to build a simulation model. Therefore, I think that the output of the model which is searched for is a random variable.
With this, every time you ask the model a simulation, you will have different results (unless you set the variance to 0 as he does in the end of the presentation under the "biases samples").
I also think that if you do have direct output (such as actually telling move the pen right 10 pixels), since in the structure (both inputs and NN structure) there is no stochastic components you could end with the same results in all cases.
|
Why use a mixture model with RNN instead of just directly predictive real values?
|
I am very new in the area so please take my comments with care !
I saw a lecture from Alex in this youtube channel https://www.youtube.com/channel/UC0z_jCi0XWqI8awUuQRFnyw
In this video, the first ob
|
Why use a mixture model with RNN instead of just directly predictive real values?
I am very new in the area so please take my comments with care !
I saw a lecture from Alex in this youtube channel https://www.youtube.com/channel/UC0z_jCi0XWqI8awUuQRFnyw
In this video, the first objective of Alex was to build a simulation model. Therefore, I think that the output of the model which is searched for is a random variable.
With this, every time you ask the model a simulation, you will have different results (unless you set the variance to 0 as he does in the end of the presentation under the "biases samples").
I also think that if you do have direct output (such as actually telling move the pen right 10 pixels), since in the structure (both inputs and NN structure) there is no stochastic components you could end with the same results in all cases.
|
Why use a mixture model with RNN instead of just directly predictive real values?
I am very new in the area so please take my comments with care !
I saw a lecture from Alex in this youtube channel https://www.youtube.com/channel/UC0z_jCi0XWqI8awUuQRFnyw
In this video, the first ob
|
43,474
|
Is F test used for feature selection only for features with numerical and continuous domain?
|
Assuming you are in the context of stepwise regression, the scale of the feature does not matter. The F-test is done on the difference of RSS values between the smaller and larger model as calculated on the outcome variable (also taking into to account the difference in the number of parameters).
For more information see: http://en.wikipedia.org/wiki/F-test#Regression_problems
|
Is F test used for feature selection only for features with numerical and continuous domain?
|
Assuming you are in the context of stepwise regression, the scale of the feature does not matter. The F-test is done on the difference of RSS values between the smaller and larger model as calculated
|
Is F test used for feature selection only for features with numerical and continuous domain?
Assuming you are in the context of stepwise regression, the scale of the feature does not matter. The F-test is done on the difference of RSS values between the smaller and larger model as calculated on the outcome variable (also taking into to account the difference in the number of parameters).
For more information see: http://en.wikipedia.org/wiki/F-test#Regression_problems
|
Is F test used for feature selection only for features with numerical and continuous domain?
Assuming you are in the context of stepwise regression, the scale of the feature does not matter. The F-test is done on the difference of RSS values between the smaller and larger model as calculated
|
43,475
|
Hamiltonian Monte-Carlo with piecewise differentiable log likelihood
|
This paper is likely relevant. Abstract:
Hamiltonian Monte Carlo (HMC) is a successful approach for sampling from continuous
densities. However, it has difficulty simulating Hamiltonian dynamics
with non-smooth functions, leading to poor performance. This paper is motivated
by the behavior of Hamiltonian dynamics in physical systems like optics. We introduce
a modification of the Leapfrog discretization of Hamiltonian dynamics on
piecewise continuous energies, where intersections of the trajectory with discontinuities
are detected, and the momentum is reflected or refracted to compensate for
the change in energy.
|
Hamiltonian Monte-Carlo with piecewise differentiable log likelihood
|
This paper is likely relevant. Abstract:
Hamiltonian Monte Carlo (HMC) is a successful approach for sampling from continuous
densities. However, it has difficulty simulating Hamiltonian dynamics
|
Hamiltonian Monte-Carlo with piecewise differentiable log likelihood
This paper is likely relevant. Abstract:
Hamiltonian Monte Carlo (HMC) is a successful approach for sampling from continuous
densities. However, it has difficulty simulating Hamiltonian dynamics
with non-smooth functions, leading to poor performance. This paper is motivated
by the behavior of Hamiltonian dynamics in physical systems like optics. We introduce
a modification of the Leapfrog discretization of Hamiltonian dynamics on
piecewise continuous energies, where intersections of the trajectory with discontinuities
are detected, and the momentum is reflected or refracted to compensate for
the change in energy.
|
Hamiltonian Monte-Carlo with piecewise differentiable log likelihood
This paper is likely relevant. Abstract:
Hamiltonian Monte Carlo (HMC) is a successful approach for sampling from continuous
densities. However, it has difficulty simulating Hamiltonian dynamics
|
43,476
|
What determines the precision of uncertainties?
|
Your pencil example is peculiar. You'll see why when I describe how this precision thing works in a typical case.
Say, you're measuring a room with a measuring tape that has 1 mm ticks. You get 10033 mm measurement. The way to report this is 10033$\pm$0.5 mm. You usually take the half the tick as an a priori uncertainty $\sigma=0.5$.
To increase precision you measure the room several times: 10033, 10041, 10031. Now you can calculate the standard deviation $\sigma_3\approx 5.3$ mm, so you can throw out the a priori uncertainty, and report $10035\pm 5$. You see how $\sigma_3>\sigma$.
Your ruler is graded with 1 cm ticks then the a priori precision is usually reported as 0.5 cm, but you can certainly eye ball with close to 1 mm precision, so maybe 0.5 mm is an appropriate precision to report. Also, who would measure a pencil with 1 cm graded ruler? I would say it's not an appropriate instrument for the task. In fact I have never seen a ruler with 1 cm ticks, even the measuring tapes used in construction would have 1 mm marks.
Get a ruler with 1 mm grading or a standard caliper, where the a priori precision is going to be much lower than the uncertainty calculated from the few repeated measurement. This way you don't need to deal with interaction of your instrument's precision and the subject of your interest.
|
What determines the precision of uncertainties?
|
Your pencil example is peculiar. You'll see why when I describe how this precision thing works in a typical case.
Say, you're measuring a room with a measuring tape that has 1 mm ticks. You get 10033
|
What determines the precision of uncertainties?
Your pencil example is peculiar. You'll see why when I describe how this precision thing works in a typical case.
Say, you're measuring a room with a measuring tape that has 1 mm ticks. You get 10033 mm measurement. The way to report this is 10033$\pm$0.5 mm. You usually take the half the tick as an a priori uncertainty $\sigma=0.5$.
To increase precision you measure the room several times: 10033, 10041, 10031. Now you can calculate the standard deviation $\sigma_3\approx 5.3$ mm, so you can throw out the a priori uncertainty, and report $10035\pm 5$. You see how $\sigma_3>\sigma$.
Your ruler is graded with 1 cm ticks then the a priori precision is usually reported as 0.5 cm, but you can certainly eye ball with close to 1 mm precision, so maybe 0.5 mm is an appropriate precision to report. Also, who would measure a pencil with 1 cm graded ruler? I would say it's not an appropriate instrument for the task. In fact I have never seen a ruler with 1 cm ticks, even the measuring tapes used in construction would have 1 mm marks.
Get a ruler with 1 mm grading or a standard caliper, where the a priori precision is going to be much lower than the uncertainty calculated from the few repeated measurement. This way you don't need to deal with interaction of your instrument's precision and the subject of your interest.
|
What determines the precision of uncertainties?
Your pencil example is peculiar. You'll see why when I describe how this precision thing works in a typical case.
Say, you're measuring a room with a measuring tape that has 1 mm ticks. You get 10033
|
43,477
|
What determines the precision of uncertainties?
|
In A, a standard deviation in the measured values which is smaller than the error on a single measurement would come about from measuring, say, 7.30 $\pm$ 0.05 cm over and over again, in which case the uncertainty in each measurement cannot be ignored in the error propagation -- in fact it dominates.
In B and C, rounding the average value to the matching most significant digit or keeping one additional digit are typical, as can be seen, for instance, in the PDG review of particle physics books/booklets or in papers on arxiv.org.
In C, note that 7.3 $\pm$ 1.3 cm has useful information: if someone else measures 8.5, this is 'within uncertainty,' but would not be if you reported 7 $\pm$ 1 cm.
|
What determines the precision of uncertainties?
|
In A, a standard deviation in the measured values which is smaller than the error on a single measurement would come about from measuring, say, 7.30 $\pm$ 0.05 cm over and over again, in which case th
|
What determines the precision of uncertainties?
In A, a standard deviation in the measured values which is smaller than the error on a single measurement would come about from measuring, say, 7.30 $\pm$ 0.05 cm over and over again, in which case the uncertainty in each measurement cannot be ignored in the error propagation -- in fact it dominates.
In B and C, rounding the average value to the matching most significant digit or keeping one additional digit are typical, as can be seen, for instance, in the PDG review of particle physics books/booklets or in papers on arxiv.org.
In C, note that 7.3 $\pm$ 1.3 cm has useful information: if someone else measures 8.5, this is 'within uncertainty,' but would not be if you reported 7 $\pm$ 1 cm.
|
What determines the precision of uncertainties?
In A, a standard deviation in the measured values which is smaller than the error on a single measurement would come about from measuring, say, 7.30 $\pm$ 0.05 cm over and over again, in which case th
|
43,478
|
What determines the precision of uncertainties?
|
You asked
"Would there ever be a reason where one is justified in reporting an uncertainty with more than one significant figure? For example, 7.3 ± 1.3 cm?"
On one hand, 7.3 ± 1.3 has a relative uncertainty of 1.3/7.3 = 0.178 whereas 7.3 ± 1 has a relative uncertainty of 1/7.3 = 0.137. You are saying you "know more" in the second case than you do in the first. It is not a good practice to state the uncertainty in a way that overstates what you know, so the uncertainty should be presented with two significant digits. One can extend this logic and argue that we should use more than two digits in the uncertainty, but the uncertainty in the uncertainty is so large that this is usually not justified.
|
What determines the precision of uncertainties?
|
You asked
"Would there ever be a reason where one is justified in reporting an uncertainty with more than one significant figure? For example, 7.3 ± 1.3 cm?"
On one hand, 7.3 ± 1.3 has a relative u
|
What determines the precision of uncertainties?
You asked
"Would there ever be a reason where one is justified in reporting an uncertainty with more than one significant figure? For example, 7.3 ± 1.3 cm?"
On one hand, 7.3 ± 1.3 has a relative uncertainty of 1.3/7.3 = 0.178 whereas 7.3 ± 1 has a relative uncertainty of 1/7.3 = 0.137. You are saying you "know more" in the second case than you do in the first. It is not a good practice to state the uncertainty in a way that overstates what you know, so the uncertainty should be presented with two significant digits. One can extend this logic and argue that we should use more than two digits in the uncertainty, but the uncertainty in the uncertainty is so large that this is usually not justified.
|
What determines the precision of uncertainties?
You asked
"Would there ever be a reason where one is justified in reporting an uncertainty with more than one significant figure? For example, 7.3 ± 1.3 cm?"
On one hand, 7.3 ± 1.3 has a relative u
|
43,479
|
How do you find the population size N based on the highest n values?
|
This is a nice question. I’ll give it a try... Denote by $\Phi$ the cdf of the normal distribution and by $\phi$ its density. The joint distribution of the $n$ highest scores $y_{(N-n+1)}, \dots, y_{(N)} $ is
$$ {N ! \over (N-n) !} \Phi(y_{(N-n+1)})^{N-n} \phi(y_{(N-n+1)}) \cdots \phi( y_{(N)} ), $$
(that is, $N-n$ values among $N$ below $y_{(N-n+1)}$, and the others where observed).
This is a bit puzzling at first sight: the usual setting would be that you know $N$ and $n$ and you want to infer the parameters of the distribution. Here you are interested only in $N$ so the MLE is obtained by maximizing
$$(N - n) \log \Phi(y_{(N-n+1)}) + \log(N!) - \log\left((N-n) !\right).$$
This is kind of intuitive: the grade of the last admitted $y_{(N-n+1)}$ and the number of admitted are all that matters.
A quick numerical experiment:
> N <- 1000
> set.seed(1)
> x <- sort(rnorm(N), decreasing=TRUE)[1:10]
> x
[1] 3.810277 3.055742 2.675741 2.649167 2.497662 2.446531 2.401618 2.350554
[9] 2.349493 2.321334
> f <- function(N, n = 10, xn = x[n])
+ (N-n)*log(pnorm(xn)) + lfactorial(N) - lfactorial(N-n)
> plot( 800:1200, sapply(800:1200, f), type="l")
This looks promising. Let's have a look on the properties of this estimator, again for $n = 10$:
> MLE <- replicate( 1e4, {x <- sort(rnorm(N), decreasing=TRUE)[1:10];
+ optimize(f, c(100,20000), maximum=TRUE, xn = x[10])$maximum} )
> mean(MLE)
[1] 1112.798
> sd(MLE)
[1] 393.086
> hist(MLE, breaks=40)
However from you edits to your question I think that you want to estimate both $n$ and the parameters of the normal distribution. This could be done by maximizing the log of above the joint density. However for your concrete application, the underlying distribution is unlikely to be normal. It is surely a mixture between the grades of diversely prepared candidates, and I am not optimistic about the possibility of obtaining good estimates.
So let’s try that again, with unknown parameters for the normal distribution:
g <- function(N, mu, sd, X) {
n <- length(x);
(N-n)*pnorm(X[n], mean = mu, sd = sd, log.p = TRUE)
+ sum(dnorm(X, mean=mu, sd=sd, log=TRUE))
+ lfactorial(N) - lfactorial(N-n)
}
> optim( c(1000,0,1), function(theta) -g(theta[1], theta[2], theta[3], x) )
$par
[1] 292951.707061 -3.650634 1.498264
$value
[1] -13.78503
So the MLE says here that the best guess is a mean of -3.65 (instead of 0), a standard deviation of 1.49 (instead of 1, well, ok), and a size $N = 293 000$... hu... Well let’s try again with $n = 100$: 10 observations is not much!
> set.seed(17)
> x <- sort(rnorm(N), decreasing=TRUE)[1:100]
> optim( c(1000,0,1), function(theta) -g(theta[1], theta[2], theta[3], x) )
$par
[1] 1031.1320174 -0.2112833 1.1694436
$value
[1] -321.6677
Not so bad...? but if I try again with set.seed(18), the estimate for $N$ is 5000...! I might be missing something, but for the moment I continue to be pessimistic.
Moreover, in the real world the grades are not normal. It is not rare to have a frankly bi-modal distribution, and the right tail is often quite special. The best students/candidates are far off the distribution, I have had multiple occasions to check this. So it is wrong to rely on the right tail for making these estimates: for example, if the $n = 20$ best candidates are all from a (relatively) homogeneous group of $100$ very smart and well prepared candidates, you will estimate only the size of this group; you won’t have any information on the (much more numerous) less prepared candidates.
|
How do you find the population size N based on the highest n values?
|
This is a nice question. I’ll give it a try... Denote by $\Phi$ the cdf of the normal distribution and by $\phi$ its density. The joint distribution of the $n$ highest scores $y_{(N-n+1)}, \dots, y_{(
|
How do you find the population size N based on the highest n values?
This is a nice question. I’ll give it a try... Denote by $\Phi$ the cdf of the normal distribution and by $\phi$ its density. The joint distribution of the $n$ highest scores $y_{(N-n+1)}, \dots, y_{(N)} $ is
$$ {N ! \over (N-n) !} \Phi(y_{(N-n+1)})^{N-n} \phi(y_{(N-n+1)}) \cdots \phi( y_{(N)} ), $$
(that is, $N-n$ values among $N$ below $y_{(N-n+1)}$, and the others where observed).
This is a bit puzzling at first sight: the usual setting would be that you know $N$ and $n$ and you want to infer the parameters of the distribution. Here you are interested only in $N$ so the MLE is obtained by maximizing
$$(N - n) \log \Phi(y_{(N-n+1)}) + \log(N!) - \log\left((N-n) !\right).$$
This is kind of intuitive: the grade of the last admitted $y_{(N-n+1)}$ and the number of admitted are all that matters.
A quick numerical experiment:
> N <- 1000
> set.seed(1)
> x <- sort(rnorm(N), decreasing=TRUE)[1:10]
> x
[1] 3.810277 3.055742 2.675741 2.649167 2.497662 2.446531 2.401618 2.350554
[9] 2.349493 2.321334
> f <- function(N, n = 10, xn = x[n])
+ (N-n)*log(pnorm(xn)) + lfactorial(N) - lfactorial(N-n)
> plot( 800:1200, sapply(800:1200, f), type="l")
This looks promising. Let's have a look on the properties of this estimator, again for $n = 10$:
> MLE <- replicate( 1e4, {x <- sort(rnorm(N), decreasing=TRUE)[1:10];
+ optimize(f, c(100,20000), maximum=TRUE, xn = x[10])$maximum} )
> mean(MLE)
[1] 1112.798
> sd(MLE)
[1] 393.086
> hist(MLE, breaks=40)
However from you edits to your question I think that you want to estimate both $n$ and the parameters of the normal distribution. This could be done by maximizing the log of above the joint density. However for your concrete application, the underlying distribution is unlikely to be normal. It is surely a mixture between the grades of diversely prepared candidates, and I am not optimistic about the possibility of obtaining good estimates.
So let’s try that again, with unknown parameters for the normal distribution:
g <- function(N, mu, sd, X) {
n <- length(x);
(N-n)*pnorm(X[n], mean = mu, sd = sd, log.p = TRUE)
+ sum(dnorm(X, mean=mu, sd=sd, log=TRUE))
+ lfactorial(N) - lfactorial(N-n)
}
> optim( c(1000,0,1), function(theta) -g(theta[1], theta[2], theta[3], x) )
$par
[1] 292951.707061 -3.650634 1.498264
$value
[1] -13.78503
So the MLE says here that the best guess is a mean of -3.65 (instead of 0), a standard deviation of 1.49 (instead of 1, well, ok), and a size $N = 293 000$... hu... Well let’s try again with $n = 100$: 10 observations is not much!
> set.seed(17)
> x <- sort(rnorm(N), decreasing=TRUE)[1:100]
> optim( c(1000,0,1), function(theta) -g(theta[1], theta[2], theta[3], x) )
$par
[1] 1031.1320174 -0.2112833 1.1694436
$value
[1] -321.6677
Not so bad...? but if I try again with set.seed(18), the estimate for $N$ is 5000...! I might be missing something, but for the moment I continue to be pessimistic.
Moreover, in the real world the grades are not normal. It is not rare to have a frankly bi-modal distribution, and the right tail is often quite special. The best students/candidates are far off the distribution, I have had multiple occasions to check this. So it is wrong to rely on the right tail for making these estimates: for example, if the $n = 20$ best candidates are all from a (relatively) homogeneous group of $100$ very smart and well prepared candidates, you will estimate only the size of this group; you won’t have any information on the (much more numerous) less prepared candidates.
|
How do you find the population size N based on the highest n values?
This is a nice question. I’ll give it a try... Denote by $\Phi$ the cdf of the normal distribution and by $\phi$ its density. The joint distribution of the $n$ highest scores $y_{(N-n+1)}, \dots, y_{(
|
43,480
|
two margin comparison and one conclusion?
|
Since the value of $\phi_2$ is twice that of $\phi_1$, all the distances in $\phi_2$-space are twice as big as the distances in $\phi_1$-space. This means that the margin (which is roughly the "thickness" of the separating hyperplane that the SVM learns) is twice as big also. We can show this with an even simpler pair of kernel functions, $\phi_1(x, y) = (x, y)$ and $\phi_2(x) = (2x, 2y)$--the principle is exactly the same as with the pair of kernels you suggested.
If you have a dataset with positive points at $(0,0), (0,1)$ and negative points at $(1,0), (1,1)$, then using $\phi_1$ you'll learn the following SVM:
On the other hand, $\phi_2$ multiplies each coordinate by 2 relative to $\phi_1$, so you learn the following hyperplane instead:
As you can see, because all distances are inflated by a factor of 2, the margin is greater as well.
Appendix: R code for plots
do.plot <- function(D, main, sub) {
plot(NA, xlim=c(-0.5, 2.5), ylim=c(-0.5, 2.5), xlab='x', ylab='y', main=main, sub=sub)
points(c(0, 0), c(0, D), pch='+')
points(c(D, D), c(0, D), pch=4)
abline(v=0, lty=2)
abline(v=D, lty=2)
abline(v=D/2)
}
do.plot(1, 'phi1', 'margin=1')
do.plot(2, 'phi2', 'margin=2')
|
two margin comparison and one conclusion?
|
Since the value of $\phi_2$ is twice that of $\phi_1$, all the distances in $\phi_2$-space are twice as big as the distances in $\phi_1$-space. This means that the margin (which is roughly the "thickn
|
two margin comparison and one conclusion?
Since the value of $\phi_2$ is twice that of $\phi_1$, all the distances in $\phi_2$-space are twice as big as the distances in $\phi_1$-space. This means that the margin (which is roughly the "thickness" of the separating hyperplane that the SVM learns) is twice as big also. We can show this with an even simpler pair of kernel functions, $\phi_1(x, y) = (x, y)$ and $\phi_2(x) = (2x, 2y)$--the principle is exactly the same as with the pair of kernels you suggested.
If you have a dataset with positive points at $(0,0), (0,1)$ and negative points at $(1,0), (1,1)$, then using $\phi_1$ you'll learn the following SVM:
On the other hand, $\phi_2$ multiplies each coordinate by 2 relative to $\phi_1$, so you learn the following hyperplane instead:
As you can see, because all distances are inflated by a factor of 2, the margin is greater as well.
Appendix: R code for plots
do.plot <- function(D, main, sub) {
plot(NA, xlim=c(-0.5, 2.5), ylim=c(-0.5, 2.5), xlab='x', ylab='y', main=main, sub=sub)
points(c(0, 0), c(0, D), pch='+')
points(c(D, D), c(0, D), pch=4)
abline(v=0, lty=2)
abline(v=D, lty=2)
abline(v=D/2)
}
do.plot(1, 'phi1', 'margin=1')
do.plot(2, 'phi2', 'margin=2')
|
two margin comparison and one conclusion?
Since the value of $\phi_2$ is twice that of $\phi_1$, all the distances in $\phi_2$-space are twice as big as the distances in $\phi_1$-space. This means that the margin (which is roughly the "thickn
|
43,481
|
How to make a trained neural network "forget" an instance?
|
It depends on the type of Neural Network you are using. A single layer Perceptron could do this by subtracting the eta value from each node the number of iterations you trained on based on the activated or not activated features and outputs.
If you are using any optimization techniques like early stopping however it wont make sense since the network was dynamically adjusted during training. If you want to incorporate or exclude data from your training set, I would instead go with an unsupervised learning model like KNN, or save the data and re-train the network using something like early stopping to optimize the outputs for the next version of the model without the instance of data you are attempting to "forget"
|
How to make a trained neural network "forget" an instance?
|
It depends on the type of Neural Network you are using. A single layer Perceptron could do this by subtracting the eta value from each node the number of iterations you trained on based on the activat
|
How to make a trained neural network "forget" an instance?
It depends on the type of Neural Network you are using. A single layer Perceptron could do this by subtracting the eta value from each node the number of iterations you trained on based on the activated or not activated features and outputs.
If you are using any optimization techniques like early stopping however it wont make sense since the network was dynamically adjusted during training. If you want to incorporate or exclude data from your training set, I would instead go with an unsupervised learning model like KNN, or save the data and re-train the network using something like early stopping to optimize the outputs for the next version of the model without the instance of data you are attempting to "forget"
|
How to make a trained neural network "forget" an instance?
It depends on the type of Neural Network you are using. A single layer Perceptron could do this by subtracting the eta value from each node the number of iterations you trained on based on the activat
|
43,482
|
Ridge regression in multivariate Gaussian distribution
|
It is beyond my current knowledge to present a detailed answer. However, I hope that the following resources will help you figure out the solution. Check this set of presentation slides. Take a look at page 9 of this document: see references to Thisted (1976) and to Brown and Zidek (1980) before equation 18. Finally, this more recent document on ridge regression might provide additional ideas.
|
Ridge regression in multivariate Gaussian distribution
|
It is beyond my current knowledge to present a detailed answer. However, I hope that the following resources will help you figure out the solution. Check this set of presentation slides. Take a look a
|
Ridge regression in multivariate Gaussian distribution
It is beyond my current knowledge to present a detailed answer. However, I hope that the following resources will help you figure out the solution. Check this set of presentation slides. Take a look at page 9 of this document: see references to Thisted (1976) and to Brown and Zidek (1980) before equation 18. Finally, this more recent document on ridge regression might provide additional ideas.
|
Ridge regression in multivariate Gaussian distribution
It is beyond my current knowledge to present a detailed answer. However, I hope that the following resources will help you figure out the solution. Check this set of presentation slides. Take a look a
|
43,483
|
Can I penalize an arbitrary regression model and get Elastic-Net-esque results?
|
I'll try to address this question in a general way. For generalized linear models (GLM), it makes complete sense to use elastic-net priors on the parameters as you describe. This is merely to say that the standard elastic-net regularization framework works out-of-the-box for a broader class of models than simply Bernoulli and Gaussian observation models which are simple examples of GLMs, (e.g. Poisson observations correspond to another GLM).
Each GLM has a canonical link and when using this link function, the GLM is log-concave, and the negative log likelihood (NLL) is convex. The L1 and L2 penalties are convex. The sum of these convex penalties with the convex objective (NLL) gives an overall convex objective.
The possible issues arise is if you use a non-standard link (specific non-standard links won't break things) or aren't using a GLM. Basically for an arbitrary regression objective, it may be the case that the NLL part of your objective will no longer be convex (although the penalties will remain convex). Even if the NLL is not convex, the penalties will affect the estimated weights, but guarantees are weaker since you will obtain locally optimal weights.
For specific examples you have, you could check whether your objective function is convex before the addition of penalties. If it is, then the addition of convex penalties usually preserves convexity. If the original objective is not convex, then the messiness is probably coming from that rather than the penalties.
|
Can I penalize an arbitrary regression model and get Elastic-Net-esque results?
|
I'll try to address this question in a general way. For generalized linear models (GLM), it makes complete sense to use elastic-net priors on the parameters as you describe. This is merely to say th
|
Can I penalize an arbitrary regression model and get Elastic-Net-esque results?
I'll try to address this question in a general way. For generalized linear models (GLM), it makes complete sense to use elastic-net priors on the parameters as you describe. This is merely to say that the standard elastic-net regularization framework works out-of-the-box for a broader class of models than simply Bernoulli and Gaussian observation models which are simple examples of GLMs, (e.g. Poisson observations correspond to another GLM).
Each GLM has a canonical link and when using this link function, the GLM is log-concave, and the negative log likelihood (NLL) is convex. The L1 and L2 penalties are convex. The sum of these convex penalties with the convex objective (NLL) gives an overall convex objective.
The possible issues arise is if you use a non-standard link (specific non-standard links won't break things) or aren't using a GLM. Basically for an arbitrary regression objective, it may be the case that the NLL part of your objective will no longer be convex (although the penalties will remain convex). Even if the NLL is not convex, the penalties will affect the estimated weights, but guarantees are weaker since you will obtain locally optimal weights.
For specific examples you have, you could check whether your objective function is convex before the addition of penalties. If it is, then the addition of convex penalties usually preserves convexity. If the original objective is not convex, then the messiness is probably coming from that rather than the penalties.
|
Can I penalize an arbitrary regression model and get Elastic-Net-esque results?
I'll try to address this question in a general way. For generalized linear models (GLM), it makes complete sense to use elastic-net priors on the parameters as you describe. This is merely to say th
|
43,484
|
An 'easy' exercise on conditional expectations and filtrations
|
Following the hint given by Windridge, let $\mathbb{E} \left[ \mathbb{E} \left[X \middle \vert F\right] \middle\vert G\right] = \mathbb{E} \left[ Y \middle\vert G\right]$, where $Y = \mathbb{E} \left[X \middle\vert F\right]$.
$\mathbb{E} \left[Y \middle\vert G\right] = \sum y \, \Pr\left(Y = y \middle\vert G\right)$.
If $\omega =\{a, b\}$, $\mathbb{E} \left[Y \middle\vert G\right] = \frac{1}{2} \bullet \Pr \left( \mathbb{E} \left[X \middle\vert F\right] = \frac{1}{2} \middle\vert \omega =\{a, b\} \right) + 1 \bullet \Pr \left( \mathbb{E} \left[X \middle\vert F\right] = 1\middle\vert \omega =\{a, b\} \right) = \frac{1}{2} \bullet \frac{\mathbb{Q}(a)}{\mathbb{Q}(a)+\mathbb{Q}(b)} + 1 \bullet \frac{\mathbb{Q}(b)}{\mathbb{Q}(a)+\mathbb{Q}(b)} = \frac{2}{3} \, .$
|
An 'easy' exercise on conditional expectations and filtrations
|
Following the hint given by Windridge, let $\mathbb{E} \left[ \mathbb{E} \left[X \middle \vert F\right] \middle\vert G\right] = \mathbb{E} \left[ Y \middle\vert G\right]$, where $Y = \mathbb{E} \left[
|
An 'easy' exercise on conditional expectations and filtrations
Following the hint given by Windridge, let $\mathbb{E} \left[ \mathbb{E} \left[X \middle \vert F\right] \middle\vert G\right] = \mathbb{E} \left[ Y \middle\vert G\right]$, where $Y = \mathbb{E} \left[X \middle\vert F\right]$.
$\mathbb{E} \left[Y \middle\vert G\right] = \sum y \, \Pr\left(Y = y \middle\vert G\right)$.
If $\omega =\{a, b\}$, $\mathbb{E} \left[Y \middle\vert G\right] = \frac{1}{2} \bullet \Pr \left( \mathbb{E} \left[X \middle\vert F\right] = \frac{1}{2} \middle\vert \omega =\{a, b\} \right) + 1 \bullet \Pr \left( \mathbb{E} \left[X \middle\vert F\right] = 1\middle\vert \omega =\{a, b\} \right) = \frac{1}{2} \bullet \frac{\mathbb{Q}(a)}{\mathbb{Q}(a)+\mathbb{Q}(b)} + 1 \bullet \frac{\mathbb{Q}(b)}{\mathbb{Q}(a)+\mathbb{Q}(b)} = \frac{2}{3} \, .$
|
An 'easy' exercise on conditional expectations and filtrations
Following the hint given by Windridge, let $\mathbb{E} \left[ \mathbb{E} \left[X \middle \vert F\right] \middle\vert G\right] = \mathbb{E} \left[ Y \middle\vert G\right]$, where $Y = \mathbb{E} \left[
|
43,485
|
An 'easy' exercise on conditional expectations and filtrations
|
Let $ \Omega = ${a,b,c} with $\mathbb{P}$({a}) = 1/2, $\mathbb{P}$({b}) = 1/4 and $\mathbb{P}$({c}) = 1/4.
Define a random variable X
$$ X =
\begin{cases}
1 , \quad & w = \{ a \}, P(X = 1) = 1/2\\
2 , \quad & w = \{ b,c \}, P(X = 2) = 1/2\\
\end{cases} \\
$$
Define 2 sigma-algebra:
$ \mathcal{F}:=\left\{ \emptyset ,\left\{a\right\},\left\{b,c\right\},\Omega\right\} $
$ \mathcal{G}:=\left \{ \emptyset ,\left \{a,b\right \},\left \{c\right \},\Omega\right \}$
Obviously, $X$ is $\mathcal{F}$-measurable,so $\mathbb{E} \left [ X|\mathcal{F} \right ] = X $
$$\begin{aligned}
\mathbb{E} \left [\mathbb{E} \left [ X|\mathcal{F} \right ]|\mathcal{G} \right ]
& =
\mathbb{E} \left [ X|\mathcal{G} \right ] \\
& =
\begin{cases}
4/3 , & w = \{ a,b \}, P(Y = 4/3) = 3/4 \\
2 , & w = \{ c \}, P(Y = 2) = 1/4 \\
\end{cases} \\
& := Y \\
\end{aligned}$$
$$\begin{aligned}
\mathbb{E} \left [\mathbb{E} \left [ X|\mathcal{G} \right ]|\mathcal{F} \right ]
& =
\mathbb{E} \left [ Y|\mathcal{F} \right ] \\
& =
\begin{cases}
4/3 , & w = \{ a \}, P(Y = 4/3) = 1/2 \\
5/3 , & w = \{ b,c \}, P(Y = 5/3) = 1/2 \\
\end{cases} \\
\end{aligned}$$
|
An 'easy' exercise on conditional expectations and filtrations
|
Let $ \Omega = ${a,b,c} with $\mathbb{P}$({a}) = 1/2, $\mathbb{P}$({b}) = 1/4 and $\mathbb{P}$({c}) = 1/4.
Define a random variable X
$$ X =
\begin{cases}
1 , \quad & w = \{ a \}, P(X = 1) = 1/2\\
|
An 'easy' exercise on conditional expectations and filtrations
Let $ \Omega = ${a,b,c} with $\mathbb{P}$({a}) = 1/2, $\mathbb{P}$({b}) = 1/4 and $\mathbb{P}$({c}) = 1/4.
Define a random variable X
$$ X =
\begin{cases}
1 , \quad & w = \{ a \}, P(X = 1) = 1/2\\
2 , \quad & w = \{ b,c \}, P(X = 2) = 1/2\\
\end{cases} \\
$$
Define 2 sigma-algebra:
$ \mathcal{F}:=\left\{ \emptyset ,\left\{a\right\},\left\{b,c\right\},\Omega\right\} $
$ \mathcal{G}:=\left \{ \emptyset ,\left \{a,b\right \},\left \{c\right \},\Omega\right \}$
Obviously, $X$ is $\mathcal{F}$-measurable,so $\mathbb{E} \left [ X|\mathcal{F} \right ] = X $
$$\begin{aligned}
\mathbb{E} \left [\mathbb{E} \left [ X|\mathcal{F} \right ]|\mathcal{G} \right ]
& =
\mathbb{E} \left [ X|\mathcal{G} \right ] \\
& =
\begin{cases}
4/3 , & w = \{ a,b \}, P(Y = 4/3) = 3/4 \\
2 , & w = \{ c \}, P(Y = 2) = 1/4 \\
\end{cases} \\
& := Y \\
\end{aligned}$$
$$\begin{aligned}
\mathbb{E} \left [\mathbb{E} \left [ X|\mathcal{G} \right ]|\mathcal{F} \right ]
& =
\mathbb{E} \left [ Y|\mathcal{F} \right ] \\
& =
\begin{cases}
4/3 , & w = \{ a \}, P(Y = 4/3) = 1/2 \\
5/3 , & w = \{ b,c \}, P(Y = 5/3) = 1/2 \\
\end{cases} \\
\end{aligned}$$
|
An 'easy' exercise on conditional expectations and filtrations
Let $ \Omega = ${a,b,c} with $\mathbb{P}$({a}) = 1/2, $\mathbb{P}$({b}) = 1/4 and $\mathbb{P}$({c}) = 1/4.
Define a random variable X
$$ X =
\begin{cases}
1 , \quad & w = \{ a \}, P(X = 1) = 1/2\\
|
43,486
|
Statistics for model selection and model evaluation
|
I'll attempt to answer each question in turn. Contrary to fg nu's comment, I think there are real questions here - and real, although perhaps difficult, answers, too. Throughout, when I refer to the mis-use of statistics, I mean failing to recognise that one has made the mistake of mis-using the statistics for both model selection and model evaluation, as opposed to intentionally doing so. In other words, intellectual honesty is assumed. I self-answer in order to motivate more answers.
Q: Are there any guidelines that producers of models can follow in order to avoid misusing statistics in this way?
One guideline would be to put a considerable amount of time into planning one's research. This seems to sit in nicely with both Hendry and Leamer's methodological standpoints (despite it being arguable to attach the labels frequentist and Bayesian, respectively). For example, Leamer suggests three stages of data analysis; planning, criticism, and revision. He says that much time should be dedicated to the planning stage, which he defines as "preparing responses to hypothetical data sets". Having thought about the research process, the decisions faced at each node, and the corresponding responses, one ought to be less inclined to make the mistake of using a statistic for two conflicting purposes. As long as everything is tractable, the possibility of making this mistake could be eliminated. This is related to algorithmic research or automatic selection methods mentioned below.
Q: Which model building strategies are least/most open to this trap?
Without knowing the complete set of strategies, it's difficult to pin down the exact strategies most/least exposed to this trap. However, I will classify strategies based on one particular property to try and get a sensible answer. The key property is programmable. Modelling strategies that involve a significant amount of planning and that can be programmed or written out as a recipe - however complex that may be - are the strategies least open to using statistics for the dual purpose of model selection and model evaluation. That is, of course, under the assumption that one of the goals of the programmer would be to avoid the mis-use of statistics!
Interestingly, fast forwarding in time from Hendry's Dynamic Econometrics to his latest work with Doornik on automatic selection methods, one gets the sense that such programmatic or algorithmic research is something that will become more of a norm in the future.
The strategies most susceptible to the mis-use of statistics are modelling strategies that are unstructured; those that contain ad hockery and which may not be replicable. These unstructured methods are closely related to what Leamer refers to ad hoc specification searches (which disguise private beliefs) and the patchwork textbook econometrics that Hendry gives examples of.
Q: What can consumers of models do when they suspect that statistics have been used in this way?
Try to perform a replication study - or have someone else skilled enough to try and do it for you.
Q: Is the crime to the extent that the model loses its usefulness altogether?
Here, I borrow on Hendry, who says that "how a final model is derived is largely irrelevant; it is either useful or not, and that characteristic is independent of whether it comes purely from whimsy, some precise theory, or a very structured search." Note that it's largely irrelevant and not completely irrelevant; the advice to avoid mis-using statistics for model selection and model evaluation still stands. In other words, mis-use would likely result in the model not being the most dominant model (hence the advice to avoid it), however, if, for whatever reason, it did turn out to be the best and final model, any decision made during the research process would not impact on the model's usefulness.
References that I found to be useful when answering this question include:
The ET Dialogue: A Conversation on Econometric Methodology David F. Hendry, Edward E. Leamer and Dale J. Poirier Econometric Theory Vol. 6, No. 2 (Jun., 1990), pp. 171-261
Empirical Model Discovery and Theory Evaluation - Automatic Selection Methods in Econometrics By David F. Hendry and Jurgen A. Doornik
And the following presentation, entitled "How Empirical Evidence Does or Does Not Influence Economic Thinking and Theory" by David Hendry.
|
Statistics for model selection and model evaluation
|
I'll attempt to answer each question in turn. Contrary to fg nu's comment, I think there are real questions here - and real, although perhaps difficult, answers, too. Throughout, when I refer to the m
|
Statistics for model selection and model evaluation
I'll attempt to answer each question in turn. Contrary to fg nu's comment, I think there are real questions here - and real, although perhaps difficult, answers, too. Throughout, when I refer to the mis-use of statistics, I mean failing to recognise that one has made the mistake of mis-using the statistics for both model selection and model evaluation, as opposed to intentionally doing so. In other words, intellectual honesty is assumed. I self-answer in order to motivate more answers.
Q: Are there any guidelines that producers of models can follow in order to avoid misusing statistics in this way?
One guideline would be to put a considerable amount of time into planning one's research. This seems to sit in nicely with both Hendry and Leamer's methodological standpoints (despite it being arguable to attach the labels frequentist and Bayesian, respectively). For example, Leamer suggests three stages of data analysis; planning, criticism, and revision. He says that much time should be dedicated to the planning stage, which he defines as "preparing responses to hypothetical data sets". Having thought about the research process, the decisions faced at each node, and the corresponding responses, one ought to be less inclined to make the mistake of using a statistic for two conflicting purposes. As long as everything is tractable, the possibility of making this mistake could be eliminated. This is related to algorithmic research or automatic selection methods mentioned below.
Q: Which model building strategies are least/most open to this trap?
Without knowing the complete set of strategies, it's difficult to pin down the exact strategies most/least exposed to this trap. However, I will classify strategies based on one particular property to try and get a sensible answer. The key property is programmable. Modelling strategies that involve a significant amount of planning and that can be programmed or written out as a recipe - however complex that may be - are the strategies least open to using statistics for the dual purpose of model selection and model evaluation. That is, of course, under the assumption that one of the goals of the programmer would be to avoid the mis-use of statistics!
Interestingly, fast forwarding in time from Hendry's Dynamic Econometrics to his latest work with Doornik on automatic selection methods, one gets the sense that such programmatic or algorithmic research is something that will become more of a norm in the future.
The strategies most susceptible to the mis-use of statistics are modelling strategies that are unstructured; those that contain ad hockery and which may not be replicable. These unstructured methods are closely related to what Leamer refers to ad hoc specification searches (which disguise private beliefs) and the patchwork textbook econometrics that Hendry gives examples of.
Q: What can consumers of models do when they suspect that statistics have been used in this way?
Try to perform a replication study - or have someone else skilled enough to try and do it for you.
Q: Is the crime to the extent that the model loses its usefulness altogether?
Here, I borrow on Hendry, who says that "how a final model is derived is largely irrelevant; it is either useful or not, and that characteristic is independent of whether it comes purely from whimsy, some precise theory, or a very structured search." Note that it's largely irrelevant and not completely irrelevant; the advice to avoid mis-using statistics for model selection and model evaluation still stands. In other words, mis-use would likely result in the model not being the most dominant model (hence the advice to avoid it), however, if, for whatever reason, it did turn out to be the best and final model, any decision made during the research process would not impact on the model's usefulness.
References that I found to be useful when answering this question include:
The ET Dialogue: A Conversation on Econometric Methodology David F. Hendry, Edward E. Leamer and Dale J. Poirier Econometric Theory Vol. 6, No. 2 (Jun., 1990), pp. 171-261
Empirical Model Discovery and Theory Evaluation - Automatic Selection Methods in Econometrics By David F. Hendry and Jurgen A. Doornik
And the following presentation, entitled "How Empirical Evidence Does or Does Not Influence Economic Thinking and Theory" by David Hendry.
|
Statistics for model selection and model evaluation
I'll attempt to answer each question in turn. Contrary to fg nu's comment, I think there are real questions here - and real, although perhaps difficult, answers, too. Throughout, when I refer to the m
|
43,487
|
Deviance of a regression model
|
I'm also trying to understand how the dispersion parameter should be included in the formula to compute the deviance of a linear model from its log-likelihood, and I cannot find any reference in books about GLMs. This is really a mystery to me. Even if this is quite a basic point, the fact that nobody answered seems to indicate it's obscure for many people...
My small contribution: since the log-likelihood of the saturated model is Inf, we may also start with a simpler question, and compute the difference in deviance between two non-saturated models. But this still doesn't work:
library(MASS)
data(cats)
m0=lm(Hwt~Bwt,data=cats)
m1=lm(Hwt~Bwt+Sex,data=cats)
deviance(m1)-deviance(m0)
#[1] -0.1548002
as.numeric(-2*(logLik(m1)-logLik(m0)))
#[1] -0.07443916
It seems obvious to me that the dispersion parameter should be included in the formula, but how? For a start, there are two estimations of the dispersion, one for m1 and one for m2.
|
Deviance of a regression model
|
I'm also trying to understand how the dispersion parameter should be included in the formula to compute the deviance of a linear model from its log-likelihood, and I cannot find any reference in books
|
Deviance of a regression model
I'm also trying to understand how the dispersion parameter should be included in the formula to compute the deviance of a linear model from its log-likelihood, and I cannot find any reference in books about GLMs. This is really a mystery to me. Even if this is quite a basic point, the fact that nobody answered seems to indicate it's obscure for many people...
My small contribution: since the log-likelihood of the saturated model is Inf, we may also start with a simpler question, and compute the difference in deviance between two non-saturated models. But this still doesn't work:
library(MASS)
data(cats)
m0=lm(Hwt~Bwt,data=cats)
m1=lm(Hwt~Bwt+Sex,data=cats)
deviance(m1)-deviance(m0)
#[1] -0.1548002
as.numeric(-2*(logLik(m1)-logLik(m0)))
#[1] -0.07443916
It seems obvious to me that the dispersion parameter should be included in the formula, but how? For a start, there are two estimations of the dispersion, one for m1 and one for m2.
|
Deviance of a regression model
I'm also trying to understand how the dispersion parameter should be included in the formula to compute the deviance of a linear model from its log-likelihood, and I cannot find any reference in books
|
43,488
|
How to implement Gaussian process using GPML toolbox with known output noise?
|
The output noise in the GPML toolbox is defined in a very different way. As clearly described here:
Likelihood vs. noise kernel hyper-parameter in GPML Toolbox
If you are using the @likGauss function then the output noise will be represented by the "hyp.lik" and not by adding the @covNoise covariance function to your covariance kernel.
So, creating a new covariance function with restricted hyper-parameter will not work in my opinion. You will have to explore how the @likGauss or @infExact function are implemented.
One suggestion after a little bit of research
Define
hyp.lik = "known output noise";
And change the line 24 in your @infExact function;
from:
sn2 = exp(2*hyp.lik);
to:
sn2 = "known output noise";
I hope this will work.
Cheers
|
How to implement Gaussian process using GPML toolbox with known output noise?
|
The output noise in the GPML toolbox is defined in a very different way. As clearly described here:
Likelihood vs. noise kernel hyper-parameter in GPML Toolbox
If you are using the @likGauss function
|
How to implement Gaussian process using GPML toolbox with known output noise?
The output noise in the GPML toolbox is defined in a very different way. As clearly described here:
Likelihood vs. noise kernel hyper-parameter in GPML Toolbox
If you are using the @likGauss function then the output noise will be represented by the "hyp.lik" and not by adding the @covNoise covariance function to your covariance kernel.
So, creating a new covariance function with restricted hyper-parameter will not work in my opinion. You will have to explore how the @likGauss or @infExact function are implemented.
One suggestion after a little bit of research
Define
hyp.lik = "known output noise";
And change the line 24 in your @infExact function;
from:
sn2 = exp(2*hyp.lik);
to:
sn2 = "known output noise";
I hope this will work.
Cheers
|
How to implement Gaussian process using GPML toolbox with known output noise?
The output noise in the GPML toolbox is defined in a very different way. As clearly described here:
Likelihood vs. noise kernel hyper-parameter in GPML Toolbox
If you are using the @likGauss function
|
43,489
|
How to implement Gaussian process using GPML toolbox with known output noise?
|
The first thing that came to mind is to create your own kernel. GPML allows for that fairly easily, so just copy the kernel you want to use and change one of he hyper parameters to a constant. Remove the code where it calculates the derivative too for that hyper parameter.
This might not be the only way to do it but if no one else answers and you can't do this yourself leave a comment and I can show you step by step how to do this.
|
How to implement Gaussian process using GPML toolbox with known output noise?
|
The first thing that came to mind is to create your own kernel. GPML allows for that fairly easily, so just copy the kernel you want to use and change one of he hyper parameters to a constant. Remove
|
How to implement Gaussian process using GPML toolbox with known output noise?
The first thing that came to mind is to create your own kernel. GPML allows for that fairly easily, so just copy the kernel you want to use and change one of he hyper parameters to a constant. Remove the code where it calculates the derivative too for that hyper parameter.
This might not be the only way to do it but if no one else answers and you can't do this yourself leave a comment and I can show you step by step how to do this.
|
How to implement Gaussian process using GPML toolbox with known output noise?
The first thing that came to mind is to create your own kernel. GPML allows for that fairly easily, so just copy the kernel you want to use and change one of he hyper parameters to a constant. Remove
|
43,490
|
Difference between calculated inclusion probability and what is returned by sampling function?
|
Sampling with replacement is boring. Sampling without replacement is very interesting. That's why the authors of library(sampling) restricted their attention to sampling WOR. So inclusionprobabilities() takes the baseline rates in your y, and figure out what would the inclusion probabilities be should a proper unequal probability WOR sampling algorithm applied to these numbers.
Looking at the source code, I imagine that your snippet of code reproduces the "regular" case of inclusionprobabilities() when none of the inclusion probabilities exceed 1. In that regular case, the inclusion probabilities are simply the input probabilities scaled up so that their sum is equal to the target sample size. Note that inclusion probabilities refer to the units on the frame, rather than the specific samples, as your code does.
For sampling with replacement, I believe your calculations are correct, in that probability of each pair is the product of probabilities. Then what inclusionprobabilities refers to are the sums across all rows where either X1 or X2 are equal to 1, 2, 3 or 4 (the indices of the original units):
for(k in 1:4) {
print(sum(df$p[df$X1==k|df$X2==k]))
}
This is to say, unit 1 appears in 1.8% of the samples, while unit 3, in 77.3% of the samples. However, these numbers sum up neither to 1 (as base probabilities should) nor to 2 (as correct inclusion probabilities should), and so they are kinda weird, in the end.
|
Difference between calculated inclusion probability and what is returned by sampling function?
|
Sampling with replacement is boring. Sampling without replacement is very interesting. That's why the authors of library(sampling) restricted their attention to sampling WOR. So inclusionprobabilities
|
Difference between calculated inclusion probability and what is returned by sampling function?
Sampling with replacement is boring. Sampling without replacement is very interesting. That's why the authors of library(sampling) restricted their attention to sampling WOR. So inclusionprobabilities() takes the baseline rates in your y, and figure out what would the inclusion probabilities be should a proper unequal probability WOR sampling algorithm applied to these numbers.
Looking at the source code, I imagine that your snippet of code reproduces the "regular" case of inclusionprobabilities() when none of the inclusion probabilities exceed 1. In that regular case, the inclusion probabilities are simply the input probabilities scaled up so that their sum is equal to the target sample size. Note that inclusion probabilities refer to the units on the frame, rather than the specific samples, as your code does.
For sampling with replacement, I believe your calculations are correct, in that probability of each pair is the product of probabilities. Then what inclusionprobabilities refers to are the sums across all rows where either X1 or X2 are equal to 1, 2, 3 or 4 (the indices of the original units):
for(k in 1:4) {
print(sum(df$p[df$X1==k|df$X2==k]))
}
This is to say, unit 1 appears in 1.8% of the samples, while unit 3, in 77.3% of the samples. However, these numbers sum up neither to 1 (as base probabilities should) nor to 2 (as correct inclusion probabilities should), and so they are kinda weird, in the end.
|
Difference between calculated inclusion probability and what is returned by sampling function?
Sampling with replacement is boring. Sampling without replacement is very interesting. That's why the authors of library(sampling) restricted their attention to sampling WOR. So inclusionprobabilities
|
43,491
|
Simulating a data generating process
|
I would start with fraction of variance unexplained, and think of what would be a reasonable value for your domain. Maybe in your field you expect the models have VFU 20%. In this case you can use $\sigma^2\sim0.2Var[y_t]$ for errors.
|
Simulating a data generating process
|
I would start with fraction of variance unexplained, and think of what would be a reasonable value for your domain. Maybe in your field you expect the models have VFU 20%. In this case you can use $\s
|
Simulating a data generating process
I would start with fraction of variance unexplained, and think of what would be a reasonable value for your domain. Maybe in your field you expect the models have VFU 20%. In this case you can use $\sigma^2\sim0.2Var[y_t]$ for errors.
|
Simulating a data generating process
I would start with fraction of variance unexplained, and think of what would be a reasonable value for your domain. Maybe in your field you expect the models have VFU 20%. In this case you can use $\s
|
43,492
|
Simulating a data generating process
|
Just saw your question ... Please look at how to generate random time series for a given one, including all trends? for my suggestion as to how to simulate a series given its DGF ( read model form ! ) .
I determine the error variance from a useful model and then use it in conjunction with estimated model parameters to launch the simulation.
regards to a fellow time series enthusiast ...
|
Simulating a data generating process
|
Just saw your question ... Please look at how to generate random time series for a given one, including all trends? for my suggestion as to how to simulate a series given its DGF ( read model form ! )
|
Simulating a data generating process
Just saw your question ... Please look at how to generate random time series for a given one, including all trends? for my suggestion as to how to simulate a series given its DGF ( read model form ! ) .
I determine the error variance from a useful model and then use it in conjunction with estimated model parameters to launch the simulation.
regards to a fellow time series enthusiast ...
|
Simulating a data generating process
Just saw your question ... Please look at how to generate random time series for a given one, including all trends? for my suggestion as to how to simulate a series given its DGF ( read model form ! )
|
43,493
|
variable reduction before doing random forest in R
|
There might be two reasons for which you would want to reduce the number of features:
Predictive Power: Random forest model accuracy does not really get impacted by the multicollinearity much. You can have a look at this.
It actually selects random samples of the training data and also subsets of features while running each of the decision trees. So whichever feature gives it more decrease in impurity, it will pick that. That way, be it large number of predictors or correlated predictors the model accuracy should not be affected.
Interpretability : If you want to interpret the model output using the features and their impact, in that case you might suffer because of the multicollinearity. If two predictors are correlated and they are important, the tree will choose one of them and you might lose the other one if you have small number of trees. So for that you might wanna reduce features.
Methods :
I would suggest you to use the inbuilt importance function in randomForest.
This is calculating the importance of each feature based on Gini Importance or Mean Decrease in Impurity (MDI).
```
fit <- randomForest(Target ~.,importance = T,ntree = 500, data=training_data)
var.imp1 <- data.frame(importance(fit, type=2))
var.imp1$Variables <- row.names(var.imp1)
varimp1 <- var.imp1[order(var.imp1$MeanDecreaseGini,decreasing = T),]
par(mar=c(10,5,1,1))
giniplot <- barplot(t(varimp1[-2]/sum(varimp1[-2])),las=2,
cex.names=1,
main="Gini Impurity Index Plot")
This will give something like below, and you can exclude features with lesser importance.
You can also check other methods like
Permutation Importance or Mean Decrease in Accuracy (MDA)
Information Gain / Entropy
Gain Ratio
All these are really useful when the dependent is categorical. In case your dependent variable is continuous, you can follow the classical approach , which leads to the correlation calculation between each feature and the target.
|
variable reduction before doing random forest in R
|
There might be two reasons for which you would want to reduce the number of features:
Predictive Power: Random forest model accuracy does not really get impacted by the multicollinearity much. You ca
|
variable reduction before doing random forest in R
There might be two reasons for which you would want to reduce the number of features:
Predictive Power: Random forest model accuracy does not really get impacted by the multicollinearity much. You can have a look at this.
It actually selects random samples of the training data and also subsets of features while running each of the decision trees. So whichever feature gives it more decrease in impurity, it will pick that. That way, be it large number of predictors or correlated predictors the model accuracy should not be affected.
Interpretability : If you want to interpret the model output using the features and their impact, in that case you might suffer because of the multicollinearity. If two predictors are correlated and they are important, the tree will choose one of them and you might lose the other one if you have small number of trees. So for that you might wanna reduce features.
Methods :
I would suggest you to use the inbuilt importance function in randomForest.
This is calculating the importance of each feature based on Gini Importance or Mean Decrease in Impurity (MDI).
```
fit <- randomForest(Target ~.,importance = T,ntree = 500, data=training_data)
var.imp1 <- data.frame(importance(fit, type=2))
var.imp1$Variables <- row.names(var.imp1)
varimp1 <- var.imp1[order(var.imp1$MeanDecreaseGini,decreasing = T),]
par(mar=c(10,5,1,1))
giniplot <- barplot(t(varimp1[-2]/sum(varimp1[-2])),las=2,
cex.names=1,
main="Gini Impurity Index Plot")
This will give something like below, and you can exclude features with lesser importance.
You can also check other methods like
Permutation Importance or Mean Decrease in Accuracy (MDA)
Information Gain / Entropy
Gain Ratio
All these are really useful when the dependent is categorical. In case your dependent variable is continuous, you can follow the classical approach , which leads to the correlation calculation between each feature and the target.
|
variable reduction before doing random forest in R
There might be two reasons for which you would want to reduce the number of features:
Predictive Power: Random forest model accuracy does not really get impacted by the multicollinearity much. You ca
|
43,494
|
Explain log likelihood behaviour
|
Several things could be wrong; I can only suggest some things to look at.
What's the smallest $N$ to debug with — 5, 10 ?
Plot that with $N_r = N/2, N, 2N$ .
Follow the steps, with rug plots or quantiles of
$|p_i - q_j|, exp_{ij}$, row sums.
(It's not clear to me if $1 / M_r$ scaling is correct, maybe row sums 1
in the $N \times N_r$ array of $exp_{ij}$ ?)
$exp^{ - |p - q|^2 / r }$ is very sensitive to radius $r$.
And it doesn't scale:
as $N_r \to \infty$, the $exp$ s crowd near 1 (I believe).
There are lots of other metrics between 2d point sets;
average nearest-neighbor with nnear say 10 is fast and easy with
scipy.spatial.cKDTree .
Can the data be viewed as a continuous terrain, 1 at the data points, falling off to 0 in between ?
If so, the average error of the $N_r$ points interpolated at the $N$ sounds
like a reasonable metric; see (ahem)
inverse-distance-weighted-idw-interpolation-with-python.
And terrains are nice to plot.
|
Explain log likelihood behaviour
|
Several things could be wrong; I can only suggest some things to look at.
What's the smallest $N$ to debug with — 5, 10 ?
Plot that with $N_r = N/2, N, 2N$ .
Follow the steps, with rug plots or quanti
|
Explain log likelihood behaviour
Several things could be wrong; I can only suggest some things to look at.
What's the smallest $N$ to debug with — 5, 10 ?
Plot that with $N_r = N/2, N, 2N$ .
Follow the steps, with rug plots or quantiles of
$|p_i - q_j|, exp_{ij}$, row sums.
(It's not clear to me if $1 / M_r$ scaling is correct, maybe row sums 1
in the $N \times N_r$ array of $exp_{ij}$ ?)
$exp^{ - |p - q|^2 / r }$ is very sensitive to radius $r$.
And it doesn't scale:
as $N_r \to \infty$, the $exp$ s crowd near 1 (I believe).
There are lots of other metrics between 2d point sets;
average nearest-neighbor with nnear say 10 is fast and easy with
scipy.spatial.cKDTree .
Can the data be viewed as a continuous terrain, 1 at the data points, falling off to 0 in between ?
If so, the average error of the $N_r$ points interpolated at the $N$ sounds
like a reasonable metric; see (ahem)
inverse-distance-weighted-idw-interpolation-with-python.
And terrains are nice to plot.
|
Explain log likelihood behaviour
Several things could be wrong; I can only suggest some things to look at.
What's the smallest $N$ to debug with — 5, 10 ?
Plot that with $N_r = N/2, N, 2N$ .
Follow the steps, with rug plots or quanti
|
43,495
|
Should additional crime reports about someone change our level of doubt about an initial crime report?
|
An approach to the matter may be as follows:
There exists a Bernouli random variable $Y_i$, which models whether the politician drunk ($Y_i=1$) or not ($Y_i=0$) during a specific party, indexed by $i$. Since nothing is really unprobable under the moon (parties being held usually during night hours), there exists some strictly positive probability $p_i>0$ that the politician did drink during party $i$ (this is also consistent with Cromwell's rule). Since parties can only be attended sequentially, the collection of these random variables forms a stochastic process through time, $\{Y_i\}_{i\in N}$. Note that it is difficult to argue that the elements of the process are independent, since after all we are talking about the same person.
This process is not observed by the general public. Instead, what we observe is the process of public statements made by participants in the same parties as to whether the politician did drink or not. Denote this process $\{X_i\}_{i\in N}$. We assume that no conflicting statements are made for the same party. So either somebody declares that the politician drunk, or $X$ takes the value $0$.
The deterministic question is: Does $X_i=1 \Rightarrow ? \;Y_i=1$. But in a statistical framework, we can only relativize the issue and transform it into the question : Does $X_i=1 \Rightarrow ? \;p_{i} > p_{i-1}$.
We can view the $X$-process as an "imperfect measurement" of the $Y$-process -and the crucial point here is how we evaluate the measurement error. The various "prior assumptions" the OP states at the second part of the question pertain to the evaluation of the reliability of the sample. Allowing for conflicting statements that negate the previous ones, again, affects how we will evaluate the reliability of the sample.
Assuming some reliability, accumulation of realizations of the $X$-process where $X_i=1$, is bound to increase the probability that the politician is/has become a drinker, and this can be mapped to the question whether a structural break had happened, given the sample: after all people may change as time passes, and so the politician may have attended many parties without drinking, but at some point things changed. But when did this happen?
So it is not false reasoning to argue that these signals may also make us revise any assessments we have made in the past about the matter, because, it has to do with when the structural break actually happened -and it may be the case that it did happen the first time it was declared that it did, even though, back then, we did not concede as much, due to thin evidence.
So, in this framework, this "common informal statistical reasoning" is not invalid.
...And real life agrees: say, fraud is alleged. Again. And Again. Finally, auditors appear. Why will they go over past transactions, as they do? Because they reckon "the fact that signals of fraud got sufficiently strong in order for us to investigate only now (given limited resources, materiality principle and the like), does not mean that fraud was not conducted in the past. Including the specific past instances where fraud was specifically alleged in the past". Have editors fallen into some logical or statistical fallacy? I wouldn't say so, if experience from audit results is any indication.
|
Should additional crime reports about someone change our level of doubt about an initial crime repor
|
An approach to the matter may be as follows:
There exists a Bernouli random variable $Y_i$, which models whether the politician drunk ($Y_i=1$) or not ($Y_i=0$) during a specific party, indexed by $i$
|
Should additional crime reports about someone change our level of doubt about an initial crime report?
An approach to the matter may be as follows:
There exists a Bernouli random variable $Y_i$, which models whether the politician drunk ($Y_i=1$) or not ($Y_i=0$) during a specific party, indexed by $i$. Since nothing is really unprobable under the moon (parties being held usually during night hours), there exists some strictly positive probability $p_i>0$ that the politician did drink during party $i$ (this is also consistent with Cromwell's rule). Since parties can only be attended sequentially, the collection of these random variables forms a stochastic process through time, $\{Y_i\}_{i\in N}$. Note that it is difficult to argue that the elements of the process are independent, since after all we are talking about the same person.
This process is not observed by the general public. Instead, what we observe is the process of public statements made by participants in the same parties as to whether the politician did drink or not. Denote this process $\{X_i\}_{i\in N}$. We assume that no conflicting statements are made for the same party. So either somebody declares that the politician drunk, or $X$ takes the value $0$.
The deterministic question is: Does $X_i=1 \Rightarrow ? \;Y_i=1$. But in a statistical framework, we can only relativize the issue and transform it into the question : Does $X_i=1 \Rightarrow ? \;p_{i} > p_{i-1}$.
We can view the $X$-process as an "imperfect measurement" of the $Y$-process -and the crucial point here is how we evaluate the measurement error. The various "prior assumptions" the OP states at the second part of the question pertain to the evaluation of the reliability of the sample. Allowing for conflicting statements that negate the previous ones, again, affects how we will evaluate the reliability of the sample.
Assuming some reliability, accumulation of realizations of the $X$-process where $X_i=1$, is bound to increase the probability that the politician is/has become a drinker, and this can be mapped to the question whether a structural break had happened, given the sample: after all people may change as time passes, and so the politician may have attended many parties without drinking, but at some point things changed. But when did this happen?
So it is not false reasoning to argue that these signals may also make us revise any assessments we have made in the past about the matter, because, it has to do with when the structural break actually happened -and it may be the case that it did happen the first time it was declared that it did, even though, back then, we did not concede as much, due to thin evidence.
So, in this framework, this "common informal statistical reasoning" is not invalid.
...And real life agrees: say, fraud is alleged. Again. And Again. Finally, auditors appear. Why will they go over past transactions, as they do? Because they reckon "the fact that signals of fraud got sufficiently strong in order for us to investigate only now (given limited resources, materiality principle and the like), does not mean that fraud was not conducted in the past. Including the specific past instances where fraud was specifically alleged in the past". Have editors fallen into some logical or statistical fallacy? I wouldn't say so, if experience from audit results is any indication.
|
Should additional crime reports about someone change our level of doubt about an initial crime repor
An approach to the matter may be as follows:
There exists a Bernouli random variable $Y_i$, which models whether the politician drunk ($Y_i=1$) or not ($Y_i=0$) during a specific party, indexed by $i$
|
43,496
|
Building a predictive model, regression with a long right tail
|
The two modelling methods you propose seem to me to be legitimate in
principle, but obviously the best model will emerge from analysis.
Modelling the data under a logarithmic transformation (assuming you
have no zero values that would stuff it up) implicitly gives you a
non-linear model anyway, so that is fine in principle. As far as the
decision to split the data for training and testing, I would suggest
that rather than oversampling a particular part of the distribution,
you should instead be explicit about a loss function for getting
things wrong (maybe higher loss for high end?)
|
Building a predictive model, regression with a long right tail
|
The two modelling methods you propose seem to me to be legitimate in
principle, but obviously the best model will emerge from analysis.
Modelling the data under a logarithmic transformation (assum
|
Building a predictive model, regression with a long right tail
The two modelling methods you propose seem to me to be legitimate in
principle, but obviously the best model will emerge from analysis.
Modelling the data under a logarithmic transformation (assuming you
have no zero values that would stuff it up) implicitly gives you a
non-linear model anyway, so that is fine in principle. As far as the
decision to split the data for training and testing, I would suggest
that rather than oversampling a particular part of the distribution,
you should instead be explicit about a loss function for getting
things wrong (maybe higher loss for high end?)
|
Building a predictive model, regression with a long right tail
The two modelling methods you propose seem to me to be legitimate in
principle, but obviously the best model will emerge from analysis.
Modelling the data under a logarithmic transformation (assum
|
43,497
|
Predict Failure time/ Weibull analysis
|
The precision of survival analysis is typically limited by the number of events. A rule of thumb is that you need about 15 events per parameter that you want to fit; you only have 13 events while a Weibull (and many parametric survival models) has 2 parameters. I'm not sure that there are enough events to rule out a Weibull distribution, but there are many other distribution famililes provided in R packages like survival and flexsurv that you could try, and those packages also let you define your own distributions.
The problems with extrapolation from so few events can be illustrated with a Weibull model of the 13 failure times that you provided. Censoring the other 87 cases at the last event time, 11584 days, putting the data together into a data frame, and fitting and plotting with the flexsurv package gives the following:
ftimes <- c(10162, 8300, 11110, 11520, 11520, 8460, 7320, 11424, 11112, 11321, 11584, 10436, 9560)
allTimes <- c(ftimes,rep(11584,87))
events <- c(rep(1,13),rep(0,87))
failDF <- data.frame(time=allTimes,event=events)
library(flexsurv)
weiFit <- flexsurvreg(Surv(time,event)~1,data=failDF,dist="weibull")
plot(weiFit,t=seq(6000,15000,length.out=100),xlim=c(6000,15000),bty="n",xlab="Days",ylab="Survivl Probability")
abline(v=12679)
This superimposes the Weibull fit and its 95% confidence intervals (in red) over the Kaplan-Meier plot of the observations (in black). The vertical line is a prediction time 1095 days after the last event time. The point estimate of survival at that time is 75% (or 75 out of 100 original units still in service at that time), but the 95% confidence interval covers a range from about 40% to 84%.
So you might estimate a loss of 12 more units over the next 1095 days, but it could reasonably be as few as 3 more or as many as 47 more. I played with a few other distributions (gamma, lognormal, loglogistic); the Weibull was the most conservative among them, with the widest confidence interval.
|
Predict Failure time/ Weibull analysis
|
The precision of survival analysis is typically limited by the number of events. A rule of thumb is that you need about 15 events per parameter that you want to fit; you only have 13 events while a We
|
Predict Failure time/ Weibull analysis
The precision of survival analysis is typically limited by the number of events. A rule of thumb is that you need about 15 events per parameter that you want to fit; you only have 13 events while a Weibull (and many parametric survival models) has 2 parameters. I'm not sure that there are enough events to rule out a Weibull distribution, but there are many other distribution famililes provided in R packages like survival and flexsurv that you could try, and those packages also let you define your own distributions.
The problems with extrapolation from so few events can be illustrated with a Weibull model of the 13 failure times that you provided. Censoring the other 87 cases at the last event time, 11584 days, putting the data together into a data frame, and fitting and plotting with the flexsurv package gives the following:
ftimes <- c(10162, 8300, 11110, 11520, 11520, 8460, 7320, 11424, 11112, 11321, 11584, 10436, 9560)
allTimes <- c(ftimes,rep(11584,87))
events <- c(rep(1,13),rep(0,87))
failDF <- data.frame(time=allTimes,event=events)
library(flexsurv)
weiFit <- flexsurvreg(Surv(time,event)~1,data=failDF,dist="weibull")
plot(weiFit,t=seq(6000,15000,length.out=100),xlim=c(6000,15000),bty="n",xlab="Days",ylab="Survivl Probability")
abline(v=12679)
This superimposes the Weibull fit and its 95% confidence intervals (in red) over the Kaplan-Meier plot of the observations (in black). The vertical line is a prediction time 1095 days after the last event time. The point estimate of survival at that time is 75% (or 75 out of 100 original units still in service at that time), but the 95% confidence interval covers a range from about 40% to 84%.
So you might estimate a loss of 12 more units over the next 1095 days, but it could reasonably be as few as 3 more or as many as 47 more. I played with a few other distributions (gamma, lognormal, loglogistic); the Weibull was the most conservative among them, with the widest confidence interval.
|
Predict Failure time/ Weibull analysis
The precision of survival analysis is typically limited by the number of events. A rule of thumb is that you need about 15 events per parameter that you want to fit; you only have 13 events while a We
|
43,498
|
Identifiability in generalized linear random effect model?
|
The identifiability problem in the probit model occurs because each latent vector $\boldsymbol{\lambda}_i$ affects the observable outcome only through its sign, and so if the underlying parameters do not affect the distributions of the sign, they are not identifiable. To see this, we note that it is possible to rewrite your multivariate probit model in the alternative form:
$$Y_{ij} = \mathbb{I}(\lambda_{ij} \leqslant 0)
\quad \quad \quad
\boldsymbol{\lambda}_i \sim \text{IID N}(\boldsymbol{\mu},\boldsymbol{\Sigma}).$$
We can see from this model form that the parameters $\boldsymbol{\mu}$ and $\boldsymbol{\Sigma}$ will affect the likelihood function only through their effect on the joint distribution of the $\text{sgn } \lambda_{ij}$ values. If we have two different parameter settings that give the same joint distribution for these sign values, then those different parameter settings are observationally equivalent. For example, if we take $\boldsymbol{\mu} = \alpha \boldsymbol{\mu}_0$ and $\boldsymbol{\Sigma} = \alpha^2 \boldsymbol{\Sigma}_0$ then the parameter $\alpha$ is not identifiable, since changing this parameter does not affect the joint distribution of the sign values of the latent variables.
Framing the model in terms of IID standard normal variables: Suppose we let $\boldsymbol{\Lambda} \equiv \boldsymbol{\Sigma}^{1/2}$ denote the principal square root of the covariance matrix $\boldsymbol{\Sigma}$ (which is also a symmetric non-negative definite matrix), so that $\boldsymbol{\Sigma} = \boldsymbol{\Lambda}^2$. We now create the standardised random vector:
$$\boldsymbol{\theta}_i \equiv \boldsymbol{\Lambda}^{-1} (\boldsymbol{\lambda}_i-\boldsymbol{\mu}) \sim \text{N}(\mathbf{0}, \mathbf{I}).$$
We can write the individual elements of our latent vector $\boldsymbol{\lambda}_i$ as:
$$\lambda_{ij} = [\boldsymbol{\mu}+\boldsymbol{\Lambda} \boldsymbol{\theta}_i]_j
= \mu_j + \sum_{\ell=1}^J \Lambda_{j, \ell} \cdot \theta_{i,\ell}.$$
Using this standardised random vector, we can therefore rewrite your model as:
$$Y_{ij} = \mathbb{I} \Bigg( \sum_{\ell=1}^J \Lambda_{j, \ell} \cdot \theta_{i,\ell} \leqslant - \mu_j \Bigg)
\quad \quad \quad
\boldsymbol{\theta}_{i,\ell} \sim \text{IID N}(0, 1).$$
In this alternative framing of the model we have a matrix of IID standard normal values $\boldsymbol{\theta}_{i,\ell} \sim \text{IID N}(0, 1)$, and the parameters $\boldsymbol{\mu}$ and $\boldsymbol{\Sigma}$ now appear inside the indicator function for the sign of the latent variable (the latter through the elements of its principal square root matrix). This form also allows you to see when changes in the parameters will be observationally equivalent.
|
Identifiability in generalized linear random effect model?
|
The identifiability problem in the probit model occurs because each latent vector $\boldsymbol{\lambda}_i$ affects the observable outcome only through its sign, and so if the underlying parameters do
|
Identifiability in generalized linear random effect model?
The identifiability problem in the probit model occurs because each latent vector $\boldsymbol{\lambda}_i$ affects the observable outcome only through its sign, and so if the underlying parameters do not affect the distributions of the sign, they are not identifiable. To see this, we note that it is possible to rewrite your multivariate probit model in the alternative form:
$$Y_{ij} = \mathbb{I}(\lambda_{ij} \leqslant 0)
\quad \quad \quad
\boldsymbol{\lambda}_i \sim \text{IID N}(\boldsymbol{\mu},\boldsymbol{\Sigma}).$$
We can see from this model form that the parameters $\boldsymbol{\mu}$ and $\boldsymbol{\Sigma}$ will affect the likelihood function only through their effect on the joint distribution of the $\text{sgn } \lambda_{ij}$ values. If we have two different parameter settings that give the same joint distribution for these sign values, then those different parameter settings are observationally equivalent. For example, if we take $\boldsymbol{\mu} = \alpha \boldsymbol{\mu}_0$ and $\boldsymbol{\Sigma} = \alpha^2 \boldsymbol{\Sigma}_0$ then the parameter $\alpha$ is not identifiable, since changing this parameter does not affect the joint distribution of the sign values of the latent variables.
Framing the model in terms of IID standard normal variables: Suppose we let $\boldsymbol{\Lambda} \equiv \boldsymbol{\Sigma}^{1/2}$ denote the principal square root of the covariance matrix $\boldsymbol{\Sigma}$ (which is also a symmetric non-negative definite matrix), so that $\boldsymbol{\Sigma} = \boldsymbol{\Lambda}^2$. We now create the standardised random vector:
$$\boldsymbol{\theta}_i \equiv \boldsymbol{\Lambda}^{-1} (\boldsymbol{\lambda}_i-\boldsymbol{\mu}) \sim \text{N}(\mathbf{0}, \mathbf{I}).$$
We can write the individual elements of our latent vector $\boldsymbol{\lambda}_i$ as:
$$\lambda_{ij} = [\boldsymbol{\mu}+\boldsymbol{\Lambda} \boldsymbol{\theta}_i]_j
= \mu_j + \sum_{\ell=1}^J \Lambda_{j, \ell} \cdot \theta_{i,\ell}.$$
Using this standardised random vector, we can therefore rewrite your model as:
$$Y_{ij} = \mathbb{I} \Bigg( \sum_{\ell=1}^J \Lambda_{j, \ell} \cdot \theta_{i,\ell} \leqslant - \mu_j \Bigg)
\quad \quad \quad
\boldsymbol{\theta}_{i,\ell} \sim \text{IID N}(0, 1).$$
In this alternative framing of the model we have a matrix of IID standard normal values $\boldsymbol{\theta}_{i,\ell} \sim \text{IID N}(0, 1)$, and the parameters $\boldsymbol{\mu}$ and $\boldsymbol{\Sigma}$ now appear inside the indicator function for the sign of the latent variable (the latter through the elements of its principal square root matrix). This form also allows you to see when changes in the parameters will be observationally equivalent.
|
Identifiability in generalized linear random effect model?
The identifiability problem in the probit model occurs because each latent vector $\boldsymbol{\lambda}_i$ affects the observable outcome only through its sign, and so if the underlying parameters do
|
43,499
|
Unbalanced Panel: pooled OLS vs FE vs RE - which method yields unbiased and robust estimators?
|
"Clustering by firms" doesn't exclude OLS as a possibility. One could simply adjust for a dummy variable indicating the firm and objectively call that a "cluster". More commonly, "clustering by firm" means adding a random intercept term for firms. This is the preferred approach when the number of firms is large relatively to the sample size. Adding a random intercept makes this type of model a mixed effects model. Pooled OLS will estimate a random intercept and a random slope, thus is a more general model. However, the estimates can be very unstable when the number of observations-per-firm is small.
Time can be handled using fixed effects as a dummy variable. It's better as a continuous variable. Splines interpolate dummy variables without requiring that all (or even more than 1) firm measure outcomes at exactly the same time. This can save you from binning or matching times and improves analysis significantly. You can still add a dummy variable for season if there are cyclic effects relating to time-of-year.
Without a prespecified hypothesis about the impact of omitted variables, variance structures, or other things, the Hausman and Breush Pagan test make no sense in isolation. Diagnostic tests are prone to reject too often because they are simply over powered by moderate-to-large samples. It is better to use diagnostic plots like a variogram.
One way to check pooled OLS vs fixed effects is to do a likelihood ratio test. They are both fully ML procedures. The numerator degrees of freedom for the pooled OLS would be $n_c * 2 + p$ where $p$ is the number of endogenous parameters (like firm type, season) and $n_c$ number of firms, 2 is the slope and intercept terms within each subOLS though they may be different.
|
Unbalanced Panel: pooled OLS vs FE vs RE - which method yields unbiased and robust estimators?
|
"Clustering by firms" doesn't exclude OLS as a possibility. One could simply adjust for a dummy variable indicating the firm and objectively call that a "cluster". More commonly, "clustering by firm"
|
Unbalanced Panel: pooled OLS vs FE vs RE - which method yields unbiased and robust estimators?
"Clustering by firms" doesn't exclude OLS as a possibility. One could simply adjust for a dummy variable indicating the firm and objectively call that a "cluster". More commonly, "clustering by firm" means adding a random intercept term for firms. This is the preferred approach when the number of firms is large relatively to the sample size. Adding a random intercept makes this type of model a mixed effects model. Pooled OLS will estimate a random intercept and a random slope, thus is a more general model. However, the estimates can be very unstable when the number of observations-per-firm is small.
Time can be handled using fixed effects as a dummy variable. It's better as a continuous variable. Splines interpolate dummy variables without requiring that all (or even more than 1) firm measure outcomes at exactly the same time. This can save you from binning or matching times and improves analysis significantly. You can still add a dummy variable for season if there are cyclic effects relating to time-of-year.
Without a prespecified hypothesis about the impact of omitted variables, variance structures, or other things, the Hausman and Breush Pagan test make no sense in isolation. Diagnostic tests are prone to reject too often because they are simply over powered by moderate-to-large samples. It is better to use diagnostic plots like a variogram.
One way to check pooled OLS vs fixed effects is to do a likelihood ratio test. They are both fully ML procedures. The numerator degrees of freedom for the pooled OLS would be $n_c * 2 + p$ where $p$ is the number of endogenous parameters (like firm type, season) and $n_c$ number of firms, 2 is the slope and intercept terms within each subOLS though they may be different.
|
Unbalanced Panel: pooled OLS vs FE vs RE - which method yields unbiased and robust estimators?
"Clustering by firms" doesn't exclude OLS as a possibility. One could simply adjust for a dummy variable indicating the firm and objectively call that a "cluster". More commonly, "clustering by firm"
|
43,500
|
Unbalanced Panel: pooled OLS vs FE vs RE - which method yields unbiased and robust estimators?
|
You can check FE vs POLS through this method,
Source: Park, Hun Myoung. 2011. Practical Guides To Panel Data Modeling: A Step-by-step Analysis Using Stata. Tutorial Working Paper. Graduate School of International Relations, International University of Japan
|
Unbalanced Panel: pooled OLS vs FE vs RE - which method yields unbiased and robust estimators?
|
You can check FE vs POLS through this method,
Source: Park, Hun Myoung. 2011. Practical Guides To Panel Data Modeling: A Step-by-step Analysis Using Stata. Tutorial Working Paper. Graduate School of
|
Unbalanced Panel: pooled OLS vs FE vs RE - which method yields unbiased and robust estimators?
You can check FE vs POLS through this method,
Source: Park, Hun Myoung. 2011. Practical Guides To Panel Data Modeling: A Step-by-step Analysis Using Stata. Tutorial Working Paper. Graduate School of International Relations, International University of Japan
|
Unbalanced Panel: pooled OLS vs FE vs RE - which method yields unbiased and robust estimators?
You can check FE vs POLS through this method,
Source: Park, Hun Myoung. 2011. Practical Guides To Panel Data Modeling: A Step-by-step Analysis Using Stata. Tutorial Working Paper. Graduate School of
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.