Questions tagged [numerics]

Also known as Numerical Analysis, Numerics aims to provide methods and algorithms for numerical computations.

Filter by
Sorted by
Tagged with
2 votes
1 answer
58 views

Establish numerical equivalence of statistical model across software

we are trying to establish numerical equivalence (within reasonable precision) for selected statistical models across programming languages such as SAS, R & Python or even different packages ...
user avatar
  • 21
0 votes
0 answers
17 views

How can I compute rectangular confidence regions for parameters using R?

Simultaneous confidence regions for multivariate parameters (say, a confidence region for multivariate mean, or for regression parameters) usually find an elliptical region when the parameters' ...
user avatar
  • 1,063
1 vote
0 answers
87 views

Can I make Stata run lasso faster?

I am trying to run a lasso in Stata. I have 1.5 million observations and 1700 variables. Stata is running too slow. I am in 36th grid after 4 days. And get slower ever grid. I am using a 98GB Memory, ...
user avatar
  • 11
0 votes
1 answer
36 views

More stable reparametrization of a parameter on $(-1,1)$?

Suppose that a distribution contains a parameter $\theta \in (-1,1)$. I want to reparametrize this model in terms of $\beta = h(\theta) \in (-\infty,\infty)$. I am considering: $$h(\theta) = \mbox{...
user avatar
  • 1
4 votes
1 answer
154 views

Is there a closed form approximation for the composition of the Gamma CDF with the inverse Normal CDF?

Given $k$, $\theta$ fixed shape and scale parameters for some Gamma distribution which has a CDF $F$. Let $G^{-1}$ be the inverse CDF of the standard Normal distribution. Consider the composition $H(x)...
user avatar
  • 43
0 votes
0 answers
22 views

Generalized variance of a multivariate normal without calculating determinants

In order to calculate ‘generalized variance’ of a multivariate normal distribution, it is often recommended (e.g., here: https://online.stat.psu.edu/stat505/lesson/1/1.5) to calculate the determinant ...
user avatar
  • 395
0 votes
0 answers
14 views

Can I create a numerical variable from the combination of other numerical variables? [duplicate]

I am working with a dataset that contains limnological parameters. This dataset contains turbidity-related measures in different units and consequently different ranges. Is there a way to create a ...
user avatar
0 votes
0 answers
39 views

Is there a way to create a numeric variable from a numeric set of measurements with different ranges?

I am working with a dataset that contains limnological parameters. One of them is turbidity-related measures in different units and consequently different ranges. Is there a way to create a numerical ...
user avatar
0 votes
0 answers
20 views

Are numerical solutions appropriate for inference (eg, estimating variance for confidence intervals)?

For a nicely differentiable objective function, we traditionally always derive the gradients to use for e.g. estimating the variance. (1) Is it common nowadays to use numerical rather than analytical ...
user avatar
  • 5,246
3 votes
1 answer
278 views

Estimate MLE of discrete distribution with two parameters in R [closed]

I want to estimate the MLE of a discrete distribution in R using a numeric method. My data looks like this: data1<-c(5,2,2,3,0,2,1 2,4,4,1) If we assume it ...
user avatar
2 votes
1 answer
92 views

Avoid numerical problems with product of probabilities when taking logs or subtracting the maximum is not enough

I have to take draws from the discrete posterior distribution: $ P(X = x_i |y) \propto P(X = x_i)\prod_{t}^N p(Y_t|X)$ where $P(X = x )$ is the probability mass function of a discrete uniform with ...
user avatar
  • 137
8 votes
3 answers
564 views

Get accurate eigenvectors, when eigenvalues are minuscule

I have a symmetric matrix A. I'm not able to compute all the eigenvectors accurately, and I believe it is due to the last few eigenvalues for ...
user avatar
  • 117
2 votes
1 answer
65 views

Numerically PCA implements SVD or SVD implements PCA

How do we numerically implement SVD? I confused the numerically implementations between PCA and SVD (who implements who). Since we know that PCA can be numerically implemented by ...
user avatar
  • 1,017
0 votes
0 answers
49 views

Find the shape parameter for gamma CDF with other parameters known

Is there a reasonably computationally efficient way to find an approximation of the shape parameter (which will always be positive, but not limited to integers) for a gamma CDF (scale = 1) where the ...
user avatar
  • 123
0 votes
1 answer
44 views

Are there examples where errors in numerical analysis has caused wrong decisions in statistics?

I read from statistics books that numerical analysis is not in important role in statistics. Are there any examples in history where numerical approximation has been caused wrong decisions in ...
user avatar
1 vote
1 answer
62 views

Is the QR Algorithm guaranteed to compute eigenvectors?

I'm writing some C++ matrix library for hobby. For computing eigenvalues and eigenvectors, I referred the following "Francis double step QR algorithm": In particular, page 82 of https://...
user avatar
  • 131
0 votes
0 answers
19 views

First difference in logs transformation produces biased results on back-transformation [duplicate]

I have a strongly trended series where the trend appears to be exponential and I believe the errors tend to be proportional to the current value. In order to convert it to a stationary series for ...
user avatar
  • 2,597
3 votes
1 answer
142 views

What is the correct equation for Newton's Method?

Different publications provide different equations for Newton's method or the Newton-Raphson method. In Giudici, P., Givens, G. H., & Mallick, B. K. (2013). Wiley Series in Computational ...
user avatar
  • 280
1 vote
2 answers
52 views

I'm so confused about MLE

In maximum likelihood estimation, we maximise the likelihood. I don't understand how this is possibly: for any reasonable dataset, the likelihood of hitting that EXACT data set is obviously zero! So ...
user avatar
  • 11
2 votes
2 answers
83 views

Numeric variable with outliers as a categories

I'm working with a dataset that has a few variables that I'm having difficulty trying to preprocess. So one of them is called MENTHLTH where it is a numeric variable. The point of the variable is to ...
user avatar
  • 43
0 votes
0 answers
37 views

Seeking algorithms for fast, simple linear regressions

I am working on a project which requires me to work in a proprietary programming language. Unfortunately, this language lacks a matrix algebra library. In this environment, I would like to perform a ...
user avatar
  • 218
0 votes
0 answers
33 views

Discrete correlation function (sample cross-covariance)

The continuous correlation function for the random variable $A(t)$ at a instant of time $t$ is given by \begin{equation} C_{AA}(\tau) =\frac{1}{T} \int_{0}^T d\bar{t} A(\bar{t})A(\bar{t}+\tau) \end{...
user avatar
  • 101
5 votes
4 answers
179 views

How to plot $x^{1700}(1-x)^{300}$?

I'm trying to plot a Bernoulli likelihood function on R: $$x^{1700}(1-x)^{300}$$ But when I try to plot this function on R it looks like this: I think the maximum should be at 0.85, but it shows me a ...
user avatar
  • 53
0 votes
0 answers
102 views

Log Sum Exponential Trick On Weibull Mixture [duplicate]

I am trying to evaluate the log-likelihood of a mixture of weibull distributions and am running into problems with the numerical aspect. In short, I have $M$ mixtures and want to evaluate: $$ \log \...
user avatar
8 votes
3 answers
886 views

log(1 - softmax(X))? [closed]

Let $\vec X$ be a vector. The $\vec V = \mathrm{logsoftmax}(\vec{X})$ function is defined as: $$v_i = \ln\left(\frac{e^{x_i}}{\sum_i e^{x_i}}\right)$$ This is provided in machine learning numerical ...
user avatar
  • 3,358
0 votes
0 answers
88 views

Time series reference - Estimating ARIMA models using the Yule-Walker equations and Durbin-Levinson algorithm

I am doing some research related to time-series analysis, and hence was trying to find some good examples of implementations of the common estimation algorithms. For example, I wanted to fit some ...
user avatar
  • 1,150
0 votes
0 answers
71 views

Reference request - time series analysis book with numerical algorithms

I am working on some applications of time series, and I wanted to find a book that has the numerical algorithms or pseudocode for computing things like AR models, and ARIMA models, using nonlinear ...
user avatar
  • 1,150
3 votes
0 answers
68 views

Why is my QR decomposition updating code numerically off?

I apologize if this is the wrong place for this question; there are a number of potential points of failure each of which suggest either Math StackExchange or StackOverflow or here, but since the ...
user avatar
  • 1,063
2 votes
3 answers
470 views

Wrong coefficients in a polynomial fit

I am trying to fit data to a fourth-degree polynomial. I tried this in multiple programs (R, Origin Pro, SigmaPlot), all of which give me a polynomial of the form $ 40000 -2000x + 40x^2 -0.3x^3 + 0....
user avatar
3 votes
2 answers
172 views

Where is the error in my computation of the wrapped normal distribution density?

Let $\sigma\in(0,1)$ $$\phi(x):=\frac1{\sqrt{2\pi\sigma^2}}e^{-\frac{x^2}{2\sigma^2}}\;\;\;\text{for }x\in\mathbb R$$ and $$\psi(x):=\sum_{k\in\mathbb Z}\phi(x+k)\;\;\;\text{for }x\in\mathbb R$$ $\...
user avatar
  • 539
0 votes
0 answers
68 views

How should I compute this proposal kernel density?

Let $d\in\mathbb N$ and $$u(x,y):=\beta+(1-\beta)\prod_{i=1}^d\psi(y_i-x_i)\;\;\;\text{for }x,y\in[0,1)^d,$$ where $\beta\in[0,1]$, $$\psi(x):=\sum_{k\in\mathbb Z}\varphi(k+x)\;\;\;\text{for }x\in(-1,...
user avatar
  • 539
1 vote
1 answer
129 views

Algorithm for simple linear regression that is efficient and numerically stable

I'm developing an application that is fed with continuous data while older data is discarded. I'm using some algorithms to compute simple linear regression on these data with Perl. Basically that ...
user avatar
  • 111
0 votes
0 answers
45 views

Equivalent of log sum exp trick for subtraction [duplicate]

I have two small positive real numbers $u, w$ such that $u > w$. Given $\log(u), \log(w)$ I'd like to find a numerically stable way to calculate $\log(u - w)$. One possible way of transforming the ...
user avatar
  • 43
1 vote
0 answers
106 views

Why did the log likelihood decrease with additional parameters?

I'm trying to decide the effect of some factors on the time for an event to happen . Specifically, I am looking at how long it takes for the subject to pass a test (recognize the stimulus) when ...
user avatar
7 votes
4 answers
880 views

Expectation of $\ln(1 + e^x)$, where $x$ is normally distributed

I need to evaluate the following integral: $$\int_{-\infty}^\infty\mathrm d x \exp\left(-\frac{(x-\mu)^2}{2\nu}\right) \ln(1+e^x)$$ where $\mu$ is a finite real number and $\nu > 0$. This is just ...
user avatar
  • 3,358
1 vote
0 answers
11 views

How does the choice of norm affect the condition of a problem?

we know that for a differentiable problem, the absolute condition number is the norm of its jacobian i.e. ||J||. We also know that a well-conditioned problem typically has a small condition number. ...
user avatar
0 votes
1 answer
799 views

Inverse-normal CDF approximation in Excel, Python or R

I read that the implementations of Inverse-normal cumulative distribution function (CDF) /quantile / ppf in R, Python (scipy) and Excel give similar results. However, I can't find the very formulae ...
user avatar
  • 11
3 votes
0 answers
119 views

Why does lasso return unstable features when using the same data?

I am using scikit-learn to shrink my data set having around 800 features. It is a very noisy data (market and economic data) To my best knowledge, lasso returns same features for the same data set. ...
user avatar
2 votes
0 answers
176 views

Intuition about a coupon problem were we ask for the distribution of the unique coupons when the number of draws is fixed

Alternative viewpoint of the coupon collectors problem In the coupon collectors problem we draw from a collection of $n$ coupons, with replacement and ask the question how many draws $K$ it takes to ...
user avatar
3 votes
0 answers
345 views

Why is it much quicker to compute ridge regression than regular linear regression? [duplicate]

By my understanding, for a matrix with n samples and p features: Ridge regression using cholesky takes O(p^3) time Ordinary linear regression takes O(p^3) time Singular value decomposition if u, v ...
user avatar
  • 105
5 votes
1 answer
547 views

How can we numerically compute the autocorrelation of a sample from a Markov chain generated by the Metropolis-Hastings algorithm?

Let $(X_n)_{n\in\mathbb N_0}$ denote a $\mathbb R^d$-valued Markov chain generated by the Metropolis-Hastings algorithm. Suppose I've run the algorithm on a computer and obtained a sample $x_0,\ldots,...
user avatar
  • 539
0 votes
0 answers
122 views

Model failed to converge in lme4::glmer() when the a factor is centered or releveled

I'm running a mixed-effects model using glmer() function. The modeling works well with R's default dummy coding. But if I center or relevel a factor of 2 levels, the model failed to converge. I am ...
user avatar
  • 33
0 votes
0 answers
47 views

chi square distribution as a function of other variables

I'm minimizing $\chi^2$ between some data and a function. The expression $\chi^2 = \sum\frac{1}{\sigma_i^2}(y_i-f(A,B))^2$ happens to be analytically solvable, so I have a value for the minimum $\chi^...
user avatar
3 votes
2 answers
1k views

adding a small constant to the diagonals of a matrix to stabilize

I have a large correlation matrix (110x110) with some small eigenvalues (about 20 < 0.1). It has been suggested that adding a constant (about 0.1) to the diagonals will help to stabilize the matrix....
user avatar
2 votes
2 answers
278 views

downsampling a kde / combining kde and histogram

I'm calculating a KDE of one parameter (y, particle density) in bins of another parameter (x, distance from the origin). At ...
user avatar
1 vote
0 answers
32 views

Model or numerical inaccuracy in R package distr

With the goal to have an "outlier"-aware normal distribution, I build a simple univariate mixing model of normal and uniform distributions: ...
user avatar
  • 51
1 vote
3 answers
296 views

NUTS Drawing samples from slice sampler; how to keep bounds on log scale?

I'm currently working to adapt the No U-Turn Sampler from this paper for a model I'm working on. The No-U Turn sampler augments the typical hamiltonian system by incorporating a slice variable $u$ ...
user avatar
1 vote
0 answers
180 views

Natural Splines and Smoother Matrix

In the context of smoothing splines, one can show that the Reinsch form is given by: $ \hat{y} = N (N^{T}N +\lambda \Omega)^{-1}N^{T} y = (I+ \lambda K)^{-1}y $ where (1) $K = (N^{T})^{-1}\Omega N^{-...
user avatar
  • 11
1 vote
0 answers
305 views

Moment generating function of a Weibull distribution and root finding heavy and light tailed case

I consider the equation $M_x(v)=1+(1+\beta)\mu$ and I need to find the solution $v>0$ such that the equation is fulfilled. For this example I consider the moment generating function $M_X(v)$ of a ...
user avatar
  • 915
3 votes
3 answers
951 views

Estimating correlation matrix using numeric likelihood maximization

I'm performing maximum likelihood estimation on jointly distributed data and I'm having some issues estimating the correlation terms. I am using an approach based on the Cholesky decomposition, but I ...
user avatar
  • 238